名前空間
変種
操作

std::negation

From cppreference.com
< cpp‎ | types
 
 
メタプログラミングライブラリ
型特性
型のカテゴリ
(C++11)
(C++11)(DR*)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11) 
(C++11)
(C++11)
型のプロパティ
(C++11)
(C++11)
(C++14)
(C++11)(C++26で非推奨)
(C++11)(C++20まで*)
(C++11)(C++20で非推奨)
(C++11)
型特性定数
メタ関数
negation
(C++17)
サポートされている操作
関係とプロパティクエリ
型の変更
(C++11)(C++11)(C++11)
型の変換
(C++11)(C++23で非推奨)
(C++11)(C++23で非推奨)
(C++11)
(C++11)(C++20まで*)(C++17)

(C++11)
(C++17)
コンパイル時有理数演算
コンパイル時整数シーケンス
 
ヘッダ <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() {}

[編集] 関連項目

可変長論理ANDメタ関数
(クラステンプレート) [編集]
可変長論理ORメタ関数
(クラステンプレート) [編集]
指定された値を持つ、指定された型のコンパイル時定数
(クラステンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)