Class template Dune::XT::Common::ConstStorageProvider¶
-
template<class T>
class Dune::XT::Common::ConstStorageProvider<T>¶ Provides generic (const) access to objects of different origins.
struct Base { Base(const std::vector
& vec); }; struct Derived : public Base { Derived(const std::vector
& vec); Derived(); }; struct Derived : private ConstStorageProvider<std::vector
> , public Base { using VectorProvider = ConstStorageProvider<std::vector >; Derived(const std::vector & vec) : VectorProvider(vec) , Base(VectorProvider::access()) {} Derived() : VectorProvider(new std::vector ()) , Base(VectorProvider::access()) }; const T* tt = new T(); { ConstStorageProvider
provider(tt); } const T& derefed_tt = *tt; const T* tt = new T(); { ConstStorageProvider
provider(*tt); } const T& derefed_tt = *tt; Cosider the following base class which always requires a vector:
Consider further a derived class which should be constructible with a given vector as well as without:
In the latter case, a vector should be created automatically, which is problematic due to the requirements of Base. The solution is to first derive from ConstStorageProvider or StorageProvider, which handles the management of the vector:
For the latter to work, ConstStorageProvider (as well as StorageProvider) needs to take ownership of the provided raw pointer.
Do the following instead:
Warning
ConstStorageProvider (as well as StorageProvider) takes ownership of the provided raw pointer. Thus, the following code is supposed to fail:
Method Dune::XT::Common::ConstStorageProvider::operator=¶
-
template<class T>
ConstStorageProvider<T> &Dune::XT::Common::ConstStorageProvider<T>::operator=(const ConstStorageProvider<T> &other)¶ No documentation provided.
Method Dune::XT::Common::ConstStorageProvider::operator=¶
-
template<class T>
ConstStorageProvider<T> &Dune::XT::Common::ConstStorageProvider<T>::operator=(ConstStorageProvider<T> &&source) noexcept = default¶ No documentation provided.
Method Dune::XT::Common::ConstStorageProvider::valid¶
-
template<class T>
bool Dune::XT::Common::ConstStorageProvider<T>::valid() const¶ No documentation provided.
Method Dune::XT::Common::ConstStorageProvider::access¶
-
template<class T>
const T &Dune::XT::Common::ConstStorageProvider<T>::access() const¶ No documentation provided.
Constructor Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>¶
Constructor Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>¶
Constructor Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>¶
Constructor Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>¶
No documentation provided.
Constructor Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>¶
Constructor Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>¶
-
template<>
template<class T>
Dune::XT::Common::ConstStorageProvider<T>::ConstStorageProvider<T>(const ConstStorageProvider<T> &other)¶ No documentation provided.
Constructor Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>¶
-
template<>
template<class T>
Dune::XT::Common::ConstStorageProvider<T>::ConstStorageProvider<T>(ConstStorageProvider<T> &&source) noexcept = default¶ No documentation provided.
Field Dune::XT::Common::ConstStorageProvider::storage_¶
-
int Dune::XT::Common::ConstStorageProvider::storage_¶
No documentation provided.
Function template Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>¶
-
template<class T>
template<class S, typename>
explicit Dune::XT::Common::ConstStorageProvider<T>::ConstStorageProvider<T>(S &&tt)¶ No documentation provided.
Function template Dune::XT::Common::ConstStorageProvider::make¶
-
template<class T>
template<typename ...Args>
static ConstStorageProvider<T> Dune::XT::Common::ConstStorageProvider<T>::make(Args&&... args)¶ No documentation provided.