Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::result< void, E > Class Template Reference

Specialization of result<T, E> for void value types. More...

Inheritance diagram for arene::base::result< void, E >:
Inheritance graph

Public Types

using error_type
 The type when the result contains an error.
 
using error_type = E
 The type when the result contains an error.
 
using value_type
 The type when the result contains a value.
 
using value_type = void
 The type when the result contains a value.
 

Public Member Functions

constexpr result ()=default
 Constructs a result with a default-constructed value_type . Does not participate in overload resolution if value_type is not default constructible.
 
constexpr result ()=default
 Constructs a result with the value-channel engaged.
 
constexpr result (in_place_error_t, P &&... args) noexcept(noexcept(base_type(in_place_error, std::forward< P >(args)...)))
 Constructs a result containing the error_type by way of direct-non-list-initialization.
 
template<class... P, constraints< std::enable_if_t< std::is_constructible< error_type, P &&... >::value > > = nullptr>
constexpr result (in_place_error_t, P &&... args) noexcept(noexcept(base_type(in_place_error, std::forward< P >(args)...)))
 Constructs a result containing the error_type by way of direct-non-list-initialization.
 
constexpr result (in_place_value_t) noexcept(noexcept(base_type(in_place_value, monostate{})))
 Constructs a result with the value-channel engaged.
 
constexpr result (in_place_value_t, monostate) noexcept(noexcept(base_type(in_place_value, monostate{})))
 Constructs a result with the value-channel engaged. Provided for backwards compatibility.
 
constexpr result (in_place_value_t, P &&... args) noexcept(noexcept(base_type(in_place_value, std::forward< P >(args)...)))
 Constructs a result containing the value_type by way of direct-non-list-initialization.
 
constexpr result (result &&move) noexcept(noexcept(base_type(std::declval< result && >())))=default
 Default move constructor.
 
constexpr result (result &&move) noexcept(noexcept(base_type(std::declval< result && >())))=default
 Default move constructor.
 
constexpr result (result const &copy) noexcept(noexcept(base_type(std::declval< result const & >())))=default
 Default copy constructor.
 
constexpr result (result const &copy) noexcept(noexcept(base_type(std::declval< result const & >())))=default
 Default copy constructor.
 
 ~result ()=default
 Destroy the stored value or error.
 
 ~result ()=default
 Destroy the stored value or error.
 
void emplace (in_place_value_t) noexcept
 Emplaces the void value into the result.
 
auto emplace (in_place_value_t, ArgTypes &&... args) noexcept -> value_type &
 Emplaces a value into the result.
 
ARENE_NODISCARD constexpr auto error () &&noexcept -> error_type &&
 Accesses a reference to the content of the error channel.
 
ARENE_NODISCARD constexpr auto error () &noexcept -> error_type &
 Accesses a reference to the content of the error channel.
 
ARENE_NODISCARD constexpr auto error () const &&noexcept -> error_type const &&
 Accesses a reference to the content of the error channel.
 
ARENE_NODISCARD constexpr auto error () const &noexcept -> error_type const &
 Accesses a reference to the content of the error channel.
 
ARENE_NODISCARD constexpr auto has_value (value_type const &val) const noexcept(noexcept(val==std::declval< value_type >())) -> bool
 Checks if the value channel contains a specific value.
 
ARENE_NODISCARD constexpr auto operator* () &&noexcept -> value_type &&
 Accesses a reference to the content of the value channel.
 
ARENE_NODISCARD constexpr auto operator* () &noexcept -> value_type &
 Accesses a reference to the content of the value channel.
 
ARENE_NODISCARD constexpr auto operator* () const &&noexcept -> value_type const &&
 Accesses a reference to the content of the value channel.
 
constexpr void operator* () const &noexcept
 Access the content of the value channel.
 
ARENE_NODISCARD constexpr auto operator* () const &noexcept -> value_type const &
 Accesses a reference to the content of the value channel.
 
ARENE_NODISCARD constexpr auto operator-> () const noexcept -> value_type const *
 Accesses a pointer to the content of the value channel.
 
ARENE_NODISCARD constexpr auto operator-> () noexcept -> value_type *
 Accesses a pointer to the content of the value channel.
 
constexpr auto operator= (copy_assign_arg const &other) noexcept -> result &
 Copy-assignment for the case that value_type and error_type satisfy std::is_nothrow_copy_constructible and std::is_nothrow_copy_assignable, otherwise a dummy assignment operator that can never be called.
 
constexpr auto operator= (copy_assign_arg const &other) noexcept -> result &
 Copy-assignment for the case that error_type satisfies std::is_nothrow_copy_constructible and std::is_nothrow_copy_assignable, otherwise a dummy assignment operator that can never be called.
 
constexpr auto operator= (deleted_copy_assign_arg const &other) noexcept -> result &=delete
 Deleted Copy-assignment if value_type or error_type do not satisfy std::is_nothrow_copy_constructible and std::is_nothrow_copy_assignable, otherwise a deleted dummy assignment operator.
 
constexpr auto operator= (deleted_copy_assign_arg const &other) noexcept -> result &=delete
 Deleted Copy-assignment if error_type does not satisfy std::is_nothrow_copy_constructible and std::is_nothrow_copy_assignable, otherwise a deleted dummy assignment operator.
 
constexpr auto operator= (deleted_move_assign_arg &&other) noexcept -> result &=delete
 Deleted Move-assignment if value_type or error_type do not satisfy std::is_nothrow_move_constructible and std::is_nothrow_move_assignable, otherwise a deleted dummy assignment operator.
 
constexpr auto operator= (deleted_move_assign_arg &&other) noexcept -> result &=delete
 Deleted Move-assignment if error_type does not satisfy std::is_nothrow_move_constructible and std::is_nothrow_move_assignable, otherwise a deleted dummy assignment operator.
 
constexpr auto operator= (move_assign_arg &&other) noexcept -> result &
 Move-assignment for the case that value_type and error_type satisfy std::is_nothrow_move_constructible and std::is_nothrow_move_assignable, otherwise a dummy assignment operator that can never be called.
 
constexpr auto operator= (move_assign_arg &&other) noexcept -> result &
 Move-assignment for the case that error_type satisfies std::is_nothrow_move_constructible and std::is_nothrow_move_assignable, otherwise a dummy assignment operator that can never be called.
 
template<typename SourceErrorType = E, constraints< std::enable_if_t< is_swappable_v< SourceErrorType > >, std::enable_if_t< std::is_nothrow_move_constructible< SourceErrorType >::value > > = nullptr>
constexpr void swap (result &other) noexcept(is_nothrow_swappable_v< SourceErrorType >)
 Swaps the state of two results.
 
