15 #include <daw/daw_cpp_feature_check.h>
19 #include <type_traits>
21 #if defined( __cpp_aggregate_paren_init )
22 #if __cpp_aggregate_paren_init >= 201902L
23 #define DAW_HAS_AGG_PAREN_INIT
31 struct nullable_value_traits<
std::optional<T>> {
34 static constexpr
bool is_nullable =
true;
37 assert( has_value( val ) );
42 operator( )( construct_nullable_with_value_t,
nullable_type const &opt )
44 noexcept( std::is_nothrow_copy_constructible_v<nullable_type> ) {
49 operator( )( construct_nullable_with_value_t,
51 noexcept( std::is_nothrow_move_constructible_v<nullable_type> ) {
56 nullable_impl::is_nullable_value_type_constructible_v<value_type,
59 nullable_impl::is_nullable_value_type_constructible_v<
value_type,
62 operator( )( construct_nullable_with_value_t,
65 #if not defined( DAW_HAS_AGG_PAREN_INIT )
66 if constexpr( std::is_aggregate_v<value_type> and
67 nullable_impl::is_list_constructible_v<
value_type,
69 return std::optional<value_type>(
73 return std::optional<value_type>( std::in_place,
75 #if not defined( DAW_HAS_AGG_PAREN_INIT )
81 operator( )( construct_nullable_with_empty_t )
87 return val.has_value( );
92 struct nullable_value_traits<
std::unique_ptr<T>> {
95 static constexpr
bool is_nullable =
true;
98 assert( has_value( val ) );
103 operator( )( construct_nullable_with_value_t,
105 noexcept( std::is_nothrow_move_constructible_v<nullable_type> ) {
110 nullable_impl::is_nullable_value_type_constructible_v<value_type,
113 nullable_impl::is_nullable_value_type_constructible_v<
value_type,
116 operator( )( construct_nullable_with_value_t,
119 #if not defined( DAW_HAS_AGG_PAREN_INIT )
120 if constexpr( std::is_aggregate_v<value_type> and
121 nullable_impl::is_list_constructible_v<
value_type,
123 return std::make_unique<value_type>(
127 return std::make_unique<value_type>( DAW_FWD( args )... );
128 #if not defined( DAW_HAS_AGG_PAREN_INIT )
134 construct_nullable_with_pointer_t,
140 operator( )( construct_nullable_with_empty_t )
146 return static_cast<bool>( val );
151 struct nullable_value_traits<
std::shared_ptr<T>> {
154 static constexpr
bool is_nullable =
true;
157 assert( has_value( val ) );
164 noexcept( std::is_nothrow_copy_constructible_v<nullable_type> ) {
169 operator( )( construct_nullable_with_value_t,
171 noexcept( std::is_nothrow_move_constructible_v<nullable_type> ) {
176 nullable_impl::is_nullable_value_type_constructible_v<value_type,
179 nullable_impl::is_nullable_value_type_constructible_v<
value_type,
182 operator( )( construct_nullable_with_value_t,
185 #if not defined( DAW_HAS_AGG_PAREN_INIT )
186 if constexpr( std::is_aggregate_v<value_type> and
187 nullable_impl::is_list_constructible_v<
value_type,
189 return std::make_shared<value_type>(
193 return std::make_shared<value_type>( DAW_FWD( args )... );
194 #if not defined( DAW_HAS_AGG_PAREN_INIT )
200 construct_nullable_with_pointer_t,
206 operator( )( construct_nullable_with_empty_t )
212 return static_cast<bool>( val );
217 struct nullable_value_traits<T *> {
220 static constexpr
bool is_nullable =
true;
223 assert( has_value( val ) );
228 construct_nullable_with_value_t,
234 nullable_impl::is_nullable_value_type_constructible_v<value_type,
237 nullable_impl::is_nullable_value_type_constructible_v<
value_type,
240 operator( )( construct_nullable_with_value_t,
243 #if not defined( DAW_HAS_AGG_PAREN_INIT )
244 if constexpr( std::is_aggregate_v<T> and
245 nullable_impl::is_list_constructible_v<T, Args...> ) {
250 #if not defined( DAW_HAS_AGG_PAREN_INIT )
256 construct_nullable_with_pointer_t,
262 operator( )( construct_nullable_with_empty_t )
268 return static_cast<bool>( val );
274 #if defined( DAW_HAS_AGG_PAREN_INIT )
275 #undef DAW_HAS_AGG_PAREN_INIT
#define DAW_JSON_CPP23_STATIC_CALL_OP_CONST
#define DAW_JSON_ENABLEIF(...)
#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 ...
Customization point traits.
DAW_JSON_REQUIRES(nullable_impl::is_nullable_value_type_constructible_v< value_type, Args... >) DAW_JSON_CPP23_STATIC_CALL_OP const expr nullable_type operator()(const ruct_nullable_with_value_t
std::unique_ptr< T > nullable_type
std::shared_ptr< T > nullable_type
DAW_JSON_REQUIRES(nullable_impl::is_nullable_value_type_constructible_v< value_type, Args... >) DAW_JSON_CPP23_STATIC_CALL_OP const expr nullable_type operator()(const ruct_nullable_with_value_t
DAW_JSON_REQUIRES(nullable_impl::is_nullable_value_type_constructible_v< value_type, Args... >) DAW_JSON_CPP23_STATIC_CALL_OP const expr nullable_type operator()(const ruct_nullable_with_value_t
std::optional< T > nullable_type
DAW_JSON_REQUIRES(nullable_impl::is_nullable_value_type_constructible_v< value_type, Args... >) DAW_JSON_CPP23_STATIC_CALL_OP const expr nullable_type operator()(const ruct_nullable_with_value_t
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.