일부 데이터를 std::array
에 넣어야하는 코드가 있습니다. 두 개의 배열을 교체하고 그 중 하나를 버려서이 작업을 수행 할 수 있다고 생각했습니다. 코드는 다음과 같습니다.std :: swap이 std :: array와 함께 작동하지 않습니다.
int main()
{
std::array<double, 10> a;
std::array<double, 5> b;
/*populate b*/
/*swap them round*/
std::swap(a, b);
}
그러나 매우 이상한 컴파일러 오류 (MSVC2013)가 발생합니다.
CashFlows.cpp(27): error C2665: 'std::swap' : none of the 3 overloads could convert all the argument types
include\exception(502): could be 'void std::swap(std::exception_ptr &,std::exception_ptr &)'
include\tuple(572): or 'void std::swap(std::tuple<> &,std::tuple<> &)'
include\thread(232): or 'void std::swap(std::thread &,std::thread &) throw()'
while trying to match the argument list '(std::array<_Ty,_Size>, std::array<_Ty,_Size>)'
with
[
_Ty=double,
_Size=0x0a
]
and
[
_Ty=double,
_Size=0x05
]
나는 이해할 수 없다. std::tuple<>
등은 무엇을해야합니까? 서로 다른 템플릿 인스턴스화만큼
Procrustean 오류 ... –
안녕하십니까. 그 이름을 심각하게 지키려고합니까? 이것은 분명히 밝혀진 좋은 질문입니다. 고맙습니다! – Bathsheba
@KerrekSB : 약간의 재량으로 사전에 연락합니다 ... – Bathsheba