Date: Sun, 25 Feb 2024 16:47:20 +0100
> { _Bulldoze;
> std::string s(":3");
> std::cout << s;
> }
In this example, what is supposed to happen if std::string::string
throws std::bad_alloc?
Is it supposed to magically create a hypothetical string which is
initialized using the hypothetical value that a string would have if
hypothetically speaking, the constructor didn't throw?
It neither seems feasible nor desirable to suppress all exceptions as
if they didn't happen. Even in the cases where it's not outright
unimplementable, it can totally mess up class invariants and other
assumptions about internal state.
Bad idea.
> std::string s(":3");
> std::cout << s;
> }
In this example, what is supposed to happen if std::string::string
throws std::bad_alloc?
Is it supposed to magically create a hypothetical string which is
initialized using the hypothetical value that a string would have if
hypothetically speaking, the constructor didn't throw?
It neither seems feasible nor desirable to suppress all exceptions as
if they didn't happen. Even in the cases where it's not outright
unimplementable, it can totally mess up class invariants and other
assumptions about internal state.
Bad idea.
Received on 2024-02-25 15:47:31