|
|
|
|
|
by maccard
1064 days ago
|
|
C++ got this wrong, again. The default usage should be safe, with an escape hatch, i.e. deref operator should be safe and value() should be unsafe. Ideally, a sufficiently smart compiler would be able to see code like if (auto t = get_optional())
{
do_something(*t);
}
And elide the double safety check, but because optional is a library feature not a language feature, the compiler needs to detect general usages of that pattern rather than specifically optimising for a language level construct. That's another place c++ is going in the wrong direction in... |
|