Namespaces
Variants

deduction guides for std::multimap

From cppreference.net

헤더에 정의됨 <map>
template < class InputIt,

class Comp = std:: less < /*iter-key-t*/ < InputIt >> ,
class Alloc = std:: allocator < /*iter-to-alloc-t*/ < InputIt >> >
multimap ( InputIt, InputIt, Comp = Comp ( ) , Alloc = Alloc ( ) )

- > multimap < /*iter-key-t*/ < InputIt > , /*iter-val-t*/ < InputIt > , Comp, Alloc > ;
(1) (C++17부터)
template < class Key,

class T,
class Comp = std:: less < Key > ,
class Alloc = std:: allocator < std:: pair < const Key, T >> >
multimap ( std:: initializer_list < std:: pair < Key, T >> , Comp = Comp ( ) , Alloc = Alloc ( ) )

- > multimap < Key, T, Comp, Alloc > ;
(2) (C++17부터)
template < class InputIt, class Alloc >

multimap ( InputIt, InputIt, Alloc )
- > multimap < /*iter-key-t*/ < InputIt > , /*iter-val-t*/ < InputIt > ,

std:: less < /*iter-key-t*/ < InputIt >> , Alloc > ;
(3) (C++17부터)
template < class Key, class T, class Alloc >

multimap ( std:: initializer_list < std:: pair < Key, T >> , Alloc )

- > multimap < Key, T, std:: less < Key > , Alloc > ;
(4) (C++17부터)
template < ranges:: input_range R, class Compare = std:: less < /*range-key-t*/ < R > ,

class Alloc = std:: allocator < /*range-to-alloc-t*/ < R >> >
multimap ( std:: from_range_t , R && , Compare = Compare ( ) , Alloc = Alloc ( ) )

- > multimap < /*range-key-t*/ < R > , range_mapped_t < R > , Compare, Alloc > ;
(5) (C++23부터)
template < ranges:: input_range R, class Alloc >

multimap ( std:: from_range_t , R && , Alloc )
- > multimap < /*range-key-t*/ < R > , range_mapped_t < R > ,

multimap std:: less < /*range-key-t*/ < R >> , Alloc > ;
(6) (C++23 이후)
설명 전용 헬퍼 타입 별칭
template < class InputIt >

using /*iter-val-t*/ =

typename std:: iterator_traits < InputIt > :: value_type ;
( 설명 전용* )
template < class InputIt >

using /*iter-key-t*/ =

std:: remove_const_t < std:: tuple_element_t < 0 , /*iter-val-t*/ < InputIt >>> ;
( 설명 전용* )
template < class InputIt >

using /*iter-mapped-t*/ =

std:: tuple_element_t < 1 , /*iter-val-t*/ < InputIt >> ;
( 설명 전용* )
template < class InputIt >

using /*iter-to-alloc-t*/ =
std:: pair < std:: add_const_t < tuple_element_t < 0 , /*iter-val-t*/ < InputIt >>> ,

std:: tuple_element_t < 1 , /*iter-val-t*/ < InputIt >>> ;
( 설명 전용* )
template < ranges:: input_range Range >

using /*range-key-t*/ =

std:: remove_const_t < typename ranges:: range_value_t < Range > :: first_type > ;
(C++23 이후)
( 설명 전용* )
template < ranges:: input_range Range >

using /*range-mapped-t*/ =

typename ranges:: range_value_t < Range > :: second_type ;
(C++23부터)
( 설명 전용* )
template < ranges:: input_range Range >

using /*range-to-alloc-t*/ =
std:: pair < std:: add_const_t < typename ranges:: range_value_t < Range > :: first_type > ,

typename ranges:: range_value_t < Range > :: second_type > ;
(C++23부터)
( 설명 전용* )
1-4) 이러한 deduction guides multimap 에 대해 반복자 범위(오버로드 (1,3) )와 std::initializer_list (오버로드 (2,4) )로부터의 추론을 허용하기 위해 제공됩니다.
5,6) 이 추론 가이드들은 multimap 에 대해 std::from_range_t 태그와 input_range 로부터의 추론을 허용하기 위해 제공됩니다.

이 오버로드들은 다음 조건에서만 오버로드 해결에 참여합니다: InputIt LegacyInputIterator 요구 사항을 충족하고, Alloc Allocator 요구 사항을 충족하며, Comp Allocator 요구 사항을 충족하지 않는 경우에 한합니다.

참고: 라이브러리가 특정 타입이 LegacyInputIterator 요구사항을 만족하지 않는다고 판단하는 범위는 명시되지 않았으나, 최소한 정수 타입들은 입력 반복자로 적격하지 않습니다. 마찬가지로, 특정 타입이 Allocator 요구사항을 만족하지 않는다고 판단하는 범위도 명시되지 않았으나, 최소한 멤버 타입 Alloc::value_type 이 존재해야 하며 표현식 std:: declval < Alloc & > ( ) . allocate ( std:: size_t { } ) 가 평가되지 않은 피연산자로 취급될 때 형식이 올바르게 구성되어야 합니다.

참고 사항

기능 테스트 매크로 표준 기능
__cpp_lib_containers_ranges 202202L (C++23) 범위 인식 생성 및 삽입; 오버로드 ( 5,6 )

예제

#include <map>
int main()
{
    // std::multimap m1 = {{"foo", 1}, {"bar", 2}};
        // 오류: 중괄호 초기화 목록에 타입이 없음; {"foo", 1} 또는 {"bar", 2}에서
        // pair<Key, T>를 추론할 수 없음
    std::multimap m1 = {std::pair{"foo", 2}, {"bar", 3}}; // 가이드 #2
    std::multimap m2(m1.begin(), m1.end()); // 가이드 #1
}

결함 보고서

다음 동작 변경 결함 보고서는 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 3025 C++17 initializer-list guides ( 2,4 ) take std:: pair < const Key, T > use std:: pair < Key, T >