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
12
14
15#include <daw/cpp_17.h>
16#include <daw/daw_attributes.h>
17#include <daw/daw_cpp20_concept.h>
18#include <daw/daw_enable_requires.h>
19#include <daw/daw_move.h>
20#include <daw/daw_traits.h>
21
22#include <memory>
23#include <type_traits>
24
25/***
26 * Customization point traits
27 *
28 */
29namespace daw::json {
30 inline namespace DAW_JSON_VER {
31 namespace json_details {
32 template<typename T, typename... Args>
33 DAW_CPP20_CONCEPT should_list_construct_v =
34 not std::is_constructible_v<T, Args...> and
35 daw::traits::is_list_constructible_v<T, Args...>;
36 }
40 template<typename T, typename = void>
43
44 template<
45 typename... Args DAW_ENABLEIF( std::is_constructible_v<T, Args...> )>
46 DAW_REQUIRES( std::is_constructible_v<T, Args...> )
47 [[nodiscard]] DAW_ATTRIB_INLINE DAW_JSON_CPP23_STATIC_CALL_OP constexpr T
48 operator( )( Args &&...args ) DAW_JSON_CPP23_STATIC_CALL_OP_CONST {
49
50 return T( DAW_FWD( args )... );
51 }
52
53 template<typename... Args DAW_ENABLEIF(
54 json_details::should_list_construct_v<T, Args...> )>
55 DAW_REQUIRES( json_details::should_list_construct_v<T, Args...> )
56 [[nodiscard]] DAW_ATTRIB_INLINE DAW_JSON_CPP23_STATIC_CALL_OP constexpr T
57 operator( )( Args &&...args ) DAW_JSON_CPP23_STATIC_CALL_OP_CONST
58 noexcept( std::is_nothrow_constructible_v<T, Args...> ) {
59 return T{ DAW_FWD( args )... };
60 }
61 };
62
67 template<typename T, typename = void>
70 using default_constructor<T>::operator( );
71 };
72
73 template<typename T>
74 DAW_REQUIRES( concepts::nullable_impl::is_list_constructible_v<T> and
75 not concepts::is_nullable_value_v<T> )
76 struct nullable_constructor<T DAW_ENABLEIF_S(
77 concepts::nullable_impl::is_list_constructible_v<T> and
78 not concepts::is_nullable_value_v<T> )> : default_constructor<T> {
80 using default_constructor<T>::operator( );
81 [[nodiscard]] DAW_ATTRIB_INLINE DAW_JSON_CPP23_STATIC_CALL_OP constexpr T
83 return T{ };
84 }
85 };
86 } // namespace DAW_JSON_VER
87} // namespace daw::json
DAW_REQUIRES(daw::json::json_details::is_container_opted_into_json_iostreams_v< Container >) std
An opt in ostream interface for containers of types that have JSON mappings.
#define DAW_JSON_CPP23_STATIC_CALL_OP_CONST
#define DAW_JSON_CPP23_STATIC_CALL_OP
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