1
0
mirror of https://github.com/nlohmann/json.git synced 2025-08-09 05:22:48 +03:00

use detected instead of has_* traits

This commit is contained in:
Théo DELRIEU
2018-09-05 16:02:13 +02:00
parent 1ea8cd128c
commit b59c3367c9
4 changed files with 157 additions and 178 deletions

View File

@@ -102,22 +102,3 @@
basic_json<ObjectType, ArrayType, StringType, BooleanType, \
NumberIntegerType, NumberUnsignedType, NumberFloatType, \
AllocatorType, JSONSerializer>
/*!
@brief Helper to determine whether there's a key_type for T.
This helper is used to tell associative containers apart from other containers
such as sequence containers. For instance, `std::map` passes the test as it
contains a `mapped_type`, whereas `std::vector` fails the test.
@sa http://stackoverflow.com/a/7728728/266378
@since version 1.0.0, overworked in version 2.0.6
*/
#define NLOHMANN_JSON_HAS_HELPER(type) \
template<typename T> struct has_##type { \
template<typename U, typename = typename U::type> \
static int detect(U &&); \
static void detect(...); \
static constexpr bool value = \
std::is_integral<decltype(detect(std::declval<T>()))>::value; \
}