constexpr void swap (result &other) noexcept(is_nothrow_swappable_v< SourceValueType > &&is_nothrow_swappable_v< SourceErrorType >)
 Swaps the state of two results.
 
template<typename F>
constexpr auto transform_error (F &&handle_error) &
 Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.
 
template<typename F>
constexpr auto transform_error (F &&handle_error) &&
 Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.
 
template<typename F>
constexpr auto transform_error (F &&handle_error) const &
 Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.
 
template<typename F>
constexpr auto transform_error (F &&handle_error) const &&
 Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.
 
constexpr void value () &&noexcept
 Access the content of the value channel.
 
ARENE_NODISCARD constexpr auto value () &&noexcept -> value_type &&
 Accesses a reference to the content of the value channel.
 
ARENE_NODISCARD constexpr auto value () &noexcept -> value_type &
 Accesses a reference to the content of the value channel.
 
ARENE_NODISCARD constexpr auto value () const &&noexcept -> value_type const &&
 Accesses a reference to the content of the value channel.
 
constexpr void value () const &noexcept
 Access the content of the value channel.
 
ARENE_NODISCARD constexpr auto value () const &noexcept -> value_type const &
 Accesses a reference to the content of the value channel.
 
ARENE_NODISCARD constexpr auto value_or (U &&default_value) &&noexcept -> value_type
 Returns the value if the value channel is populated, else another value. Not declared if T is void .
 
ARENE_NODISCARD constexpr auto value_or (U &&default_value) const &noexcept -> value_type
 Returns the value if the value channel is populated, else another value. Not declared if T is void .
 
ARENE_NODISCARD constexpr auto error () &noexcept -> error_type &
 Accesses a reference to the content of the error channel.
 
ARENE_NODISCARD constexpr auto error () const &noexcept -> error_type const &
 Accesses a reference to the content of the error channel.
 
ARENE_NODISCARD constexpr auto error () &&noexcept -> error_type &&
 Accesses a reference to the content of the error channel.
 
ARENE_NODISCARD constexpr auto error () const &&noexcept -> error_type const &&
 Accesses a reference to the content of the error channel.
 
template<typename F>
constexpr auto and_then (F &&handle_value) &
 Monadic API which invokes a functor with the contents of value() if the value channel is populated.
 
template<typename F>
constexpr auto and_then (F &&handle_value) const &
 Monadic API which invokes a functor with the contents of value() if the value channel is populated.
 
template<typename F>
constexpr auto and_then (F &&handle_value) &&
 Monadic API which invokes a functor with the contents of value() if the value channel is populated.
 
template<typename F>
constexpr auto and_then (F &&handle_value) const &&
 Monadic API which invokes a functor with the contents of value() if the value channel is populated.
 
template<typename F>
constexpr auto or_else (F &&handle_error) &
 Monadic API which invokes a functor with the contents of error() if the error channel is populated.
 
template<typename F>
constexpr auto or_else (F &&handle_error) const &
 Monadic API which invokes a functor with the contents of error() if the error channel is populated.
 
template<typename F>
constexpr auto or_else (F &&handle_error) &&
 Monadic API which invokes a functor with the contents of error() if the error channel is populated.
 
template<typename F>
constexpr auto or_else (F &&handle_error) const &&
 Monadic API which invokes a functor with the contents of error() if the error channel is populated.
 
template<typename F>
constexpr auto transform (F &&handle_value) &
 Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.
 
template<typename F>
constexpr auto transform (F &&handle_value) const &
 Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.
 
template<typename F>
constexpr auto transform (F &&handle_value) &&
 Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.
 
template<typename F>
constexpr auto transform (F &&handle_value) const &&
 Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.
 
constexpr auto and_then (F &&handle_value) &
 Monadic API which invokes a functor with the contents of value() if the value channel is populated.
 
constexpr auto and_then (F &&handle_value) const &
 Monadic API which invokes a functor with the contents of value() if the value channel is populated.
 
constexpr auto and_then (F &&handle_value) &&
 Monadic API which invokes a functor with the contents of value() if the value channel is populated.
 
constexpr auto and_then (F &&handle_value) const &&
 Monadic API which invokes a functor with the contents of value() if the value channel is populated.
 
constexpr auto or_else (F &&handle_error) &
 Monadic API which invokes a functor with the contents of error() if the error channel is populated.
 
constexpr auto or_else (F &&handle_error) const &
 Monadic API which invokes a functor with the contents of error() if the error channel is populated.
 
constexpr auto or_else (F &&handle_error) &&
 Monadic API which invokes a functor with the contents of error() if the error channel is populated.
 
constexpr auto or_else (F &&handle_error) const &&
 Monadic API which invokes a functor with the contents of error() if the error channel is populated.
 
constexpr auto transform (F &&handle_value) &
 Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.
 
constexpr auto transform (F &&handle_value) const &
 Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.
 
constexpr auto transform (F &&handle_value) &&
 Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.
 
constexpr auto transform (F &&handle_value) const &&
 Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.
 
constexpr auto transform_error (F &&handle_error) &
 Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.
 
constexpr auto transform_error (F &&handle_error) const &
 Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.
 
constexpr auto transform_error (F &&handle_error) &&
 Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.
 
constexpr auto transform_error (F &&handle_error) const &&
 Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.
 

Friends

ARENE_NODISCARD friend constexpr auto operator!= (result const &lhs, result const &rhs) noexcept(noexcept(lhs==rhs)) -> bool
 Compare two results for inequality.
 
ARENE_NODISCARD friend constexpr auto operator!= (result const &lhs, result const &rhs) noexcept(noexcept(lhs==rhs)) -> bool
 Compare two results for inequality.
 
ARENE_NODISCARD friend constexpr auto operator== (result const &lhs, result const &rhs) noexcept(noexcept(lhs.has_error(rhs.error()))) -> bool
 Compare two results for equality.
 
ARENE_NODISCARD friend constexpr auto operator== (result const &lhs, result const &rhs) noexcept(noexcept(lhs.has_value(rhs.value())) &&noexcept(lhs.has_error(rhs.error()))) -> bool
 Compare two results for equality.
 
constexpr void swap (result &lhs, result &rhs) noexcept(noexcept(lhs.swap(rhs)))
 Swaps the state of two results.
 
template<typename SourceErrorType = E, constraints< std::enable_if_t< is_swappable_v< SourceErrorType > >, std::enable_if_t< std::is_move_constructible< SourceErrorType >::value > > = nullptr>
constexpr void swap (result &lhs, result &rhs) noexcept(noexcept(lhs.swap(rhs)))
 Swaps the state of two results.
 

