0
컨테이너 요소는 초기화 후에도 변경되지 않는 것 같습니다. 샘플 코드에서, 나는 'C'로 A의 채널을 변경하려면,하지만 난 오류 얻을 : initializer_list 컨테이너를 변경할 수 있습니까?
c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple(1203): note: see reference to function template instantiation 'std::pair<const int,A>::pair<std::tuple<_Ty &&>,std::tuple<>,0,>(_Tuple1 &,_Tuple2 &,std::integer_sequence<size_t,0>,std::integer_sequence<size_t>)' being compiled
with
[
_Ty=const int,
_Tuple1=std::tuple<const int &&>,
_Tuple2=std::tuple<>
]
내 질문
은 다음과 같습니다 :#include "stdafx.h"
#include <memory>
#include <map>
struct A
{
A(char ch) {}
};
struct H
{
H(std::initializer_list< std::pair< const int, A > > initializerList) : myMap(initializerList) {}
std::map< const int, A > myMap;
};
int main()
{
H h { { 33, 'a' }, { 44, 'b' } };
//h.myMap[ 33 ] = 'c'; // error C2512: 'A::A': no appropriate default constructor available
return 0;
}
오류 텍스트의 나머지 부분은이 1) 이니셜 라이저 목록의 컨테이너 데이터 (이 경우 std :: map)를 변경할 수 있습니까? 2) 컴파일러가 기본 생성자를 묻는 이유는 무엇입니까?