std::not_fn
提供: cppreference.com
< cpp | utility | functional
| ヘッダ <functional> で定義
|
||
| template< class F> /*unspecified*/ not_fn( F&& f ); |
(C++17以上) | |
保持する呼び出し可能なオブジェクトの否定を返す転送呼び出しラッパーを作成します。
目次 |
[編集] 引数
| f | - | ラッパーによって保持される Callable なオブジェクトの構築元 |
| 型の要件 | ||
-std::decay_t<F> は Callable および MoveConstructible の要件を満たさなければなりません。
| ||
| -std::is_constructible_v<std::decay_t<F>, F> が true であることが要求されます。 | ||
[編集] 戻り値
未規定な型 T の関数オブジェクト。 以下のメンバを持ちます。
std::not_fn の戻り値の型
メンバオブジェクト
std::not_fn の戻り値の型は std::decay_t<F> 型のメンバオブジェクトを保持します。
コンストラクタ
| explicit T(F&& f); |
(1) | |
| T(T&& f) = default; T(const T& f) = default; |
(2) | |
1) コンストラクタは (std::decay_t<F> 型の) メンバオブジェクトを std::forward<F>(f) から初期化します。 選択されたコンストラクタによって投げられたあらゆる例外を投げます。
2) std::decay_t<F> は MoveConstructible であることが要求されるため、返された呼び出しラッパーは必ず MoveConstructible であり、 std::decay_t<F> が CopyConstructible であれば CopyConstructible でもあります。
メンバ関数 operator()
| template<class... Args> auto operator()(Args&&... args) & -> decltype(!std::declval<std::invoke_result_t<std::decay_t<F>&, Args...>>()); |
(1) | |
| template<class... Args> auto operator()(Args&&... args) && -> decltype(!std::declval<std::invoke_result_t<std::decay_t<F>, Args...>>()); |
(2) | |
1) return !std::invoke(fd, std::forward<Args>(args)...) と同等です。
2) return !std::invoke(std::move(fd), std::forward<Args>(args)...) と同等です。
ただし fd は std::decay_t<F> 型のメンバオブジェクトです。
[編集] 例外
fd の構築が例外を投げなければ、例外を投げません。
[編集] ノート
not_fn は C++03 時代の否定子 std::not1 および std::not2 を置き換える意図があります。
[編集] 関連項目
| (C++17で非推奨)(C++20で削除) |
カスタム std::unary_negate オブジェクトを構築します (関数テンプレート) |
| (C++17で非推奨)(C++20で削除) |
カスタム std::binary_negate オブジェクトを構築します (関数テンプレート) |