proxsuite 0.7.1
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
constructible.hpp
Go to the documentation of this file.
1#ifndef VEG_CONSTRUCTIBLE_HPP_D6CRVBJYS
2#define VEG_CONSTRUCTIBLE_HPP_D6CRVBJYS
3
6
7#include <new>
8#include <type_traits>
9
10namespace proxsuite {
11namespace linalg {
12namespace veg {
13namespace concepts {
14
15#if VEG_HAS_BUILTIN(__is_final) || defined(VEG_WITH_CXX14_SUPPORT)
16VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD(typename T, final, T);
17#else
18VEG_DEF_CONCEPT(typename T, final, (sizeof(T) < 0));
19#endif
21
22VEG_DEF_CONCEPT(typename T,
23 nothrow_destructible,
24 noexcept(static_cast<T*>(nullptr)->~T()));
25
26VEG_DEF_CONCEPT(typename T,
27 trivially_destructible,
28 std::is_trivially_destructible<T>::value);
29
30VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD(typename T, trivially_copyable, T);
31
33 trivially_default_constructible,
34 is_trivially_constructible,
35 T);
36
38 trivially_copy_constructible,
39 is_trivially_constructible,
40 T,
41 T const&);
43 trivially_move_constructible,
44 is_trivially_constructible,
45 T,
46 T&&);
47
48VEG_CONCEPT_EXPR((typename T, typename... Ts),
49 (T, Ts...),
50 inplace_constructible,
51 new(static_cast<void*>(nullptr)) T(VEG_DECLVAL(Ts&&)...),
52 true);
53
54VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD((typename T, typename... Ts),
55 constructible,
56 T,
57 Ts&&...);
58
59VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD((typename T, typename... Ts),
60 nothrow_constructible,
61 T,
62 Ts&&...);
63
64VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD((typename From, typename To),
65 convertible,
66 From&&,
67 To);
68
69VEG_DEF_CONCEPT((typename T, typename U),
70 implicitly_constructible,
71 VEG_CONCEPT(convertible<U&&, T>));
72
73VEG_DEF_CONCEPT(typename T,
74 movable,
75 VEG_HAS_BUILTIN_OR(__is_constructiblex,
76 __is_constructible(T, T&&),
77 (VEG_CONCEPT(constructible<T, T&&>))));
79 typename T,
80 nothrow_movable,
81 VEG_HAS_BUILTIN_OR(__is_nothrow_constructiblex,
82 __is_nothrow_constructible(T, T&&),
83 (VEG_CONCEPT(nothrow_constructible<T, T&&>))));
84
85VEG_DEF_CONCEPT(typename T, copyable, VEG_CONCEPT(constructible<T, T const&>));
86VEG_DEF_CONCEPT(typename T,
87 nothrow_copyable,
88 VEG_CONCEPT(nothrow_constructible<T, T const&>));
89
90} // namespace concepts
91namespace cpo {
92template<typename T>
93struct is_trivially_constructible;
94
95template<typename T>
96struct is_trivially_relocatable;
97} // namespace cpo
98
99namespace _detail {
100namespace _cpo {
101
102template<bool, template<typename> class Trait, typename T>
105
106template<template<typename> class Trait, typename Tuple>
108
109template<template<typename> class Trait,
110 usize... Is,
111 typename... Bases,
112 typename... Ts>
114 Trait,
115 SimpleITuple<_meta::integer_sequence<usize, Is...>, Ts Bases::*...>>
116 : meta::bool_constant<VEG_ALL_OF(Trait<Ts>::value)>
117{};
118
119template<template<typename> class Trait, typename T>
122 Trait,
123 decltype(_detail::member_extract_access<T>::Type::member_pointers())>
124{};
125
126template<template<typename> class Trait, typename T>
128 : extract_members_deduce_trait_impl<_detail::member_extract_access<T>::value,
129 Trait,
130 T>
131{};
132
133} // namespace _cpo
134} // namespace _detail
135
136namespace cpo {
137template<typename T>
139 : meta::if_t<
140 VEG_CONCEPT(trivially_default_constructible<T>),
141 meta::true_type,
142 _detail::_cpo::extract_members_deduce_trait<is_trivially_relocatable, T>>
143{};
144
145template<typename T>
147 : meta::if_t<
148 VEG_CONCEPT(trivially_copyable<T>) &&
149 VEG_CONCEPT(trivially_move_constructible<T>),
150 meta::true_type,
151 _detail::_cpo::extract_members_deduce_trait<is_trivially_relocatable, T>>
152{};
153} // namespace cpo
154
155namespace _detail {
156template<typename T>
158{
159 VEG_INLINE constexpr auto operator()() const&& VEG_NOEXCEPT_IF(
160 VEG_CONCEPT(nothrow_constructible<T>)) -> T
161 {
162 return T();
163 }
164};
165template<typename T>
166struct MoveFn
167{
168 T&& value;
169 VEG_INLINE constexpr auto operator()() const&& VEG_NOEXCEPT_IF(
170 VEG_CONCEPT(nothrow_movable<T>)) -> T
171 {
172 return T(VEG_FWD(value));
173 }
174};
175template<typename T>
176struct CopyFn
177{
178 T const& value;
179 VEG_INLINE constexpr auto operator()() const&& VEG_NOEXCEPT_IF(
180 VEG_CONCEPT(nothrow_copyable<T>)) -> T
181 {
182 return T(value);
183 }
184};
185
186template<typename Fn, typename T>
188{
189 Fn&& fn;
190 T&& arg;
191 VEG_INLINE constexpr auto operator()() const&& -> decltype(VEG_FWD(fn)(
192 VEG_FWD(arg)))
193 {
194 return VEG_FWD(fn)(VEG_FWD(arg));
195 }
196};
197
198} // namespace _detail
199} // namespace veg
200} // namespace linalg
201} // namespace proxsuite
202
204#endif /* end of include guard VEG_CONSTRUCTIBLE_HPP_D6CRVBJYS */
#define VEG_CONCEPT_EXPR(Tpl, TplNames, Name, Expr,...)
Definition macros.hpp:272
#define VEG_CONCEPT(...)
Definition macros.hpp:1241
#define VEG_INLINE
Definition macros.hpp:118
#define VEG_FWD(X)
Definition macros.hpp:569
#define VEG_DECLVAL(...)
Definition macros.hpp:131
#define VEG_DEF_CONCEPT(Tpl, Name,...)
Definition macros.hpp:321
typename _detail::_meta::conditional_< B >::template type< T, F > if_t
Definition core.hpp:83
decltype(sizeof(0)) usize
Definition macros.hpp:702
#define VEG_HAS_BUILTIN_OR(Builtin, True, False)
Definition prologue.hpp:38
#define VEG_DEF_CONCEPT_FROM_BUILTIN_OR_TRAIT(Tpl, Trait, Std_Trait,...)
Definition prologue.hpp:40
#define VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD(Tpl, Trait,...)
Definition prologue.hpp:50
#define VEG_NOEXCEPT_IF(...)
Definition prologue.hpp:31
VEG_INLINE constexpr auto operator()() const &&VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_copyable< T >)) -> T
VEG_INLINE constexpr auto operator()() const &&VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_constructible< T >)) -> T
VEG_INLINE constexpr auto operator()() const &&VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_movable< T >)) -> T
VEG_INLINE constexpr auto operator()() const &&-> decltype(VEG_FWD(fn)(VEG_FWD(arg)))