28#if !defined(_WIN32) && !(defined(__APPLE__) && defined(__clang__)) && __cplusplus < 201703L
29template <
typename To,
typename From>
32 return std::shared_ptr<To>(ptr,
reinterpret_cast<To *
>(ptr.get()));
36inline std::ostream&
operator<<(std::ostream& os,
const uint8_t v)
38 os << static_cast<int>(v)
39 <<
"(0x" << std::uppercase << std::hex << std::setfill(
'0') << std::setw(2)
40 <<
static_cast<int>(v) <<
")";
45inline std::ostream&
operator<<(std::ostream& os,
const std::vector<uint8_t>& v)
47 for (
int i = 0; i < static_cast<int>(v.size()); i++)
48 os << std::uppercase << std::hex << std::setfill(
'0') << std::setw(2)
49 <<
static_cast<int>(v[i]);
54inline std::ostream&
operator<<(std::ostream& os,
const std::vector<int>& v)
56 for (
int i = 0; i < static_cast<int>(v.size()); i++) {
61 os << std::hex << std::setfill(
'0') << std::setw(8)
62 <<
static_cast<int>(v[i]);
68inline std::ostream&
operator<<(std::ostream& os,
const std::vector<std::string>& v)
71 for (
auto it = v.begin(); it != v.end(); ++it)
82inline std::ostream&
operator<<(std::ostream& os,
const std::set<std::string>& s)
85 for (
auto it = s.begin(); it != s.end(); ++it)
96template<
class A,
class B>
98std::ostream&
operator<<(std::ostream& os,
const std::map<A, B>& s)
101 for (
auto it = s.begin(); it != s.end(); ++it)
105 os <<
"{" << it->first <<
", " << it->second <<
"}";
112template<
class A,
class B>
114std::ostream&
operator<<(std::ostream& os,
const std::map<const A, B>& s)
117 for (
auto it = s.begin(); it != s.end(); ++it)
121 os <<
"{" << it->first <<
", " << it->second <<
"}";
128template <
typename out>
129inline void split(
const std::string &s,
const std::regex& re, out result)
131 std::sregex_token_iterator d(s.begin(), s.end(), re, -1);
132 std::sregex_token_iterator end;
140inline std::string&
ltrim(std::string& s,
const char* t =
" \t\n\r\f\v")
142 s.erase(0, s.find_first_not_of(t));
148inline std::string&
rtrim(std::string& s,
const char* t =
" \t\n\r\f\v")
150 s.erase(s.find_last_not_of(t) + 1);
156inline std::string&
trim(std::string& s,
const char* t =
" \t\n\r\f\v")
std::string & ltrim(std::string &s, const char *t=" \t\n\r\f\v")
std::shared_ptr< To > reinterpret_pointer_cast(std::shared_ptr< From > const &ptr) noexcept
std::ostream & operator<<(std::ostream &os, const uint8_t v)
std::string & trim(std::string &s, const char *t=" \t\n\r\f\v")
std::string & rtrim(std::string &s, const char *t=" \t\n\r\f\v")
void split(const std::string &s, const std::regex &re, out result)