std::negation
From cppreference.com
| ヘッダ <type_traits> で定義 |
||
| template< class B > struct negation; |
(C++17以降) | |
型特性 B の論理否定を形成する。
型 std::negation<B> は、std::bool_constant<!bool(B::value)> を基本特性とする UnaryTypeTrait である。
プログラムが std::negation または std::negation_v の特殊化を追加する場合、その動作は未定義である。
目次 |
[編集] テンプレートパラメータ
| B | - | 式 bool(B::value) が有効な定数式である任意の型 |
[編集] ヘルパー変数テンプレート
| template< class B > constexpr bool negation_v = negation<B>::value; |
(C++17以降) | |
std::integral_constant から継承
メンバ定数
| value [static] |
B が明示的に bool に変換されたときに false となるメンバ ::value を持つ場合 true、そうでない場合 false(公開静的メンバ定数) |
メンバ関数
| operator bool |
オブジェクトを bool に変換し、value を返します。 (public member function) |
| operator() (C++14) |
value を返します。 (public member function) |
メンバ型
| 型 | 定義 |
value_type
|
bool |
type
|
std::integral_constant<bool, value> |
[編集] 可能な実装
template<class B> struct negation : std::bool_constant<!bool(B::value)> { }; |
[編集] 注釈
| 機能テストマクロ | 値 | 規格 | 機能 |
|---|---|---|---|
__cpp_lib_logical_traits |
201510L |
(C++17) | 論理演算子型特性 |
[編集] 例
このコードを実行
#include <type_traits> static_assert( std::is_same< std::bool_constant<false>, typename std::negation<std::bool_constant<true>>::type>::value, ""); static_assert( std::is_same< std::bool_constant<true>, typename std::negation<std::bool_constant<false>>::type>::value, ""); static_assert(std::negation_v<std::bool_constant<true>> == false); static_assert(std::negation_v<std::bool_constant<false>> == true); int main() {}
[編集] 関連項目
| (C++17) |
可変長論理ANDメタ関数 (クラステンプレート) |
| (C++17) |
可変長論理ORメタ関数 (クラステンプレート) |
| (C++11)(C++17) |
指定された値を持つ、指定された型のコンパイル時定数 (クラステンプレート) |