proxsuite 0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
prologue.hpp
Go to the documentation of this file.
1#ifdef VEG_PROLOGUE
2#error "missing epilogue"
3#endif
4#define VEG_PROLOGUE
5
6#if (__cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002))
7#define VEG_WITH_CXX20_SUPPORT
8#endif
9
10#if (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703))
11#define VEG_WITH_CXX17_SUPPORT
12#endif
13
14#if (__cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201403))
15#define VEG_WITH_CXX14_SUPPORT
16#endif
17
18#if (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
19#define VEG_WITH_CXX11_SUPPORT
20#endif
21
22#define VEG_ALWAYS_NOEXCEPT noexcept
23
24#ifdef __VEG_DISABLE_NOEXCEPT
25#define VEG_NOEXCEPT noexcept(false)
26#define VEG_NOEXCEPT_IF(...) \
27 noexcept(VEG_WRAP_SILENCE_WARNING((__VA_ARGS__)) && false)
28#define VEG_IS_NOEXCEPT(Expr) noexcept(Expr)
29#else
30#define VEG_NOEXCEPT noexcept(true)
31#define VEG_NOEXCEPT_IF(...) noexcept(VEG_WRAP_SILENCE_WARNING(__VA_ARGS__))
32#define VEG_IS_NOEXCEPT(Expr) noexcept(Expr)
33#endif
34#define VEG_NOEXCEPT_LIKE(Expr) VEG_NOEXCEPT_IF(VEG_IS_NOEXCEPT(Expr))
35
36#define VEG_HAS_BUILTIN_OR_0(True, False) __VEG_PP_REMOVE_PAREN(False)
37#define VEG_HAS_BUILTIN_OR_1(True, False) __VEG_PP_REMOVE_PAREN(True)
38#define VEG_HAS_BUILTIN_OR(Builtin, True, False) \
39 __VEG_PP_CAT(VEG_HAS_BUILTIN_OR_, VEG_HAS_BUILTIN(Builtin))(True, False)
40#define VEG_DEF_CONCEPT_FROM_BUILTIN_OR_TRAIT(Tpl, Trait, Std_Trait, ...) \
41 VEG_DEF_CONCEPT( \
42 Tpl, \
43 Trait, \
44 VEG_HAS_BUILTIN_OR(__VEG_PP_CAT(__, Std_Trait), \
45 ((::proxsuite::linalg::veg::_detail::assert_complete< \
46 ::proxsuite::linalg::veg::_detail::Wrapper< \
47 __VEG_PP_HEAD(__VA_ARGS__)>>(), \
48 __VEG_PP_CAT(__, Std_Trait)(__VA_ARGS__))), \
49 (::std::Std_Trait<__VA_ARGS__>::value)))
50#define VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD(Tpl, Trait, ...) \
51 VEG_DEF_CONCEPT_FROM_BUILTIN_OR_TRAIT( \
52 Tpl, Trait, __VEG_PP_CAT(is_, Trait), __VA_ARGS__)
53
54#define VEG_EXPLICIT_COPY(Class) \
55 ~Class() = default; \
56 Class(Class&&) = default; \
57 explicit Class(Class const&) = default; \
58 auto operator=(Class&&)&->Class& = default; \
59 auto operator=(Class const&)&->Class& = default
60
61#define VEG_NO_COPY(Class) \
62 ~Class() = default; \
63 Class(Class&&) = default; \
64 Class(Class const&) = delete; \
65 auto operator=(Class&&)&->Class& = default; \
66 auto operator=(Class const&)&->Class& = delete
67
68#ifdef VEG_WITH_CXX14_SUPPORT
69#define VEG_CPP14(...) __VA_ARGS__
70#else
71#define VEG_CPP14(...)
72#endif
73
74#ifdef VEG_WITH_CXX17_SUPPORT
75#define VEG_CPP17(...) __VA_ARGS__
76#else
77#define VEG_CPP17(...)
78#endif
79
80#ifdef VEG_WITH_CXX20_SUPPORT
81#define VEG_CPP20(...) __VA_ARGS__
82#else
83#define VEG_CPP20(...)
84#endif
85
86#if defined(__has_builtin)
87#define VEG_HAS_BUILTIN(x) __has_builtin(x)
88#else
89#define VEG_HAS_BUILTIN(x) 0
90#endif
91
92#ifdef VEG_WITH_CXX17_SUPPORT
93#define VEG_NODISCARD [[nodiscard]]
94#elif defined(__clang__)
95#define VEG_NODISCARD HEDLEY_WARN_UNUSED_RESULT
96#else
97#define VEG_NODISCARD
98#endif
99
100#define VEG_INTERNAL_ASSERT_PRECONDITION VEG_ASSERT
101#define VEG_INTERNAL_ASSERT_PRECONDITIONS VEG_ASSERT_ALL_OF
102
103#ifdef __VEG_INTERNAL_ASSERTIONS
104#define VEG_INTERNAL_ASSERT_INVARIANT(...) \
105 VEG_ASSERT_ELSE("inner assertion failed", __VA_ARGS__)
106#else
107#define VEG_INTERNAL_ASSERT_INVARIANT(...) \
108 (VEG_DEBUG_ASSERT_ELSE("inner assertion failed", __VA_ARGS__), \
109 HEDLEY_UNREACHABLE())
110#endif
111
112#ifdef __VEG_DISABLE_NOEXCEPT
113#undef VEG_INTERNAL_ASSERT_PRECONDITION
114#undef VEG_INTERNAL_ASSERT_PRECONDITIONS
115#undef VEG_INTERNAL_ASSERT_INVARIANT
116
117#define VEG_INTERNAL_ASSERT_PRECONDITIONS(...) \
118 VEG_INTERNAL_ASSERT_PRECONDITION( \
119 ::proxsuite::linalg::veg::_detail::all_of({ __VA_ARGS__ }))
120
121#define VEG_INTERNAL_ASSERT_PRECONDITION(Cond) \
122 (bool(Cond) ? (void)0 : ((throw 0) /* NOLINT */, (void)0))
123#define VEG_INTERNAL_ASSERT_INVARIANT(...) \
124 (bool(__VA_ARGS__) ? (void)0 : ((throw 0), (void)0))
125#endif
126
127#ifdef VEG_WITH_CXX14_SUPPORT
128
129#define VEG_IGNORE_CPP14_EXTENSION_WARNING(...) __VA_ARGS__
130#else
131#define VEG_IGNORE_CPP14_EXTENSION_WARNING(...)
132#endif
133
134#ifdef VEG_WITH_CXX20_SUPPORT
135#define VEG_ABI _20
136#elif defined(VEG_WITH_CXX17_SUPPORT)
137#define VEG_ABI _17
138#elif defined(VEG_WITH_CXX14_SUPPORT)
139#define VEG_ABI _14
140#elif defined(VEG_WITH_CXX11_SUPPORT)
141#define VEG_ABI _11
142#else
143#error "[veg] c++ standards earlier than c++11 are not supported"
144#endif
145
146#define VEG_ABI_VERSION v0
147
148#ifdef VEG_MODE_DOCS
149#define VEG_DOC(...) __VA_ARGS__
150#define VEG_DOC_LOCATION char loc[__LINE__] = __FILE__
151#else
152#define VEG_DOC(...)
153#define VEG_DOC_LOCATION VEG_NOM_SEMICOLON
154#endif
155#define VEG_DOC_FN VEG_DOC_LOCATION; /* proxsuite::linalg::veg::@func */
156#define VEG_DOC_CTOR VEG_DOC_LOCATION; /* proxsuite::linalg::veg::@ctor */
157#define VEG_DOC_CLASS VEG_DOC_LOCATION; /* proxsuite::linalg::veg::@class */