46 template<
typename T, std::
size_t N,
typename Allocator = std::allocator<T>>
78 template<
typename... Args>
81 template<
typename... Args>
98 alignas(
T) char m_inplace[
N * sizeof(
T)];
105 template<typename T, std::
size_t N, typename Allocator>
115 template<
typename T, std::
size_t N,
typename Allocator>
118 T* ptr =
reinterpret_cast<T*
>(m_inplace);
125 template<
typename T, std::
size_t N,
typename Allocator>
128 T* ptr = m_onheap.
data;
130 std::allocator_traits<Allocator>::destroy(
m_alloc, ptr);
132 std::allocator_traits<Allocator>::deallocate(
135 m_onheap.
data =
nullptr;
138 template<
typename T, std::
size_t N,
typename Allocator>
141 return *(
reinterpret_cast<T*
>(m_inplace) + idx);
147 template<
typename T, std::
size_t N,
typename Allocator>
150 return *(
reinterpret_cast<const T*
>(m_inplace) + idx);
156 template<
typename T, std::
size_t N,
typename Allocator>
159 return (
m_size <=
N) ?
reinterpret_cast<T*
>(m_inplace) : m_onheap.
data;
162 template<
typename T, std::
size_t N,
typename Allocator>
165 return (
m_size <=
N) ?
reinterpret_cast<const T*
>(m_inplace) : m_onheap.
data;
168 template<
typename T, std::
size_t N,
typename Allocator>
179 template<
typename T, std::
size_t N,
typename Allocator>
180 template<
typename... Args>
183 using AllocatorTraits = std::allocator_traits<Allocator>;
191 T* i =
const_cast<T*
>(
pos);
198 std::move_backward(i, e, std::next(e));
201 *i =
T(std::forward<Args>(args)...);
213 for (
T*
e = const_cast<T*>(pos); source !=
e; ++source, ++
target) {
214 AllocatorTraits::construct(
m_alloc, target, std::move(*source));
217 T* insert = target++;
218 AllocatorTraits::construct(
m_alloc, insert, std::forward<Args>(args)...);
221 AllocatorTraits::construct(
m_alloc, target, std::move(*source));
236 template<
typename T, std::
size_t N,
typename Allocator>
237 template<
typename... Args>
240 return *
emplace(
end(), std::forward<Args>(args)...);