mirror of
https://github.com/shadps4-emu/ext-fmt.git
synced 2024-11-23 09:49:42 +00:00
Make is_constructible public (#918)
This commit is contained in:
parent
4373153800
commit
ccd3e8bbf3
@ -208,14 +208,6 @@ FMT_CONSTEXPR typename std::make_unsigned<Int>::type to_unsigned(Int value) {
|
||||
return static_cast<typename std::make_unsigned<Int>::type>(value);
|
||||
}
|
||||
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 405
|
||||
template <typename... T>
|
||||
struct is_constructible: std::false_type {};
|
||||
#else
|
||||
template <typename... T>
|
||||
struct is_constructible : std::is_constructible<T...> {};
|
||||
#endif
|
||||
|
||||
/** A contiguous memory buffer with an optional growing ability. */
|
||||
template <typename T>
|
||||
class basic_buffer {
|
||||
@ -337,6 +329,14 @@ template <typename T>
|
||||
struct no_formatter_error : std::false_type {};
|
||||
} // namespace internal
|
||||
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 405
|
||||
template <typename... T>
|
||||
struct is_constructible: std::false_type {};
|
||||
#else
|
||||
template <typename... T>
|
||||
struct is_constructible : std::is_constructible<T...> {};
|
||||
#endif
|
||||
|
||||
/**
|
||||
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
|
||||
subset of the API. ``fmt::basic_string_view`` is used for format strings even
|
||||
@ -725,7 +725,7 @@ inline typename std::enable_if<
|
||||
|
||||
template <typename C, typename T, typename Char = typename C::char_type>
|
||||
inline typename std::enable_if<
|
||||
internal::is_constructible<basic_string_view<Char>, T>::value &&
|
||||
is_constructible<basic_string_view<Char>, T>::value &&
|
||||
!internal::is_string<T>::value,
|
||||
init<C, basic_string_view<Char>, string_type>>::type
|
||||
make_value(const T &val) { return basic_string_view<Char>(val); }
|
||||
@ -734,7 +734,7 @@ template <typename C, typename T, typename Char = typename C::char_type>
|
||||
inline typename std::enable_if<
|
||||
!convert_to_int<T, Char>::value && !std::is_same<T, Char>::value &&
|
||||
!std::is_convertible<T, basic_string_view<Char>>::value &&
|
||||
!internal::is_constructible<basic_string_view<Char>, T>::value &&
|
||||
!is_constructible<basic_string_view<Char>, T>::value &&
|
||||
!internal::is_string<T>::value,
|
||||
// Implicit conversion to std::string is not handled here because it's
|
||||
// unsafe: https://github.com/fmtlib/fmt/issues/729
|
||||
|
@ -569,3 +569,43 @@ TEST(CoreTest, FormatForeignStrings) {
|
||||
EXPECT_EQ(fmt::format(QString(L"{}"), my_string<wchar_t>(L"42")), L"42");
|
||||
EXPECT_EQ(fmt::format(my_string<wchar_t>(L"{}"), QString(L"42")), L"42");
|
||||
}
|
||||
|
||||
struct implicitly_convertible_to_string_view {
|
||||
operator fmt::string_view() const { return "foo"; }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatImplicitlyConvertibleToStringView) {
|
||||
EXPECT_EQ("foo", fmt::format("{}", implicitly_convertible_to_string_view()));
|
||||
}
|
||||
|
||||
// std::is_constructible is broken in MSVC until version 2015.
|
||||
#if FMT_USE_EXPLICIT && (!FMT_MSC_VER || FMT_MSC_VER >= 1900)
|
||||
struct explicitly_convertible_to_string_view {
|
||||
explicit operator fmt::string_view() const { return "foo"; }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStringView) {
|
||||
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_view()));
|
||||
}
|
||||
|
||||
struct explicitly_convertible_to_wstring_view {
|
||||
explicit operator fmt::wstring_view() const { return L"foo"; }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToWStringView) {
|
||||
EXPECT_EQ(L"foo",
|
||||
fmt::format(L"{}", explicitly_convertible_to_wstring_view()));
|
||||
}
|
||||
|
||||
struct explicitly_convertible_to_string_like {
|
||||
template <
|
||||
typename String,
|
||||
typename = typename std::enable_if<
|
||||
std::is_constructible<String, const char*, std::size_t>::value>::type>
|
||||
FMT_EXPLICIT operator String() const { return String("foo", 3u); }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStringLike) {
|
||||
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||
}
|
||||
#endif
|
||||
|
@ -1549,45 +1549,6 @@ TEST(FormatterTest, FormatStdStringView) {
|
||||
}
|
||||
#endif
|
||||
|
||||
struct implicitly_convertible_to_string_view {
|
||||
operator fmt::string_view() const { return "foo"; }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatImplicitlyConvertibleToStringView) {
|
||||
EXPECT_EQ("foo", format("{}", implicitly_convertible_to_string_view()));
|
||||
}
|
||||
|
||||
// std::is_constructible is broken in MSVC until version 2015.
|
||||
#if FMT_USE_EXPLICIT && (!FMT_MSC_VER || FMT_MSC_VER >= 1900)
|
||||
struct explicitly_convertible_to_string_view {
|
||||
explicit operator fmt::string_view() const { return "foo"; }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStringView) {
|
||||
EXPECT_EQ("foo", format("{}", explicitly_convertible_to_string_view()));
|
||||
}
|
||||
|
||||
struct explicitly_convertible_to_wstring_view {
|
||||
explicit operator fmt::wstring_view() const { return L"foo"; }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToWStringView) {
|
||||
EXPECT_EQ(L"foo", format(L"{}", explicitly_convertible_to_wstring_view()));
|
||||
}
|
||||
|
||||
struct explicitly_convertible_to_string_like {
|
||||
template <
|
||||
typename String,
|
||||
typename = typename std::enable_if<
|
||||
std::is_constructible<String, const char*, std::size_t>::value>::type>
|
||||
FMT_EXPLICIT operator String() const { return String("foo", 3u); }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStringLike) {
|
||||
EXPECT_EQ("foo", format("{}", explicitly_convertible_to_string_like()));
|
||||
}
|
||||
#endif
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
template <>
|
||||
struct formatter<Date> {
|
||||
|
Loading…
Reference in New Issue
Block a user