名前空間
変種
操作

std::multiset に対する推定ガイド

提供: cppreference.com
< cpp‎ | container‎ | multiset
 
 
 
 
ヘッダ <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以上)

イテレータ範囲 (オーバーロード (1,3)) および std::initializer_list (オーバーロード (2,4)) からの推定を可能とするため multiset に対してこれらの推定ガイドが提供されます。 これらのオーバーロードは、InputItLegacyInputIterator を満たし、 AllocAllocator を満たし、 CompAllocator を満たさない場合場合にのみ、オーバーロード解決に参加します。

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

[編集]

#include <set>
int main() {
   std::multiset s = {1,2,3,4}; // guide #2 deduces std::multiset<int>
   std::multiset s2(s.begin(), s.end()); // guide #1 deduces std::multiset<int>
}