Sacado Package Browser (Single Doxygen Collection)
Version of the Day
|
Container class to manager template instantiations of a template class. More...
#include <Sacado_TemplateContainer.hpp>
Classes | |
struct | BuildObject |
Helper class for building objects in container. More... | |
struct | DefaultBuilderOp |
The default builder class for building objects for each ScalarT. More... | |
Public Types | |
typedef TypeSeq | types |
Type sequence containing template types. More... | |
Public Member Functions | |
TemplateContainer () | |
Default constructor. More... | |
~TemplateContainer () | |
Destructor. More... | |
template<typename T > | |
Sacado::mpl::apply< ObjectT, T > ::type & | get () |
Get object corrensponding ObjectT<T> More... | |
template<typename T > | |
const Sacado::mpl::apply < ObjectT, T >::type & | get () const |
Get object corrensponding ObjectT<T> More... | |
template<typename BuilderOpT = DefaultBuilderOp> | |
void | build (const BuilderOpT &builder) |
Build objects for each type T. More... | |
Private Types | |
typedef Impl::TupleSeq < TypeSeq, ObjectT > | tuple_type |
Our container for storing each object. More... | |
Private Attributes | |
tuple_type | objects |
Stores type of objects of each type. More... | |
Container class to manager template instantiations of a template class.
This class provides a generic container class for managing multiple instantiations of a class ObjectT<T> with the values of T specified through a type sequence. Objects of type ObjectT<T> must have value semantics, be default constructable and copyable/assignable (for objects that don't satisfy these requirements, one would typically wrap them in a (smart) pointer. Methods are provided to access the object of type ObjectT<T> for a given type T, as well as initialize them. One would typically operate on the contained objects using mpl::for_each(), e.g.,
template <class t>=""> class MyClass; typedef mpl::vector< double, Fad::DFad<double> > MyTypes; typedef TemplateContainer< MyTypes, MyClass<_> > MyObjects; MyObjects myObjects; mpl::for_each<MyObjects>([](auto x) { typedef decltype(x) T; myObjects.get<T>() = T; });
(Note: This requires generalized lambda's introduced in C++14. For C++11, provide a functor that implements the lambda body).
Definition at line 76 of file Sacado_TemplateContainer.hpp.
|
private |
Our container for storing each object.
Definition at line 79 of file Sacado_TemplateContainer.hpp.
typedef TypeSeq Sacado::TemplateContainer< TypeSeq, ObjectT >::types |
Type sequence containing template types.
Definition at line 97 of file Sacado_TemplateContainer.hpp.
|
inline |
Default constructor.
Definition at line 111 of file Sacado_TemplateContainer.hpp.
|
inline |
Destructor.
Definition at line 114 of file Sacado_TemplateContainer.hpp.
|
inline |
Get object corrensponding ObjectT<T>
Definition at line 118 of file Sacado_TemplateContainer.hpp.
|
inline |
Get object corrensponding ObjectT<T>
Definition at line 124 of file Sacado_TemplateContainer.hpp.
|
inline |
Build objects for each type T.
Definition at line 130 of file Sacado_TemplateContainer.hpp.
|
private |
Stores type of objects of each type.
Definition at line 138 of file Sacado_TemplateContainer.hpp.