13 #include <daw/daw_is_detected.h>
16 #include <type_traits>
21 namespace nullable_impl {
22 #if not defined( DAW_HAS_GCC ) or DAW_HAS_GCC_VER_GTE( 12, 0 )
23 template<
typename T,
typename... Args>
24 using is_list_constructible_test =
25 decltype( T{ std::declval<Args>( )... } );
27 template<
typename T,
typename... Args>
28 using is_list_constructible_test =
29 decltype( std::declval<
void ( * )( T )>( )(
30 { std::declval<Args>( )... } ) );
32 template<
typename T,
typename... Args>
33 inline constexpr
bool is_list_constructible_v =
34 daw::is_detected_v<is_list_constructible_test, T, Args...>;
36 template<
typename T,
typename... Args>
37 inline constexpr
bool is_nullable_value_type_constructible_v =
38 std::is_constructible_v<T, Args...> or
39 is_list_constructible_v<T, Args...>;
64 template<
typename T,
typename...>
74 static constexpr
bool is_nullable =
false;
79 inline constexpr
value_type read( T
const &v )
const noexcept {
86 noexcept( std::is_nothrow_default_constructible_v<value_type> ) {
91 nullable_impl::is_nullable_value_type_constructible_v<nullable_type,
94 nullable_impl::is_nullable_value_type_constructible_v<
nullable_type,
100 if constexpr( std::is_constructible_v<nullable_type, Args...> ) {
101 return T( DAW_FWD( args )... );
103 return T{ DAW_FWD( args )... };
107 static constexpr
bool has_value( T
const & ) noexcept {
136 template<
typename T,
typename... Args>
138 is_nullable_value_v<T> and
139 std::is_invocable_v<nullable_value_traits<T>,
142 template<
typename T,
typename... Args>
144 is_nullable_value_v<T> and
145 std::is_invocable_v<nullable_value_traits<T>,
148 template<
typename T,
typename... Args>
151 std::is_nothrow_invocable_v<nullable_value_traits<T>,
156 is_nullable_value_v<T> and
157 std::is_invocable_v<nullable_value_traits<T>,
162 is_nullable_empty_constructible_v<T> and
163 std::is_nothrow_invocable_v<nullable_value_traits<T>,
#define DAW_JSON_CPP23_STATIC_CALL_OP_DISABLE_WARNING
#define DAW_JSON_CPP23_STATIC_CALL_OP_CONST
#define DAW_JSON_ENABLEIF(...)
#define DAW_JSON_CPP23_STATIC_CALL_OP_ENABLE_WARNING
#define DAW_JSON_CPP23_STATIC_CALL_OP
This is in addition to the parse policy. Always do a full name match instead of sometimes relying on ...
constexpr bool is_nullable_value_constructible_v
constexpr bool is_nullable_value_v
Is T a nullable type.
constexpr bool nullable_value_has_value(T const &opt)
Check if nullable value has a value.
constexpr bool is_nullable_pointer_constructible_v
constexpr bool is_nullable_value_nothrow_constructible_v
constexpr auto const & nullable_value_read(T const &opt)
Read value from a non-empty nullable value.
constexpr bool is_nullable_empty_nothrow_constructible_v
constexpr auto construct_nullable_with_value
constexpr auto construct_nullable_with_empty
constexpr auto construct_nullable_with_pointer
constexpr bool is_nullable_empty_constructible_v
typename nullable_value_traits< T >::value_type nullable_value_type_t
Determines the type stored inside T.
Customization point traits.
construct_nullable_with_pointer_t()=default
construct_nullable_with_empty_t()=default
construct_nullable_with_value_t()=default
Readable values models an option/maybe/nullable type.
DAW_JSON_REQUIRES(nullable_impl::is_nullable_value_type_constructible_v< nullable_type, Args... >) DAW_JSON_CPP23_STATIC_CALL_OP const expr nullable_type operator()(const ruct_nullable_with_empty_t
Return an empty nullable type.
T nullable_type
The type of the nullable type.
T value_type
The type of the value stored in the nullable type.
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.