sparrow 2.6.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Loading...
Searching...
No Matches
sparrow::nullable_variant< T > Class Template Reference

Variant of nullable types with has_value() convenience method. More...

#include <nullable.hpp>

Inheritance diagram for sparrow::nullable_variant< T >:
[legend]
Collaboration diagram for sparrow::nullable_variant< T >:
[legend]

Public Types

using base_type = std::variant<T...>

Public Member Functions

template<class U, mpl::boolean_like B>
requires ((std::same_as<nullable<U, B>, T> || ...))
constexpr nullable_variant (const nullable< U, B > &value)
template<class... U>
requires impl::materializable_into<nullable_variant<U...>, nullable_variant<T...>>
constexpr nullable_variant (const nullable_variant< U... > &rhs)
 Converting constructor from another nullable variant.
template<class... U>
requires impl::materializable_into<nullable_variant<U...>, nullable_variant<T...>>
constexpr nullable_variant & operator= (const nullable_variant< U... > &rhs)
 Converting assignment operator from another nullable variant.
constexpr nullable_variant (const nullable_variant &)=default
constexpr nullable_variant (nullable_variant &&) noexcept=default
constexpr nullable_variant & operator= (const nullable_variant &)
 Copy assignment operator.
constexpr nullable_variant & operator= (nullable_variant &&) noexcept
 Move assignment operator.
constexpr operator bool () const
 Conversion to bool indicating non-null state.
constexpr bool has_value () const
 Checks whether the active alternative contains a valid value.

Detailed Description

template<class... T>
requires (sizeof...(T) > 0 && (is_nullable_v<T> && ...))
class sparrow::nullable_variant< T >

Variant of nullable types with has_value() convenience method.

This class extends std::variant to work specifically with nullable types, providing a uniform has_value() interface across all alternative types.

Template Parameters
TPack of nullable types that can be stored in the variant
Precondition
All types in T must be nullable types
sizeof...(T) must be > 0
Postcondition
Provides has_value() that works regardless of active alternative
Maintains all std::variant functionality
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/utils/nullable.hpp.

Definition at line 1241 of file nullable.hpp.

Member Typedef Documentation

◆ base_type

template<class... T>
using sparrow::nullable_variant< T >::base_type = std::variant<T...>

Constructor & Destructor Documentation

◆ nullable_variant() [1/4]

template<class... T>
template<class U, mpl::boolean_like B>
requires ((std::same_as<nullable<U, B>, T> || ...))
sparrow::nullable_variant< T >::nullable_variant ( const nullable< U, B > & value)
inlineconstexpr
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/utils/nullable.hpp.

Definition at line 1250 of file nullable.hpp.

Here is the caller graph for this function:

◆ nullable_variant() [2/4]

template<class... T>
template<class... U>
requires impl::materializable_into<nullable_variant<U...>, nullable_variant<T...>>
sparrow::nullable_variant< T >::nullable_variant ( const nullable_variant< U... > & rhs)
inlineconstexpr

Converting constructor from another nullable variant.

Converts each alternative to its owning counterpart, so a variant of references or views (e.g. array_traits::const_reference) converts to a variant of owned values (e.g. array_traits::value_type). Only available when every alternative of the source has exactly one owning counterpart among T (see impl::materialized).

Template Parameters
UAlternative types of the source variant
Parameters
rhsVariant to convert
Postcondition
The active alternative is the owning counterpart of the active alternative of rhs

Definition at line 1270 of file nullable.hpp.

Here is the call graph for this function:

◆ nullable_variant() [3/4]

template<class... T>
sparrow::nullable_variant< T >::nullable_variant ( const nullable_variant< T > & )
constexprdefault
Here is the call graph for this function:

◆ nullable_variant() [4/4]

template<class... T>
sparrow::nullable_variant< T >::nullable_variant ( nullable_variant< T > && )
constexprdefaultnoexcept
Here is the call graph for this function:

Member Function Documentation

◆ has_value()

template<class... T>
requires (sizeof...(T) > 0 && (is_nullable_v<T> && ...))
bool sparrow::nullable_variant< T >::has_value ( ) const
constexpr

Checks whether the active alternative contains a valid value.

Returns
true if active alternative is non-null, false otherwise
Postcondition
Calls has_value() on the active nullable alternative
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/utils/nullable.hpp.

Definition at line 1620 of file nullable.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator bool()

template<class... T>
requires (sizeof...(T) > 0 && (is_nullable_v<T> && ...))
sparrow::nullable_variant< T >::operator bool ( ) const
explicitconstexpr

Conversion to bool indicating non-null state.

Returns
true if active alternative has a valid value
Postcondition
Return value equals has_value()

Definition at line 1613 of file nullable.hpp.

Here is the call graph for this function:

◆ operator=() [1/3]

template<class... T>
requires (sizeof...(T) > 0 && (is_nullable_v<T> && ...))
nullable_variant< T... > & sparrow::nullable_variant< T >::operator= ( const nullable_variant< T > & rhs)
constexpr

Copy assignment operator.

Parameters
rhsSource variant to copy from
Returns
Reference to this variant
Postcondition
This variant contains a copy of rhs
Active alternative matches rhs

Definition at line 1597 of file nullable.hpp.

Here is the call graph for this function:

◆ operator=() [2/3]

template<class... T>
template<class... U>
requires impl::materializable_into<nullable_variant<U...>, nullable_variant<T...>>
nullable_variant & sparrow::nullable_variant< T >::operator= ( const nullable_variant< U... > & rhs)
inlineconstexpr

Converting assignment operator from another nullable variant.

See the converting constructor for the conditions under which the conversion is available.

Template Parameters
UAlternative types of the source variant
Parameters
rhsVariant to convert
Returns
Reference to this variant
Postcondition
The active alternative is the owning counterpart of the active alternative of rhs
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/utils/nullable.hpp.

Definition at line 1289 of file nullable.hpp.

Here is the call graph for this function:

◆ operator=() [3/3]

template<class... T>
requires (sizeof...(T) > 0 && (is_nullable_v<T> && ...))
nullable_variant< T... > & sparrow::nullable_variant< T >::operator= ( nullable_variant< T > && rhs)
constexprnoexcept

Move assignment operator.

Parameters
rhsSource variant to move from
Returns
Reference to this variant
Postcondition
This variant contains moved content from rhs
rhs is left in valid but unspecified state

Definition at line 1605 of file nullable.hpp.

Here is the call graph for this function:

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