File indexing completed on 2025-01-18 10:02:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef META_FWD_HPP
0016 #define META_FWD_HPP
0017
0018 #include <type_traits>
0019 #include <utility>
0020
0021 #ifdef __clang__
0022 #pragma GCC diagnostic push
0023 #pragma GCC diagnostic ignored "-Wmissing-variable-declarations"
0024 #endif
0025
0026 #define META_CXX_STD_14 201402L
0027 #define META_CXX_STD_17 201703L
0028
0029 #if defined(_MSVC_LANG) && _MSVC_LANG > __cplusplus
0030 #define META_CXX_VER _MSVC_LANG
0031 #else
0032 #define META_CXX_VER __cplusplus
0033 #endif
0034
0035 #if defined(__apple_build_version__) || defined(__clang__)
0036 #if defined(__apple_build_version__) || (defined(__clang__) && __clang_major__ < 6)
0037 #define META_WORKAROUND_LLVM_28385
0038 #endif
0039
0040 #elif defined(_MSC_VER)
0041 #define META_HAS_MAKE_INTEGER_SEQ 1
0042 #if _MSC_VER < 1920
0043 #define META_WORKAROUND_MSVC_702792
0044 #define META_WORKAROUND_MSVC_703656
0045 #endif
0046
0047 #if _MSC_VER < 1921
0048 #define META_WORKAROUND_MSVC_756112
0049 #endif
0050
0051 #elif defined(__GNUC__)
0052 #define META_WORKAROUND_GCC_86356
0053 #if __GNUC__ < 8
0054 #define META_WORKAROUND_GCC_UNKNOWN1
0055 #endif
0056 #if __GNUC__ == 5 && __GNUC_MINOR__ == 1
0057 #define META_WORKAROUND_GCC_66405
0058 #endif
0059 #if __GNUC__ < 5
0060 #define META_WORKAROUND_CWG_1558
0061 #endif
0062 #endif
0063
0064 #ifndef META_CXX_VARIABLE_TEMPLATES
0065 #ifdef __cpp_variable_templates
0066 #define META_CXX_VARIABLE_TEMPLATES __cpp_variable_templates
0067 #else
0068 #define META_CXX_VARIABLE_TEMPLATES (META_CXX_VER >= META_CXX_STD_14)
0069 #endif
0070 #endif
0071
0072 #ifndef META_CXX_INLINE_VARIABLES
0073 #ifdef __cpp_inline_variables
0074 #define META_CXX_INLINE_VARIABLES __cpp_inline_variables
0075 #else
0076 #define META_CXX_INLINE_VARIABLES (META_CXX_VER >= META_CXX_STD_17)
0077 #endif
0078 #endif
0079
0080 #ifndef META_INLINE_VAR
0081 #if META_CXX_INLINE_VARIABLES
0082 #define META_INLINE_VAR inline
0083 #else
0084 #define META_INLINE_VAR
0085 #endif
0086 #endif
0087
0088 #ifndef META_CXX_INTEGER_SEQUENCE
0089 #ifdef __cpp_lib_integer_sequence
0090 #define META_CXX_INTEGER_SEQUENCE __cpp_lib_integer_sequence
0091 #else
0092 #define META_CXX_INTEGER_SEQUENCE (META_CXX_VER >= META_CXX_STD_14)
0093 #endif
0094 #endif
0095
0096 #ifndef META_HAS_MAKE_INTEGER_SEQ
0097 #ifdef __has_builtin
0098 #if __has_builtin(__make_integer_seq)
0099 #define META_HAS_MAKE_INTEGER_SEQ 1
0100 #endif
0101 #endif
0102 #endif
0103 #ifndef META_HAS_MAKE_INTEGER_SEQ
0104 #define META_HAS_MAKE_INTEGER_SEQ 0
0105 #endif
0106
0107 #ifndef META_HAS_TYPE_PACK_ELEMENT
0108 #ifdef __has_builtin
0109 #if __has_builtin(__type_pack_element)
0110 #define META_HAS_TYPE_PACK_ELEMENT 1
0111 #endif
0112 #endif
0113 #endif
0114 #ifndef META_HAS_TYPE_PACK_ELEMENT
0115 #define META_HAS_TYPE_PACK_ELEMENT 0
0116 #endif
0117
0118 #if !defined(META_DEPRECATED) && !defined(META_DISABLE_DEPRECATED_WARNINGS)
0119 #if defined(__cpp_attribute_deprecated) || META_CXX_VER >= META_CXX_STD_14
0120 #define META_DEPRECATED(...) [[deprecated(__VA_ARGS__)]]
0121 #elif defined(__clang__) || defined(__GNUC__)
0122 #define META_DEPRECATED(...) __attribute__((deprecated(__VA_ARGS__)))
0123 #endif
0124 #endif
0125 #ifndef META_DEPRECATED
0126 #define META_DEPRECATED(...)
0127 #endif
0128
0129 #ifndef META_CXX_FOLD_EXPRESSIONS
0130 #ifdef __cpp_fold_expressions
0131 #define META_CXX_FOLD_EXPRESSIONS __cpp_fold_expressions
0132 #else
0133 #define META_CXX_FOLD_EXPRESSIONS (META_CXX_VER >= META_CXX_STD_17)
0134 #endif
0135 #endif
0136
0137 #if META_CXX_FOLD_EXPRESSIONS
0138 #if !META_CXX_VARIABLE_TEMPLATES
0139 #error Fold expressions, but no variable templates?
0140 #endif
0141 #endif
0142
0143 #if (defined(__cpp_concepts) && __cpp_concepts > 0) || defined(META_DOXYGEN_INVOKED)
0144 #if !META_CXX_VARIABLE_TEMPLATES
0145 #error Concepts, but no variable templates?
0146 #endif
0147 #if __cpp_concepts <= 201507L && !defined(META_DOXYGEN_INVOKED)
0148 #define META_CONCEPT concept bool
0149
0150 #define META_CONCEPT_BARRIER(...) ::meta::detail::barrier<__VA_ARGS__>
0151 #define META_TYPE_CONSTRAINT(...) typename
0152 #else
0153 #define META_CONCEPT concept
0154 #define META_CONCEPT_BARRIER(...) __VA_ARGS__
0155 #define META_TYPE_CONSTRAINT(...) __VA_ARGS__
0156 #endif
0157 #else
0158 #define META_TYPE_CONSTRAINT(...) typename
0159 #endif
0160
0161 #if (defined(__cpp_lib_type_trait_variable_templates) && \
0162 __cpp_lib_type_trait_variable_templates > 0)
0163 #define META_CXX_TRAIT_VARIABLE_TEMPLATES 1
0164 #else
0165 #define META_CXX_TRAIT_VARIABLE_TEMPLATES 0
0166 #endif
0167
0168 #if defined(__clang__)
0169 #define META_IS_SAME(...) __is_same(__VA_ARGS__)
0170 #elif defined(__GNUC__) && __GNUC__ >= 6
0171 #define META_IS_SAME(...) __is_same_as(__VA_ARGS__)
0172 #elif META_CXX_TRAIT_VARIABLE_TEMPLATES
0173 #define META_IS_SAME(...) std::is_same_v<__VA_ARGS__>
0174 #else
0175 #define META_IS_SAME(...) std::is_same<__VA_ARGS__>::value
0176 #endif
0177
0178 #if defined(__GNUC__) || defined(_MSC_VER)
0179 #define META_IS_BASE_OF(...) __is_base_of(__VA_ARGS__)
0180 #elif META_CXX_TRAIT_VARIABLE_TEMPLATES
0181 #define META_IS_BASE_OF(...) std::is_base_of_v<__VA_ARGS__>
0182 #else
0183 #define META_IS_BASE_OF(...) std::is_base_of<__VA_ARGS__>::value
0184 #endif
0185
0186 #if defined(__clang__) || defined(_MSC_VER) || \
0187 (defined(__GNUC__) && __GNUC__ >= 8)
0188 #define META_IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__)
0189 #elif META_CXX_TRAIT_VARIABLE_TEMPLATES
0190 #define META_IS_CONSTRUCTIBLE(...) std::is_constructible_v<__VA_ARGS__>
0191 #else
0192 #define META_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value
0193 #endif
0194
0195
0196
0197 #ifdef _LIBCPP_VERSION
0198 #define META_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
0199 #define META_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
0200 #elif defined(_MSVC_STL_VERSION)
0201 #define META_BEGIN_NAMESPACE_STD _STD_BEGIN
0202 #define META_END_NAMESPACE_STD _STD_END
0203 #else
0204 #define META_BEGIN_NAMESPACE_STD namespace std {
0205 #define META_END_NAMESPACE_STD }
0206 #endif
0207
0208 #if defined(__GLIBCXX__)
0209 #define META_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
0210 #define META_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
0211 #define META_BEGIN_NAMESPACE_CONTAINER _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
0212 #define META_END_NAMESPACE_CONTAINER _GLIBCXX_END_NAMESPACE_CONTAINER
0213 #else
0214 #define META_BEGIN_NAMESPACE_VERSION
0215 #define META_END_NAMESPACE_VERSION
0216 #define META_BEGIN_NAMESPACE_CONTAINER
0217 #define META_END_NAMESPACE_CONTAINER
0218 #endif
0219
0220 #if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 4000
0221 #define META_TEMPLATE_VIS _LIBCPP_TEMPLATE_VIS
0222 #elif defined(_LIBCPP_VERSION)
0223 #define META_TEMPLATE_VIS _LIBCPP_TYPE_VIS_ONLY
0224 #else
0225 #define META_TEMPLATE_VIS
0226 #endif
0227
0228
0229 namespace meta
0230 {
0231 #if META_CXX_INTEGER_SEQUENCE
0232 using std::integer_sequence;
0233 #else
0234 template <typename T, T...>
0235 struct integer_sequence;
0236 #endif
0237
0238 template <typename... Ts>
0239 struct list;
0240
0241 template <typename T>
0242 struct id;
0243
0244 template <template <typename...> class>
0245 struct quote;
0246
0247 template <typename T, template <T...> class F>
0248 struct quote_i;
0249
0250 template <template <typename...> class C, typename... Ts>
0251 struct defer;
0252
0253 template <typename T, template <T...> class C, T... Is>
0254 struct defer_i;
0255
0256 #if META_CXX_VARIABLE_TEMPLATES || defined(META_DOXYGEN_INVOKED)
0257
0258
0259
0260
0261 template <typename, template <typename...> class>
0262 META_INLINE_VAR constexpr bool is_v = false;
0263 template <typename... Ts, template <typename...> class C>
0264 META_INLINE_VAR constexpr bool is_v<C<Ts...>, C> = true;
0265 #endif
0266
0267 #ifdef META_CONCEPT
0268 namespace detail
0269 {
0270 template <bool B>
0271 META_INLINE_VAR constexpr bool barrier = B;
0272
0273 template <class T, T> struct require_constant;
0274 }
0275
0276 template <typename...>
0277 META_CONCEPT is_true = META_CONCEPT_BARRIER(true);
0278
0279 template <typename T, typename U>
0280 META_CONCEPT same_as =
0281 META_CONCEPT_BARRIER(META_IS_SAME(T, U));
0282
0283 template <template <typename...> class C, typename... Ts>
0284 META_CONCEPT valid = requires
0285 {
0286 typename C<Ts...>;
0287 };
0288
0289 template <typename T, template <T...> class C, T... Is>
0290 META_CONCEPT valid_i = requires
0291 {
0292 typename C<Is...>;
0293 };
0294
0295 template <typename T>
0296 META_CONCEPT trait = requires
0297 {
0298 typename T::type;
0299 };
0300
0301 template <typename T>
0302 META_CONCEPT invocable = requires
0303 {
0304 typename quote<T::template invoke>;
0305 };
0306
0307 template <typename T>
0308 META_CONCEPT list_like = is_v<T, list>;
0309
0310
0311 template <typename T>
0312 META_CONCEPT integral = requires
0313 {
0314 typename T::type;
0315 typename T::value_type;
0316 typename T::type::value_type;
0317 }
0318 && same_as<typename T::value_type, typename T::type::value_type>
0319 #if META_CXX_TRAIT_VARIABLE_TEMPLATES
0320 && std::is_integral_v<typename T::value_type>
0321 #else
0322 && std::is_integral<typename T::value_type>::value
0323 #endif
0324
0325 && requires
0326 {
0327
0328 T::value;
0329 requires same_as<decltype(T::value), const typename T::value_type>;
0330 typename detail::require_constant<decltype(T::value), T::value>;
0331
0332
0333 T::type::value;
0334 requires same_as<decltype(T::type::value), const typename T::value_type>;
0335 typename detail::require_constant<decltype(T::type::value), T::type::value>;
0336 requires T::value == T::type::value;
0337
0338
0339 T{}();
0340 requires same_as<decltype(T{}()), typename T::value_type>;
0341 typename detail::require_constant<decltype(T{}()), T{}()>;
0342 requires T{}() == T::value;
0343
0344
0345 };
0346
0347 #endif
0348
0349 namespace extension
0350 {
0351 template <META_TYPE_CONSTRAINT(invocable) F, typename L>
0352 struct apply;
0353 }
0354 }
0355
0356 #ifdef __clang__
0357 #pragma GCC diagnostic pop
0358 #endif
0359
0360 #endif