BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
CloneableVector< T > Class Template Reference

A vector of unique pointers to objects that are cloneable. More...

Inheritance diagram for CloneableVector< T >:
[legend]
Collaboration diagram for CloneableVector< T >:
[legend]

Public Member Functions

 CloneableVector ()
 
 CloneableVector (const CloneableVector &other)
 
void emplace_back (std::unique_ptr< T > &&t)
 
void push_back (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 35 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 36 of file CloneableVector.h.

Constructor & Destructor Documentation

◆ CloneableVector() [1/2]

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

Definition at line 39 of file CloneableVector.h.

39 : 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 40 of file CloneableVector.h.

40  : super()
41  {
42  super::reserve(other.size());
43  for (const std::unique_ptr<T>& t : other)
44  super::emplace_back(t->clone());
45  }

Member Function Documentation

◆ emplace_back()

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

Definition at line 47 of file CloneableVector.h.

47 { super::emplace_back(t); }

◆ push_back()

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

Definition at line 46 of file CloneableVector.h.

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

Referenced by IDetector::addAxis().


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