std::map<std::string, std::ofstream> Map;
std::string name="name";
std::ofstream ofs(name,std::ios::app);
Map[name] = std::move(ofs);
을 삭제 ofstream. -std = C++ 11을 사용하여 Ubuntu12.04 및 g ++ - 5 (gcc 버전 5.4.1 20160904 (Ubuntu 5.4.1-2ubuntu1 ~ 12.04))에서 g ++ 4.9로 컴파일했습니다. 그러면 아래와 같은 오류 메시지가 나타납니다. IOSTREAMS를 이동오류 : 삭제 기능의 사용 방법 '표준 : basic_ofstream <char> 및 표준 : basic_ofstream <char> :: 연산자 = (const를 표준 : basic_ofstream <char> &)'나는 위의 코드를 실행하지만 실패
error: use of deleted function ‘std::basic_ofstream& std::basic_ofstream::operator=(const std::basic_ofstream&)’ Map[name] = std::move(ofs);
/usr/include/c++/4.9/fstream:602:11: note: ‘std::basic_ofstream& std::basic_ofstream::operator=(const std::basic_ofstream&)’ is implicitly deleted because the default definition would be ill-formed: class basic_ofstream : public basic_ostream<_CharT,_Traits>
g ++ 버전 특정 것 같습니다. VS 2013 및 [g ++ - 5.1] (http://coliru.stacked-crooked.com/a/c83e8a3939ac3115)을 사용하여 빌드하십시오. – acraig5075