1#ifndef VEG_PLACEMENT_HPP_LP0HMLTPS
2#define VEG_PLACEMENT_HPP_LP0HMLTPS
11#if defined(VEG_WITH_CXX20_SUPPORT) && !VEG_HAS_BUILTIN(__builtin_bit_cast)
13#define VEG_HAS_BITCAST 1
14#define VEG_BITCAST(T, x) ::std::bit_cast<T>(x)
15#define VEG_BITCAST_CONSTEXPR constexpr
16#elif VEG_HAS_BUILTIN(__builtin_bit_cast)
17#define VEG_HAS_BITCAST 1
18#define VEG_BITCAST(T, x) __builtin_bit_cast(T, x)
19#define VEG_BITCAST_CONSTEXPR constexpr
22#define VEG_HAS_BITCAST 0
23#define VEG_BITCAST_CONSTEXPR
27#if defined(VEG_WITH_CXX20_SUPPORT)
30#if __VEG_HAS_INCLUDE(<bits / stl_construct.h>) && \
31 __VEG_HAS_INCLUDE(<bits / stl_iterator_base_types.h>) && \
32 __VEG_HAS_INCLUDE(<bits / stl_iterator_base_funcs.h>)
33#include <bits/stl_iterator_base_types.h>
34#include <bits/stl_iterator_base_funcs.h>
35#include <bits/stl_construct.h>
42#if VEG_HAS_BUILTIN(__builtin_launder) || __GNUC__ >= 7
43#define VEG_LAUNDER(p) (__builtin_launder(p))
44#elif defined(VEG_WITH_CXX17_SUPPORT) && __GNUC__ >= 6
46#define VEG_LAUNDER(p) (::std::launder(p))
48#define VEG_LAUNDER(p) (+p)
79#if defined(VEG_WITH_CXX20_SUPPORT)
80 return ::std::construct_at(mem,
VEG_FWD(args)...);
82 return ::new (mem) T(
VEG_FWD(args)...);
98#if defined(VEG_WITH_CXX20_SUPPORT)
109 return ::std::construct_at(mem, Convertor{
VEG_FWD(fn) });
111 return ::new (mem) T(
VEG_FWD(fn)());
129 using byte_ptr =
unsigned char*;
130 std::uintptr_t lo_mask = alignment - 1U;
131 std::uintptr_t hi_mask = ~lo_mask;
132 auto const intptr =
reinterpret_cast<std::uintptr_t
>(ptr);
133 auto*
const byteptr =
static_cast<byte_ptr
>(ptr);
134 auto offset = ((intptr + alignment - 1U) & hi_mask) - intptr;
136 return byteptr + offset;
141 return this->
operator()(alignment,
const_cast<void*
>(ptr));
148 using byte_ptr =
unsigned char*;
149 std::uintptr_t lo_mask = alignment - 1U;
150 std::uintptr_t hi_mask = ~lo_mask;
151 auto const intptr =
reinterpret_cast<std::uintptr_t
>(ptr);
152 auto*
const byteptr =
static_cast<byte_ptr
>(ptr);
153 auto offset = ((intptr)&hi_mask) - intptr;
155 return byteptr + offset;
160 return this->
operator()(alignment,
const_cast<void*
>(ptr));
178 (
sizeof(From) ==
sizeof(To)))),
185 return VEG_BITCAST(To, from);
187 alignas(To)
unsigned char buf[
sizeof(To)];
188 To* ptr =
reinterpret_cast<To*
>(
static_cast<unsigned char*
>(buf));
#define VEG_NIEBLOID_TEMPLATE(Tpl, Name,...)
#define VEG_NIEBLOID(Name)
decltype(sizeof(0)) usize
#define VEG_BITCAST_CONSTEXPR
#define VEG_NOEXCEPT_IF(...)
auto operator()(usize alignment, void *ptr) const VEG_NOEXCEPT -> void *
auto operator()(usize alignment, void const *ptr) const VEG_NOEXCEPT -> void const *
auto operator()(usize alignment, void *ptr) const VEG_NOEXCEPT -> void *
auto operator()(usize alignment, void const *ptr) const VEG_NOEXCEPT -> void const *
VEG_TEMPLATE(typename From, requires((VEG_CONCEPT(trivially_copyable< From >) &&VEG_CONCEPT(trivially_copyable< To >) &&(sizeof(From)==sizeof(To)))), VEG_INLINE VEG_BITCAST_CONSTEXPR auto operator(),(from, From const &)) const VEG_NOEXCEPT -> To
VEG_TEMPLATE((typename T, typename... Args), requires(!VEG_CONCEPT(const_type< T >) &&VEG_CONCEPT(inplace_constructible< T, Args... >)), VEG_INLINE VEG_CPP20(constexpr) auto operator(),(mem, T *),(... args, Args &&)) const VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_inplace_constructible< T
VEG_TEMPLATE((typename T, typename Fn), requires(!VEG_CONCEPT(const_type< T >) &&VEG_CONCEPT(fn_once< Fn, T >)), VEG_INLINE VEG_CPP20(constexpr) auto operator(),(mem, T *),(fn, Fn &&)) const VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_fn_once< Fn
VEG_TEMPLATE((typename T), requires(VEG_CONCEPT(complete< T >)), VEG_INLINE VEG_CPP14(constexpr) void operator(),(mem, T *)) const VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_destructible< T >))
VEG_TEMPLATE(typename T, requires(VEG_CONCEPT(complete< T >)), VEG_INLINE constexpr auto operator(),(mem, T *)) const VEG_NOEXCEPT -> T *