Detailed Description

template<class E>
class arene::base::result< void, E >

Specialization of result<T, E> for void value types.

Template Parameters
EThe error type

Member Typedef Documentation

◆ error_type [1/2]

using arene::base::result< void, E >::error_type

The type when the result contains an error.

◆ error_type [2/2]

template<class E>
using arene::base::result< void, E >::error_type = E

The type when the result contains an error.

◆ value_type [1/2]

using arene::base::result< void, E >::value_type

The type when the result contains a value.

◆ value_type [2/2]

template<class E>
using arene::base::result< void, E >::value_type = void

The type when the result contains a value.

Constructor & Destructor Documentation

◆ result() [1/11]

template<class E>
arene::base::result< void, E >::result ( )
constexprdefault

Constructs a result with the value-channel engaged.

Postcondition
has_value() returns true

◆ result() [2/11]

template<class E>
arene::base::result< void, E >::result ( in_place_value_t )
inlineconstexprnoexcept

Constructs a result with the value-channel engaged.

Template Parameters
PThe type of the initializers. Must satisfy std::is_constructible<value_type,P&&...> .
Postcondition
has_value() returns true

◆ result() [3/11]

template<class E>
arene::base::result< void, E >::result ( in_place_value_t ,
monostate  )
inlineconstexprnoexcept

Constructs a result with the value-channel engaged. Provided for backwards compatibility.

Template Parameters
PThe type of the initializers. Must satisfy std::is_constructible<value_type,P&&...> .
Postcondition
has_value() returns true

◆ result() [4/11]

template<class E>
template<class... P, constraints< std::enable_if_t< std::is_constructible< error_type, P &&... >::value > > = nullptr>
arene::base::result< void, E >::result ( in_place_error_t ,
P &&... args )
inlineconstexprnoexcept

Constructs a result containing the error_type by way of direct-non-list-initialization.

Template Parameters
PThe type of the initializers. Must satisfy std::is_constructible<error_type,P&&...> .
Parameters
argsThe arguments to initialize the value channel with.
Postcondition
has_error() returns true
error() returns reference to an object equivalent to constructing error_type with args .

Example Usage:

class geometry_error {
int x_out_of_bounds_by;
int y_out_of_bounds_by;
public:
geometry_error(int x, int y)
: x_out_of_bounds_by(x),
y_out_of_bounds_by(y) {}
};
// error will have a error-channel populated equivalent to geometry_error{1,2}
arene::base::result<void, geometry_error> error(arene::base::in_place_error, 1, 2);

◆ result() [5/11]

template<class E>
arene::base::result< void, E >::result ( result< void, E > const & copy) const &
constexprdefaultnoexcept

Default copy constructor.

◆ result() [6/11]

template<class E>
arene::base::result< void, E >::result ( result< void, E > && move) &&
constexprdefaultnoexcept

Default move constructor.

◆ ~result() [1/2]

template<class E>
arene::base::result< void, E >::~result ( )
default

Destroy the stored value or error.

◆ result() [7/11]

arene::base::result< void, E >::result ( )
constexprdefault

Constructs a result with a default-constructed value_type . Does not participate in overload resolution if value_type is not default constructible.

Postcondition
has_value() returns true
value() returns reference to an object equivalent to default-constructing value_type .

◆ result() [8/11]

arene::base::result< void, E >::result ( in_place_value_t ,
P &&... args )
inlineconstexprnoexcept

Constructs a result containing the value_type by way of direct-non-list-initialization.

Template Parameters
PThe type of the initializers. Must satisfy std::is_constructible<value_type,P&&...> .
Parameters
argsThe arguments to initialize the value channel with.
Postcondition
has_value() returns true
value() returns reference to an object equivalent to constructing value_type with args .

Example Usage:

class point {
int x_val;
int y_val;
public:
point(int x, int y)
: x_val(x),
y_val(y) {}
};
// position will have a value-channel populated equivalent to point{1,2}
arene::base::result<point, geometry_error> position(arene::base::in_place_value, 1, 2);

◆ result() [9/11]

arene::base::result< void, E >::result ( in_place_error_t ,
P &&... args )
inlineconstexprnoexcept

Constructs a result containing the error_type by way of direct-non-list-initialization.

Template Parameters
PThe type of the initializers. Must satisfy std::is_constructible<error_type,P&&...> .
Parameters
argsThe arguments to initialize the value channel with.
Postcondition
has_error() returns true
error() returns reference to an object equivalent to constructing error_type with args .

Example Usage:

class geometry_error {
int x_out_of_bounds_by;
int y_out_of_bounds_by;
public:
geometry_error(int x, int y)
: x_out_of_bounds_by(x),
y_out_of_bounds_by(y) {}
};
// position will have a error-channel populated equivalent to geometry_error{1,2}
arene::base::result<point, geometry_error> position(arene::base::in_place_error, 1, 2);

◆ result() [10/11]

arene::base::result< void, E >::result ( result< void, E > const & copy)
constexprdefaultnoexcept

Default copy constructor.

◆ result() [11/11]

arene::base::result< void, E >::result ( result< void, E > && move)
constexprdefaultnoexcept

Default move constructor.

◆ ~result() [2/2]

arene::base::result< void, E >::~result ( )
default

Destroy the stored value or error.

Member Function Documentation

◆ and_then() [1/8]

auto arene::base::result< void, E >::and_then ( F && handle_value) &
inlineconstexpr

Monadic API which invokes a functor with the contents of value() if the value channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of SelfType, and return result<U,error_type> , where U may be any valid value_type .
Parameters
handle_valuethe functor to invoke if self.has_value() is true .
Returns
result<U, error_type> which will be either the result of invoking handle_value with the contents of self.value() , or it will contain a copy of self.error() .

Basic usage example for opening a file:

auto maybe_file = arene::base::filesystem::directory_handle::open(dir_path).and_then(
[&filename](arene::base::filesystem::directory_handle dir) { return dir.open_file(filename); }
);

After this statement, maybe_file will contain either a valid instance of arene::base::file_handle in the value channel, or it will contain an instance of arene::base::error_code representing either the failure to open the file or the failure to open the directory.

