Range support

This commit is contained in:
kitegi
2020-10-24 11:25:29 +02:00
committed by Victor Zverovich
parent cb224ecaa3
commit f4ca065cfb
3 changed files with 160 additions and 9 deletions
+10 -1
View File
@@ -1198,7 +1198,11 @@ template <typename Context> struct arg_mapper {
FMT_CONSTEXPR const void* map(void* val) { return val; }
FMT_CONSTEXPR const void* map(const void* val) { return val; }
FMT_CONSTEXPR const void* map(std::nullptr_t val) { return val; }
template <typename T> FMT_CONSTEXPR int map(const T*) {
// We use SFINAE instead of a const T* parameter to avoid conflicting with
// the C array overload.
template <typename T>
FMT_CONSTEXPR auto map(T) -> enable_if_t<std::is_pointer<T>::value, int> {
// Formatting of arbitrary pointers is disallowed. If you want to output
// a pointer cast it to "void *" or "const void *". In particular, this
// forbids formatting of "[const] volatile char *" which is printed as bool
@@ -1207,6 +1211,11 @@ template <typename Context> struct arg_mapper {
return 0;
}
template <typename T, std::size_t N>
FMT_CONSTEXPR auto map(const T (&values)[N]) -> const T (&)[N] {
return values;
}
template <typename T,
FMT_ENABLE_IF(std::is_enum<T>::value &&
!has_formatter<T, Context>::value &&