GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
公開型 | 公開メンバ関数 | 全メンバ一覧
designlab::nostd::expected< T, E > クラステンプレートfinal

自作の expected クラス [詳解]

#include <my_expected.h>

公開型

using value_type = T
 
using error_type = E
 
using unexpected_type = unexpected< E >
 

公開メンバ関数

constexpr expected ()
 デフォルトコンストラクタ
 
constexpr expected (const expected &rhs)
 
constexpr expected (expected &&rhs) noexcept
 
template<class U , class G >
requires (std::is_constructible_v<T, const U&> && std::is_constructible_v<E, const G&> && !converts_from_any_cvref<T, expected<U, G>&> && !std::is_constructible_v<unexpected<E>, expected<U, G>&> && !std::is_constructible_v<unexpected<E>, expected<U, G>> && !std::is_constructible_v<unexpected<E>, const expected<U, G>&> && !std::is_constructible_v<unexpected<E>, const expected<U, G>>)
constexpr expected (const expected< U, G > &rhs)
 
template<class U , class G >
requires (std::is_constructible_v<T, U> && std::is_constructible_v<E, G> && !converts_from_any_cvref<T, expected<U, G>> && !std::is_constructible_v<unexpected<E>, expected<U, G>&> && !std::is_constructible_v<unexpected<E>, expected<U, G>> && !std::is_constructible_v<unexpected<E>, const expected<U, G>&> && !std::is_constructible_v<unexpected<E>, const expected<U, G>>)
constexpr expected (const expected< U, G > &&rhs) noexcept
 
template<class U = T>
requires (std::is_constructible_v<T, U> && !std::is_same_v<expected, std::remove_cvref_t<U>> && !std::is_same_v<std::remove_cvref_t<U>, std::in_place_t>)
constexpr expected (U &&v)
 
template<class G >
constexpr expected (const unexpected< G > &e)
 
constexpr ~expected ()=default
 デストラクタ
 
constexpr const T * operator-> () const noexcept
 正常値のポインタを返す.
 
constexpr T * operator-> () noexcept
 正常値のポインタを返す.
 
constexpr const T & operator* () const &noexcept
 正常値を参照する.
 
constexpr T & operator* () &noexcept
 正常値を参照する.
 
constexpr operator bool () const noexcept
 
constexpr bool has_value () const noexcept
 正常値を持っている場合に true を返す.
 
constexpr const T & value () const
 正常値を返す.
 
constexpr T & value ()
 正常値を返す.
 
constexpr const E & error () const
 失敗時の値を返す.
 
constexpr E & error ()
 失敗時の値を返す.
 
template<class U >
requires (std::is_constructible_v<T, U> && std::is_copy_constructible_v<T>)
constexpr T value_or (U &&v) const &
 
template<class G = E>
requires (std::is_constructible_v<E, G> && std::is_copy_constructible_v<E>)
constexpr E error_or (G &&e) const &
 
template<class Return >
constexpr expected< Return, E > and_then (const std::function< expected< Return, E >(T)> &func) const &
 
template<class Func , class Ret = std::invoke_result_t<Func, T>>
requires (std::is_invocable_r_v<Ret, Func, T> && std::is_same_v<typename Ret::error_type, E> && std::is_same_v<std::remove_cvref_t<Ret>, expected<typename Ret::value_type, E>>)
constexpr auto and_then (Func &&func) const &
 

詳解

template<impl::IsExpected T, typename E>
class designlab::nostd::expected< T, E >

自作の expected クラス

テンプレート引数
T型 T は成功時の値の型
E型 E は失敗時の値の型

my_expected.h46 行目に定義があります。

型定義メンバ詳解

◆ error_type

template<impl::IsExpected T, typename E >
using designlab::nostd::expected< T, E >::error_type = E

my_expected.h49 行目に定義があります。

◆ unexpected_type

template<impl::IsExpected T, typename E >
using designlab::nostd::expected< T, E >::unexpected_type = unexpected<E>