◆ and_then() [2/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::and_then ( F && handle_value) &
inlineconstexpr

Monadic API which invokes a functor with the contents of value() if the value channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of SelfType , or with no arguments if value_type is void , and return result<U,error_type> , where U may be any valid value_type .
Parameters
handle_valuethe functor to invoke if self.has_value() is true .
Returns
result<U, error_type> which will be either the result of invoking handle_value with the contents of self.value() , or it will contain a copy of self.error() .

Basic usage example for opening a file:

auto maybe_file = arene::base::filesystem::directory_handle::open(dir_path).and_then(
[&filename](arene::base::filesystem::directory_handle dir) { return dir.open_file(filename); }
);

After this statement, maybe_file will contain either a valid instance of arene::base::file_handle in the value channel, or it will contain an instance of arene::base::error_code representing either the failure to open the file or the failure to open the directory.

◆ and_then() [3/8]

auto arene::base::result< void, E >::and_then ( F && handle_value) &&
inlineconstexpr

Monadic API which invokes a functor with the contents of value() if the value channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of SelfType, and return result<U,error_type> , where U may be any valid value_type .
Parameters
handle_valuethe functor to invoke if self.has_value() is true .
Returns
result<U, error_type> which will be either the result of invoking handle_value with the contents of self.value() , or it will contain a copy of self.error() .

Basic usage example for opening a file:

auto maybe_file = arene::base::filesystem::directory_handle::open(dir_path).and_then(
[&filename](arene::base::filesystem::directory_handle dir) { return dir.open_file(filename); }
);

After this statement, maybe_file will contain either a valid instance of arene::base::file_handle in the value channel, or it will contain an instance of arene::base::error_code representing either the failure to open the file or the failure to open the directory.

◆ and_then() [4/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::and_then ( F && handle_value) &&
inlineconstexpr

Monadic API which invokes a functor with the contents of value() if the value channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of SelfType , or with no arguments if value_type is void , and return result<U,error_type> , where U may be any valid value_type .
Parameters
handle_valuethe functor to invoke if self.has_value() is true .
Returns
result<U, error_type> which will be either the result of invoking handle_value with the contents of self.value() , or it will contain a copy of self.error() .

Basic usage example for opening a file:

auto maybe_file = arene::base::filesystem::directory_handle::open(dir_path).and_then(
[&filename](arene::base::filesystem::directory_handle dir) { return dir.open_file(filename); }
);

After this statement, maybe_file will contain either a valid instance of arene::base::file_handle in the value channel, or it will contain an instance of arene::base::error_code representing either the failure to open the file or the failure to open the directory.

◆ and_then() [5/8]

auto arene::base::result< void, E >::and_then ( F && handle_value) const &
inlineconstexpr

Monadic API which invokes a functor with the contents of value() if the value channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of SelfType, and return result<U,error_type> , where U may be any valid value_type .
Parameters
handle_valuethe functor to invoke if self.has_value() is true .
Returns
result<U, error_type> which will be either the result of invoking handle_value with the contents of self.value() , or it will contain a copy of self.error() .

Basic usage example for opening a file:

auto maybe_file = arene::base::filesystem::directory_handle::open(dir_path).and_then(
[&filename](arene::base::filesystem::directory_handle dir) { return dir.open_file(filename); }
);

After this statement, maybe_file will contain either a valid instance of arene::base::file_handle in the value channel, or it will contain an instance of arene::base::error_code representing either the failure to open the file or the failure to open the directory.

◆ and_then() [6/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::and_then ( F && handle_value) const &
inlineconstexpr

Monadic API which invokes a functor with the contents of value() if the value channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of SelfType , or with no arguments if value_type is void , and return result<U,error_type> , where U may be any valid value_type .
Parameters
handle_valuethe functor to invoke if self.has_value() is true .
Returns
result<U, error_type> which will be either the result of invoking handle_value with the contents of self.value() , or it will contain a copy of self.error() .

Basic usage example for opening a file:

auto maybe_file = arene::base::filesystem::directory_handle::open(dir_path).and_then(
[&filename](arene::base::filesystem::directory_handle dir) { return dir.open_file(filename); }
);

After this statement, maybe_file will contain either a valid instance of arene::base::file_handle in the value channel, or it will contain an instance of arene::base::error_code representing either the failure to open the file or the failure to open the directory.

◆ and_then() [7/8]

auto arene::base::result< void, E >::and_then ( F && handle_value) const &&
inlineconstexpr

Monadic API which invokes a functor with the contents of value() if the value channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of SelfType, and return result<U,error_type> , where U may be any valid value_type .
Parameters
handle_valuethe functor to invoke if self.has_value() is true .
Returns
result<U, error_type> which will be either the result of invoking handle_value with the contents of self.value() , or it will contain a copy of self.error() .

Basic usage example for opening a file:

auto maybe_file = arene::base::filesystem::directory_handle::open(dir_path).and_then(
[&filename](arene::base::filesystem::directory_handle dir) { return dir.open_file(filename); }
);

After this statement, maybe_file will contain either a valid instance of arene::base::file_handle in the value channel, or it will contain an instance of arene::base::error_code representing either the failure to open the file or the failure to open the directory.

◆ and_then() [8/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::and_then ( F && handle_value) const &&
inlineconstexpr

Monadic API which invokes a functor with the contents of value() if the value channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of SelfType , or with no arguments if value_type is void , and return result<U,error_type> , where U may be any valid value_type .
Parameters
handle_valuethe functor to invoke if self.has_value() is true .
Returns
result<U, error_type> which will be either the result of invoking handle_value with the contents of self.value() , or it will contain a copy of self.error() .

Basic usage example for opening a file:

auto maybe_file = arene::base::filesystem::directory_handle::open(dir_path).and_then(
[&filename](arene::base::filesystem::directory_handle dir) { return dir.open_file(filename); }
);

After this statement, maybe_file will contain either a valid instance of arene::base::file_handle in the value channel, or it will contain an instance of arene::base::error_code representing either the failure to open the file or the failure to open the directory.

◆ emplace() [1/2]

template<class E>
void arene::base::result< void, E >::emplace ( in_place_value_t )
inlinenoexcept

Emplaces the void value into the result.

Postcondition
has_value() returns true .

◆ emplace() [2/2]

auto arene::base::result< void, E >::emplace ( in_place_value_t ,
ArgTypes &&... args )-> value_type&
inlinenoexcept

Emplaces a value into the result.

Template Parameters
ArgTypesthe types of the arguments to construct the value with
Parameters
argsThe arguments to construct the value with
Returns
A reference to the newly emplaced value
Postcondition
has_value() returns true
The content of value() will be equivalent to a value_type direct-initialized from args .

◆ error() [1/8]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::error ( ) && -> error_type&&
inlineconstexprnoexcept

Accesses a reference to the content of the error channel.

Precondition
has_error(), else ARENE_PRECONDITION violation
Returns
An rvalue reference to the contained error

◆ error() [2/8]

template<class E>
ARENE_NODISCARD constexpr auto arene::base::result< void, E >::error ( ) && -> error_type&&
inlineconstexprnoexcept

Accesses a reference to the content of the error channel.

Precondition
has_error(), else ARENE_PRECONDITION violation
Returns
A reference to the contained error

◆ error() [3/8]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::error ( ) & -> error_type&
inlineconstexprnoexcept

Accesses a reference to the content of the error channel.

Precondition
has_error(), else ARENE_PRECONDITION violation
Returns
A reference to the contained error

◆ error() [4/8]

template<class E>
ARENE_NODISCARD constexpr auto arene::base::result< void, E >::error ( ) & -> error_type&
inlineconstexprnoexcept

Accesses a reference to the content of the error channel.

Precondition
has_error(), else ARENE_PRECONDITION violation
Returns
A reference to the contained error

◆ error() [5/8]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::error ( ) const && -> error_type const&&
inlineconstexprnoexcept

Accesses a reference to the content of the error channel.

Precondition
has_error(), else ARENE_PRECONDITION violation
Returns
A const rvalue reference to the contained error

◆ error() [6/8]

template<class E>
ARENE_NODISCARD constexpr auto arene::base::result< void, E >::error ( ) const && -> error_type const&&
inlineconstexprnoexcept

Accesses a reference to the content of the error channel.

Precondition
has_error(), else ARENE_PRECONDITION violation
Returns
A reference to the contained error

◆ error() [7/8]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::error ( ) const & -> error_type const&
inlineconstexprnoexcept

Accesses a reference to the content of the error channel.

Precondition
has_error(), else ARENE_PRECONDITION violation
Returns
A const reference to the contained error

◆ error() [8/8]

template<class E>
ARENE_NODISCARD constexpr auto arene::base::result< void, E >::error ( ) const & -> error_type const&
inlineconstexprnoexcept

Accesses a reference to the content of the error channel.

Precondition
has_error(), else ARENE_PRECONDITION violation
Returns
A reference to the contained error

◆ has_value()

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::has_value ( value_type const & val) const-> bool
inlineconstexprnoexcept

Checks if the value channel contains a specific value.

Parameters
valThe value to check for.
Returns
true If has_value() and value()==val .
false Otherwise.

◆ operator*() [1/5]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::operator* ( ) && -> value_type&&
inlineconstexprnoexcept

Accesses a reference to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
An rvalue reference to the contained value

◆ operator*() [2/5]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::operator* ( ) & -> value_type&
inlineconstexprnoexcept

Accesses a reference to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
A reference to the contained value

◆ operator*() [3/5]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::operator* ( ) const && -> value_type const&&
inlineconstexprnoexcept

Accesses a reference to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
A const rvalue reference to the contained value

◆ operator*() [4/5]

template<class E>
void arene::base::result< void, E >::operator* ( ) const &
inlineconstexprnoexcept

Access the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.

◆ operator*() [5/5]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::operator* ( ) const & -> value_type const&
inlineconstexprnoexcept

Accesses a reference to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
A const reference to the contained value

◆ operator->() [1/2]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::operator-> ( ) const -> value_type const*
inlineconstexprnoexcept

Accesses a pointer to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
A pointer to the contained value

◆ operator->() [2/2]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::operator-> ( ) -> value_type*
inlineconstexprnoexcept

Accesses a pointer to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
A pointer to the contained value

◆ operator=() [1/8]

auto arene::base::result< void, E >::operator= ( copy_assign_arg const & other) -> result&
inlineconstexprnoexcept

Copy-assignment for the case that value_type and error_type satisfy std::is_nothrow_copy_constructible and std::is_nothrow_copy_assignable, otherwise a dummy assignment operator that can never be called.

Parameters
otherThe value to copy from
Returns
*this

◆ operator=() [2/8]

template<class E>
auto arene::base::result< void, E >::operator= ( copy_assign_arg const & other) -> result&
inlineconstexprnoexcept

Copy-assignment for the case that error_type satisfies std::is_nothrow_copy_constructible and std::is_nothrow_copy_assignable, otherwise a dummy assignment operator that can never be called.

Parameters
otherThe value to copy from
Returns
*this

◆ operator=() [3/8]

auto arene::base::result< void, E >::operator= ( deleted_copy_assign_arg const & other) -> result&
constexprdeletenoexcept

Deleted Copy-assignment if value_type or error_type do not satisfy std::is_nothrow_copy_constructible and std::is_nothrow_copy_assignable, otherwise a deleted dummy assignment operator.

Parameters
otherThe value to copy from
Returns
*this

◆ operator=() [4/8]

template<class E>
auto arene::base::result< void, E >::operator= ( deleted_copy_assign_arg const & other) -> result &=delete
constexprdeletenoexcept

Deleted Copy-assignment if error_type does not satisfy std::is_nothrow_copy_constructible and std::is_nothrow_copy_assignable, otherwise a deleted dummy assignment operator.

Parameters
otherThe value to copy from
Returns
*this

◆ operator=() [5/8]

auto arene::base::result< void, E >::operator= ( deleted_move_assign_arg && other) -> result&
constexprdeletenoexcept

Deleted Move-assignment if value_type or error_type do not satisfy std::is_nothrow_move_constructible and std::is_nothrow_move_assignable, otherwise a deleted dummy assignment operator.

Parameters
otherThe value to move from
Returns
*this

◆ operator=() [6/8]

template<class E>
auto arene::base::result< void, E >::operator= ( deleted_move_assign_arg && other) -> result &=delete
constexprdeletenoexcept

Deleted Move-assignment if error_type does not satisfy std::is_nothrow_move_constructible and std::is_nothrow_move_assignable, otherwise a deleted dummy assignment operator.

Parameters
otherThe value to move from
Returns
*this

◆ operator=() [7/8]

auto arene::base::result< void, E >::operator= ( move_assign_arg && other) -> result&
inlineconstexprnoexcept

Move-assignment for the case that value_type and error_type satisfy std::is_nothrow_move_constructible and std::is_nothrow_move_assignable, otherwise a dummy assignment operator that can never be called.

Parameters
otherThe value to move from
Returns
*this

◆ operator=() [8/8]

template<class E>
auto arene::base::result< void, E >::operator= ( move_assign_arg && other) -> result&
inlineconstexprnoexcept

Move-assignment for the case that error_type satisfies std::is_nothrow_move_constructible and std::is_nothrow_move_assignable, otherwise a dummy assignment operator that can never be called.

Parameters
otherThe value to move from
Returns
*this

◆ or_else() [1/8]

auto arene::base::result< void, E >::or_else ( F && handle_error) &
inlineconstexpr

Monadic API which invokes a functor with the contents of error() if the error channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of SelfType and return result<value_type,E> , where E may be any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either the result of invoking handle_error with the contents of self.error() , or it will contain a copy of self.value() .

Basic usage example for opening a directory:

auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).or_else(
[&logger](arene::base::filesystem::error_code err
) -> arene::base::result<arene::base::filesystem::directory_handle, arene::base::filesystem::error_code> {
logger.log(err);
}
);

◆ or_else() [2/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::or_else ( F && handle_error) &
inlineconstexpr

Monadic API which invokes a functor with the contents of error() if the error channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of SelfType and return result<value_type,E> , where E may be any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either the result of invoking handle_error with the contents of self.error() , or it will contain a copy of self.value() .

Basic usage example for opening a directory:

auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).or_else(
[&logger](arene::base::filesystem::error_code err
) -> arene::base::result<arene::base::filesystem::directory_handle, arene::base::filesystem::error_code> {
logger.log(err);
}
);

After this statement, maybe_dir will contain either a valid instance of arene::base::directory_handle in the value channel, or it will have logged the error and contain the passed through error_code .

◆ or_else() [3/8]

auto arene::base::result< void, E >::or_else ( F && handle_error) &&
inlineconstexpr

Monadic API which invokes a functor with the contents of error() if the error channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of SelfType and return result<value_type,E> , where E may be any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either the result of invoking handle_error with the contents of self.error() , or it will contain a copy of self.value() .

Basic usage example for opening a directory:

auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).or_else(
[&logger](arene::base::filesystem::error_code err
) -> arene::base::result<arene::base::filesystem::directory_handle, arene::base::filesystem::error_code> {
logger.log(err);
}
);

◆ or_else() [4/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::or_else ( F && handle_error) &&
inlineconstexpr

Monadic API which invokes a functor with the contents of error() if the error channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of SelfType and return result<value_type,E> , where E may be any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either the result of invoking handle_error with the contents of self.error() , or it will contain a copy of self.value() .

Basic usage example for opening a directory:

auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).or_else(
[&logger](arene::base::filesystem::error_code err
) -> arene::base::result<arene::base::filesystem::directory_handle, arene::base::filesystem::error_code> {
logger.log(err);
}
);

After this statement, maybe_dir will contain either a valid instance of arene::base::directory_handle in the value channel, or it will have logged the error and contain the passed through error_code .

◆ or_else() [5/8]

auto arene::base::result< void, E >::or_else ( F && handle_error) const &
inlineconstexpr

Monadic API which invokes a functor with the contents of error() if the error channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of SelfType and return result<value_type,E> , where E may be any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either the result of invoking handle_error with the contents of self.error() , or it will contain a copy of self.value() .

Basic usage example for opening a directory:

auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).or_else(
[&logger](arene::base::filesystem::error_code err
) -> arene::base::result<arene::base::filesystem::directory_handle, arene::base::filesystem::error_code> {
logger.log(err);
}
);

◆ or_else() [6/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::or_else ( F && handle_error) const &
inlineconstexpr

Monadic API which invokes a functor with the contents of error() if the error channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of SelfType and return result<value_type,E> , where E may be any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either the result of invoking handle_error with the contents of self.error() , or it will contain a copy of self.value() .

Basic usage example for opening a directory:

auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).or_else(
[&logger](arene::base::filesystem::error_code err
) -> arene::base::result<arene::base::filesystem::directory_handle, arene::base::filesystem::error_code> {
logger.log(err);
}
);

After this statement, maybe_dir will contain either a valid instance of arene::base::directory_handle in the value channel, or it will have logged the error and contain the passed through error_code .

◆ or_else() [7/8]

auto arene::base::result< void, E >::or_else ( F && handle_error) const &&
inlineconstexpr

Monadic API which invokes a functor with the contents of error() if the error channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of SelfType and return result<value_type,E> , where E may be any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either the result of invoking handle_error with the contents of self.error() , or it will contain a copy of self.value() .

Basic usage example for opening a directory:

auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).or_else(
[&logger](arene::base::filesystem::error_code err
) -> arene::base::result<arene::base::filesystem::directory_handle, arene::base::filesystem::error_code> {
logger.log(err);
}
);

