mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-11 21:38:05 +00:00
Workaround an issue with std::filesystem::path being an infinitely deep range (#1268)
This commit is contained in:
parent
2aae6b120c
commit
b2d4ca1546
@ -242,13 +242,16 @@ struct formatter<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::value>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> struct is_range {
|
template <typename T, typename Char> struct is_range {
|
||||||
static FMT_CONSTEXPR_DECL const bool value =
|
static FMT_CONSTEXPR_DECL const bool value =
|
||||||
internal::is_range_<T>::value && !internal::is_like_std_string<T>::value;
|
internal::is_range_<T>::value &&
|
||||||
|
!internal::is_like_std_string<T>::value &&
|
||||||
|
!std::is_convertible<T, std::basic_string<Char>>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename RangeT, typename Char>
|
template <typename RangeT, typename Char>
|
||||||
struct formatter<RangeT, Char, enable_if_t<fmt::is_range<RangeT>::value>> {
|
struct formatter<RangeT, Char,
|
||||||
|
enable_if_t<fmt::is_range<RangeT, Char>::value>> {
|
||||||
formatting_range<Char> formatting;
|
formatting_range<Char> formatting;
|
||||||
|
|
||||||
template <typename ParseContext>
|
template <typename ParseContext>
|
||||||
|
@ -87,5 +87,16 @@ TEST(RangesTest, FormatTo) {
|
|||||||
EXPECT_STREQ(buf, "{1, 2, 3}");
|
EXPECT_STREQ(buf, "{1, 2, 3}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct path_like {
|
||||||
|
const path_like* begin() const;
|
||||||
|
const path_like* end() const;
|
||||||
|
|
||||||
|
operator std::string() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(RangesTest, PathLike) {
|
||||||
|
EXPECT_FALSE((fmt::is_range<path_like, char>::value));
|
||||||
|
}
|
||||||
|
|
||||||
#endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >
|
#endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >
|
||||||
// 201402L && _MSC_VER >= 1910)
|
// 201402L && _MSC_VER >= 1910)
|
||||||
|
Loading…
Reference in New Issue
Block a user