4 #ifndef LEXY_DETAIL_CONFIG_HPP_INCLUDED
5 #define LEXY_DETAIL_CONFIG_HPP_INCLUDED
10 #if defined(LEXY_USER_CONFIG_HEADER)
11 # include LEXY_USER_CONFIG_HEADER
12 #elif defined(__has_include)
13 # if __has_include(<lexy_user_config.hpp>)
14 # include <lexy_user_config.hpp>
15 # elif __has_include("lexy_user_config.hpp")
16 # include "lexy_user_config.hpp"
20 #ifndef LEXY_HAS_UNICODE_DATABASE
21 # define LEXY_HAS_UNICODE_DATABASE 0
24 #ifndef LEXY_EXPERIMENTAL
25 # define LEXY_EXPERIMENTAL 0
29 #define LEXY_MOV(...) static_cast<std::remove_reference_t<decltype(__VA_ARGS__)>&&>(__VA_ARGS__)
30 #define LEXY_FWD(...) static_cast<decltype(__VA_ARGS__)>(__VA_ARGS__)
32 #define LEXY_DECLVAL(...) lexy::_detail::declval<__VA_ARGS__>()
34 #define LEXY_DECAY_DECLTYPE(...) std::decay_t<decltype(__VA_ARGS__)>
38 #define LEXY_INSTANTIATION_NEWTYPE(Name, Templ, ...) \
39 struct Name : Templ<__VA_ARGS__> \
41 using Templ<__VA_ARGS__>::Templ; \
46 template <
typename... T>
50 std::add_rvalue_reference_t<T>
declval();
53 constexpr
void swap(T& lhs, T& rhs)
60 template <
typename T,
typename U>
61 constexpr
bool is_decayed_same = std::is_same_v<std::decay_t<T>, std::decay_t<U>>;
63 template <
typename T,
typename Fallback>
64 using type_or = std::conditional_t<std::is_void_v<T>, Fallback, T>;
70 # if __cpp_nontype_template_parameter_class >= 201806 || __cpp_nontype_template_args >= 201911
71 # define LEXY_HAS_NTTP 1
73 # define LEXY_HAS_NTTP 0
78 # define LEXY_NTTP_PARAM auto
80 # define LEXY_NTTP_PARAM const auto&
84 #ifndef LEXY_HAS_CONSTEVAL
85 # if defined(_MSC_VER) && !defined(__clang__)
87 # define LEXY_HAS_CONSTEVAL 0
88 # elif __cpp_consteval
89 # define LEXY_HAS_CONSTEVAL 1
91 # define LEXY_HAS_CONSTEVAL 0
95 #if LEXY_HAS_CONSTEVAL
96 # define LEXY_CONSTEVAL consteval
98 # define LEXY_CONSTEVAL constexpr
102 #ifndef LEXY_HAS_CONSTEXPR_DTOR
103 # if __cpp_constexpr_dynamic_alloc
104 # define LEXY_HAS_CONSTEXPR_DTOR 1
106 # define LEXY_HAS_CONSTEXPR_DTOR 0
110 #if LEXY_HAS_CONSTEXPR_DTOR
111 # define LEXY_CONSTEXPR_DTOR constexpr
113 # define LEXY_CONSTEXPR_DTOR
117 #ifndef LEXY_HAS_CHAR8_T
119 # define LEXY_HAS_CHAR8_T 1
121 # define LEXY_HAS_CHAR8_T 0
127 # define LEXY_CHAR_OF_u8 char8_t
128 # define LEXY_CHAR8_T char8_t
129 # define LEXY_CHAR8_STR(Str) u8##Str
138 # define LEXY_CHAR_OF_u8 char
139 # define LEXY_CHAR8_T ::lexy::_char8_t
140 # define LEXY_CHAR8_STR(Str) \
141 LEXY_NTTP_STRING(::lexy::_detail::type_string, u8##Str)::c_str<LEXY_CHAR8_T>
146 #ifndef LEXY_IS_LITTLE_ENDIAN
147 # if defined(__BYTE_ORDER__)
148 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
149 # define LEXY_IS_LITTLE_ENDIAN 1
150 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
151 # define LEXY_IS_LITTLE_ENDIAN 0
153 # error "unsupported byte order"
155 # elif defined(_MSC_VER)
156 # define LEXY_IS_LITTLE_ENDIAN 1
158 # error "unknown endianness"
163 #ifndef LEXY_FORCE_INLINE
164 # if defined(__has_cpp_attribute)
165 # if __has_cpp_attribute(gnu::always_inline)
166 # define LEXY_FORCE_INLINE [[gnu::always_inline]]
170 # ifndef LEXY_FORCE_INLINE
171 # define LEXY_FORCE_INLINE inline
176 #ifndef LEXY_EMPTY_MEMBER
178 # if defined(__has_cpp_attribute)
179 # if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 11
181 # define LEXY_HAS_EMPTY_MEMBER 0
182 # elif __has_cpp_attribute(no_unique_address)
183 # define LEXY_HAS_EMPTY_MEMBER 1
186 # ifndef LEXY_HAS_EMPTY_MEMBER
187 # define LEXY_HAS_EMPTY_MEMBER 0
190 # if LEXY_HAS_EMPTY_MEMBER
191 # define LEXY_EMPTY_MEMBER [[no_unique_address]]
193 # define LEXY_EMPTY_MEMBER
198 #endif // LEXY_DETAIL_CONFIG_HPP_INCLUDED