Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions include/nlohmann/detail/meta/logic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#pragma once

#include <nlohmann/detail/macro_scope.hpp>

NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
#ifdef JSON_HAS_CPP_17

template<bool... Booleans>
struct cxpr_or_impl : std::integral_constant < bool, (Booleans || ...) > {};

template<bool... Booleans>
struct cxpr_and_impl : std::integral_constant < bool, (Booleans &&...) > {};

#else

template<bool... Booleans>
struct cxpr_or_impl : std::false_type {};

template<bool... Booleans>
struct cxpr_or_impl<true, Booleans...> : std::true_type {};

template<bool... Booleans>
struct cxpr_or_impl<false, Booleans...> : cxpr_or_impl<Booleans...> {};

template<bool... Booleans>
struct cxpr_and_impl : std::true_type {};

template<bool... Booleans>
struct cxpr_and_impl<true, Booleans...> : cxpr_and_impl<Booleans...> {};

template<bool... Booleans>
struct cxpr_and_impl<false, Booleans...> : std::false_type {};

#endif

template<class Boolean>
struct cxpr_not : std::integral_constant < bool, !Boolean::value > {};

template<class... Booleans>
struct cxpr_or : cxpr_or_impl<Booleans::value...> {};

template<bool... Booleans>
struct cxpr_or_c : cxpr_or_impl<Booleans...> {};

template<class... Booleans>
struct cxpr_and : cxpr_and_impl<Booleans::value...> {};

template<bool... Booleans>
struct cxpr_and_c : cxpr_and_impl<Booleans...> {};

} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
14 changes: 14 additions & 0 deletions include/nlohmann/detail/meta/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <nlohmann/detail/meta/call_std/end.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/detected.hpp>
#include <nlohmann/detail/meta/logic.hpp>
#include <nlohmann/json_fwd.hpp>

NLOHMANN_JSON_NAMESPACE_BEGIN
Expand Down Expand Up @@ -559,6 +560,19 @@ template<typename BasicJsonType, typename CompatibleType>
struct is_compatible_type
: is_compatible_type_impl<BasicJsonType, CompatibleType> {};

template<typename BasicJsonType, typename CompatibleReferenceType, typename = void>
struct is_compatible_reference_type_impl: std::false_type {};

template<typename BasicJsonType, typename CompatibleReferenceType>
struct is_compatible_reference_type_impl <
BasicJsonType, CompatibleReferenceType,
void_t<bool >>
: std::is_reference<CompatibleReferenceType> {};

template<typename BasicJsonType, typename CompatibleReferenceType>
struct is_compatible_reference_type
: is_compatible_reference_type_impl<BasicJsonType, CompatibleReferenceType> {};

template<typename T1, typename T2>
struct is_constructible_tuple : std::false_type {};

Expand Down
13 changes: 13 additions & 0 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4103,6 +4103,19 @@ template<typename BasicJsonType, typename CompatibleType>
struct is_compatible_type
: is_compatible_type_impl<BasicJsonType, CompatibleType> {};

template<typename BasicJsonType, typename CompatibleReferenceType, typename = void>
struct is_compatible_reference_type_impl: std::false_type {};

template<typename BasicJsonType, typename CompatibleReferenceType>
struct is_compatible_reference_type_impl <
BasicJsonType, CompatibleReferenceType,
void_t<bool >>
: std::is_reference<CompatibleReferenceType> {};

template<typename BasicJsonType, typename CompatibleReferenceType>
struct is_compatible_reference_type
: is_compatible_reference_type_impl<BasicJsonType, CompatibleReferenceType> {};

template<typename T1, typename T2>
struct is_constructible_tuple : std::false_type {};

Expand Down
Loading