13#include "daw/daw_callable.h"
15#include <daw/daw_cpp_feature_check.h>
16#include <daw/daw_enable_requires.h>
17#include <daw/daw_is_detected.h>
25 namespace nullable_impl {
26#if not defined( DAW_HAS_GCC ) or DAW_HAS_GCC_VER_GTE( 12, 0 )
27 template<
typename T,
typename... Args>
28 using is_list_constructible_test =
29 decltype( T{ std::declval<Args>( )... } );
31 template<
typename T,
typename... Args>
32 using is_list_constructible_test =
33 decltype( std::declval<void ( * )( T )>( )(
34 { std::declval<Args>( )... } ) );
36 template<
typename T,
typename... Args>
37 DAW_CPP20_CONCEPT is_list_constructible_v =
38 daw::is_detected_v<is_list_constructible_test, T, Args...>;
40 template<
typename T,
typename... Args>
41 DAW_CPP20_CONCEPT is_nullable_value_type_constructible_v =
42 std::is_constructible_v<T, Args...> or
43 is_list_constructible_v<T, Args...>;
67 template<
typename T,
typename...>
77 static constexpr bool is_nullable =
false;
88 noexcept( std::is_nothrow_default_constructible_v<value_type> ) {
92 template<
typename... Args DAW_ENABLEIF(
93 nullable_impl::is_nullable_value_type_constructible_v<nullable_type,
95 DAW_REQUIRES( nullable_impl::is_nullable_value_type_constructible_v<
101 if constexpr( std::is_constructible_v<
nullable_type, Args...> ) {
102 return T( DAW_FWD( args )... );
104 return T{ DAW_FWD( args )... };
137 template<
typename T,
typename... Args>
139 is_nullable_value_v<T> and
140 daw::is_callable_v<nullable_value_traits<T>,
143 template<
typename T,
typename... Args>
145 is_nullable_value_v<T> and
146 daw::is_callable_v<nullable_value_traits<T>,
149 template<
typename T,
typename... Args>
152 daw::is_nothrow_callable_v<nullable_value_traits<T>,
157 is_nullable_value_v<T> and
158 daw::is_callable_v<nullable_value_traits<T>,
163 is_nullable_empty_constructible_v<T> and
164 daw::is_nothrow_callable_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_CPP23_STATIC_CALL_OP_ENABLE_WARNING
#define DAW_JSON_CPP23_STATIC_CALL_OP
DAW_CPP20_CONCEPT is_nullable_value_nothrow_constructible_v
DAW_CPP20_CONCEPT is_nullable_empty_constructible_v
constexpr bool nullable_value_has_value(T const &opt)
Check if nullable value has a value.
DAW_CPP20_CONCEPT is_nullable_value_v
Is T a nullable type.
constexpr auto const & nullable_value_read(T const &opt)
Read value from a non-empty nullable value.
DAW_CPP20_CONCEPT is_nullable_empty_nothrow_constructible_v
DAW_CPP20_CONCEPT is_nullable_pointer_constructible_v
constexpr auto construct_nullable_with_value
constexpr auto construct_nullable_with_empty
DAW_CPP20_CONCEPT is_nullable_value_constructible_v
constexpr auto construct_nullable_with_pointer
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.
static constexpr bool has_value(T const &) noexcept
Check the state of the nullable type for a value.
constexpr value_type read(T const &v) const noexcept
read the value in the nullable type
T nullable_type
The type of the nullable type.
T value_type
The type of the value stored in the nullable type.
DAW_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.
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.