Merge pull request #919 from theodelrieu/fix/sfinae_for_incomplete_types
fix sfinae on basic_json UDT constructor
This commit is contained in:
commit
f5c4e9f3a1
4 changed files with 83 additions and 20 deletions
|
@ -96,6 +96,14 @@ template<> struct priority_tag<0> {};
|
|||
// has_/is_ functions //
|
||||
////////////////////////
|
||||
|
||||
// source: https://stackoverflow.com/a/37193089/4116453
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct is_complete_type : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
|
||||
|
||||
NLOHMANN_JSON_HAS_HELPER(mapped_type);
|
||||
NLOHMANN_JSON_HAS_HELPER(key_type);
|
||||
NLOHMANN_JSON_HAS_HELPER(value_type);
|
||||
|
@ -171,7 +179,6 @@ struct is_compatible_integer_type
|
|||
RealIntegerType, CompatibleNumberIntegerType > ::value;
|
||||
};
|
||||
|
||||
|
||||
// trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists
|
||||
template<typename BasicJsonType, typename T>
|
||||
struct has_from_json
|
||||
|
@ -221,6 +228,23 @@ struct has_to_json
|
|||
std::declval<typename BasicJsonType::template json_serializer<T, void>>()))>::value;
|
||||
};
|
||||
|
||||
template <typename BasicJsonType, typename CompatibleCompleteType>
|
||||
struct is_compatible_complete_type
|
||||
{
|
||||
static constexpr bool value =
|
||||
not std::is_base_of<std::istream, CompatibleCompleteType>::value and
|
||||
not std::is_same<BasicJsonType, CompatibleCompleteType>::value and
|
||||
not is_basic_json_nested_type<BasicJsonType, CompatibleCompleteType>::value and
|
||||
has_to_json<BasicJsonType, CompatibleCompleteType>::value;
|
||||
};
|
||||
|
||||
template <typename BasicJsonType, typename CompatibleType>
|
||||
struct is_compatible_type
|
||||
: conjunction<is_complete_type<CompatibleType>,
|
||||
is_compatible_complete_type<BasicJsonType, CompatibleType>>
|
||||
{
|
||||
};
|
||||
|
||||
// taken from ranges-v3
|
||||
template<typename T>
|
||||
struct static_const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue