|
Sacado
Development
|
Container class to manager template instantiations of a template class. More...
#include <Sacado_TemplateContainer.hpp>
Classes | |
| struct | DefaultBuilderOp |
| The default builder class for building objects for each ScalarT. More... | |
Public Types | |
| typedef TypeSeq | types |
| Type sequence containing template types. | |
Public Member Functions | |
| TemplateContainer () | |
| Default constructor. | |
| ~TemplateContainer () | |
| Destructor. | |
| template<typename T > | |
| Sacado::mpl::apply< ObjectT, T > ::type & | get () |
| Get object corrensponding ObjectT<T> | |
| template<typename T > | |
| const Sacado::mpl::apply < ObjectT, T >::type & | get () const |
| Get object corrensponding ObjectT<T> | |
| template<typename BuilderOpT = DefaultBuilderOp> | |
| void | build (const BuilderOpT &builder) |
| Build objects for each type T. | |
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).
1.8.5