Class template Dune::XT::Common::ConstStorageProvider

template<class T>
class Dune::XT::Common::ConstStorageProvider

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:

ConstStorageProvider<T> &Dune::XT::Common::ConstStorageProvider::operator=(const ConstStorageProvider<T> &other)

No documentation provided.

ConstStorageProvider<T> &Dune::XT::Common::ConstStorageProvider::operator=(ConstStorageProvider<T> &&source) noexcept = default

No documentation provided.

bool Dune::XT::Common::ConstStorageProvider::valid() const

No documentation provided.

const T &Dune::XT::Common::ConstStorageProvider::access() const

No documentation provided.

template<>
explicit Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>()

No documentation provided.

template<>
explicit Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>(const T &tt)

No documentation provided.

template<>
explicit Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>(T *&&tt)

Warning

This ctor transfers ownership to ConstStorageProvider, do not delete tt manually!

template<>
explicit Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>(std::shared_ptr<const T> tt)

No documentation provided.

template<>
explicit Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>(int &&tt)

No documentation provided.

template<>
Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>(const ConstStorageProvider<T> &other)

No documentation provided.

template<>
Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>(ConstStorageProvider<T> &&source) noexcept = default

No documentation provided.

int Dune::XT::Common::ConstStorageProvider::storage_

No documentation provided.

template<class S, typename>
explicit Dune::XT::Common::ConstStorageProvider::ConstStorageProvider<T>(S &&tt)

No documentation provided.

template<typename ...Args>
static ConstStorageProvider<T> Dune::XT::Common::ConstStorageProvider::make(Args&&... args)

No documentation provided.