Namespaces
Variants

deduction guides for std::multiset

From cppreference.net

HTMLタグ、属性、コードブロック内のテキストは翻訳せず、C++固有の用語もそのまま保持しました。唯一翻訳したのは「(since C++17)」を「(C++17以降)」に変更した部分のみです。 (注:このHTML要素には翻訳対象のテキストコンテンツが含まれていないため、元の構造を保持したまま出力します)
定義済みヘッダー <set>
template <

class InputIt,
class Comp = std:: less < typename std:: iterator_traits < InputIt > :: value_type > ,
class Alloc = std:: allocator < typename std:: iterator_traits < InputIt > :: value_type >>
multiset ( InputIt, InputIt, Comp = Comp ( ) , Alloc = Alloc ( ) )

- > multiset < typename std:: iterator_traits < InputIt > :: value_type , Comp, Alloc > ;
(1) (C++17以降)
template <

class Key, class Comp = std:: less < Key > ,
class Alloc = std:: allocator < Key > >
multiset ( std:: initializer_list < Key > , Comp = Comp ( ) , Alloc = Alloc ( ) )

- > multiset < Key, Comp, Alloc > ;
(2) (C++17以降)
template < class InputIt, class Alloc >

multiset ( InputIt, InputIt, Alloc )
- > multiset < typename std:: iterator_traits < InputIt > :: value_type ,

std:: less < typename std:: iterator_traits < InputIt > :: value_type > , Alloc > ;
(3) (C++17以降)
template < class Key, class Alloc >

multiset ( std:: initializer_list < Key > , Alloc )

- > multiset < Key, std:: less < Key > , Alloc > ;
(4) (C++17以降)
template < ranges:: input_range R, class Compare = less < ranges:: range_value_t < R >> ,

class Alloc = std:: allocator < ranges:: range_value_t < R >> >
multiset ( std:: from_range_t , R && , Compare = Compare ( ) , Alloc = Alloc ( ) )

- > multiset < ranges:: range_value_t < R > , Compare, Alloc > ;
(5) (C++23以降)
template < ranges:: input_range R, class Alloc >

multiset ( std:: from_range_t , R && , Alloc )

- > multiset < ranges:: range_value_t < R > , std:: less < ranges:: range_value_t < R >> , Alloc > ;
(6) (C++23以降)
1-4) これらの 推論ガイド は、 multiset に対してイテレータ範囲(オーバーロード (1,3) )および std::initializer_list (オーバーロード (2,4) )からの推論を可能にするために提供されています。
5,6) これらの導出ガイドは、 multiset に対して提供されており、 std::from_range_t タグと input_range からの導出を可能にします。

これらのオーバーロードは、以下の条件が満たされる場合にのみオーバーロード解決に参加します: InputIt LegacyInputIterator を満たし、 Alloc Allocator を満たし、かつ Comp Allocator を満たさない場合です。

注意: ライブラリが型が LegacyInputIterator を満たさないと判断する範囲は未規定であるが、少なくとも整数型は入力イテレータとして適格ではない。同様に、型が Allocator を満たさないと判断する範囲も未規定であるが、少なくともメンバ型 Alloc::value_type が存在しなければならず、式 std:: declval < Alloc & > ( ) . allocate ( std:: size_t { } ) が未評価オペランドとして扱われた際に well-formed でなければならない。

注記

機能テスト マクロ 標準 機能
__cpp_lib_containers_ranges 202202L (C++23) Ranges-aware 構築と挿入; オーバーロード (5,6)

#include <set>
int main()
{
    // ガイド #2 は std::multiset<int> を推論
    std::multiset s = {1, 2, 3, 4};
    // ガイド #1 は std::multiset<int> を推論
    std::multiset s2(s.begin(), s.end());
}