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