proxygen
Alloc< T > Struct Template Reference
Inheritance diagram for Alloc< T >:
AllocTracker Ticker folly::Arena< Alloc >::AllocAndSize

Public Types

typedef std::allocator< T >::pointer pointer
 
typedef std::allocator< T >::const_pointer const_pointer
 
typedef std::allocator< T >::difference_type difference_type
 
typedef std::allocator< T >::size_type size_type
 
typedef std::allocator< T >::value_type value_type
 
typedef isPropCopy< Tpropagate_on_container_copy_assignment
 
typedef isPropMove< Tpropagate_on_container_move_assignment
 
typedef isPropSwap< Tpropagate_on_container_swap
 

Public Member Functions

 Alloc (int i=8)
 
 Alloc (const Alloc &o)
 
 Alloc (Alloc &&o) noexcept
 
Allocoperator= (const Alloc &)=default
 
Allocoperator= (Alloc &&) noexcept=default
 
bool operator== (const Alloc &o) const
 
bool operator!= (const Alloc &o) const
 
pointer allocate (size_type n)
 
void deallocate (pointer p, size_type n)
 
template<class U , class... Args>
void construct (U *p, Args &&...args)
 
template<class U >
void destroy (U *p)
 
Alloc select_on_container_copy_construction () const
 

Public Attributes

std::allocator< Ta
 
int id
 

Additional Inherited Members

- Static Public Member Functions inherited from Ticker
static void Tick (const std::string &s)
 
- Static Public Attributes inherited from AllocTracker
static int Constructed = 0
 
static int Destroyed = 0
 
static map< void *, size_t > Allocated
 
static map< void *, int > Owner
 
- Static Public Attributes inherited from Ticker
static int CountTicks = 0
 
static int TicksLeft = -1
 

Detailed Description

template<class T>
struct Alloc< T >

Definition at line 650 of file StlVectorTest.cpp.

Member Typedef Documentation

template<class T>
typedef std::allocator<T>::const_pointer Alloc< T >::const_pointer

Definition at line 652 of file StlVectorTest.cpp.

template<class T>
typedef std::allocator<T>::difference_type Alloc< T >::difference_type

Definition at line 653 of file StlVectorTest.cpp.

template<class T>
typedef std::allocator<T>::pointer Alloc< T >::pointer

Definition at line 651 of file StlVectorTest.cpp.

template<class T>
typedef isPropCopy<T> Alloc< T >::propagate_on_container_copy_assignment

Definition at line 736 of file StlVectorTest.cpp.

template<class T>
typedef isPropMove<T> Alloc< T >::propagate_on_container_move_assignment

Definition at line 737 of file StlVectorTest.cpp.

template<class T>
typedef isPropSwap<T> Alloc< T >::propagate_on_container_swap

Definition at line 738 of file StlVectorTest.cpp.

template<class T>
typedef std::allocator<T>::size_type Alloc< T >::size_type

Definition at line 654 of file StlVectorTest.cpp.

template<class T>
typedef std::allocator<T>::value_type Alloc< T >::value_type

Definition at line 655 of file StlVectorTest.cpp.

Constructor & Destructor Documentation

template<class T>
Alloc< T >::Alloc ( int  i = 8)
inlineexplicit

Definition at line 662 of file StlVectorTest.cpp.

662 : a(), id(i) {}
std::allocator< T > a
template<class T>
Alloc< T >::Alloc ( const Alloc< T > &  o)
inline

Definition at line 663 of file StlVectorTest.cpp.

663 : a(o.a), id(o.id) {}
std::allocator< T > a
template<class T>
Alloc< T >::Alloc ( Alloc< T > &&  o)
inlinenoexcept

Definition at line 664 of file StlVectorTest.cpp.

References folly::pushmi::__adl::noexcept(), and D0< b >::operator=().

664 : a(move(o.a)), id(o.id) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::allocator< T > a

Member Function Documentation

template<class T>
pointer Alloc< T >::allocate ( size_type  n)
inline

Definition at line 677 of file StlVectorTest.cpp.

