|
2 | 2 | #define TOML11_TYPES_HPP |
3 | 3 |
|
4 | 4 | #include "comments.hpp" |
| 5 | +#include "compat.hpp" |
5 | 6 | #include "error_info.hpp" |
6 | 7 | #include "format.hpp" |
7 | 8 | #include "ordered_map.hpp" |
@@ -299,77 +300,53 @@ namespace detail |
299 | 300 | // ---------------------------------------------------------------------------- |
300 | 301 | // check if type T has all the needed member types |
301 | 302 |
|
302 | | -struct has_comment_type_impl |
303 | | -{ |
304 | | - template<typename T> static std::true_type check(typename T::comment_type*); |
305 | | - template<typename T> static std::false_type check(...); |
306 | | -}; |
| 303 | +template<typename T, typename U = void> |
| 304 | +struct has_comment_type: std::false_type{}; |
307 | 305 | template<typename T> |
308 | | -using has_comment_type = decltype(has_comment_type_impl::check<T>(nullptr)); |
| 306 | +struct has_comment_type<T, cxx::void_t<typename T::comment_type>>: std::true_type{}; |
309 | 307 |
|
310 | | -struct has_integer_type_impl |
311 | | -{ |
312 | | - template<typename T> static std::true_type check(typename T::integer_type*); |
313 | | - template<typename T> static std::false_type check(...); |
314 | | -}; |
| 308 | +template<typename T, typename U = void> |
| 309 | +struct has_integer_type: std::false_type{}; |
315 | 310 | template<typename T> |
316 | | -using has_integer_type = decltype(has_integer_type_impl::check<T>(nullptr)); |
| 311 | +struct has_integer_type<T, cxx::void_t<typename T::integer_type>>: std::true_type{}; |
317 | 312 |
|
318 | | -struct has_floating_type_impl |
319 | | -{ |
320 | | - template<typename T> static std::true_type check(typename T::floating_type*); |
321 | | - template<typename T> static std::false_type check(...); |
322 | | -}; |
| 313 | +template<typename T, typename U = void> |
| 314 | +struct has_floating_type: std::false_type{}; |
323 | 315 | template<typename T> |
324 | | -using has_floating_type = decltype(has_floating_type_impl::check<T>(nullptr)); |
| 316 | +struct has_floating_type<T, cxx::void_t<typename T::floating_type>>: std::true_type{}; |
325 | 317 |
|
326 | | -struct has_string_type_impl |
327 | | -{ |
328 | | - template<typename T> static std::true_type check(typename T::string_type*); |
329 | | - template<typename T> static std::false_type check(...); |
330 | | -}; |
| 318 | +template<typename T, typename U = void> |
| 319 | +struct has_string_type: std::false_type{}; |
331 | 320 | template<typename T> |
332 | | -using has_string_type = decltype(has_string_type_impl::check<T>(nullptr)); |
| 321 | +struct has_string_type<T, cxx::void_t<typename T::string_type>>: std::true_type{}; |
333 | 322 |
|
334 | | -struct has_array_type_impl |
335 | | -{ |
336 | | - template<typename T> static std::true_type check(typename T::template array_type<int>*); |
337 | | - template<typename T> static std::false_type check(...); |
338 | | -}; |
| 323 | +template<typename T, typename U = void> |
| 324 | +struct has_array_type: std::false_type{}; |
339 | 325 | template<typename T> |
340 | | -using has_array_type = decltype(has_array_type_impl::check<T>(nullptr)); |
| 326 | +struct has_array_type<T, cxx::void_t<typename T::template array_type<int>>>: std::true_type{}; |
341 | 327 |
|
342 | | -struct has_table_type_impl |
343 | | -{ |
344 | | - template<typename T> static std::true_type check(typename T::template table_type<int, int>*); |
345 | | - template<typename T> static std::false_type check(...); |
346 | | -}; |
| 328 | +template<typename T, typename U = void> |
| 329 | +struct has_table_type: std::false_type{}; |
347 | 330 | template<typename T> |
348 | | -using has_table_type = decltype(has_table_type_impl::check<T>(nullptr)); |
| 331 | +struct has_table_type<T, cxx::void_t<typename T::template table_type<int, int>>>: std::true_type{}; |
349 | 332 |
|
350 | | -struct has_parse_int_impl |
351 | | -{ |
352 | | - template<typename T> static std::true_type check(decltype(std::declval<T>().parse_int( |
353 | | - std::declval<const std::string&>(), |
354 | | - std::declval<const source_location>(), |
355 | | - std::declval<const std::uint8_t>() |
356 | | - ))*); |
357 | | - template<typename T> static std::false_type check(...); |
358 | | -}; |
| 333 | +template<typename T, typename U = void> |
| 334 | +struct has_parse_int: std::false_type{}; |
359 | 335 | template<typename T> |
360 | | -using has_parse_int = decltype(has_parse_int_impl::check<T>(nullptr)); |
361 | | - |
362 | | -struct has_parse_float_impl |
363 | | -{ |
364 | | - template<typename T> static std::true_type check(decltype(std::declval<T>().parse_float( |
365 | | - std::declval<const std::string&>(), |
366 | | - std::declval<const source_location>(), |
367 | | - std::declval<const bool>() |
368 | | - ))*); |
369 | | - template<typename T> static std::false_type check(...); |
370 | | -}; |
| 336 | +struct has_parse_int<T, cxx::void_t<decltype(std::declval<T>().parse_int( |
| 337 | + std::declval<std::string const&>(), |
| 338 | + std::declval<::toml::source_location const&>(), |
| 339 | + std::declval<std::uint8_t>() |
| 340 | + ))>>: std::true_type{}; |
| 341 | + |
| 342 | +template<typename T, typename U = void> |
| 343 | +struct has_parse_float: std::false_type{}; |
371 | 344 | template<typename T> |
372 | | -using has_parse_float = decltype(has_parse_float_impl::check<T>(nullptr)); |
| 345 | +struct has_parse_float<T, cxx::void_t<decltype(std::declval<T>().parse_float( |
| 346 | + std::declval<std::string const&>(), |
| 347 | + std::declval<::toml::source_location const&>(), |
| 348 | + std::declval<bool>() |
| 349 | + ))>>: std::true_type{}; |
373 | 350 |
|
374 | 351 | template<typename T> |
375 | 352 | using is_type_config = cxx::conjunction< |
|
0 commit comments