Skip to content

Instantly share code, notes, and snippets.

@matts1
Created November 18, 2017 07:15
Show Gist options
  • Save matts1/cf3b12845b05ace538766bb5cb8eb5b8 to your computer and use it in GitHub Desktop.
Save matts1/cf3b12845b05ace538766bb5cb8eb5b8 to your computer and use it in GitHub Desktop.
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