Referenced by MemoryLeakCheckerAllocator< Alloc >::allocate().

677  {
678  if (n == 0) {
679  cerr << "called allocate(0)" << endl;
680  throw runtime_error("allocate fail");
681  }
682  Tick("allocate");
683  auto p = a.allocate(n);
684  Allocated[p] = n;
685  Owner[p] = id;
686  return p;
687  }
static map< void *, size_t > Allocated
static map< void *, int > Owner
std::allocator< T > a
static void Tick(const std::string &s)
template<class T>
template<class U , class... Args>
void Alloc< T >::construct ( U *  p,
Args &&...  args 
)
inline

Definition at line 716 of file StlVectorTest.cpp.

Referenced by MemoryLeakCheckerAllocator< Alloc >::construct().

716  {
717  Tick("construct");
718  a.construct(p, std::forward<Args>(args)...);
719  Constructed++;
720  }
std::allocator< T > a
static void Tick(const std::string &s)
static int Constructed
template<class T>
void Alloc< T >::deallocate ( pointer  p,
size_type  n 
)
inline

Definition at line 689 of file StlVectorTest.cpp.

References testing::Args(), and FAIL.

Referenced by MemoryLeakCheckerAllocator< Alloc >::deallocate().

689  {
690  if (p == nullptr) {
691  cerr << "deallocate(nullptr, " << n << ")" << endl;
692  FAIL() << "deallocate failed";
693  }
694  if (Allocated[p] != n) {
695  cerr << "deallocate(" << p << ", " << n << ") invalid: ";
696  if (Allocated[p] == 0) {
697  cerr << "never allocated";
698  } else if (Allocated[p] == size_t(-1)) {
699  cerr << "already deallocated";
700  } else {
701  cerr << "wrong number (want " << Allocated[p] << ")";
702  }
703  cerr << endl;
704  FAIL() << "deallocate failed";
705  }
706  if (Owner[p] != id) {
707  cerr << "deallocate(" << p << "), where pointer is owned by " << Owner[p]
708  << ", instead of self - " << id << endl;
709  FAIL() << "deallocate failed";
710  }
711  Allocated[p] = -1;
712  a.deallocate(p, n);
713  }
static map< void *, size_t > Allocated
#define FAIL()
Definition: gtest.h:1822
static map< void *, int > Owner
std::allocator< T > a
template<class T>
template<class U >
void Alloc< T >::destroy ( U *  p)
inline

Definition at line 723 of file StlVectorTest.cpp.

Referenced by MemoryLeakCheckerAllocator< Alloc >::destroy().

723  {
724  Destroyed++;
725  a.destroy(p);
726  }
static int Destroyed
std::allocator< T > a
template<class T>
bool Alloc< T >::operator!= ( const Alloc< T > &  o) const
inline

Definition at line 670 of file StlVectorTest.cpp.

670  {
671  return !(*this == o);
672  }
template<class T>
Alloc& Alloc< T >::operator= ( const Alloc< T > &  )
default
template<class T>
Alloc& Alloc< T >::operator= ( Alloc< T > &&  )
defaultnoexcept
template<class T>
bool Alloc< T >::operator== ( const Alloc< T > &  o) const
inline

Definition at line 667 of file StlVectorTest.cpp.

References Alloc< T >::a, and Alloc< T >::id.

667  {
668  return a == o.a && id == o.id;
669  }
std::allocator< T > a
template<class T>
Alloc Alloc< T >::select_on_container_copy_construction ( ) const
inline

Definition at line 731 of file StlVectorTest.cpp.

731  {
732  Tick("select allocator for copy");
733  return Alloc(id + 1);
734  }
static void Tick(const std::string &s)
Alloc(int i=8)

Member Data Documentation

template<class T>
std::allocator<T> Alloc< T >::a

Definition at line 660 of file StlVectorTest.cpp.

Referenced by Alloc< T >::operator==().

template<class T>
int Alloc< T >::id

Definition at line 661 of file StlVectorTest.cpp.

Referenced by convertToInt(), and Alloc< T >::operator==().


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