DAW JSON Link
Loading...
Searching...
No Matches
daw_json_default_constuctor_fwd.h
Go to the documentation of this file.
1// Copyright (c) Darrell Wright
2//
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
5//
6// Official repository: https://github.com/beached/daw_json_link
7//
8
9#pragma once
10
11#include "impl/version.h"
12
14
15#include <daw/cpp_17.h>
16#include <daw/daw_attributes.h>
17#include <daw/daw_move.h>
18#include <daw/daw_traits.h>
19
20#include <memory>
21#include <type_traits>
22
23/***
24 * Customization point traits
25 *
26 */
27namespace daw::json {
28 inline namespace DAW_JSON_VER {
29 namespace json_details {
30 template<typename T, typename... Args>
31 inline constexpr bool should_list_construct_v =
32 not std::is_constructible_v<T, Args...> and
33 daw::traits::is_list_constructible_v<T, Args...>;
34 }
38 template<typename T, typename = void>
41
42 template<typename... Args DAW_JSON_ENABLEIF(
43 std::is_constructible_v<T, Args...> )>
44 DAW_JSON_REQUIRES( std::is_constructible_v<T, Args...> )
45 [[nodiscard]] DAW_ATTRIB_INLINE DAW_JSON_CPP23_STATIC_CALL_OP constexpr T
46 operator( )( Args &&...args ) DAW_JSON_CPP23_STATIC_CALL_OP_CONST {
47
48 return T( DAW_FWD( args )... );
49 }
50
51 template<typename... Args DAW_JSON_ENABLEIF(
52 json_details::should_list_construct_v<T, Args...> )>
53 DAW_JSON_REQUIRES( json_details::should_list_construct_v<T, Args...> )
54 [[nodiscard]] DAW_ATTRIB_INLINE DAW_JSON_CPP23_STATIC_CALL_OP constexpr T
55 operator( )( Args &&...args ) DAW_JSON_CPP23_STATIC_CALL_OP_CONST
56 noexcept( std::is_nothrow_constructible_v<T, Args...> ) {
57 return T{ DAW_FWD( args )... };
58 }
59 };
60
65 template<typename T, typename = void>
68 using default_constructor<T>::operator( );
69 };
70
71 template<typename T>
72 DAW_JSON_REQUIRES( concepts::nullable_impl::is_list_constructible_v<T> and
73 not concepts::is_nullable_value_v<T> )
75 concepts::nullable_impl::is_list_constructible_v<T> and
76 not concepts::is_nullable_value_v<T> )> : default_constructor<T> {
78 using default_constructor<T>::operator( );
79 [[nodiscard]] DAW_ATTRIB_INLINE DAW_JSON_CPP23_STATIC_CALL_OP constexpr T
81 return T{ };
82 }
83 };
84 } // namespace DAW_JSON_VER
85} // namespace daw::json
#define DAW_JSON_ENABLEIF_S(...)
#define DAW_JSON_CPP23_STATIC_CALL_OP_CONST
#define DAW_JSON_ENABLEIF(...)
#define DAW_JSON_CPP23_STATIC_CALL_OP
#define DAW_JSON_REQUIRES(...)
Customization point traits.
Default Constructor for a type. It accounts for aggregate types and uses brace construction for them.
Default constructor for nullable types. Specializations must accept accept an operator( )( ) that sig...
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition version.h:20