5 #ifndef UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED 6 #define UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED 13 #ifndef UAVCAN_CPP_VERSION 14 # error UAVCAN_CPP_VERSION 29 #if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 32 alignas(T)
unsigned char pool[
sizeof(T)];
37 unsigned char pool[
sizeof(T)];
38 long double _aligner1;
65 fill(data_.pool, data_.pool +
sizeof(T),
uint8_t(0));
71 fill(data_.pool, data_.pool +
sizeof(T),
uint8_t(0));
74 construct<const T&>(*rhs);
85 construct<const T&>(*rhs);
92 operator T*()
const {
return ptr_; }
94 const T*
operator->()
const { ensureConstructed();
return ptr_; }
97 const T&
operator*()
const { ensureConstructed();
return *ptr_; }
98 T&
operator*() { ensureConstructed();
return *ptr_; }
107 fill(data_.pool, data_.pool +
sizeof(T),
uint8_t(0));
112 ensureNotConstructed();
113 ptr_ =
new (
static_cast<void*
>(data_.pool)) T();
131 template <
typename P1>
134 ensureNotConstructed();
135 ptr_ =
new (
static_cast<void*
>(data_.pool)) T(p1);
138 template<
typename P1,
typename P2>
141 ensureNotConstructed();
142 ptr_ =
new (
static_cast<void*
>(data_.pool)) T(p1, p2);
145 template<
typename P1,
typename P2,
typename P3>
149 ensureNotConstructed();
150 ptr_ =
new (
static_cast<void*
>(data_.pool)) T(p1, p2, p3);
153 template<
typename P1,
typename P2,
typename P3,
typename P4>
157 ensureNotConstructed();
158 ptr_ =
new (
static_cast<void*
>(data_.pool)) T(p1, p2, p3, p4);
161 template<
typename P1,
typename P2,
typename P3,
typename P4,
typename P5>
166 ensureNotConstructed();
167 ptr_ =
new (
static_cast<void*
>(data_.pool)) T(p1, p2, p3, p4, p5);
170 template<
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6>
175 ensureNotConstructed();
176 ptr_ =
new (
static_cast<void*
>(data_.pool)) T(p1, p2, p3, p4, p5, p6);
182 #endif // UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED
void construct(typename ParameterType< P1 >::Type p1, typename ParameterType< P2 >::Type p2, typename ParameterType< P3 >::Type p3, typename ParameterType< P4 >::Type p4, typename ParameterType< P5 >::Type p5)
bool isConstructed() const
void construct(typename ParameterType< P1 >::Type p1, typename ParameterType< P2 >::Type p2, typename ParameterType< P3 >::Type p3, typename ParameterType< P4 >::Type p4)
UAVCAN_EXPORT void handleFatalError(const char *msg)
const T & operator*() const
UAVCAN_EXPORT void fill(ForwardIt first, ForwardIt last, const T &value)
LazyConstructor(const LazyConstructor< T > &rhs)
void construct(typename ParameterType< P1 >::Type p1, typename ParameterType< P2 >::Type p2, typename ParameterType< P3 >::Type p3, typename ParameterType< P4 >::Type p4, typename ParameterType< P5 >::Type p5, typename ParameterType< P6 >::Type p6)
void construct(typename ParameterType< P1 >::Type p1, typename ParameterType< P2 >::Type p2, typename ParameterType< P3 >::Type p3)
void ensureNotConstructed() const
void ensureConstructed() const
void construct(typename ParameterType< P1 >::Type p1, typename ParameterType< P2 >::Type p2)
const T * operator->() const
void construct(typename ParameterType< P1 >::Type p1)
LazyConstructor< T > & operator=(const LazyConstructor< T > &rhs)