Gromacs
2016.6
|
#include <gromacs/utility/classhelpers.h>
Helper class to manage a pointer to a private implementation class.
This helper provides the following benefits (all but the last could also be achieved with std::unique_ptr):
Move construction and assignment are also disallowed, but can be enabled by providing explicit move constructor and/or assignment.
Intended use:
Public Member Functions | |
PrivateImplPointer (std::nullptr_t) | |
Allow implicit initialization from nullptr to support comparison. | |
PrivateImplPointer (Impl *ptr) | |
Initialize with the given implementation class. | |
void | reset (Impl *ptr) |
Sets a new implementation class and destructs the previous one. More... | |
Impl * | get () |
Access the raw pointer. | |
Impl * | operator-> () |
Access the implementation class as with a raw pointer. | |
Impl & | operator* () |
Access the implementation class as with a raw pointer. | |
const Impl * | operator-> () const |
Access the implementation class as with a raw pointer. | |
const Impl & | operator* () const |
Access the implementation class as with a raw pointer. | |
operator bool () const | |
Allows testing whether the implementation is initialized. | |
bool | operator== (const PrivateImplPointer &other) const |
Tests for equality (mainly useful against nullptr). | |
bool | operator!= (const PrivateImplPointer &other) const |
Tests for inequality (mainly useful against nullptr). | |
|
inline |
Sets a new implementation class and destructs the previous one.
Needed, e.g., to implement lazily initializable or copy-assignable classes.