Created
February 5, 2018 18:05
-
-
Save laverdet/605399df8d837cdcd4107c3aaa7db09b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
marcel@localhost ~/isolated-vm $ g++ thing.cc -std=c++11 | |
thing.cc: In instantiation of 'void MakeThing(Args&& ...) [with Args = {}]': | |
thing.cc:16:12: required from here | |
thing.cc:12:44: error: use of deleted function 'Thing::Thing(const Thing&)' | |
Thing instance(std::forward<Args>(args)...); | |
^ | |
thing.cc:5:2: note: declared here | |
Thing(const Thing&) = delete; | |
^ | |
marcel@localhost ~/isolated-vm $ g++ --version | |
g++ (Gentoo 5.4.0-r3 p1.3, pie-0.6.5) 5.4.0 | |
Copyright (C) 2015 Free Software Foundation, Inc. | |
This is free software; see the source for copying conditions. There is NO | |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
struct Thing { | |
Thing() = default; | |
Thing(const Thing&) = delete; | |
// It works fine if you don't have any virtual methods | |
virtual ~Thing() = default; | |
}; | |
template <typename ...Args> | |
void MakeThing(Args&&... args) { | |
Thing instance(std::forward<Args>(args)...); | |
} | |
int main() { | |
MakeThing(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment