名稱空間
變體
操作

std::logical_and

來自 cppreference.com
 
 
 
函式物件
函式呼叫
(C++17)(C++23)
恆等函式物件
(C++20)
透明運算子包裝器
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

舊繫結器和介面卡
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)  
(直到 C++17*)
(直到 C++17*)(直到 C++17*)(直到 C++17*)(直到 C++17*)
(直到 C++20*)
(直到 C++20*)
(直到 C++17*)(直到 C++17*)
(直到 C++17*)(直到 C++17*)

(直到 C++17*)
(直到 C++17*)(直到 C++17*)(直到 C++17*)(直到 C++17*)
(直到 C++20*)
(直到 C++20*)
 
定義於標頭檔案 <functional>
template< class T >
struct logical_and;
(直到 C++14)
template< class T = void >
struct logical_and;
(C++14 起)

用於執行邏輯與(邏輯合取)的函式物件。實際上對型別T呼叫operator&&

目錄

[編輯] 特化

當未指定T時,標準庫提供std::logical_and的特化,它允許引數型別和返回型別被推導。

函式物件,實現x && y,推導引數和返回型別
(類模板特化) [編輯]
(C++14 起)

[編輯] 成員型別

型別 定義
result_type (C++17 中已棄用)(C++20 中已移除) bool
first_argument_type (C++17 中已棄用)(C++20 中已移除) T
second_argument_type (C++17 中已棄用)(C++20 中已移除) T

這些成員型別透過公開繼承std::binary_function<T, T, bool>獲得。

(C++11 前)

[編輯] 成員函式

operator()
返回兩個引數的邏輯與
(公開成員函式)

std::logical_and::operator()

bool operator()( const T& lhs, const T& rhs ) const;
(C++14 起為 constexpr)

返回lhsrhs的邏輯與。

引數

lhs, rhs - 要計算邏輯與的值

返回值

lhs && rhs的結果。

[編輯] 異常

可能丟擲實現定義的異常。

可能的實現

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