Commit 0fc7bd15 authored by Victor Zverovich's avatar Victor Zverovich

Fix ambiguity for types with dodgy conversions

parent b4f1988c
...@@ -246,7 +246,8 @@ template <typename T, typename Char> struct is_range { ...@@ -246,7 +246,8 @@ 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_range_<T>::value &&
!internal::is_like_std_string<T>::value && !internal::is_like_std_string<T>::value &&
!std::is_convertible<T, std::basic_string<Char>>::value; !std::is_convertible<T, std::basic_string<Char>>::value &&
!std::is_constructible<internal::std_string_view<Char>, T>::value;
}; };
template <typename RangeT, typename Char> template <typename RangeT, typename Char>
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
// All Rights Reserved // All Rights Reserved
// {fmt} support for ranges, containers and types tuple interface. // {fmt} support for ranges, containers and types tuple interface.
/// Check if 'if constexpr' is supported. #include "fmt/ranges.h"
#include "gtest.h"
// Check if 'if constexpr' is supported.
#if (__cplusplus > 201402L) || \ #if (__cplusplus > 201402L) || \
(defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910) (defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910)
# include "fmt/ranges.h"
# include "gtest.h"
# include <array> # include <array>
# include <map> # include <map>
# include <string> # include <string>
...@@ -119,3 +119,16 @@ TEST(RangesTest, PathLike) { ...@@ -119,3 +119,16 @@ TEST(RangesTest, PathLike) {
#endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG > #endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >
// 201402L && _MSC_VER >= 1910) // 201402L && _MSC_VER >= 1910)
#ifdef FMT_USE_STRING_VIEW
struct string_like {
const char* begin();
const char* end();
explicit operator fmt::string_view() const { return "foo"; }
explicit operator std::string_view() const { return "foo"; }
};
TEST(RangesTest, FormatStringLike) {
EXPECT_EQ("foo", fmt::format("{}", string_like()));
}
#endif // FMT_USE_STRING_VIEW
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment