名前空間
変種
操作

std::less<void>

From cppreference.com
< cpp‎ | utility‎ | functional
 
 
ユーティリティライブラリ
言語サポート
型のサポート (基本型、RTTI)
ライブラリ機能検査マクロ (C++20)
プログラムユーティリティ
可変引数関数
コルーチンサポート (C++20)
契約サポート (C++26)
三方比較
(C++20)
(C++20)(C++20)(C++20)  
(C++20)(C++20)(C++20)

汎用ユーティリティ
関係演算子 (C++20で非推奨)
 
関数オブジェクト
関数の呼び出し
(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)
less<>
(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 less<void>;
(C++14以降)

std::less<void> は、パラメータと戻り値の型が推論される std::less の特殊化です。

目次

[編集] ネストされた型

ネストされた型 定義
is_transparent unspecified

[編集] メンバ関数

operator()
lhsrhs より小さいかどうかをテストします。
(public member function)

std::less<void>::operator()

template< class T, class U >

constexpr auto operator()( T&& lhs, U&& rhs ) const

    -> decltype(std::forward<T>(lhs) < std::forward<U>(rhs));

std::forward<T>(lhs) < std::forward<U>(rhs) の結果を返します。

パラメータ

lhs, rhs - 比較する値

戻り値

std::forward<T>(lhs) < std::forward<U>(rhs).

ポインタを比較する組み込み演算子が呼び出される場合、結果は「ポインタの厳密な全順序」に基づいて実装依存となります。

[編集] 例外

実装定義の例外をスローする場合があります。

[編集]

#include <algorithm>
#include <functional>
 
constexpr bool strictly_negative(int lhs)
{
    return std::less<>()(lhs, 0);
}
 
int main()
{
    constexpr signed low = 010;
    constexpr unsigned high = 10;
    std::less<> less{};
    static_assert(less(low, high));
 
    constexpr static auto arr = {0, -1, -2, -3, -4, -5};
    static_assert(!std::all_of(arr.begin(), arr.end(), strictly_negative));
    static_assert(std::all_of(arr.begin() + 1, arr.end(), strictly_negative));
}

[編集] 不具合レポート

以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。

DR 適用対象 公開された動作 正しい動作
LWG 2562 C++98 ポインタの全順序が不整合である可能性がある 一貫性が保証される
English 日本語 中文(简体) 中文(繁體)