57 template <
typename T,
typename = std::enable_if_t<!std::is_same<std::decay_t<T>, Dynamic>::value>>
59 : storage(
std::forward<T>(value)) {}
62 : storage(other.storage) {}
65 : storage(
std::move(other.storage)) {}
68 template <typename T, typename = std::enable_if_t<DynamicVariant::canHold<T>()>>
70 storage = std::forward<T>(rhs);
75 storage = other.storage;
80 storage = std::move(other.storage);
87 template <typename T, typename = std::enable_if_t<DynamicVariant::canHold<T>()>>
89 return storage.
get<T>();
93 template <typename T, typename = std::enable_if_t<DynamicVariant::canHold<T>()>>
94 const T&
get()
const {
95 return storage.
get<T>();
99 template <typename T, typename = std::enable_if_t<DynamicVariant::canHold<T>()>>
101 return this->get<T>();
105 template <typename T, typename = std::enable_if_t<DynamicVariant::canHold<T>()>>
106 operator const T&()
const {
107 return this->get<T>();
112 return forValue(storage, ScalarFunctor());
124 explicit operator bool()
const {
125 return !this->
empty();
129 return this->
empty();
133 template <typename T, typename = std::enable_if_t<DynamicVariant::canHold<T>()>>
135 return this->get<T>() == value;
140 forValue(value.storage, [&stream](
const auto& v) { stream << std::setw(20) << v; });
145 struct ScalarFunctor {
146 template <
typename T>
147 Float operator()(
const T& value) {
159 Float operator()(
const std::string&) {
INLINE Float norm(const AntisymmetricTensor &t)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
DynamicId
Enum representing a value type stored in a Value object.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Computing minimum, maximum and mean value of floats.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Generic tensor of the 2nd order.
Symmetric traceless 2nd order tensor.
Object capable of storing values of different types.
decltype(auto) INLINE forValue(Variant< TArgs... > &variant, TFunctor &&functor)
INLINE Float getLength(const Vector &v)
Returns the length of the vector. Enabled only for vectors of floating-point precision.
BasicVector< Float > Vector
Convenient object for storing a single value of different types.
Float getScalar() const
Converts the stored value into a single number, using one of possible conversions.
Dynamic & operator=(Dynamic &&other)
const T & get() const
Returns the const reference to the stored value given its type.
bool operator==(const T &value) const
Equality operator with one of stored types.
Dynamic(const Dynamic &other)
bool empty() const
Checks if the value has been initialized.
~Dynamic()
Needs to be in .cpp to compile with clang, for some reason.
Dynamic & operator=(T &&rhs)
Assign one of possible value types into the value.
friend std::ostream & operator<<(std::ostream &stream, const Dynamic &value)
Prints the currently stored value into the stream, using << operator of its type.
DynamicId getType() const
INLINE T & get()
Returns the reference to the stored value given its type.
Dynamic()
Construct an uninitialized value.
Dynamic & operator=(const Dynamic &other)
Dynamic(T &&value)
Contruct value from one of possible value types.
Helper class for statistics, accumulating minimal, maximal and mean value of a set of numbers.
INLINE Float mean() const
Symmetric tensor of 2nd order.
Generic 2nd-order tensor with 9 independent components.
Symmetric traceless 2nd order tensor.
INLINE Size getTypeIdx() const
Returns index of type currently stored in variant.
INLINE T & get()
Returns the stored value.
Overload of std::swap for Sph::Array.