33 template<
typename... Args>
34 fast_pimpl(Args&&...
args) {
35 new (ptr()) T(std::forward<Args>(
args)...);
36 static_assert(storageSize >=
sizeof(T),
"not enough size");
37 static_assert(storageAlignment %
alignof(T) == 0,
"alignment does not match");
40 fast_pimpl(
const fast_pimpl& other) {
41 new (ptr()) T(other.value());
44 fast_pimpl(fast_pimpl&& other)
noexcept {
45 new (ptr()) T(std::move(other.value()));
48 fast_pimpl& operator=(
const fast_pimpl& other) {
49 new (ptr()) T(other.value());
53 fast_pimpl& operator=(fast_pimpl&& other)
noexcept {
54 new (ptr()) T(std::move(other.value()));
58 fast_pimpl& operator=(T&& other)
noexcept {
59 new (ptr()) T(std::move(other));
70 return reinterpret_cast<T&
>(mStorage);
74 const T& value()
const noexcept {
75 return reinterpret_cast<const T&
>(mStorage);
80 return &
reinterpret_cast<T&
>(mStorage);
84 const T* ptr()
const noexcept {
85 return &
reinterpret_cast<const T&
>(mStorage);
89 T* operator->()
noexcept {
90 return &
reinterpret_cast<T&
>(mStorage);
94 const T* operator->()
const noexcept {
95 return &
reinterpret_cast<const T&
>(mStorage);
99 T& operator*()
noexcept {
100 return reinterpret_cast<T&
>(mStorage);
104 const T& operator*()
const noexcept {
105 return reinterpret_cast<const T&
>(mStorage);
110 std::aligned_storage_t<storageSize, storageAlignment> mStorage;