◆ or_else() [8/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::or_else ( F && handle_error) const &&
inlineconstexpr

Monadic API which invokes a functor with the contents of error() if the error channel is populated.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of SelfType and return result<value_type,E> , where E may be any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either the result of invoking handle_error with the contents of self.error() , or it will contain a copy of self.value() .

Basic usage example for opening a directory:

auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).or_else(
[&logger](arene::base::filesystem::error_code err
) -> arene::base::result<arene::base::filesystem::directory_handle, arene::base::filesystem::error_code> {
logger.log(err);
}
);

After this statement, maybe_dir will contain either a valid instance of arene::base::directory_handle in the value channel, or it will have logged the error and contain the passed through error_code .

◆ swap() [1/2]

template<class E>
template<typename SourceErrorType = E, constraints< std::enable_if_t< is_swappable_v< SourceErrorType > >, std::enable_if_t< std::is_nothrow_move_constructible< SourceErrorType >::value > > = nullptr>
void arene::base::result< void, E >::swap ( result< void, E > & other)
inlineconstexprnoexcept

Swaps the state of two results.

Template Parameters
SourceErrorTypeMust satisfy is_swappable_v<error_type> and std::is_nothrow_move_constructable<error_type>
Parameters
otherThe result to swap with
Postcondition
If both this and other have matching channels populated, the content of those channels are swapped as if via arene::base::swap . Otherwise, it is equivalent to emplacing this with the active channel from other , and vice-versa.

