Go to the documentation of this file.
4 #ifndef LEXY_DETAIL_LAZY_INIT_HPP_INCLUDED
5 #define LEXY_DETAIL_LAZY_INIT_HPP_INCLUDED
25 template <
typename... Args>
30 template <
typename... Args>
49 template <
typename... Args>
74 if (
_init && other._init)
76 else if (
_init && !other._init)
81 else if (!
_init && other._init)
98 return std::is_trivially_destructible_v<T>
99 && std::is_trivially_copy_constructible_v<T>
100 && std::is_trivially_copy_assignable_v<T>
101 && std::is_trivially_move_constructible_v<T>
102 && std::is_trivially_move_assignable_v<T>;
104 template <
typename T>
105 using _lazy_init_storage = std::conditional_t<_lazy_init_trivial<T>, _lazy_init_storage_trivial<T>,
108 template <
typename T>
114 constexpr
lazy_init() noexcept = default;
116 template <typename... Args>
120 this->_value = T(
LEXY_FWD(args)...);
127 template <
typename Fn,
typename... Args>
133 constexpr
explicit operator bool() const noexcept
162 return &this->_value;
167 return &this->_value;
171 template <
typename... Args>
172 constexpr
explicit lazy_init(
int, Args&&... args) noexcept
176 template <
typename T>
190 template <
typename Fn,
typename... Args>
196 constexpr
explicit operator bool() const noexcept
198 return _ptr !=
nullptr;
228 template <
typename Fn,
typename... Args>
235 constexpr
explicit operator bool() const noexcept
245 #endif // LEXY_DETAIL_LAZY_INIT_HPP_INCLUDED
constexpr lazy_init() noexcept
constexpr T * operator->() const noexcept
constexpr T && operator*() &&noexcept
constexpr const T && operator*() const &&noexcept
constexpr void _construct(Args &&... args)
constexpr lazy_init(int, Args &&... args) noexcept
LEXY_CONSTEXPR_DTOR _lazy_init_storage_non_trivial(_lazy_init_storage_non_trivial &&other) noexcept
LEXY_CONSTEXPR_DTOR ~_lazy_init_storage_non_trivial()
#define LEXY_CONSTEXPR_DTOR
constexpr void emplace_result(Fn &&fn, Args &&... args)
constexpr T & emplace_result(Fn &&fn, Args &&... args)
#define LEXY_PRECONDITION(Expr)
constexpr _lazy_init_storage_trivial() noexcept
constexpr const T * operator->() const noexcept
constexpr T & emplace(Args &&... args)
constexpr T & emplace_result(Fn &&fn, Args &&... args)
LEXY_CONSTEXPR_DTOR _lazy_init_storage_non_trivial & operator=(_lazy_init_storage_non_trivial &&other) noexcept
LEXY_CONSTEXPR_DTOR void _construct(Args &&... args)
std::conditional_t< _lazy_init_trivial< T >, _lazy_init_storage_trivial< T >, _lazy_init_storage_non_trivial< T > > _lazy_init_storage
constexpr _lazy_init_storage_non_trivial() noexcept
constexpr _lazy_init_storage_trivial(int, Args &&... args)
constexpr T * operator->() noexcept
constexpr T & operator*() &noexcept
constexpr T & emplace(T &ref)
constexpr auto _lazy_init_trivial
constexpr lazy_init() noexcept=default
constexpr T & operator*() const noexcept
constexpr lazy_init() noexcept
constexpr const T & operator*() const &noexcept
T * construct_at(T *ptr, Args &&... args)