Skip to content
Snippets Groups Projects
Commit 591d96a9 authored by Volker Neff's avatar Volker Neff
Browse files

add Field_t as inheritance of std::varinat<>

parent 5558b81e
No related branches found
No related tags found
1 merge request!6Draft: [WIP] New Field Architekture
......@@ -26,7 +26,8 @@ class Field;
using FieldFloat = Field<float>;
using FieldDouble = Field<double>;
using Field_t = std::variant<FieldFloat, FieldDouble>;
class Field_t;
//using Field_t = std::variant<FieldFloat, FieldDouble>;
template<typename T>
class Field3D;
......@@ -216,6 +217,73 @@ inline Field3D_t Field3D<T>::init(const CdoVar& var) {
}
}
/************************************************
************************************************
****************** Field_t ********************
************************************************
***********************************************/
using _var_ = std::variant<FieldDouble, FieldFloat>;
class Field_t : public _var_ {
public:
// Overwrites of the std::variant<> constructors
constexpr Field_t() noexcept;
Field_t(Field_t& other)
: _var_(other) { }
template< class T >
constexpr Field_t( T&& t ) noexcept
: _var_(std::move(t)) { }
template< class T,
class... Args >
constexpr explicit Field_t( std::in_place_type_t<T>,
Args&&... args )
: _var_(std::in_place_type_t<T>{}, args...) { }
template< class T,
class U,
class... Args >
constexpr explicit Field_t(std::in_place_type_t<T>,
std::initializer_list<U> il,
Args&&... args )
: _var_(std::in_place_type_t<T>{}, il, args...) { }
template< std::size_t I,
class... Args >
constexpr explicit Field_t( std::in_place_index_t<I>,
Args&&... args )
: _var_(std::in_place_index_t<I>{}, args...) { }
template< std::size_t I,
class U,
class... Args >
constexpr explicit Field_t( std::in_place_index_t<I>,
std::initializer_list<U> il,
Args&&... args )
: _var_(std::in_place_index_t<I>{}, il, args...) { }
// Overwrites of the std::variant<> operator=
Field_t& operator=( const Field_t& rhs ) {
_var_::operator=(rhs);
return *this;
}
Field_t& operator=( Field_t&& rhs ) noexcept {
_var_::operator=(std::move(rhs));
return *this;
}
template< class T >
Field_t& operator=( T&& t ) noexcept {
_var_::operator=(std::move(t));
return *this;
}
};
/************************************************
************************************************
************* FieldFactory ********************
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment