proxygen
folly::detail::IntegralSizePolicy< SizeType, true > Struct Template Reference

#include <small_vector.h>

Inheritance diagram for folly::detail::IntegralSizePolicy< SizeType, true >:
folly::detail::IntegralSizePolicyBase< SizeType, true >

Public Member Functions

template<class T >
std::enable_if<!folly::is_trivially_copyable< T >::value >::type moveToUninitialized (T *first, T *last, T *out)
 
template<class T >
std::enable_if< folly::is_trivially_copyable< T >::value >::type moveToUninitialized (T *first, T *last, T *out)
 
template<class T , class EmplaceFunc >
void moveToUninitializedEmplace (T *begin, T *end, T *out, SizeType pos, EmplaceFunc &&emplaceFunc)
 
- Public Member Functions inherited from folly::detail::IntegralSizePolicyBase< SizeType, true >
 IntegralSizePolicyBase ()
 

Additional Inherited Members

- Public Types inherited from folly::detail::IntegralSizePolicyBase< SizeType, true >
typedef SizeType InternalSizeType
 
- Protected Member Functions inherited from folly::detail::IntegralSizePolicyBase< SizeType, true >
std::size_t doSize () const
 
std::size_t isExtern () const
 
void setExtern (bool b)
 
void setSize (std::size_t sz)
 
void swapSizePolicy (IntegralSizePolicyBase &o)
 
- Static Protected Member Functions inherited from folly::detail::IntegralSizePolicyBase< SizeType, true >
static constexpr std::size_t policyMaxSize ()
 
- Static Protected Attributes inherited from folly::detail::IntegralSizePolicyBase< SizeType, true >
static bool constexpr kShouldUseHeap
 

Detailed Description

template<class SizeType>
struct folly::detail::IntegralSizePolicy< SizeType, true >

Definition at line 221 of file small_vector.h.

Member Function Documentation

template<class SizeType >
template<class T >
std::enable_if<!folly::is_trivially_copyable<T>::value>::type folly::detail::IntegralSizePolicy< SizeType, true >::moveToUninitialized ( T first,
T last,
T out 
)
inline

Definition at line 230 of file small_vector.h.

References folly::gen::first, i, folly::gen::move, T, type, and value.

230  {
231  std::size_t idx = 0;
232  try {
233  for (; first != last; ++first, ++idx) {
234  new (&out[idx]) T(std::move(*first));
235  }
236  } catch (...) {
237  // Even for callers trying to give the strong guarantee
238  // (e.g. push_back) it's ok to assume here that we don't have to
239  // move things back and that it was a copy constructor that
240  // threw: if someone throws from a move constructor the effects
241  // are unspecified.
242  for (std::size_t i = 0; i < idx; ++i) {
243  out[i].~T();
244  }
245  throw;
246  }
247  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::std T
constexpr detail::First first
Definition: Base-inl.h:2553
template<class SizeType >
template<class T >
std::enable_if<folly::is_trivially_copyable<T>::value>::type folly::detail::IntegralSizePolicy< SizeType, true >::moveToUninitialized ( T first,
T last,
T out 
)
inline

Definition at line 252 of file small_vector.h.

252  {
253  std::memmove(out, first, (last - first) * sizeof *first);
254  }
constexpr detail::First first
Definition: Base-inl.h:2553
template<class SizeType >
template<class T , class EmplaceFunc >
void folly::detail::IntegralSizePolicy< SizeType, true >::moveToUninitializedEmplace ( T begin,
T end,
T out,
SizeType  pos,
EmplaceFunc &&  emplaceFunc 
)
inline

Definition at line 263 of file small_vector.h.

References i.

268  {
269  // Must be called first so that if it throws [begin, end) is unmodified.
270  // We have to support the strong exception guarantee for emplace_back().
271  emplaceFunc(out + pos);
272  // move old elements to the left of the new one
273  try {
274  this->moveToUninitialized(begin, begin + pos, out);
275  } catch (...) {
276  out[pos].~T();
277  throw;
278  }
279  // move old elements to the right of the new one
280  try {
281  if (begin + pos < end) {
282  this->moveToUninitialized(begin + pos, end, out + pos + 1);
283  }
284  } catch (...) {
285  for (SizeType i = 0; i <= pos; ++i) {
286  out[i].~T();
287  }
288  throw;
289  }
290  }
std::enable_if<!folly::is_trivially_copyable< T >::value >::type moveToUninitialized(T *first, T *last, T *out)
Definition: small_vector.h:230
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62

The documentation for this struct was generated from the following file: