64 constexpr unititialized_t()
noexcept {}
66 explicit constexpr unititialized_t(default_init_t)
67 noexcept(detail::nothrow_default_constructible<T>)
68 requires detail::default_constructible<T>
73 template <
typename... Args>
74 explicit constexpr unititialized_t(paren_init_t, Args&&... args)
75 noexcept(detail::nothrow_paren_constructible_from<T, Args...>)
76 requires detail::paren_constructible_from<T, Args...>
78 this->paren_init(std::forward<Args>(args)...);
81 template <
typename... Args>
82 explicit constexpr unititialized_t(brace_init_t, Args&&... args)
83 noexcept(detail::nothrow_brace_constructible_from<T, Args...>)
84 requires detail::brace_constructible_from<T, Args...>
86 this->brace_init(std::forward<Args>(args)...);
89 constexpr ~unititialized_t()
90 requires std::is_trivially_destructible_v<T>
93 constexpr ~unititialized_t() {}
95 template <
typename Self>
96 constexpr auto default_init(
this Self&& self)
97 noexcept(detail::nothrow_default_constructible<T>) -> T&
98 requires detail::default_constructible<T>
100 return *::new (
static_cast<void*
>(std::addressof(self.object))) T;
103 template <
typename Self,
typename... Args>
104 constexpr auto paren_init(
this Self&& self, Args&&... args)
105 noexcept(detail::nothrow_paren_constructible_from<T, Args...>) -> T&
106 requires detail::paren_constructible_from<T, Args...>
108 return *::new (
static_cast<void*
>(std::addressof(self.object)))
109 T(std::forward<Args>(args)...);
112 template <
typename Self,
typename... Args>
113 constexpr auto brace_init(
this Self&& self, Args&&... args)
114 noexcept(detail::nothrow_brace_constructible_from<T, Args...>) -> T&
115 requires detail::brace_constructible_from<T, Args...>
117 return *::new (
static_cast<void*
>(std::addressof(self.object)))
118 T{ std::forward<Args>(args)... };
121 template <
typename Self>
122 [[nodiscard]]
constexpr auto ptr(
this Self&& self)
noexcept ->
auto*
124 return std::addressof(self.object);
127 template <
typename Self>
128 [[nodiscard]]
constexpr auto operator->(
this Self&& self)
noexcept ->
auto*
130 return std::addressof(self.object);
133 template <
typename Self>
134 [[nodiscard]]
constexpr auto ref(
this Self&& self)
noexcept ->
auto&&
136 return std::forward<Self>(self).object;
139 template <
typename Self>
140 [[nodiscard]]
constexpr auto operator*(
this Self&& self)
noexcept ->
auto&&
142 return std::forward<Self>(self).object;
145 template <
typename Self>
146 [[nodiscard]]
constexpr auto bytes(
this Self&& self)
noexcept -> std::ranges::borrowed_range
auto
148 using byte_type = std::conditional_t<
149 detail::const_ref<Self> or std::is_const_v<T>,
152 return std::span<byte_type, sizeof(T)>(
153 reinterpret_cast<byte_type*
>(std::addressof(self.object)),
158 template <
typename Self>
159 constexpr auto destroy(
this Self&& self)
noexcept(std::is_nothrow_destructible_v<T>)
161 if constexpr (not std::is_trivially_destructible_v<T>)
162 std::destroy_at(std::addressof(self.object));