@@ -202,6 +202,24 @@ template <size_t N>
202
202
using make_index_sequence = make_integer_sequence<size_t , N>;
203
203
#endif
204
204
205
+ template <typename T>
206
+ using tuple_index_sequence = make_index_sequence<std::tuple_size_v<T>>;
207
+
208
+ template <typename T, bool = is_tuple_like_<T>::value>
209
+ struct is_tuple_formattable_ {
210
+ static constexpr const bool value = false ;
211
+ };
212
+ template <typename T> struct is_tuple_formattable_ <T, true > {
213
+ template <std::size_t ... I>
214
+ static std::integral_constant<
215
+ bool , (fmt::is_formattable<std::tuple_element_t <I, T>>::value && ...)>
216
+ check (index_sequence<I...>);
217
+
218
+ public:
219
+ static constexpr const bool value =
220
+ decltype (check(tuple_index_sequence<T>{}))::value;
221
+ };
222
+
205
223
template <class Tuple , class F , size_t ... Is>
206
224
void for_each (index_sequence<Is...>, Tuple&& tup, F&& f) noexcept {
207
225
using std::get;
@@ -283,8 +301,14 @@ template <typename T> struct is_tuple_like {
283
301
detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;
284
302
};
285
303
304
+ template <typename T> struct is_tuple_formattable {
305
+ static constexpr const bool value = detail::is_tuple_formattable_<T>::value;
306
+ };
307
+
286
308
template <typename TupleT, typename Char>
287
- struct formatter <TupleT, Char, enable_if_t <fmt::is_tuple_like<TupleT>::value>> {
309
+ struct formatter <TupleT, Char,
310
+ enable_if_t <fmt::is_tuple_like<TupleT>::value &&
311
+ fmt::is_tuple_formattable<TupleT>::value>> {
288
312
private:
289
313
// C++11 generic lambda for format().
290
314
template <typename FormatContext> struct format_each {
0 commit comments