xrpld
Loading...
Searching...
No Matches
strHex.h
1#pragma once
2
3#include <boost/algorithm/hex.hpp>
4#include <boost/endian/conversion.hpp>
5
6#include <iterator>
7#include <string>
8
9namespace xrpl {
10
11template <class FwdIt>
12std::string
13strHex(FwdIt begin, FwdIt end)
14{
15 static_assert(
19 "FwdIt must be a forward iterator");
20 std::string result;
21 result.reserve(2 * std::distance(begin, end));
22 boost::algorithm::hex(begin, end, std::back_inserter(result));
23 return result;
24}
25
26template <class T, class = decltype(std::declval<T>().begin())>
28strHex(T const& from)
29{
30 return strHex(from.begin(), from.end());
31}
32
33} // namespace xrpl
T back_inserter(T... args)
T begin(T... args)
T distance(T... args)
T is_convertible_v
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:13
T reserve(T... args)