15#include <daw/daw_cpp_feature_check.h>
16#include <daw/daw_enable_requires.h>
22#if defined( __cpp_aggregate_paren_init )
23#if __cpp_aggregate_paren_init >= 201902L
24#define DAW_HAS_AGG_PAREN_INIT
32 struct nullable_value_traits<
std::optional<T>> {
35 static constexpr bool is_nullable =
true;
38 assert( has_value( val ) );
43 operator( )( construct_nullable_with_value_t,
nullable_type const &opt )
45 noexcept( std::is_nothrow_copy_constructible_v<nullable_type> ) {
50 operator( )( construct_nullable_with_value_t,
52 noexcept( std::is_nothrow_move_constructible_v<nullable_type> ) {
56 template<
typename... Args DAW_ENABLEIF(
57 nullable_impl::is_nullable_value_type_constructible_v<value_type,
59 DAW_REQUIRES( nullable_impl::is_nullable_value_type_constructible_v<
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> ) {
109 template<
typename... Args DAW_ENABLEIF(
110 nullable_impl::is_nullable_value_type_constructible_v<value_type,
115 operator( )( construct_nullable_with_value_t,
118#if not defined( DAW_HAS_AGG_PAREN_INIT )
119 if constexpr( std::is_aggregate_v<value_type> and
120 nullable_impl::is_list_constructible_v<
value_type,
122 return std::make_unique<value_type>(
126 return std::make_unique<value_type>( DAW_FWD( args )... );
127#if not defined( DAW_HAS_AGG_PAREN_INIT )
133 construct_nullable_with_pointer_t,
139 operator( )( construct_nullable_with_empty_t )
145 return static_cast<bool>( val );
150 struct nullable_value_traits<
std::shared_ptr<T>> {
153 static constexpr bool is_nullable =
true;
156 assert( has_value( val ) );
163 noexcept( std::is_nothrow_copy_constructible_v<nullable_type> ) {
168 operator( )( construct_nullable_with_value_t,
170 noexcept( std::is_nothrow_move_constructible_v<nullable_type> ) {
174 template<
typename... Args DAW_ENABLEIF(
175 nullable_impl::is_nullable_value_type_constructible_v<value_type,
180 operator( )( construct_nullable_with_value_t,
183#if not defined( DAW_HAS_AGG_PAREN_INIT )
184 if constexpr( std::is_aggregate_v<value_type> and
185 nullable_impl::is_list_constructible_v<
value_type,
187 return std::make_shared<value_type>(
191 return std::make_shared<value_type>( DAW_FWD( args )... );
192#if not defined( DAW_HAS_AGG_PAREN_INIT )
198 construct_nullable_with_pointer_t,
204 operator( )( construct_nullable_with_empty_t )
210 return static_cast<bool>( val );
215 struct nullable_value_traits<T *> {
218 static constexpr bool is_nullable =
true;
221 assert( has_value( val ) );
226 construct_nullable_with_value_t,
231 template<
typename... Args DAW_ENABLEIF(
232 nullable_impl::is_nullable_value_type_constructible_v<value_type,
237 operator( )( construct_nullable_with_value_t,
240#if not defined( DAW_HAS_AGG_PAREN_INIT )
241 if constexpr( std::is_aggregate_v<T> and
242 nullable_impl::is_list_constructible_v<T, Args...> ) {
247#if not defined( DAW_HAS_AGG_PAREN_INIT )
253 construct_nullable_with_pointer_t,
259 operator( )( construct_nullable_with_empty_t )
265 return static_cast<bool>( val );
271#if defined( DAW_HAS_AGG_PAREN_INIT )
272#undef DAW_HAS_AGG_PAREN_INIT
#define DAW_JSON_CPP23_STATIC_CALL_OP_CONST
#define DAW_JSON_CPP23_STATIC_CALL_OP
Customization point traits.
static constexpr bool has_value(nullable_type const &val)
DAW_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
static constexpr value_type const & read(nullable_type const &val)
std::unique_ptr< T > nullable_type
std::shared_ptr< T > nullable_type
static constexpr value_type const & read(nullable_type const &val)
static constexpr bool has_value(nullable_type const &val)
DAW_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
static constexpr value_type const & read(nullable_type const &val)
std::optional< T > nullable_type
static constexpr bool has_value(nullable_type const &val)
DAW_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_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
static constexpr value_type const & read(nullable_type const &val)
static constexpr bool has_value(nullable_type const &val)
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.