BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
CloneableVector< T > Class Template Reference
Inheritance diagram for CloneableVector< T >:
Collaboration diagram for CloneableVector< T >:

Public Member Functions

 CloneableVector ()
 
 CloneableVector (const CloneableVector &other)
 
void push_back (T *t)
 
void emplace_back (std::unique_ptr< T > &&t)
 

Private Types

using super = std::vector< std::unique_ptr< T > >
 

Detailed Description

template<class T>
class CloneableVector< T >

A vector of unique pointers to objects that are cloneable.

Equips vector<unique_ptr<T>> with copy constructor. For use with polymorphic objects, or in pimpl idiom. The objects pointed to must posses a clone() function.

Definition at line 30 of file CloneableVector.h.

Member Typedef Documentation

◆ super

template<class T >
using CloneableVector< T >::super = std::vector<std::unique_ptr<T> >
private

Definition at line 32 of file CloneableVector.h.

Constructor & Destructor Documentation

◆ CloneableVector() [1/2]

template<class T >
CloneableVector< T >::CloneableVector ( )
inline

Definition at line 35 of file CloneableVector.h.

35 : super() {}
std::vector< std::unique_ptr< T > > super

◆ CloneableVector() [2/2]

template<class T >
CloneableVector< T >::CloneableVector ( const CloneableVector< T > &  other)
inline

Definition at line 36 of file CloneableVector.h.

36  : super()
37  {
38  super::reserve(other.size());
39  for (const std::unique_ptr<T>& t : other)
40  super::emplace_back(t->clone());
41  }

Member Function Documentation

◆ push_back()

template<class T >
void CloneableVector< T >::push_back ( T *  t)
inline

Definition at line 42 of file CloneableVector.h.

42 { super::emplace_back(std::unique_ptr<T>(t)); }

Referenced by IDetector::addAxis().

◆ emplace_back()

template<class T >
void CloneableVector< T >::emplace_back ( std::unique_ptr< T > &&  t)
inline

Definition at line 43 of file CloneableVector.h.

43 { super::emplace_back(t); }

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