my_expected.h50 行目に定義があります。

◆ value_type

template<impl::IsExpected T, typename E >
using designlab::nostd::expected< T, E >::value_type = T

my_expected.h48 行目に定義があります。

構築子と解体子

◆ expected() [1/7]

template<impl::IsExpected T, typename E >
constexpr designlab::nostd::expected< T, E >::expected ( )
inlineconstexpr

デフォルトコンストラクタ

T はデフォルトコンストラクタが必要

my_expected.h54 行目に定義があります。

◆ expected() [2/7]

template<impl::IsExpected T, typename E >
constexpr designlab::nostd::expected< T, E >::expected ( const expected< T, E > &  rhs)
inlineconstexpr

my_expected.h58 行目に定義があります。

◆ expected() [3/7]

template<impl::IsExpected T, typename E >
constexpr designlab::nostd::expected< T, E >::expected ( expected< T, E > &&  rhs)
inlineconstexprnoexcept

my_expected.h61 行目に定義があります。

◆ expected() [4/7]

template<impl::IsExpected T, typename E >
template<class U , class G >
requires (std::is_constructible_v<T, const U&> && std::is_constructible_v<E, const G&> && !converts_from_any_cvref<T, expected<U, G>&> && !std::is_constructible_v<unexpected<E>, expected<U, G>&> && !std::is_constructible_v<unexpected<E>, expected<U, G>> && !std::is_constructible_v<unexpected<E>, const expected<U, G>&> && !std::is_constructible_v<unexpected<E>, const expected<U, G>>)
constexpr designlab::nostd::expected< T, E >::expected ( const expected< U, G > &  rhs)
inlineconstexpr

my_expected.h66 行目に定義があります。

◆ expected() [5/7]

template<impl::IsExpected T, typename E >
template<class U , class G >
requires (std::is_constructible_v<T, U> && std::is_constructible_v<E, G> && !converts_from_any_cvref<T, expected<U, G>> && !std::is_constructible_v<unexpected<E>, expected<U, G>&> && !std::is_constructible_v<unexpected<E>, expected<U, G>> && !std::is_constructible_v<unexpected<E>, const expected<U, G>&> && !std::is_constructible_v<unexpected<E>, const expected<U, G>>)
constexpr designlab::nostd::expected< T, E >::expected ( const expected< U, G > &&  rhs)
inlineconstexprnoexcept

my_expected.h77 行目に定義があります。

◆ expected() [6/7]

template<impl::IsExpected T, typename E >
template<class U = T>
requires (std::is_constructible_v<T, U> && !std::is_same_v<expected, std::remove_cvref_t<U>> && !std::is_same_v<std::remove_cvref_t<U>, std::in_place_t>)
constexpr designlab::nostd::expected< T, E >::expected ( U &&  v)
inlineconstexpr

my_expected.h87 行目に定義があります。

◆ expected() [7/7]

template<impl::IsExpected T, typename E >
template<class G >
constexpr designlab::nostd::expected< T, E >::expected ( const unexpected< G > &  e)
inlineconstexpr

my_expected.h94 行目に定義があります。

◆ ~expected()

template<impl::IsExpected T, typename E >
constexpr designlab::nostd::expected< T, E >::~expected ( )
constexprdefault

デストラクタ

関数詳解

◆ and_then() [1/2]

template<impl::IsExpected T, typename E >
template<class Return >
constexpr expected< Return, E > designlab::nostd::expected< T, E >::and_then ( const std::function< expected< Return, E >(T)> &  func) const &
inlineconstexpr

my_expected.h176 行目に定義があります。

呼び出し関係図:

◆ and_then() [2/2]

template<impl::IsExpected T, typename E >
template<class Func , class Ret = std::invoke_result_t<Func, T>>
requires (std::is_invocable_r_v<Ret, Func, T> && std::is_same_v<typename Ret::error_type, E> && std::is_same_v<std::remove_cvref_t<Ret>, expected<typename Ret::value_type, E>>)
constexpr auto designlab::nostd::expected< T, E >::and_then ( Func &&  func) const &
inlineconstexpr

