Created
November 18, 2017 07:15
-
-
Save matts1/cf3b12845b05ace538766bb5cb8eb5b8 to your computer and use it in GitHub Desktop.
This file contains 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
bool exists = false; | |
class Tester { | |
Tester() = default; | |
Tester& operator=(const Tester&) { | |
if (exists) | |
throw std::runtime_error{}; | |
else | |
exists = true; | |
} | |
}; | |
int main() { | |
Vector<Tester> v; | |
v.push_back(Tester{}); // succeeds | |
try { | |
v.push_back(Tester{}); // std::copy fails | |
} catch (...) {} | |
std::cout << v.size() << '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment