DAW JSON Link
Loading...
Searching...
No Matches
daw_json_req_helper.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 <daw/daw_cpp_feature_check.h>
12
15#if DAW_HAS_GCC_VER_LT( 13, 3 )
16#define DAW_JSON_DONT_USE_CONCEPTS
17#endif
18
19#if not defined( DAW_JSON_DONT_USE_CONCEPTS ) and defined( __cpp_lib_concepts )
20#if __cpp_lib_concepts >= 202002L
21#define DAW_JSON_USE_CONCEPTS
22#endif
23#endif
24
25#if defined( DAW_JSON_USE_CONCEPTS )
26#define DAW_JSON_MAKE_REQ_TRAIT( Name, /*ReqExpression*/... ) \
27 template<typename T> \
28 inline constexpr bool Name = requires { \
29 __VA_ARGS__; \
30 }
31#else
32#define DAW_JSON_MAKE_REQ_TRAIT( Name, /*ReqExpression*/... ) \
33 template<typename, typename = void> \
34 inline constexpr bool Name = false; \
35 \
36 template<typename T> \
37 inline constexpr bool Name<T, std::void_t<decltype( __VA_ARGS__ )>> = true
38#endif
39
40#if defined( DAW_JSON_USE_CONCEPTS )
41#define DAW_JSON_MAKE_REQ_TRAIT2( Name, /*ReqExpression*/... ) \
42 template<typename T, typename U> \
43 inline constexpr bool Name = requires { \
44 __VA_ARGS__; \
45 }
46#else
47#define DAW_JSON_MAKE_REQ_TRAIT2( Name, /*ReqExpression*/... ) \
48 template<typename, typename, typename = void> \
49 inline constexpr bool Name = false; \
50 \
51 template<typename T, typename U> \
52 inline constexpr bool Name<T, U, std::void_t<decltype( __VA_ARGS__ )>> = \
53 true
54#endif
55
56#if defined( DAW_JSON_USE_CONCEPTS )
57#define DAW_JSON_MAKE_REQ_TRAIT2( Name, /*ReqExpression*/... ) \
58 template<typename T, typename U> \
59 inline constexpr bool Name = requires { \
60 __VA_ARGS__; \
61 }
62#else
63#define DAW_JSON_MAKE_REQ_TRAIT2( Name, /*ReqExpression*/... ) \
64 template<typename, typename, typename = void> \
65 inline constexpr bool Name = false; \
66 \
67 template<typename T, typename U> \
68 inline constexpr bool Name<T, U, std::void_t<decltype( __VA_ARGS__ )>> = \
69 true
70#endif
71
72#if defined( DAW_JSON_USE_CONCEPTS )
73#define DAW_JSON_MAKE_REQ_TRAIT3( Name, /*ReqExpression*/... ) \
74 template<typename T, typename U, typename V> \
75 inline constexpr bool Name = requires { \
76 __VA_ARGS__; \
77 }
78#else
79#define DAW_JSON_MAKE_REQ_TRAIT3( Name, /*ReqExpression*/... ) \
80 template<typename, typename, typename, typename = void> \
81 inline constexpr bool Name = false; \
82 \
83 template<typename T, typename U, typename V> \
84 inline constexpr bool Name<T, U, V, std::void_t<decltype( __VA_ARGS__ )>> = \
85 true
86#endif
87
88#if defined( DAW_JSON_USE_CONCEPTS )
89#define DAW_JSON_MAKE_REQ_TYPE_ALIAS_TRAIT_NT( Name, /*MemberTypeAlias*/... ) \
90 template<typename T, typename = void> \
91 inline constexpr bool Name = requires { \
92 typename __VA_ARGS__; \
93 }
94#else
95#define DAW_JSON_MAKE_REQ_TYPE_ALIAS_TRAIT_NT( Name, /*MemberTypeAlias*/... ) \
96 template<typename, typename = void> \
97 inline constexpr bool Name = false; \
98 \
99 template<typename T> \
100 inline constexpr bool Name<T, std::void_t<__VA_ARGS__>> = true
101#endif
102
103#if defined( DAW_JSON_USE_CONCEPTS )
104#define DAW_JSON_MAKE_REQ_TYPE_ALIAS_TRAIT( Name, /*MemberTypeAlias*/... ) \
105 template<typename T, typename = void> \
106 inline constexpr bool Name = requires { \
107 typename __VA_ARGS__; \
108 }
109#else
110#define DAW_JSON_MAKE_REQ_TYPE_ALIAS_TRAIT( Name, /*MemberTypeAlias*/... ) \
111 template<typename, typename = void> \
112 inline constexpr bool Name = false; \
113 \
114 template<typename T> \
115 inline constexpr bool Name<T, std::void_t<typename __VA_ARGS__>> = true
116#endif
117
118#if defined( DAW_JSON_USE_CONCEPTS )
119#define DAW_JSON_MAKE_REQ_TYPE_ALIAS_TRAIT2( Name, /*MemberTypeAlias*/... ) \
120 template<typename T, typename U> \
121 inline constexpr bool Name = requires { \
122 __VA_ARGS__; \
123 }
124#else
125#define DAW_JSON_MAKE_REQ_TYPE_ALIAS_TRAIT2( Name, /*MemberTypeAlias*/... ) \
126 template<typename, typename, typename = void> \
127 inline constexpr bool Name = false; \
128 \
129 template<typename T, typename U> \
130 inline constexpr bool Name<T, U, std::void_t<__VA_ARGS__>> = true
131#endif