std::greater<void>
來自 cppreference.com
定義於標頭檔案 <functional> |
||
template<> class greater<void>; |
(C++14 起) | |
std::greater<void> 是 std::greater 的特化版本,其引數和返回型別均可推導。
目錄 |
[編輯] 巢狀型別
巢狀型別 | 定義 |
is_transparent
|
未指定 |
[編輯] 成員函式
operator() |
測試 lhs 是否大於 rhs (公開成員函式) |
std::greater<void>::operator()
template< class T, class U > constexpr auto operator()( T&& lhs, U&& rhs ) const |
||
返回 std::forward<T>(lhs) > std::forward<U>(rhs) 的結果。
引數
lhs, rhs | - | 要比較的值 |
返回值
std::forward<T>(lhs) > std::forward<U>(rhs).
若呼叫內建的指標比較運算子,則結果與對指標的實現定義嚴格全序一致。
[編輯] 異常
可能丟擲實現定義的異常。
[編輯] 示例
執行此程式碼
#include <algorithm> #include <cstdint> #include <functional> constexpr bool strictly_positive(int lhs) { return std::greater<>()(lhs, 0); } int main() { constexpr std::int64_t low = 0B11; constexpr std::uint16_t high = 0X11; std::greater<> greater{}; static_assert(greater(high, low)); constexpr static auto arr = {0, 1, 2, 3, 4, 5}; static_assert(!std::all_of(arr.begin(), arr.end(), strictly_positive)); static_assert(std::all_of(arr.begin() + 1, arr.end(), strictly_positive)); }
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 2562 | C++98 | 指標全序可能不一致 | 保證一致 |