mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
Merge pull request #2228 from timblechmann/feature/to_hex_span_fix
spdlog: fmt - support `std::span` in `to_hex`
This commit is contained in:
commit
32fedcf90c
@ -8,6 +8,14 @@
|
||||
#include <cctype>
|
||||
#include <spdlog/common.h>
|
||||
|
||||
#if defined(__has_include) && __has_include(<version>)
|
||||
#include <version>
|
||||
#endif
|
||||
|
||||
#if __cpp_lib_span >= 202002L
|
||||
#include <span>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Support for logging binary data as hex
|
||||
// format flags, any combination of the following:
|
||||
@ -68,6 +76,19 @@ inline details::dump_info<typename Container::const_iterator> to_hex(const Conta
|
||||
return details::dump_info<Iter>(std::begin(container), std::end(container), size_per_line);
|
||||
}
|
||||
|
||||
#if __cpp_lib_span >= 202002L
|
||||
|
||||
template <typename Value, size_t Extent>
|
||||
inline details::dump_info<typename std::span<Value, Extent>::iterator> to_hex(const std::span<Value, Extent> &container, size_t size_per_line = 32)
|
||||
{
|
||||
using Container = std::span<Value, Extent>;
|
||||
static_assert(sizeof(typename Container::value_type) == 1, "sizeof(Container::value_type) != 1");
|
||||
using Iter = typename Container::iterator;
|
||||
return details::dump_info<Iter>(std::begin(container), std::end(container), size_per_line);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// create dump_info from ranges
|
||||
template<typename It>
|
||||
inline details::dump_info<It> to_hex(const It range_begin, const It range_end, size_t size_per_line = 32)
|
||||
|
Loading…
Reference in New Issue
Block a user