rippled
Loading...
Searching...
No Matches
strHex.h
1#pragma once
2
3#include <boost/algorithm/hex.hpp>
4#include <boost/endian/conversion.hpp>
5
6namespace xrpl {
7
8template <class FwdIt>
10strHex(FwdIt begin, FwdIt end)
11{
12 static_assert(
14 "FwdIt must be a forward iterator");
15 std::string result;
16 result.reserve(2 * std::distance(begin, end));
17 boost::algorithm::hex(begin, end, std::back_inserter(result));
18 return result;
19}
20
21template <class T, class = decltype(std::declval<T>().begin())>
23strHex(T const& from)
24{
25 return strHex(from.begin(), from.end());
26}
27
28} // namespace xrpl
T back_inserter(T... args)
T begin(T... args)
T distance(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:10
T reserve(T... args)