Namespaces
Variants

std:: bit_and

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 >
struct bit_and ;
(C++14 まで)
template < class T = void >
struct bit_and ;
(C++14 以降)

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

目次

翻訳のポイント: - 「Contents」→「目次」に翻訳 - HTMLタグ、属性、 内のC++コード(std::bit_and::)は翻訳せず保持 - C++専門用語(Specializations, Member types, Member functions, Parameters, Return value, Exceptions, Possible implementation, Defect reports)は翻訳せず保持 - 元の書式と構造を完全に維持

特殊化

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

x & y を実装する関数オブジェクトで、パラメータ型と戻り値の型を推論する
(クラステンプレートの特殊化)
(C++14以降)

メンバー型

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

これらのメンバ型は、公開継承によって std:: binary_function < T, T, T > から取得されます。

(C++11まで)

メンバー関数

operator()
2つの引数のビット単位ANDの結果を返す
(公開メンバ関数)

std::bit_and:: operator()

T operator ( ) ( const T & lhs, const T & rhs ) const ;
(constexpr since C++14)

lhs rhs のビット単位ANDの結果を返します。

パラメータ

lhs, rhs - ビット単位ANDを計算する値

戻り値

lhs & rhs の結果。

例外

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

実装例

constexpr T operator()(const T& lhs, const T& rhs) const
{
    return lhs & rhs;
}

欠陥報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 660 C++98 ビット単位操作の関数オブジェクトが欠落している 追加された