Namespaces
Variants

std:: bit_not

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
ヘッダーで定義 <functional>
template < class T = void >
struct bit_not ;
(C++14以降)

ビット単位NOTを実行する関数オブジェクト。実質的に型 T に対して operator~ を呼び出します。

目次

特殊化

標準ライブラリは、 std::bit_not の特殊化を提供しており、 T が指定されていない場合、パラメータ型と戻り値の型は推論されます。

パラメータと戻り値の型を推論する ~x を実装する関数オブジェクト
(クラステンプレートの特殊化)

メンバー型

定義
result_type (C++17で非推奨) (C++20で削除) T
argument_type (C++17で非推奨) (C++20で削除) T

メンバー関数

operator()
(C++14)
引数のビット単位NOTの結果を返す
(public member function)

std::bit_not:: operator()

constexpr T operator ( ) ( const T & arg ) const ;
(C++14以降)

arg のビット単位NOTの結果を返します。

パラメータ

arg - ビット単位NOTを計算する値

戻り値

~arg の結果。

例外

実装定義の例外をスローする可能性があります。

実装例

constexpr T operator()(const T& arg) const
{
    return ~arg;
}

注記

std::bit_not はC++11以降の提案 N3421 によって追加されたが、一般的な実装では LWG issue 660 の解決策の一部として扱われ(透過的特殊化 std::bit_not<> を除く)、そのためC++98/03モードでも利用可能である。