◆ swap() [2/2]

void arene::base::result< void, E >::swap ( result< void, E > & other)
inlineconstexprnoexcept

Swaps the state of two results.

Template Parameters
SourceValueTypeMust satisfy is_swappable_v<SourceValueType> and std::is_nothrow_move_constructible<SourceValueType>
SourceErrorTypeMust satisfy is_swappable_v<SourceErrorType> and std::is_nothrow_move_constructible<SourceErrorType>
Parameters
otherThe result to swap with
Postcondition
If both this and other have matching channels populated, the content of those channels are swapped as if via arene::base::swap . Otherwise, it is equivalent to emplacing this with the active channel from other , and vice-versa.

◆ transform() [1/8]

auto arene::base::result< void, E >::transform ( F && handle_value) &
inlineconstexpr

Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this . May return any valid value_type
Parameters
handle_valuethe functor to invoke if has_value() is true .
Returns
result<U, error_type> which will be one of:
  • A result<U,error_type> constructed from the result of invoking handle_value with the contents of value() if value_type is not void and the return from F is not void
  • A result<void,error_type> constructed from the result of invoking handle_value with the contents of value() if value_type is not void and the return from F is void
  • A result<U,error_type> where U is the return type of F constructed from a copy of error() .

◆ transform() [2/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::transform ( F && handle_value) &
inlineconstexpr

Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this , or with no arguments if value_type is void . May return any valid value_type
Parameters
handle_valuethe functor to invoke if has_value() is true .
Returns
result<U, error_type> which will be one of:
  • A result<U,error_type> constructed from the result of invoking handle_value if the return from F is not void
  • A result<void,error_type> constructed from the result of invoking handle_value if the return from F is void
  • A result<U,error_type> where U is the return type of F constructed from a copy of self.error() .

◆ transform() [3/8]

auto arene::base::result< void, E >::transform ( F && handle_value) &&
inlineconstexpr

Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this . May return any valid value_type
Parameters
handle_valuethe functor to invoke if has_value() is true .
Returns
result<U, error_type> which will be one of:
  • A result<U,error_type> constructed from the result of invoking handle_value with the contents of value() if value_type is not void and the return from F is not void
  • A result<void,error_type> constructed from the result of invoking handle_value with the contents of value() if value_type is not void and the return from F is void
  • A result<U,error_type> where U is the return type of F constructed from a copy of error() .

◆ transform() [4/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::transform ( F && handle_value) &&
inlineconstexpr

Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this , or with no arguments if value_type is void . May return any valid value_type
Parameters
handle_valuethe functor to invoke if has_value() is true .
Returns
result<U, error_type> which will be one of:
  • A result<U,error_type> constructed from the result of invoking handle_value if the return from F is not void
  • A result<void,error_type> constructed from the result of invoking handle_value if the return from F is void
  • A result<U,error_type> where U is the return type of F constructed from a copy of self.error() .

◆ transform() [5/8]

auto arene::base::result< void, E >::transform ( F && handle_value) const &
inlineconstexpr

Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this . May return any valid value_type
Parameters
handle_valuethe functor to invoke if has_value() is true .
Returns
result<U, error_type> which will be one of:
  • A result<U,error_type> constructed from the result of invoking handle_value with the contents of value() if value_type is not void and the return from F is not void
  • A result<void,error_type> constructed from the result of invoking handle_value with the contents of value() if value_type is not void and the return from F is void
  • A result<U,error_type> where U is the return type of F constructed from a copy of error() .

◆ transform() [6/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::transform ( F && handle_value) const &
inlineconstexpr

Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this , or with no arguments if value_type is void . May return any valid value_type
Parameters
handle_valuethe functor to invoke if has_value() is true .
Returns
result<U, error_type> which will be one of:
  • A result<U,error_type> constructed from the result of invoking handle_value if the return from F is not void
  • A result<void,error_type> constructed from the result of invoking handle_value if the return from F is void
  • A result<U,error_type> where U is the return type of F constructed from a copy of self.error() .

◆ transform() [7/8]

auto arene::base::result< void, E >::transform ( F && handle_value) const &&
inlineconstexpr

Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this . May return any valid value_type
Parameters
handle_valuethe functor to invoke if has_value() is true .
Returns
result<U, error_type> which will be one of:
  • A result<U,error_type> constructed from the result of invoking handle_value with the contents of value() if value_type is not void and the return from F is not void
  • A result<void,error_type> constructed from the result of invoking handle_value with the contents of value() if value_type is not void and the return from F is void
  • A result<U,error_type> where U is the return type of F constructed from a copy of error() .

◆ transform() [8/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::transform ( F && handle_value) const &&
inlineconstexpr

Calls a provided functor with the value channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with value_type matching the const/ref qualification of this , or with no arguments if value_type is void . May return any valid value_type
Parameters
handle_valuethe functor to invoke if has_value() is true .
Returns
result<U, error_type> which will be one of:
  • A result<U,error_type> constructed from the result of invoking handle_value if the return from F is not void
  • A result<void,error_type> constructed from the result of invoking handle_value if the return from F is void
  • A result<U,error_type> where U is the return type of F constructed from a copy of self.error() .

◆ transform_error() [1/8]

auto arene::base::result< void, E >::transform_error ( F && handle_error) &
inlineconstexpr

Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of this. May return any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either:
  • A result constructed from the result of invoking handle_error with the contents of self.error() ,
  • A result constructed from a copy of self.value() .

◆ transform_error() [2/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::transform_error ( F && handle_error) &
inlineconstexpr

Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of this. May return any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either:
  • A result constructed from the result of invoking handle_error with the contents of self.error() ,
  • A result constructed from a copy of self.value() . Basic usage example for opening a directory:
    auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).transform_error(
    [&logger](arene::base::filesystem::error_code err) {
    logger.log(err);
    return err;
    }
    );

After this statement, maybe_dir will contain either a valid instance of arene::base::directory_handle in the value channel, or it will have logged the error and contain the passed through error_code .

◆ transform_error() [3/8]

auto arene::base::result< void, E >::transform_error ( F && handle_error) &&
inlineconstexpr

Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of this. May return any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either:
  • A result constructed from the result of invoking handle_error with the contents of self.error() ,
  • A result constructed from a copy of self.value() .

◆ transform_error() [4/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::transform_error ( F && handle_error) &&
inlineconstexpr

Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of this. May return any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either:
  • A result constructed from the result of invoking handle_error with the contents of self.error() ,
  • A result constructed from a copy of self.value() . Basic usage example for opening a directory:
    auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).transform_error(
    [&logger](arene::base::filesystem::error_code err) {
    logger.log(err);
    return err;
    }
    );

After this statement, maybe_dir will contain either a valid instance of arene::base::directory_handle in the value channel, or it will have logged the error and contain the passed through error_code .

◆ transform_error() [5/8]

auto arene::base::result< void, E >::transform_error ( F && handle_error) const &
inlineconstexpr

Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of this. May return any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either:
  • A result constructed from the result of invoking handle_error with the contents of self.error() ,
  • A result constructed from a copy of self.value() .

◆ transform_error() [6/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::transform_error ( F && handle_error) const &
inlineconstexpr

Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of this. May return any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either:
  • A result constructed from the result of invoking handle_error with the contents of self.error() ,
  • A result constructed from a copy of self.value() . Basic usage example for opening a directory:
    auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).transform_error(
    [&logger](arene::base::filesystem::error_code err) {
    logger.log(err);
    return err;
    }
    );

After this statement, maybe_dir will contain either a valid instance of arene::base::directory_handle in the value channel, or it will have logged the error and contain the passed through error_code .

◆ transform_error() [7/8]

auto arene::base::result< void, E >::transform_error ( F && handle_error) const &&
inlineconstexpr

Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of this. May return any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either:
  • A result constructed from the result of invoking handle_error with the contents of self.error() ,
  • A result constructed from a copy of self.value() .

◆ transform_error() [8/8]

template<class E>
template<typename F>
auto arene::base::result< void, E >::transform_error ( F && handle_error) const &&
inlineconstexpr

Calls a provided functor with the error channel if it is populated, and produces a new result with the return from it.

Template Parameters
FType of the visiting functor. Must be invocable with error_type matching the const/ref qualification of this. May return any valid error_type .
Parameters
handle_errorthe functor to invoke if self.has_error() is true .
Returns
result<value_type, E> which will be either:
  • A result constructed from the result of invoking handle_error with the contents of self.error() ,
  • A result constructed from a copy of self.value() . Basic usage example for opening a directory:
    auto maybe_dir = arene::base::filesystem::directory_handle::open(dir_path).transform_error(
    [&logger](arene::base::filesystem::error_code err) {
    logger.log(err);
    return err;
    }
    );

After this statement, maybe_dir will contain either a valid instance of arene::base::directory_handle in the value channel, or it will have logged the error and contain the passed through error_code .

◆ value() [1/6]

template<class E>
void arene::base::result< void, E >::value ( ) &&
inlineconstexprnoexcept

Access the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.

◆ value() [2/6]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::value ( ) && -> value_type&&
inlineconstexprnoexcept

Accesses a reference to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
An rvalue reference to the contained value

◆ value() [3/6]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::value ( ) & -> value_type&
inlineconstexprnoexcept

Accesses a reference to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
A reference to the contained value

◆ value() [4/6]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::value ( ) const && -> value_type const&&
inlineconstexprnoexcept

Accesses a reference to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
A const rvalue reference to the contained value

◆ value() [5/6]

template<class E>
void arene::base::result< void, E >::value ( ) const &
inlineconstexprnoexcept

Access the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.

◆ value() [6/6]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::value ( ) const & -> value_type const&
inlineconstexprnoexcept

Accesses a reference to the content of the value channel.

Precondition
has_value(), else ARENE_PRECONDITION violation.
Returns
A const reference to the contained value

◆ value_or() [1/2]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::value_or ( U && default_value) &&-> value_type
inlineconstexprnoexcept

Returns the value if the value channel is populated, else another value. Not declared if T is void .

Template Parameters
UThe type of the default value. Must satisfy std::is_convertible<U,value_type> .
Parameters
default_valueThe default value to use if the value channel is not populated.
Returns
value_type If has_value() is true, equivalent to value() . Otherwise, default_value converted to value_type .

◆ value_or() [2/2]

ARENE_NODISCARD constexpr auto arene::base::result< void, E >::value_or ( U && default_value) const &-> value_type
inlineconstexprnoexcept

Returns the value if the value channel is populated, else another value. Not declared if T is void .

Template Parameters
UThe type of the default value. Must satisfy std::is_convertible<U,value_type> .
Parameters
default_valueThe default value to use if the value channel is not populated.
Returns
value_type If has_value() is true, equivalent to value() . Otherwise, default_value converted to value_type .

Friends And Related Symbol Documentation

◆ operator!= [1/2]

ARENE_NODISCARD friend constexpr auto operator!= ( result< void, E > const & lhs,
result< void, E > const & rhs )-> bool
friend

Compare two results for inequality.

Parameters
lhsThe first result
rhsThe second result
Returns
bool true if the both lhs and rhs hold values that are not equal, or both hold errors that are not equal, or one holds a value and the other holds an error, false otherwise

◆ operator!= [2/2]

template<class E>
ARENE_NODISCARD friend constexpr auto operator!= ( result< void, E > const & lhs,
result< void, E > const & rhs ) -> bool
friend

Compare two results for inequality.

Parameters
lhsThe first result
rhsThe second result
Returns
bool true if the both lhs and rhs hold values that are not equal, or both hold errors that are not equal, or one holds a value and the other holds an error, false otherwise

◆ operator== [1/2]

template<class E>
ARENE_NODISCARD friend constexpr auto operator== ( result< void, E > const & lhs,
result< void, E > const & rhs ) -> bool
friend

Compare two results for equality.

Parameters
lhsThe first result
rhsThe second result
Returns
bool true if the both lhs and rhs hold values that are equal, or both hold errors that are equal, false otherwise

◆ operator== [2/2]

ARENE_NODISCARD friend constexpr auto operator== ( result< void, E > const & lhs,
result< void, E > const & rhs )-> bool
friend

Compare two results for equality.

Parameters
lhsThe first result
rhsThe second result
Returns
bool true if the both lhs and rhs hold values that are equal, or both hold errors that are equal, false otherwise

◆ swap [1/2]

void swap ( result< void, E > & lhs,
result< void, E > & rhs )
friend

Swaps the state of two results.

Template Parameters
SourceValueTypeMust satisfy is_swappable_v<SourceValueType> , std::is_nothrow_move_constructible<SourceValueType>
SourceErrorTypeMust satisfy is_swappable_v<SourceErrorType> , std::is_nothrow_move_constructible<SourceErrorType>
Parameters
lhsThe left hand result to swap
rhsThe right hand result to swap
Postcondition
If both lhs and rhs have matching channels populated, the content of those channels are swapped as if via arene::base::swap . Otherwise, it is equivalent to emplacing lhs with the active channel from rhs , and vise-versa.

◆ swap [2/2]

template<class E>
template<typename SourceErrorType = E, constraints< std::enable_if_t< is_swappable_v< SourceErrorType > >, std::enable_if_t< std::is_move_constructible< SourceErrorType >::value > > = nullptr>
void swap ( result< void, E > & lhs,
result< void, E > & rhs )
friend

Swaps the state of two results.

Template Parameters
SourceErrorTypeMust satisfy is_swappable_v<error_type> and std::is_nothrow_move_constructable<error_type>
Parameters
lhsThe left hand result to swap
rhsThe right hand result to swap
Postcondition
If both lhs and rhs have matching channels populated, the content of those channels are swapped as if via arene::base::swap . Otherwise, it is equivalent to move-assigning lhs with the active channel from rhs , and vise-versa.

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