1#ifndef VEG_MACROS_HPP_HSTLSKZXS
2#define VEG_MACROS_HPP_HSTLSKZXS
7#include <initializer_list>
13#define PROXSUITE_PRETTY_FUNCTION __FUNCSIG__
15#define PROXSUITE_PRETTY_FUNCTION __PRETTY_FUNCTION__
18#define PROXSUITE_THROW_PRETTY(condition, exception, message) \
20 std::ostringstream ss; \
21 ss << "From file: " << __FILE__ << "\n"; \
22 ss << "in function: " << PROXSUITE_PRETTY_FUNCTION << "\n"; \
23 ss << "at line: " << __LINE__ << "\n"; \
24 ss << message << "\n"; \
25 throw exception(ss.str()); \
28#define PROXSUITE_CHECK_ARGUMENT_SIZE(size, expected_size, message) \
29 if (size != expected_size) { \
30 std::ostringstream oss; \
31 oss << "wrong argument size: expected " << expected_size << ", got " \
33 oss << "hint: " << message << std::endl; \
34 PROXSUITE_THROW_PRETTY(true, std::invalid_argument, oss.str()); \
37#if HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \
38 HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
39#define VEG_DEPRECATED(Reason) __declspec(deprecated(Reason))
40#elif HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \
41 HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
42 HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \
43 HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) || \
44 HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || HEDLEY_TI_VERSION_CHECK(18, 1, 0) || \
45 HEDLEY_TI_ARMCL_VERSION_CHECK(18, 1, 0) || \
46 HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || \
47 HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
48 HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0)
49#define VEG_DEPRECATED(Reason) __attribute__((__deprecated__(Reason)))
50#elif defined(VEG_WITH_CXX14_SUPPORT)
51#define VEG_DEPRECATED(Reason) \
52 HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated(Reason)]])
53#elif HEDLEY_HAS_ATTRIBUTE(deprecated) || HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \
54 HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
55 (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
56 defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
57 HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
58 (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
59 defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
60 HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
61 (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
62 defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
63 HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
64 (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
65 defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
66 HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
67 HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
68 HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
69#define VEG_DEPRECATED(Reason) __attribute__((__deprecated__))
70#elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \
71 HEDLEY_PELLES_VERSION_CHECK(6, 50, 0) || \
72 HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
73#define VEG_DEPRECATED(Reason) __declspec(deprecated)
74#elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
75#define VEG_DEPRECATED(Reason) _Pragma("deprecated")
77#define VEG_DEPRECATED(Reason)
81#define VEG_UNUSED_VARIABLE(var) (void)(var)
83#define VEG_ONLY_USED_FOR_DEBUG(var) VEG_UNUSED_VARIABLE(var)
85#define VEG_ONLY_USED_FOR_DEBUG(var)
91#define VEG_WRAP_SILENCE_WARNING(...) \
92 HEDLEY_DIAGNOSTIC_PUSH _Pragma( \
93 "clang diagnostic ignored \"-Wc++17-extensions\"") \
94 __VA_ARGS__ HEDLEY_DIAGNOSTIC_POP
96#define VEG_WRAP_SILENCE_WARNING(...) __VA_ARGS__
99#ifndef VEG_HAS_NO_UNIQUE_ADDRESS
100#define VEG_HAS_NO_UNIQUE_ADDRESS 0
103#if VEG_HAS_NO_UNIQUE_ADDRESS
105#define VEG_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
107#define VEG_NO_UNIQUE_ADDRESS [[no_unique_address]]
110#define VEG_NO_UNIQUE_ADDRESS
115#if defined(NDEBUG) || defined(__OPTIMIZE__)
116#define VEG_INLINE HEDLEY_ALWAYS_INLINE
118#define VEG_INLINE inline
123#define VEG_NO_INLINE HEDLEY_NEVER_INLINE
125#if defined(__cpp_concepts) && __cpp_concepts >= 201907L
126#define VEG_HAS_CONCEPTS 1
128#define VEG_HAS_CONCEPTS 0
131#define VEG_DECLVAL(...) (std::declval<__VA_ARGS__>())
133#if defined(__clang__)
134#define VEG_ARROW(...) \
135 __attribute__((always_inline)) noexcept(noexcept((__VA_ARGS__))) \
136 ->decltype((__VA_ARGS__)) \
138 return __VA_ARGS__; \
140#elif defined(__GNUC__) && (__GNUC__ >= 9)
141#define VEG_ARROW(...) \
142 noexcept(noexcept((__VA_ARGS__))) __attribute__((always_inline)) \
143 ->decltype((__VA_ARGS__)) \
145 return __VA_ARGS__; \
148#define VEG_ARROW(...) \
149 noexcept(noexcept((__VA_ARGS__)))->decltype((__VA_ARGS__)) \
151 return __VA_ARGS__; \
155#define VEG_LAZY_BY_REF(...) [&]() VEG_ARROW(__VA_ARGS__)
157#define VEG_LIFT(...) \
158 [&](auto&&... args) VEG_ARROW((__VA_ARGS__)(VEG_FWD(args)...))
160#define VEG_DEDUCE_RET(...) \
161 noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \
163 return __VA_ARGS__; \
167#if defined(VEG_WITH_CXX17_SUPPORT)
168#define VEG_HAS_FOLD_EXPR 1
169#define VEG_ALL_OF(...) (__VA_ARGS__ && ... && true)
170#define VEG_ANY_OF(...) (__VA_ARGS__ || ... || false)
171#elif defined(__clang__)
172#define VEG_HAS_FOLD_EXPR 1
173#define VEG_ALL_OF(...) VEG_WRAP_SILENCE_WARNING((__VA_ARGS__ && ... && true))
174#define VEG_ANY_OF(...) VEG_WRAP_SILENCE_WARNING((__VA_ARGS__ || ... || false))
176#define VEG_HAS_FOLD_EXPR 0
177#define VEG_ALL_OF(...) \
178 ::proxsuite::linalg::veg::meta::and_test< \
179 ::proxsuite::linalg::veg::meta::make_index_sequence< \
180 ::proxsuite::linalg::veg::meta::pack_size<decltype(( \
181 void)(__VA_ARGS__))...>::value>, \
182 ::proxsuite::linalg::veg::meta::bool_constant<(__VA_ARGS__)>...>::value
183#define VEG_ANY_OF(...) \
184 ::proxsuite::linalg::veg::meta::or_test< \
185 ::proxsuite::linalg::veg::meta::make_index_sequence< \
186 ::proxsuite::linalg::veg::meta::pack_size<decltype(( \
187 void)(__VA_ARGS__))...>::value>, \
188 ::proxsuite::linalg::veg::meta::bool_constant<(__VA_ARGS__)>...>::value
191#define VEG_EVAL_ALL(...) \
192 ((void)(::proxsuite::linalg::veg::_detail::EmptyArr{ \
193 ::proxsuite::linalg::veg::_detail::Empty{}, \
194 ((void)(__VA_ARGS__), ::proxsuite::linalg::veg::_detail::Empty{})... }))
200#define __VEG_IMPL_AND(_, Param) &&__VEG_PP_UNWRAP(Param)
201#define __VEG_IMPL_OR(_, Param) || __VEG_PP_UNWRAP(Param)
203#define __VEG_IMPL_CONJUNCTION(First, ...) \
204 (__VEG_PP_UNWRAP(First) \
205 __VEG_PP_TUPLE_FOR_EACH(__VEG_IMPL_AND, _, (__VA_ARGS__)))
207#define __VEG_IMPL_DISJUNCTION(First, ...) \
208 (__VEG_PP_UNWRAP(First) \
209 __VEG_PP_TUPLE_FOR_EACH(__VEG_IMPL_OR, _, (__VA_ARGS__)))
211#define VEG_DEF_CONCEPT(Tpl, Name, ...) \
212 template<__VEG_PP_REMOVE_PAREN1(Tpl)> \
213 concept Name = __VA_ARGS__; \
216#define VEG_CHECK_CONCEPT_MACRO(Namespace, ...) \
217 static_assert(Namespace::__VA_ARGS__, \
218 __VEG_PP_STRINGIZE(__VA_ARGS__) " failed")
219#define VEG_CONCEPT_MACRO(Namespace, ...) Namespace::__VA_ARGS__
221#define VEG_DEF_CONCEPT_CONJUNCTION(Tpl, Name, Terms) \
222 VEG_DEF_CONCEPT(Tpl, Name, __VEG_IMPL_CONJUNCTION Terms)
223#define VEG_DEF_CONCEPT_DISJUNCTION(Tpl, Name, Terms) \
224 VEG_DEF_CONCEPT(Tpl, Name, __VEG_IMPL_DISJUNCTION Terms)
226#define VEG_CONCEPT_EXPR(Tpl, TplNames, Name, Expr, ...) \
227 namespace _veg_detail { \
228 template<typename ExprType, __VEG_PP_REMOVE_PAREN1(Tpl)> \
229 concept test_return_##Name = __VA_ARGS__; \
231 template<__VEG_PP_REMOVE_PAREN1(Tpl)> \
233 _veg_detail::test_return_##Name<decltype((Expr)), \
234 __VEG_PP_REMOVE_PAREN1(TplNames)>; \
235 template<__VEG_PP_REMOVE_PAREN1(Tpl)> \
236 concept xnothrow_##Name = noexcept(Expr); \
237 template<__VEG_PP_REMOVE_PAREN1(Tpl)> \
238 concept nothrow_##Name = noexcept(Expr); \
243#if defined(VEG_WITH_CXX14_SUPPORT)
244#define __VEG_IMPL_DEF_CONCEPT(Tpl, Name, Value, ...) \
246 template<__VEG_PP_REMOVE_PAREN1(Tpl)> \
247 struct Name : __VA_ARGS__ \
251 template<__VEG_PP_REMOVE_PAREN1(Tpl)> \
252 constexpr bool const& Name = \
253 ::proxsuite::linalg::veg::meta::bool_constant<Value>::value; \
257#define __VEG_IMPL_DEF_CONCEPT(Tpl, Name, Value, ...) \
258 template<__VEG_PP_REMOVE_PAREN1(Tpl)> \
259 struct Name : __VA_ARGS__ \
264#define __VEG_NO_WARNING_PRAGMA_PUSH \
265 HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic ignored \"-Wconversion\"")
266#define __VEG_NO_WARNING_PRAGMA_POP HEDLEY_DIAGNOSTIC_POP
268#define __VEG_NO_WARNING_PRAGMA_PUSH
269#define __VEG_NO_WARNING_PRAGMA_POP
272#define VEG_CONCEPT_EXPR(Tpl, TplNames, Name, Expr, ...) \
273 namespace _veg_detail { \
274 template<typename _veg_Enable, __VEG_PP_REMOVE_PAREN1(Tpl)> \
275 struct test_sfinae_##Name \
277 using TestExpr = ::proxsuite::linalg::veg::meta::false_type; \
278 using NothrowTestExpr = ::proxsuite::linalg::veg::meta::false_type; \
280 template<__VEG_PP_REMOVE_PAREN1(Tpl)> \
281 struct test_sfinae_##Name< \
282 ::proxsuite::linalg::veg::meta::void_t<decltype((Expr))>, \
283 __VEG_PP_REMOVE_PAREN1(TplNames)> \
285 using ExprType = decltype((Expr)); \
287 ::proxsuite::linalg::veg::meta::bool_constant<__VA_ARGS__>; \
288 using NothrowTestExpr = ::proxsuite::linalg::veg::meta::bool_constant< \
289 (TestExpr::value) && __VEG_NO_WARNING_PRAGMA_PUSH noexcept(Expr) \
290 __VEG_NO_WARNING_PRAGMA_POP>; \
296 _veg_detail::test_sfinae_##Name<void, __VEG_PP_REMOVE_PAREN1(TplNames)>:: \
298 VEG_DEF_CONCEPT(Tpl, nothrow_##Name, noexcept(Expr)); \
302 _veg_detail::test_sfinae_##Name<void, __VEG_PP_REMOVE_PAREN1(TplNames)>:: \
303 NothrowTestExpr::value); \
306#if defined(VEG_WITH_CXX14_SUPPORT)
307#define VEG_CONCEPT_MACRO(Namespace, ...) Namespace::__VA_ARGS__
308#define __VEG_IMPL_ADD_VALUE(I, _, Param) (Param)
309#define __VEG_IMPL_TRAIT(Param) __VEG_PP_HEAD Param _::__VEG_PP_TAIL Param
311#define VEG_CONCEPT_MACRO(Namespace, ...) Namespace::__VA_ARGS__::value
312#define __VEG_IMPL_ADD_VALUE(I, _, Param) \
313 ((__VEG_PP_REMOVE_PAREN(Param)::value))
314#define __VEG_IMPL_TRAIT(Param) __VEG_PP_UNWRAP(Param)
316#define __VEG_IMPL_PUT_TRAIT(I, _, Param) __VEG_IMPL_TRAIT(Param)
318#define VEG_CHECK_CONCEPT_MACRO(Namespace, ...) \
319 static_assert(decltype(Namespace::check_##__VA_ARGS__())::value, \
320 __VEG_PP_STRINGIZE(__VA_ARGS__) " failed")
321#define VEG_DEF_CONCEPT(Tpl, Name, ...) \
322 __VEG_IMPL_DEF_CONCEPT( \
326 ::proxsuite::linalg::veg::meta::bool_constant<__VA_ARGS__>); \
329 requires(__VA_ARGS__), \
330 constexpr auto check_##Name, \
331 (_ = 0, int)) noexcept -> ::proxsuite::linalg::veg::meta::true_type
333#define __VEG_IMPL_SFINAE(_, Param) \
334 , ::proxsuite::linalg::veg::meta:: \
335 enable_if_t<__VEG_PP_ID(__VEG_PP_UNWRAP Param), int> = 0
337#define __VEG_IMPL_OVERLOAD(Name_Tpl, Param) \
338 template<__VEG_PP_REMOVE_PAREN(__VEG_PP_TAIL Name_Tpl), \
339 typename ::proxsuite::linalg::veg::_detail::_meta:: \
340 enable_if<__VEG_PP_ID(__VEG_PP_UNWRAP Param), int>::type = 0> \
341 auto __VEG_PP_CAT(check_, __VEG_PP_HEAD Name_Tpl)() noexcept \
342 -> ::proxsuite::linalg::veg::meta::true_type;
344#define VEG_DEF_CONCEPT_BOOL_CONJUNCTION_IMPL(Tpl, Name, Base, Seq) \
345 __VEG_IMPL_DEF_CONCEPT(Tpl, \
347 (__VEG_PP_REMOVE_PAREN1(Base)::value), \
348 __VEG_PP_REMOVE_PAREN1(Base)); \
349 template<__VEG_PP_REMOVE_PAREN(Tpl) \
350 __VEG_PP_TUPLE_FOR_EACH(__VEG_IMPL_SFINAE, _, Seq)> \
351 auto check_##Name() noexcept -> ::proxsuite::linalg::veg::meta::true_type
352#define VEG_DEF_CONCEPT_BOOL_DISJUNCTION_IMPL(Tpl, Name, Base, Seq) \
353 __VEG_IMPL_DEF_CONCEPT(Tpl, \
355 (__VEG_PP_REMOVE_PAREN1(Base)::value), \
356 __VEG_PP_REMOVE_PAREN1(Base)); \
357 __VEG_PP_TUPLE_FOR_EACH(__VEG_IMPL_OVERLOAD, (Name, Tpl), Seq) \
360#define VEG_DEF_CONCEPT_CONJUNCTION(Tpl, Name, Terms) \
361 VEG_DEF_CONCEPT_BOOL_CONJUNCTION_IMPL( \
364 (__VEG_IMPL_CONJUNCTION(Terms)), \
365 __VEG_PP_TUPLE_TRANSFORM_I(__VEG_IMPL_ADD_VALUE, _, Terms))
367#define VEG_DEF_CONCEPT_DISJUNCTION(Tpl, Name, Terms) \
368 VEG_DEF_CONCEPT_BOOL_DISJUNCTION_IMPL( \
371 (__VEG_IMPL_DISJUNCTION(Terms)), \
372 __VEG_PP_TUPLE_TRANSFORM_I(__VEG_IMPL_ADD_VALUE, _, Terms))
374#define __VEG_IMPL_CONJUNCTION(Tuple) \
375 ::proxsuite::linalg::veg::meta::conjunction<__VEG_PP_REMOVE_PAREN( \
376 __VEG_PP_TUPLE_TRANSFORM_I(__VEG_IMPL_PUT_TRAIT, _, Tuple))>
377#define __VEG_IMPL_DISJUNCTION(Tuple) \
378 ::proxsuite::linalg::veg::meta::disjunction<__VEG_PP_REMOVE_PAREN( \
379 __VEG_PP_TUPLE_TRANSFORM_I(__VEG_IMPL_PUT_TRAIT, _, Tuple))>
385#define VEG_TEMPLATE(TParams, Constraint, Attr_Name, ...) \
386 __VEG_IMPL_TEMPLATE(Attr_Name, \
388 __VEG_PP_CAT2(__VEG_IMPL_PREFIX_, Constraint), \
392#define VEG_CONSTRAINED_MEMBER_FN(Constraint, Attr_Name, Params, ...) \
393 Attr_Name __VEG_PP_TUPLE_TRANSFORM_I(__VEG_IMPL_PARAM_EXPAND, _, Params) \
395 requires __VEG_PP_CAT2(__VEG_IMPL_PREFIX_, Constraint)
397#define VEG_TEMPLATE_CVT(TParams, Constraint, Attr, ...) \
398 template<__VEG_PP_REMOVE_PAREN(TParams)> \
399 Constraint Attr operator __VA_ARGS__()
401#define VEG_CONSTRAINED_MEMBER_FN(Constraint, Attr_Name, Params, ...) \
404 requires(__VEG_PP_CAT2(__VEG_IMPL_PREFIX_, Constraint) && \
405 ::proxsuite::linalg::veg::meta::bool_constant<(_ == 0)>::value), \
407 __VEG_PP_REMOVE_PAREN(Params)) \
410#define VEG_TEMPLATE_CVT(TParams, Constraint, Attr, ...) \
411 template<__VEG_PP_REMOVE_PAREN(TParams)> \
412 Attr operator ::proxsuite::linalg::veg::meta::enable_if_t< \
413 (__VEG_PP_CAT2(__VEG_IMPL_PREFIX_, Constraint)), \
417#if VEG_HAS_CONCEPTS && defined(__cpp_conditional_explicit) && \
418 (__cpp_conditional_explicit >= 201806L)
419#define VEG_TEMPLATE_EXPLICIT( \
420 TParams, Constraint, Explicit_Cond, Attr_Name, Params, ...) \
421 VEG_TEMPLATE(TParams, \
423 Explicit_Cond Attr_Name, \
424 __VEG_PP_REMOVE_PAREN(Params)) \
427#define VEG_TEMPLATE_CVT_EXPLICIT( \
428 TParams, Constraint, Explicit_Cond, Attr, Type, ...) \
429 template<__VEG_PP_REMOVE_PAREN(TParams)> \
430 Constraint Explicit_Cond Attr operator __VEG_PP_REMOVE_PAREN(Type)() \
434#define VEG_TEMPLATE_EXPLICIT( \
435 TParams, Constraint, Explicit_Cond, Attr_Name, Params, ...) \
437 (__VEG_PP_REMOVE_PAREN TParams, \
438 ::proxsuite::linalg::veg::meta:: \
439 enable_if_t<(__VEG_PP_CAT2(__VEG_IMPL_PREFIX_, Explicit_Cond)), int> = \
442 explicit Attr_Name, \
443 __VEG_PP_REMOVE_PAREN(Params)) \
445 VEG_TEMPLATE((__VEG_PP_REMOVE_PAREN TParams, \
446 ::proxsuite::linalg::veg::meta::enable_if_t< \
447 !(__VEG_PP_CAT2(__VEG_IMPL_PREFIX_, Explicit_Cond)), \
451 __VEG_PP_REMOVE_PAREN(Params)) \
454#define VEG_TEMPLATE_CVT_EXPLICIT( \
455 TParams, Constraint, Explicit_Cond, Attr, Type, ...) \
457 (__VEG_PP_REMOVE_PAREN TParams, \
458 ::proxsuite::linalg::veg::meta:: \
459 enable_if_t<(__VEG_PP_CAT2(__VEG_IMPL_PREFIX_, Explicit_Cond)), int> = \
463 __VEG_PP_REMOVE_PAREN(Type)) \
466 VEG_TEMPLATE_CVT((__VEG_PP_REMOVE_PAREN TParams, \
467 ::proxsuite::linalg::veg::meta::enable_if_t< \
468 !(__VEG_PP_CAT2(__VEG_IMPL_PREFIX_, Explicit_Cond)), \
472 __VEG_PP_REMOVE_PAREN(Type)) \
476#define __VEG_IMPL_PREFIX_requires
477#define __VEG_IMPL_PREFIX_explicit
479#define __VEG_IMPL_PARAM_EXPAND(I, _, Param) \
480 __VEG_PP_TAIL Param __VEG_PP_HEAD Param
482#define __VEG_IMPL_TEMPLATE(Attr_Name, TParams, Constraint, ...) \
483 template<__VEG_PP_REMOVE_PAREN(TParams)> \
484 requires Constraint \
485 Attr_Name __VEG_PP_TUPLE_TRANSFORM_I( \
486 __VEG_IMPL_PARAM_EXPAND, _, (__VA_ARGS__))
489#define __VEG_IMPL_TEMPLATE2_HELPER_0(Constraint, Param) \
490 __VEG_PP_TAIL Param __VEG_PP_HEAD Param
492#define __VEG_IMPL_TEMPLATE2_HELPER_1(Constraint, Param) \
493 ::proxsuite::linalg::veg::meta::enable_if_t<(Constraint), \
494 __VEG_PP_TAIL Param> \
497#define __VEG_IMPL_TEMPLATE2_HELPER(I, Constraint, Param) \
498 __VEG_PP_CAT2(__VEG_IMPL_TEMPLATE2_HELPER_, \
499 __VEG_IMPL_PP_IS_1(__VEG_IMPL_PP_INC(I))) \
502#define __VEG_IMPL_TEMPLATE(Attr_Name, TParams, Constraint, ...) \
503 template<__VEG_PP_REMOVE_PAREN(TParams)> \
504 Attr_Name __VEG_PP_TUPLE_TRANSFORM_I( \
505 __VEG_IMPL_TEMPLATE2_HELPER, Constraint, (__VA_ARGS__))
511#if defined(VEG_WITH_CXX17_SUPPORT)
512#define VEG_INLINE_VAR(Name, Obj) \
513 inline constexpr auto const& Name = \
514 ::proxsuite::linalg::veg::meta::static_const<Obj>::value; \
515 static_assert((void(Name), true), ".")
517#define VEG_INLINE_VAR_TEMPLATE(Tpl, Name, ...) \
518 template<__VEG_PP_REMOVE_PAREN(Tpl)> \
519 inline constexpr auto const& Name = \
520 ::proxsuite::linalg::veg::meta::static_const<__VA_ARGS__>::value; \
523#define VEG_INLINE_VAR(Name, Obj) \
525 constexpr auto const& Name = \
526 ::proxsuite::linalg::veg::meta::static_const<Obj>::value; \
528 static_assert((void(Name), true), ".")
530#if defined(VEG_WITH_CXX14_SUPPORT)
531#define VEG_INLINE_VAR_TEMPLATE(Tpl, Name, ...) \
533 template<__VEG_PP_REMOVE_PAREN(Tpl)> \
534 constexpr auto const& Name = \
535 ::proxsuite::linalg::veg::meta::static_const< \
541#define VEG_INLINE_VAR_TEMPLATE(Tpl, Name, ...) VEG_NOM_SEMICOLON
545#define VEG_NIEBLOID(Name) VEG_INLINE_VAR(Name, nb::Name)
547#define VEG_NIEBLOID_TEMPLATE(Tpl, Name, ...) \
548 VEG_INLINE_VAR_TEMPLATE(Tpl, Name, nb::Name<__VA_ARGS__>)
550#define VEG_TAG(Name, Type) \
555 explicit Type() = default; \
558 using Type = _::Type<0>; \
559 VEG_INLINE_VAR(Name, Type)
561#define VEG_TAG_TEMPLATE(Tpl, Name, Type, ...) \
562 template<__VEG_PP_REMOVE_PAREN(Tpl)> \
565 explicit Type() = default; \
567 VEG_INLINE_VAR_TEMPLATE(Tpl, Name, Type<__VA_ARGS__>)
569#define VEG_FWD(X) static_cast<decltype(X)&&>(X)
570#define VEG_FWD2(X) static_cast<decltype(X)>(static_cast<decltype(X)&&>(X))
574 static_cast<typename ::proxsuite::linalg::veg::uncvref_t<decltype(X)>&&>(X)
576#ifdef VEG_NO_INSTANTIATE
577#define VEG_INSTANTIATE(Fn, ...) VEG_NOM_SEMICOLON
578#define VEG_INSTANTIATE_CLASS(Class, ...) VEG_NOM_SEMICOLON
580#define VEG_INSTANTIATE(Fn, ...) \
581 __VEG_IMPL_INSTANTIATE( \
583 __VEG_PP_CAT(__VEG_PP_CAT(_dummy_explicit_instantiation, __LINE__), \
584 __VEG_PP_CAT(_, __COUNTER__)), \
586#define __VEG_IMPL_INSTANTIATE(Fn, Name, ...) \
587 template<typename... Ts> \
590 void apply(Ts&&... args) \
592 Fn(VEG_FWD(args)...); \
595 template struct Name<__VA_ARGS__>
597#define VEG_INSTANTIATE_CLASS(Class, ...) template struct Class<__VA_ARGS__>
600#define VEG_NOM_SEMICOLON static_assert(true, ".")
601#define VEG_ID(id) __VEG_PP_CAT(id, __COUNTER__)
621template<
bool B,
typename T =
void>
630template<
typename U,
typename V>
671 static constexpr T value{};
675constexpr T static_const<T>::value;
678template<
typename... Ts>
681template<
typename...
Types,
typename...
Args>
684template<
typename...
Types,
typename...
Args>
693 template<
typename... Ts>
713template<
typename T, T...
Nums>
716#if VEG_HAS_BUILTIN(__make_integer_seq)
718template<
typename T, T N>
723template<
typename T, T N>
730template<
typename Seq1,
typename Seq2>
733template<
typename Seq1,
typename Seq2>
747 (
sizeof...(Nums1) +
Nums2)...,
748 sizeof...(Nums1) +
sizeof...(
Nums2)>;
751template<
typename T, usize N,
bool Even = (N % 2) == 0>
759template<
typename T, usize N>
780template<
typename T, T N>
786#define VEG_DEF_CONCEPT_BUILTIN_OR_INTERNAL(Tpl, Name, ...) \
790 VEG_HAS_BUILTIN_OR(__is_##Name, \
791 __is_##Name(__VA_ARGS__), \
792 (_detail::_meta::is_##Name<__VA_ARGS__>::value)))
797template<
typename... Ts>
802template<usize I,
typename T>
808template<
typename Seq,
typename... Ts>
811template<
usize... Is,
typename... Ts>
815#if !defined(VEG_WITH_CXX17_SUPPORT)
823template<
typename... Ts>
827template<
typename... Ts>
831#if !defined(VEG_WITH_CXX17_SUPPORT)
840template<
typename C,
typename Mem>
849 return size == 0 ?
true
862 template<
typename U,
typename = U>
865 static constexpr bool value =
false;
872 using Type =
typename U::_veglib_impl_member_extract;
876 static constexpr bool value = Detect::value;
877 using Type =
typename Detect::Type;
881template<
bool B,
typename T =
void>
892template<
typename T, T Value>
897template<
typename T, T Value>
918template<
typename T,
typename U>
1024inline namespace tags {
1053 static constexpr CharUnit literal[
sizeof...(Cs)] = {
Cs... };
1059 return { unsafe, from_raw_parts, literal,
isize{
sizeof...(Cs) } };
1064constexpr CharUnit StrLiteralConstant<Cs...>::literal[
sizeof...(Cs)];
1069template<
typename T, usize N>
1078 static_assert(
sizeof(T) != 0,
".");
1086#if defined(__clang__) || (defined(VEG_WITH_CXX14_SUPPORT) && defined(__GNUC__))
1088#pragma GCC diagnostic ignored "-Wpedantic"
1090#pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template"
1093template<
typename Char,
1096operator""__veglib_const_literal_gnuc() noexcept
1097 ->
proxsuite::linalg::veg::StrLiteralConstant<
1098 proxsuite::linalg::veg::CharUnit(Cs)...>
1105#define __VEG_IMPL_UTF8_CONST(Literal) \
1106 (u8##Literal##__veglib_const_literal_gnuc)
1108#elif (defined(__clang__) && defined(VEG_WITH_CXX20_SUPPORT)) || \
1109 (defined(__cpp_nontype_template_args) && \
1110 (__cpp_nontype_template_args >= 201911L))
1116struct StrLiteralImpl
1120 template<
typename Char>
1121 constexpr StrLiteralImpl(Char
const* s)
1123 for (isize i = 0; i < N; ++i) {
1128template<
typename Char, isize N>
1129StrLiteralImpl(Char
const (&)[N]) -> StrLiteralImpl<N - 1>;
1132struct StrLiteralLen;
1135struct StrLiteralLen<StrLiteralImpl<N>>
1137 static constexpr usize value{ N };
1140struct StrLiteralLen<StrLiteralImpl<N> const>
1142 static constexpr usize value{ N };
1145template<
typename Seq, auto Literal>
1146struct StrLiteralExpand;
1148template<usize... Is, StrLiteralImpl<static_cast<isize>(
sizeof...(Is))> L>
1151 using Type = StrLiteralConstant<L._[Is]...>;
1158template<proxsuite::linalg::veg::_detail::StrLiteralImpl S>
1160operator""__veglib_const_literal_cpp20() noexcept ->
1161 typename
proxsuite::linalg::veg::_detail::StrLiteralExpand<
1162 proxsuite::linalg::veg::_detail::_meta::make_index_sequence<
1163 proxsuite::linalg::veg::_detail::StrLiteralLen<decltype(S)>::value>,
1168#define __VEG_IMPL_UTF8_CONST(Literal) \
1169 (u8##Literal##__veglib_const_literal_cpp20)
1178template<
typename LiteralType,
typename Seq>
1187template<
typename LiteralType,
typename Seq>
1196template<
typename LiteralType>
1206template<
typename LiteralType>
1220#define __VEG_IMPL_UTF8_CONST(Literal) \
1221 (::proxsuite::linalg::veg::_detail::extract_chars_expr( \
1223 struct __VEG_PP_CAT(_veglib_type, __LINE__) \
1225 static constexpr auto value() noexcept -> decltype(Literal) \
1229 using Size = ::proxsuite::linalg::veg::meta::constant< \
1230 ::proxsuite::linalg::veg::usize, \
1231 sizeof(value()) / sizeof(value()[0]) - 1>; \
1233 return __VEG_PP_CAT(_veglib_type, __LINE__){}; \
1237#define VEG_DECLTYPE_VOID(...) decltype(void(__VA_ARGS__))
1238#define VEG_BOOL_NOEXCEPT(...) \
1239 ::proxsuite::linalg::veg::meta::bool_constant<noexcept(__VA_ARGS__)>
1241#define VEG_CHECK_CONCEPT(...) \
1242 VEG_CHECK_CONCEPT_MACRO(::proxsuite::linalg::veg::concepts, __VA_ARGS__)
1243#define VEG_CONCEPT(...) \
1244 VEG_CONCEPT_MACRO(::proxsuite::linalg::veg::concepts, __VA_ARGS__)
1246#define __VEG_IMPL_GET_MEMBER_PTR(_, MemberPtr) , &Type::MemberPtr
1247#define __VEG_IMPL_GET_MEMBER_NAME_PTR(_, MemberPtr) \
1248 static_cast<::proxsuite::linalg::veg::_detail::NativeChar8 const*>( \
1249 __VEG_PP_CAT(u8, __VEG_PP_STRINGIZE(MemberPtr))),
1250#define __VEG_IMPL_GET_MEMBER_NAME_LEN(_, MemberPtr) \
1251 (sizeof(__VEG_PP_CAT(u8, __VEG_PP_STRINGIZE(MemberPtr))) - 1),
1253#define __VEG_IMPL_STRUCT_SETUP(PClass, ...) \
1254 void _veg_lib_name_test()&& noexcept \
1257 VEG_CONCEPT(same<decltype(this), __VEG_PP_REMOVE_PAREN(PClass)*>), \
1258 "struct mismatch in VEG_REFLECT"); \
1260 struct _veglib_impl_member_extract \
1262 using Type = __VEG_PP_REMOVE_PAREN(PClass); \
1263 using MemberTuple = \
1264 decltype(::proxsuite::linalg::veg::_detail::make_simple_tuple( \
1265 ::proxsuite::linalg::veg::_detail::Empty { \
1266 } __VEG_PP_TUPLE_FOR_EACH(__VEG_IMPL_GET_MEMBER_PTR, \
1269 static constexpr auto member_pointers() noexcept -> MemberTuple \
1271 return ::proxsuite::linalg::veg::_detail::make_simple_tuple( \
1272 ::proxsuite::linalg::veg::_detail::Empty {} __VEG_PP_TUPLE_FOR_EACH( \
1273 __VEG_IMPL_GET_MEMBER_PTR, _, (__VA_ARGS__))); \
1275 static constexpr auto class_name_ptr() noexcept \
1276 -> ::proxsuite::linalg::veg::_detail::NativeChar8 const* \
1278 return __VEG_PP_CAT(u8, \
1279 __VEG_PP_STRINGIZE(__VEG_PP_REMOVE_PAREN(PClass))); \
1281 static constexpr auto class_name_len() noexcept \
1282 -> ::proxsuite::linalg::veg::usize \
1284 return sizeof(__VEG_PP_CAT( \
1285 u8, __VEG_PP_STRINGIZE(__VEG_PP_REMOVE_PAREN(PClass)))) - \
1288 static constexpr auto member_name_ptrs() noexcept \
1289 -> ::proxsuite::linalg::veg::_detail::Array_< \
1290 ::proxsuite::linalg::veg::_detail::NativeChar8 const*, \
1291 __VEG_PP_TUPLE_SIZE((__VA_ARGS__))> \
1293 return { { __VEG_PP_TUPLE_FOR_EACH( \
1294 __VEG_IMPL_GET_MEMBER_NAME_PTR, _, (__VA_ARGS__)) } }; \
1296 static constexpr auto member_name_lens() noexcept \
1297 -> ::proxsuite::linalg::veg::_detail::Array_< \
1298 ::proxsuite::linalg::veg::usize, \
1299 __VEG_PP_TUPLE_SIZE((__VA_ARGS__))> \
1301 return { { __VEG_PP_TUPLE_FOR_EACH( \
1302 __VEG_IMPL_GET_MEMBER_NAME_LEN, _, (__VA_ARGS__)) } }; \
1305 friend struct ::proxsuite::linalg::veg::_detail::member_extract_access< \
1306 __VEG_PP_REMOVE_PAREN(PClass)>; \
1309#define VEG_REFLECT(PClass, ...) __VEG_IMPL_STRUCT_SETUP(PClass, __VA_ARGS__)
#define HEDLEY_DIAGNOSTIC_PUSH
#define HEDLEY_DIAGNOSTIC_POP
#define VEG_DEF_CONCEPT_BUILTIN_OR_INTERNAL(Tpl, Name,...)
#define VEG_TAG(Name, Type)
#define VEG_NIEBLOID(Name)
#define VEG_DEPRECATED(Reason)
meta::uncvref_t< decltype(u8""[0])> NativeChar8
auto extract_chars_expr(LiteralType) -> typename ExtractCharsImplExpr< LiteralType, _meta::make_index_sequence< LiteralType::Size::value > >::Type
constexpr auto all_of(bool const (&lst)[N]) VEG_NOEXCEPT -> bool
constexpr auto assert_complete() noexcept -> bool
auto extract_chars(LiteralType) -> typename ExtractCharsImpl< LiteralType, _meta::make_index_sequence< LiteralType::Size::value > >::Type
constexpr auto all_of_slice(bool const *arr, usize size) VEG_NOEXCEPT -> bool
constexpr auto make_simple_tuple(Empty, Ts... args) noexcept -> SimpleTuple< Ts... >
auto print_types_halt(Args &&...) -> incomplete_t< Types..., Args... >
_detail::_meta::make_signed< usize >::Type isize
decltype(sizeof(0)) usize
VEG_INLINE constexpr auto as_slice() const noexcept -> Slice< CharUnit >
VEG_INLINE constexpr auto as_slice() const noexcept -> Slice< CharUnit >
VEG_INLINE constexpr Str(Unsafe, FromRawParts, CharUnit const *ptr, isize len) noexcept