diff --git a/include/spdlog/fmt/bin_to_hex.h b/include/spdlog/fmt/bin_to_hex.h index 14908310..76dcb836 100644 --- a/include/spdlog/fmt/bin_to_hex.h +++ b/include/spdlog/fmt/bin_to_hex.h @@ -8,6 +8,14 @@ #include #include +#if defined(__has_include) && __has_include() +#include +#endif + +#if __cpp_lib_span >= 202002L +#include +#endif + // // Support for logging binary data as hex // format flags, any combination of the following: @@ -68,6 +76,19 @@ inline details::dump_info to_hex(const Conta return details::dump_info(std::begin(container), std::end(container), size_per_line); } +#if __cpp_lib_span >= 202002L + +template +inline details::dump_info::iterator> to_hex(const std::span &container, size_t size_per_line = 32) +{ + using Container = std::span; + static_assert(sizeof(typename Container::value_type) == 1, "sizeof(Container::value_type) != 1"); + using Iter = typename Container::iterator; + return details::dump_info(std::begin(container), std::end(container), size_per_line); +} + +#endif + // create dump_info from ranges template inline details::dump_info to_hex(const It range_begin, const It range_end, size_t size_per_line = 32)