Generic object to store a set of datatypes in without losing type safety.
More...
#include <Variant.hpp>
|
using | resource = variantSrc::variant< T ... > |
|
|
| Variant (resource r) |
| Construct a lightweight wrapper around a generic object that indicates the concrete datatype of the specific object stored. More...
|
|
template<typename U > |
U | get () const |
| Retrieve a stored specific object of known datatype with ensured type-safety. More...
|
|
resource | getResource () const |
| Retrieve the stored generic object. More...
|
|
constexpr size_t | index () const noexcept |
| Retrieve the index of the alternative that is currently been held. More...
|
|
template<class T_DTYPES, typename ... T>
class openPMD::auxiliary::Variant< T_DTYPES, T >
Generic object to store a set of datatypes in without losing type safety.
- Template Parameters
-
T_DTYPES | Enumeration of datatypes to be stored and identified. |
T | Varaidic template argument list of datatypes to be stored. |
◆ Variant()
template<class T_DTYPES, typename ... T>
Construct a lightweight wrapper around a generic object that indicates the concrete datatype of the specific object stored.
- Note
- Gerneric objects can only generated implicitly if their datatype is contained in T_DTYPES.
- Parameters
-
r | Generic object to be stored. |
◆ get()
template<class T_DTYPES, typename ... T>
template<typename U >
Retrieve a stored specific object of known datatype with ensured type-safety.
- Exceptions
-
std::bad_variant_access | if stored object is not of type U. |
- Template Parameters
-
U | Type of the object to be retrieved. |
- Returns
- Copy of the retrieved object of type U.
◆ getResource()
template<class T_DTYPES, typename ... T>
Retrieve the stored generic object.
- Returns
- Copy of the stored generic object.
◆ index()
template<class T_DTYPES, typename ... T>
Retrieve the index of the alternative that is currently been held.
- Returns
- zero-based index
The documentation for this class was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/openpmd-api/checkouts/0.13.3/include/openPMD/auxiliary/Variant.hpp