Acknowledge char parameter.
This commit is contained in:
parent
88bdd35b2e
commit
d6b0075742
@ -205,20 +205,22 @@ using make_index_sequence = make_integer_sequence<size_t, N>;
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using tuple_index_sequence = make_index_sequence<std::tuple_size<T>::value>;
|
using tuple_index_sequence = make_index_sequence<std::tuple_size<T>::value>;
|
||||||
|
|
||||||
template <typename T, bool = is_tuple_like_<T>::value>
|
template <typename T, typename C, bool = is_tuple_like_<T>::value>
|
||||||
struct is_tuple_formattable_ {
|
struct is_tuple_formattable_ {
|
||||||
static constexpr const bool value = false;
|
static constexpr const bool value = false;
|
||||||
};
|
};
|
||||||
template <typename T> struct is_tuple_formattable_<T, true> {
|
template <typename T, typename C> struct is_tuple_formattable_<T, C, true> {
|
||||||
template <std::size_t... I>
|
template <std::size_t... I>
|
||||||
static std::true_type
|
static std::true_type check2(index_sequence<I...>,
|
||||||
check2(index_sequence<I...>,integer_sequence<bool,(I == I)...>);
|
integer_sequence<bool, (I == I)...>);
|
||||||
static std::false_type
|
static std::false_type check2(...);
|
||||||
check2(...);
|
|
||||||
template <std::size_t... I>
|
template <std::size_t... I>
|
||||||
static decltype(check2(index_sequence<I...>{},
|
static decltype(check2(
|
||||||
integer_sequence<bool,(fmt::is_formattable<typename std::tuple_element<I, T>::type>::value)...>{}))
|
index_sequence<I...>{},
|
||||||
check(index_sequence<I...>);
|
integer_sequence<
|
||||||
|
bool, (fmt::is_formattable<typename std::tuple_element<I, T>::type,
|
||||||
|
C>::value)...>{}))
|
||||||
|
check(index_sequence<I...>);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr const bool value =
|
static constexpr const bool value =
|
||||||
@ -306,14 +308,15 @@ template <typename T> struct is_tuple_like {
|
|||||||
detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;
|
detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> struct is_tuple_formattable {
|
template <typename T, typename C> struct is_tuple_formattable {
|
||||||
static constexpr const bool value = detail::is_tuple_formattable_<T>::value;
|
static constexpr const bool value =
|
||||||
|
detail::is_tuple_formattable_<T, C>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename TupleT, typename Char>
|
template <typename TupleT, typename Char>
|
||||||
struct formatter<TupleT, Char,
|
struct formatter<TupleT, Char,
|
||||||
enable_if_t<fmt::is_tuple_like<TupleT>::value &&
|
enable_if_t<fmt::is_tuple_like<TupleT>::value &&
|
||||||
fmt::is_tuple_formattable<TupleT>::value>> {
|
fmt::is_tuple_formattable<TupleT, Char>::value>> {
|
||||||
private:
|
private:
|
||||||
// C++11 generic lambda for format().
|
// C++11 generic lambda for format().
|
||||||
template <typename FormatContext> struct format_each {
|
template <typename FormatContext> struct format_each {
|
||||||
|
|||||||
@ -315,12 +315,10 @@ TEST(xchar_test, ostream) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FMT_XCHAR_TEST_ENABLE_FORMAT_MAP
|
|
||||||
TEST(xchar_test, format_map) {
|
TEST(xchar_test, format_map) {
|
||||||
auto m = std::map<std::wstring, int>{{L"one", 1}, {L"t\"wo", 2}};
|
auto m = std::map<std::wstring, int>{{L"one", 1}, {L"t\"wo", 2}};
|
||||||
EXPECT_EQ(fmt::format(L"{}", m), L"{\"one\": 1, \"t\\\"wo\": 2}");
|
EXPECT_EQ(fmt::format(L"{}", m), L"{\"one\": 1, \"t\\\"wo\": 2}");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST(xchar_test, escape_string) {
|
TEST(xchar_test, escape_string) {
|
||||||
using vec = std::vector<std::wstring>;
|
using vec = std::vector<std::wstring>;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user