proxsuite 0.6.7
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,
24 noexcept(static_cast<T*>(nullptr)->~T()));
25
26VEG_DEF_CONCEPT(typename T,
28 std::is_trivially_destructible<T>::value);
29
31
34 is_trivially_constructible,
35 T);
36
39 is_trivially_constructible,
40 T,
41 T const&);
44 is_trivially_constructible,
45 T,
46 T&&);
47
48VEG_CONCEPT_EXPR((typename T, typename... Ts),
49 (T, Ts...),
51 new(static_cast<void*>(nullptr)) T(VEG_DECLVAL(Ts&&)...),
52 true);
53
54VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD((typename T, typename... Ts),
56 T,
57 Ts&&...);
58
59VEG_DEF_CONCEPT_FROM_BUILTIN_OR_STD((typename T, typename... Ts),
61 T,
62 Ts&&...);
63
66 From&&,
67 To);
68
69VEG_DEF_CONCEPT((typename T, typename U),
72
73VEG_DEF_CONCEPT(typename T,
74 movable,
76 __is_constructible(T, T&&),
79 typename T,
84
86VEG_DEF_CONCEPT(typename T,
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{
161 {
162 return T();
163 }
164};
165template<typename T>
166struct MoveFn
167{
168 T&& value;
171 {
172 return T(VEG_FWD(value));
173 }
174};
175template<typename T>
176struct CopyFn
177{
178 T const& value;
181 {
182 return T(value);
183 }
184};
185
186template<typename Fn, typename T>
188{
190 T&& arg;
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:1243
#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
#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)))