class either
Declaration
template <class L, class R>
class either { /* full declaration omitted */ };
Description
A monadic type that contains an element either one of it's left or right side.
Declared at: libreglisse/either.hpp:212
Member Variables
- private bool m_is_left = true
- private anonymous struct / union
Method Overview
- public constexpr auto borrow_left() const & noexcept -> const reglisse::either::left_type &
- public constexpr auto borrow_left() & noexcept -> reglisse::either::left_type &
- public constexpr auto borrow_right() const & noexcept -> const reglisse::either::right_type &
- public constexpr auto borrow_right() & noexcept -> reglisse::either::right_type &
- public constexpr either<LeftType, RightType>()
- public constexpr either<LeftType, RightType>(left<reglisse::either::left_type> && left_val)
- public constexpr either<LeftType, RightType>(right<reglisse::either::right_type> && right_val)
- public constexpr either<LeftType, RightType>(const either<LeftType, RightType> & other)
- public constexpr either<LeftType, RightType>(either<LeftType, RightType> && other) noexcept
- public constexpr auto is_left() const noexcept -> bool
- public constexpr auto is_right() const noexcept -> bool
- public constexpr auto take_left() const && noexcept -> const reglisse::either::left_type
- public constexpr auto take_left() && noexcept -> reglisse::either::left_type
- public constexpr auto take_right() const && noexcept -> const reglisse::either::right_type
- public constexpr auto take_right() && noexcept -> reglisse::either::right_type
- public constexpr ~either<LeftType, RightType>()
Methods
constexpr auto borrow_left() const& noexcept
-> const reglisse::either::left_type&
constexpr auto borrow_left() const& noexcept
-> const reglisse::either::left_type&
Description
Borrow the value stored on the left side of the monad.
If the monad does not hold a value on the left, an assert will be thrown at debug time will be thrown. If you wish to have runtime checking, defining the LIBREGLISSE_USE_EXCEPTIONS macro before including this file will turn all assertions into exceptions.
Declared at: libreglisse/either.hpp:345
Returns
The value stored on the left side of the monad.
constexpr auto borrow_left() & noexcept
-> reglisse::either::left_type&
constexpr auto borrow_left() & noexcept
-> reglisse::either::left_type&
Description
Borrow the value stored on the left side of the monad.
If the monad does not hold a value on the left, an assert will be thrown at debug time will be thrown. If you wish to have runtime checking, defining the LIBREGLISSE_USE_EXCEPTIONS macro before including this file will turn all assertions into exceptions.
Declared at: libreglisse/either.hpp:361
Returns
The value stored on the left side of the monad.
constexpr auto borrow_right() const& noexcept
-> const reglisse::either::right_type&
constexpr auto borrow_right() const& noexcept
-> const reglisse::either::right_type&
Description
Borrow the value stored on the right side of the monad.
If the monad does not hold a value on the right, an assert will be thrown at debug time will be thrown. If you wish to have runtime checking, defining the LIBREGLISSE_USE_EXCEPTIONS macro before including this file will turn all assertions into exceptions.
Declared at: libreglisse/either.hpp:416
Returns
The value stored on the right side of the monad.
constexpr auto borrow_right() & noexcept
-> reglisse::either::right_type&
constexpr auto borrow_right() & noexcept
-> reglisse::either::right_type&
Description
Borrow the value stored on the right side of the monad.
If the monad does not hold a value on the right, an assert will be thrown at debug time will be thrown. If you wish to have runtime checking, defining the LIBREGLISSE_USE_EXCEPTIONS macro before including this file will turn all assertions into exceptions.
Declared at: libreglisse/either.hpp:432
Returns
The value stored on the right side of the monad.
constexpr either<LeftType, RightType>()
constexpr either<LeftType, RightType>()
Declared at: libreglisse/either.hpp:219
constexpr either<LeftType, RightType>(
left<reglisse::either::left_type>&& left_val)
constexpr either<LeftType, RightType>(
left<reglisse::either::left_type>&& left_val)
Description
Construct from a left either.
Declared at: libreglisse/either.hpp:225
Parameters
- left<reglisse::either::left_type>&& left_val
- Temporary value to store
constexpr either<LeftType, RightType>(
right<reglisse::either::right_type>&&
right_val)
constexpr either<LeftType, RightType>(
right<reglisse::either::right_type>&&
right_val)
Description
Construct from a right either.
Declared at: libreglisse/either.hpp:234
Parameters
- right<reglisse::either::right_type>&& right_val
- Temporary value to store
constexpr either<LeftType, RightType>(
const either<LeftType, RightType>& other)
constexpr either<LeftType, RightType>(
const either<LeftType, RightType>& other)
Description
Copy construct an either
Declared at: libreglisse/either.hpp:241
Parameters
- const either<LeftType, RightType>& other
constexpr either<LeftType, RightType>(
either<LeftType, RightType>&& other) noexcept
constexpr either<LeftType, RightType>(
either<LeftType, RightType>&& other) noexcept
Description
Move construct an either
Declared at: libreglisse/either.hpp:255
Parameters
- either<LeftType, RightType>&& other
constexpr auto is_left() const noexcept -> bool
constexpr auto is_left() const noexcept -> bool
Description
Check if the monad is storing a value on the left.
Declared at: libreglisse/either.hpp:482
Returns
true if it holds a value on the left
constexpr auto is_right() const noexcept -> bool
constexpr auto is_right() const noexcept -> bool
Description
Check if the monad is storing a value on the right
Declared at: libreglisse/either.hpp:488
Returns
true if it holds a value on the right
constexpr auto take_left() const&& noexcept
-> const reglisse::either::left_type
constexpr auto take_left() const&& noexcept
-> const reglisse::either::left_type
Description
Take the value stored on the left side of the monad.
This operation leaves the monad in an undefined state, it is not recommended to use it after this function being called. If the monad does not hold a value on the left, an assert will be thrown at debug time will be thrown. If you wish to have runtime checking, defining the LIBREGLISSE_USE_EXCEPTIONS macro before including this file will turn all assertions into exceptions.
Declared at: libreglisse/either.hpp:380
Returns
The value stored on the left side of the monad.
constexpr auto take_left() && noexcept
-> reglisse::either::left_type
constexpr auto take_left() && noexcept
-> reglisse::either::left_type
Description
Take the value stored on the left side of the monad.
This operation leaves the monad in an undefined state, it is not recommended to use it after this function being called. If the monad does not hold a value on the left, an assert will be thrown at debug time will be thrown. If you wish to have runtime checking, defining the LIBREGLISSE_USE_EXCEPTIONS macro before including this file will turn all assertions into exceptions.
Declared at: libreglisse/either.hpp:399
Returns
The value stored on the left side of the monad.
constexpr auto take_right() const&& noexcept
-> const reglisse::either::right_type
constexpr auto take_right() const&& noexcept
-> const reglisse::either::right_type
Description
Take the value stored on the right side of the monad.
This operation leaves the monad in an undefined state, it is not recommended to use it after this function being called. If the monad does not hold a value on the right, an assert will be thrown at debug time will be thrown. If you wish to have runtime checking, defining the LIBREGLISSE_USE_EXCEPTIONS macro before including this file will turn all assertions into exceptions.
Declared at: libreglisse/either.hpp:451
Returns
The value stored on the right side of the monad.
constexpr auto take_right() && noexcept
-> reglisse::either::right_type
constexpr auto take_right() && noexcept
-> reglisse::either::right_type
Description
Take the value stored on the right side of the monad.
This operation leaves the monad in an undefined state, it is not recommended to use it after this function being called. If the monad does not hold a value on the right, an assert will be thrown at debug time will be thrown. If you wish to have runtime checking, defining the LIBREGLISSE_USE_EXCEPTIONS macro before including this file will turn all assertions into exceptions.
Declared at: libreglisse/either.hpp:470
Returns
The value stored on the right side of the monad.
constexpr ~either<LeftType, RightType>()
constexpr ~either<LeftType, RightType>()
Description
Destruct either.
Declared at: libreglisse/either.hpp:269