my_expected.h187 行目に定義があります。

呼び出し関係図:

◆ error() [1/2]

template<impl::IsExpected T, typename E >
constexpr E & designlab::nostd::expected< T, E >::error ( )
inlineconstexpr

失敗時の値を返す.

has_value() が false のときのみ呼び出すこと.

例外
bad_expected_access

my_expected.h154 行目に定義があります。

◆ error() [2/2]

template<impl::IsExpected T, typename E >
constexpr const E & designlab::nostd::expected< T, E >::error ( ) const
inlineconstexpr

失敗時の値を返す.

has_value() が false のときのみ呼び出すこと.

例外
bad_expected_access

my_expected.h145 行目に定義があります。

被呼び出し関係図:

◆ error_or()

template<impl::IsExpected T, typename E >
template<class G = E>
requires (std::is_constructible_v<E, G> && std::is_copy_constructible_v<E>)
constexpr E designlab::nostd::expected< T, E >::error_or ( G &&  e) const &
inlineconstexpr

my_expected.h168 行目に定義があります。

呼び出し関係図:

◆ has_value()

template<impl::IsExpected T, typename E >
constexpr bool designlab::nostd::expected< T, E >::has_value ( ) const
inlineconstexprnoexcept

正常値を持っている場合に true を返す.

my_expected.h124 行目に定義があります。

被呼び出し関係図:

◆ operator bool()

template<impl::IsExpected T, typename E >
constexpr designlab::nostd::expected< T, E >::operator bool ( ) const
inlineexplicitconstexprnoexcept

my_expected.h121 行目に定義があります。

◆ operator*() [1/2]

template<impl::IsExpected T, typename E >
constexpr T & designlab::nostd::expected< T, E >::operator* ( ) &
inlineconstexprnoexcept

正常値を参照する.

正常値を持ってない場合は未定義動作になるので注意.

my_expected.h119 行目に定義があります。

◆ operator*() [2/2]

template<impl::IsExpected T, typename E >
constexpr const T & designlab::nostd::expected< T, E >::operator* ( ) const &
inlineconstexprnoexcept

正常値を参照する.

正常値を持ってない場合は未定義動作になるので注意.

my_expected.h113 行目に定義があります。

◆ operator->() [1/2]

template<impl::IsExpected T, typename E >
constexpr const T * designlab::nostd::expected< T, E >::operator-> ( ) const
inlineconstexprnoexcept

正常値のポインタを返す.

正常値を持ってない場合は未定義動作になるので注意.

my_expected.h101 行目に定義があります。

◆ operator->() [2/2]

template<impl::IsExpected T, typename E >
constexpr T * designlab::nostd::expected< T, E >::operator-> ( )
inlineconstexprnoexcept

正常値のポインタを返す.

正常値を持ってない場合は未定義動作になるので注意.

my_expected.h107 行目に定義があります。

◆ value() [1/2]

template<impl::IsExpected T, typename E >
constexpr T & designlab::nostd::expected< T, E >::value ( )
inlineconstexpr

正常値を返す.

has_value() が true のときのみ呼び出すこと.

例外
bad_expected_access

my_expected.h137 行目に定義があります。

◆ value() [2/2]

template<impl::IsExpected T, typename E >
constexpr const T & designlab::nostd::expected< T, E >::value ( ) const
inlineconstexpr

正常値を返す.

has_value() が true のときのみ呼び出すこと.

例外
bad_expected_access

my_expected.h129 行目に定義があります。

被呼び出し関係図:

◆ value_or()

template<impl::IsExpected T, typename E >
template<class U >
requires (std::is_constructible_v<T, U> && std::is_copy_constructible_v<T>)
constexpr T designlab::nostd::expected< T, E >::value_or ( U &&  v) const &
inlineconstexpr

my_expected.h161 行目に定義があります。

呼び出し関係図:

このクラス詳解は次のファイルから抽出されました: