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...