uvcc
libuv C++ bindings
uv::union_storage< _Ts_ > Class Template Reference

A tagged union that provide a storage space being a standard layout type suited for all its type variants specified in the type list _Ts_. More...

#include "utility.hpp"

Public Types

using storage_type = typename aligned_union< _Ts_... >::type
 

Public Member Functions

 union_storage ()=default
 Create an uninitialized union storage.
 
 union_storage (const union_storage &)=delete
 
union_storageoperator= (const union_storage &)=delete
 
 union_storage (union_storage &&)=delete
 
union_storageoperator= (union_storage &&)=delete
 
template<typename _T_ , typename = std::enable_if_t< is_convertible_to_one_of< _T_, _Ts_... >::value >>
 union_storage (const _T_ &_value)
 Create a union with a copy-initialized value from the specified one.
 
template<typename _T_ , typename = std::enable_if_t< is_convertible_to_one_of< _T_, _Ts_... >::value >>
 union_storage (_T_ &&_value)
 Create a union with a move-initialized value from the specified value.
 
const std::type_infotag () const noexcept
 The type tag of the stored value. More...
 
 operator bool () const noexcept
 Equivalent to (tag() != nullptr).
 
Functions to reinitialize the union storage:
Note
The previously stored value is destroyed.
template<typename _T_ >
std::enable_if< is_convertible_to_one_of< _T_, _Ts_... >::value >::type reset ()
 Reinitialize the union storage with a default value of the one of the type from _Ts_ list that the specified type _T_ is convertible to.
 
template<typename _T_ , typename... _Args_>
std::enable_if< is_convertible_to_one_of< _T_, _Ts_... >::value >::type reset (_Args_ &&... _args)
 Ditto but the value is created from the arguments forwarded to the type constructor.
 
template<typename _T_ >
std::enable_if< is_convertible_to_one_of< _T_, _Ts_... >::value >::type reset (const _T_ &_value)
 Ditto but the value is copy-created from the specified argument.
 
template<typename _T_ >
std::enable_if< is_convertible_to_one_of< _T_, _Ts_... >::value >::type reset (_T_ &&_value)
 Ditto but the value is move-created from the specified argument.
 
Functions to get the value stored in the union:
template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, _Ts_... >::value >>
const std::decay< _T_ >::type & get () const noexcept
 
template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, _Ts_... >::value >>
std::decay< _T_ >::type & get () noexcept
 

Detailed Description

template<typename... _Ts_>
class uv::union_storage< _Ts_ >

A tagged union that provide a storage space being a standard layout type suited for all its type variants specified in the type list _Ts_.

Only values from the specified set of types _Ts_ are created and stored in the union even though the values of any types that are implicitly convertible to one of the types from _Ts_ list are acceptable for copy- or move-initialization reset() functions.

Note
All the member functions creating a new value in the union from their arguments use the curly brace initialization.

Definition at line 527 of file utility.hpp.

Member Function Documentation

◆ tag()

template<typename... _Ts_>
const std::type_info* uv::union_storage< _Ts_ >::tag ( ) const
inlinenoexcept

The type tag of the stored value.

It's just a pointer referring to the static global constant object returned by the typeid() operator for the type of the value currently stored in this union_storage variable. nullptr is returned if the union is not initialized and is not storing any value.

Definition at line 655 of file utility.hpp.


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