Rozważmy następujący kod:Usunięto konstruktor - MSVC zgłasza błąd, Clang nie
class SILPassPipelinePlan final {
public:
SILPassPipelinePlan() = default;
~SILPassPipelinePlan() = default;
SILPassPipelinePlan(const SILPassPipelinePlan &) = default;
SILPassPipelinePlan(SILPassPipelinePlan &&) = delete;
SILPassPipelinePlan x() {
SILPassPipelinePlan P;
return P;
}
};
int main() {
return 0;
}
MSVC zgłasza następujący błąd:
1>consoleapplication2.cpp(13): error C2280: 'SILPassPipelinePlan::SILPassPipelinePlan(SILPassPipelinePlan &&)': attempting to reference a deleted function
1>consoleapplication2.cpp(8): note: see declaration of 'SILPassPipelinePlan::SILPassPipelinePlan'
Clang i GCC nie.
Z punktu widzenia specyfikacji, który kompilator jest prawidłowy? Czy jest to błąd MSVC, czy błąd Clang?
MSVC pochodzi z najnowszej aktualizacji Visual Studio 2015 Update 3, Clang w wersji 3.9.0.
Która flaga '-std' przechodzi do Clang i GCC? Usunięcie konstruktora ruchu uległo istotnym zmianom między C++ 11 i C++ 14. – Angew
@Angew brak konkretnych flag. Wypróbuj tutaj: http://rextester.com/WJMW74714 –
Na podstawie tego linku w rextester używasz '-std = C++ 14'. Powinieneś dodać te informacje do pytania. – Angew