StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
StormByte::VariadicValue< Types > Class Template Reference

A class that can hold a value of any of the specified types. More...

#include <variadic_value.hxx>

Public Member Functions

 VariadicValue ()=default
 Default constructor.
 
template<typename T , typename = std::enable_if_t<(std::is_same_v<T, Types> || ...)>>
 VariadicValue (T value)
 Constructor with a value of one of the specified types.
 
 ~VariadicValue () noexcept=default
 Destructor.
 
 VariadicValue (const VariadicValue &other)
 Copy constructor with deep copy for std::unique_ptr.
 
VariadicValueoperator= (const VariadicValue &other)
 Copy assignment operator with deep copy for std::unique_ptr.
 
 VariadicValue (VariadicValue &&) noexcept=default
 Move constructor (default behavior).
 
VariadicValueoperator= (VariadicValue &&) noexcept=default
 Move assignment operator (default behavior).
 
constexpr bool operator== (const VariadicValue &other) const
 Equality operator.
 
constexpr bool operator!= (const VariadicValue &other) const
 Inequality operator.
 
template<typename T >
TGet ()
 Retrieves the stored value of the specified type.
 
template<typename T >
const TGet () const
 Retrieves the stored value of the specified type (const version).
 

Detailed Description

template<ValidVariadicType... Types>
class StormByte::VariadicValue< Types >

A class that can hold a value of any of the specified types.

This class is a variant that can hold a value of any of the specified types. It is useful when you need to store a value that can be of different types.

Template Parameters
TypesThe types that the value can be of.

Constructor & Destructor Documentation

◆ VariadicValue() [1/3]

template<ValidVariadicType... Types>
template<typename T , typename = std::enable_if_t<(std::is_same_v<T, Types> || ...)>>
StormByte::VariadicValue< Types >::VariadicValue ( T  value)
inlineexplicit

Constructor with a value of one of the specified types.

Template Parameters
TThe type of the value to store.
Parameters
valueThe value to store.

◆ VariadicValue() [2/3]

template<ValidVariadicType... Types>
StormByte::VariadicValue< Types >::VariadicValue ( const VariadicValue< Types > &  other)
inline

Copy constructor with deep copy for std::unique_ptr.

Parameters
otherThe VariadicValue instance to copy from.

◆ VariadicValue() [3/3]

template<ValidVariadicType... Types>
StormByte::VariadicValue< Types >::VariadicValue ( VariadicValue< Types > &&  )
defaultnoexcept

Move constructor (default behavior).

Parameters
otherThe VariadicValue instance to move from.

Member Function Documentation

◆ Get() [1/2]

template<ValidVariadicType... Types>
template<typename T >
T & StormByte::VariadicValue< Types >::Get ( )
inline

Retrieves the stored value of the specified type.

Template Parameters
TThe type of the value to retrieve.
Returns
A reference to the stored value.
Exceptions
ValueTypeMismatchIf the requested type does not match the stored type.

◆ Get() [2/2]

template<ValidVariadicType... Types>
template<typename T >
const T & StormByte::VariadicValue< Types >::Get ( ) const
inline

Retrieves the stored value of the specified type (const version).

Template Parameters
TThe type of the value to retrieve.
Returns
A const reference to the stored value.
Exceptions
ValueTypeMismatchIf the requested type does not match the stored type.

◆ operator!=()

template<ValidVariadicType... Types>
constexpr bool StormByte::VariadicValue< Types >::operator!= ( const VariadicValue< Types > &  other) const
inlineconstexpr

Inequality operator.

Parameters
otherThe other VariadicValue instance to compare with.
Returns
True if the stored values are not equal, false otherwise.

◆ operator=() [1/2]

template<ValidVariadicType... Types>
VariadicValue & StormByte::VariadicValue< Types >::operator= ( const VariadicValue< Types > &  other)
inline

Copy assignment operator with deep copy for std::unique_ptr.

Parameters
otherThe VariadicValue instance to copy from.
Returns
Reference to this object.

◆ operator=() [2/2]

template<ValidVariadicType... Types>
VariadicValue & StormByte::VariadicValue< Types >::operator= ( VariadicValue< Types > &&  )
defaultnoexcept

Move assignment operator (default behavior).

Parameters
otherThe VariadicValue instance to move from.
Returns
Reference to this object.

◆ operator==()

template<ValidVariadicType... Types>
constexpr bool StormByte::VariadicValue< Types >::operator== ( const VariadicValue< Types > &  other) const
inlineconstexpr

Equality operator.

Parameters
otherThe other VariadicValue instance to compare with.
Returns
True if the stored values are equal, false otherwise.

The documentation for this class was generated from the following file: