CXXIter 0.2
Loading...
Searching...
No Matches
CXXIter::IterValue< TValue > Class Template Reference

Container that is used to pass elements through CXXIter's iterator pipelines. More...

#include <IterValue.h>

Collaboration diagram for CXXIter::IterValue< TValue >:

Public Member Functions

constexpr IterValue () noexcept
 
constexpr IterValue (TValue value) noexcept
 
constexpr IterValue (const TValueDeref &value) noexcept(std::is_nothrow_copy_constructible_v< TValueDeref >)
 
constexpr IterValue (TValueDeref &&value) noexcept(std::is_nothrow_move_constructible_v< TValueDeref >)
 
constexpr IterValueoperator= (IterValue &&o)=default
 
constexpr IterValue (IterValue &&o) noexcept(std::is_nothrow_move_constructible_v< TValueDeref >)
 
constexpr auto & operator= (TValueDeref &&o)
 
constexpr const TValueDeref & value () const
 Get the contained value (if any). More...
 
constexpr TValueDeref & value ()
 Get the contained value (if any). More...
 
constexpr const TValueDeref & value_or (TValueDeref &&def) const noexcept
 Get the contained value, or alternatively the given def if none is present. More...
 
constexpr TValueDeref & value_or (TValueDeref &&def) noexcept
 Get the contained value, or alternatively the given def if none is present. More...
 
constexpr bool has_value () const noexcept
 Get whether this optional IteratorValue contains a value. More...
 
constexpr void swap (IterValue< TValue > &o) noexcept
 Swap the values within this and another IterValue container. More...
 
constexpr std::optional< TValueStore > toStdOptional () noexcept
 Convert this IterValue to a std::optional<> on the owned (no-reference) type. More...
 
constexpr operator std::optional< TValueStore > () noexcept
 Cast to std::optional<>. More...
 
template<typename TOutValue , std::invocable< TValueDeref && > TMapFn>
requires (!std::is_reference_v<TValue>)
constexpr IterValue< TOutValue > map (TMapFn mapFn)
 Map this IterValue's contained value (if any) to the requested new TOutValue type, using the given mapFn. More...
 
template<typename TOutValue , std::invocable< TValue > TMapFn>
requires std::is_reference_v<TValue>
constexpr IterValue< TOutValue > map (TMapFn mapFn)
 Map this IterValue's contained value (if any) to the requested new TOutValue type, using the given mapFn. More...
 

Detailed Description

template<typename TValue>
class CXXIter::IterValue< TValue >

Container that is used to pass elements through CXXIter's iterator pipelines.

This is essentially a std::optional<> that also transparently supports references (in comparison to the original). This is achieved by wrapping reference types in a std::reference_wrapper<> before storing them in the internal std::optional<>.

Definition at line 19 of file IterValue.h.

Constructor & Destructor Documentation

◆ IterValue() [1/5]

template<typename TValue >
constexpr CXXIter::IterValue< TValue >::IterValue ( )
inlineconstexprnoexcept

ctor

Definition at line 33 of file IterValue.h.

◆ IterValue() [2/5]

template<typename TValue >
constexpr CXXIter::IterValue< TValue >::IterValue ( TValue  value)
inlineconstexprnoexcept

ctor

Definition at line 35 of file IterValue.h.

◆ IterValue() [3/5]

template<typename TValue >
constexpr CXXIter::IterValue< TValue >::IterValue ( const TValueDeref &  value)
inlineconstexprnoexcept

ctor

Definition at line 37 of file IterValue.h.

◆ IterValue() [4/5]

template<typename TValue >
constexpr CXXIter::IterValue< TValue >::IterValue ( TValueDeref &&  value)
inlineconstexprnoexcept

ctor

Definition at line 40 of file IterValue.h.

◆ IterValue() [5/5]

template<typename TValue >
constexpr CXXIter::IterValue< TValue >::IterValue ( IterValue< TValue > &&  o)
inlineconstexprnoexcept

Assignment from another IterValue instance.

Definition at line 46 of file IterValue.h.

Member Function Documentation

◆ has_value()

template<typename TValue >
constexpr bool CXXIter::IterValue< TValue >::has_value ( ) const
inlineconstexprnoexcept

Get whether this optional IteratorValue contains a value.

Returns
true when this IterValue contains a value, false otherwise.

Definition at line 86 of file IterValue.h.

◆ map() [1/2]

template<typename TValue >
template<typename TOutValue , std::invocable< TValueDeref && > TMapFn>
requires (!std::is_reference_v<TValue>)
constexpr IterValue< TOutValue > CXXIter::IterValue< TValue >::map ( TMapFn  mapFn)
inlineconstexpr

Map this IterValue's contained value (if any) to the requested new TOutValue type, using the given mapFn.

Template Parameters
Therequested output type for the mapping operation.
Parameters
mapFnMapper function that takes this IterValue's contained value (if any) to map it to an instance of TOutValue
Returns
A new IterValue containing the mapped value if this instance contained a value.

Definition at line 115 of file IterValue.h.

Here is the call graph for this function:

◆ map() [2/2]

template<typename TValue >
template<typename TOutValue , std::invocable< TValue > TMapFn>
requires std::is_reference_v<TValue>
constexpr IterValue< TOutValue > CXXIter::IterValue< TValue >::map ( TMapFn  mapFn)
inlineconstexpr

Map this IterValue's contained value (if any) to the requested new TOutValue type, using the given mapFn.

Template Parameters
Therequested output type for the mapping operation.
Parameters
mapFnMapper function that takes this IterValue's contained value (if any) to map it to an instance of TOutValue
Returns
A new IterValue containing the mapped value if this instance contained a value.

Definition at line 128 of file IterValue.h.

Here is the call graph for this function:

◆ operator std::optional< TValueStore >()

template<typename TValue >
constexpr CXXIter::IterValue< TValue >::operator std::optional< TValueStore > ( )
inlineconstexprnoexcept

Cast to std::optional<>.

Definition at line 105 of file IterValue.h.

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename TValue >
constexpr IterValue & CXXIter::IterValue< TValue >::operator= ( IterValue< TValue > &&  o)
constexprdefault

Assignment from another IterValue instance.

◆ operator=() [2/2]

template<typename TValue >
constexpr auto & CXXIter::IterValue< TValue >::operator= ( TValueDeref &&  o)
inlineconstexpr

Assignment from an instance of the stored type.

Definition at line 52 of file IterValue.h.

◆ swap()

template<typename TValue >
constexpr void CXXIter::IterValue< TValue >::swap ( IterValue< TValue > &  o)
inlineconstexprnoexcept

Swap the values within this and another IterValue container.

Parameters
oOther IterValue container to swap contents with.

Definition at line 92 of file IterValue.h.

◆ toStdOptional()

template<typename TValue >
constexpr std::optional< TValueStore > CXXIter::IterValue< TValue >::toStdOptional ( )
inlineconstexprnoexcept

Convert this IterValue to a std::optional<> on the owned (no-reference) type.

If the contained value is a reference, the value will be copied into the returned std::optional<>.

Returns
std::optional<> containing an owned version of the value contained by this IterValue.

Definition at line 99 of file IterValue.h.

◆ value() [1/2]

template<typename TValue >
constexpr TValueDeref & CXXIter::IterValue< TValue >::value ( )
inlineconstexpr

Get the contained value (if any).

Exceptions
Ifthis is called when no value is contained.
Returns
reference to the contained value.

Definition at line 68 of file IterValue.h.

◆ value() [2/2]

template<typename TValue >
constexpr const TValueDeref & CXXIter::IterValue< TValue >::value ( ) const
inlineconstexpr

Get the contained value (if any).

Exceptions
Ifthis is called when no value is contained.
Returns
const reference to the contained value.

Definition at line 62 of file IterValue.h.

◆ value_or() [1/2]

template<typename TValue >
constexpr const TValueDeref & CXXIter::IterValue< TValue >::value_or ( TValueDeref &&  def) const
inlineconstexprnoexcept

Get the contained value, or alternatively the given def if none is present.

Parameters
defDefault value to return when this optional does not contain a value.
Returns
const reference to the contained value (if any), or alternatively the given def value.

Definition at line 74 of file IterValue.h.

◆ value_or() [2/2]

template<typename TValue >
constexpr TValueDeref & CXXIter::IterValue< TValue >::value_or ( TValueDeref &&  def)
inlineconstexprnoexcept

Get the contained value, or alternatively the given def if none is present.

Parameters
defDefault value to return when this optional does not contain a value.
Returns
reference to the contained value (if any), or alternatively the given def value.

Definition at line 80 of file IterValue.h.


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