This is the style I like to use. The returned double will be implicitly converted to a boost::optional which has been set and contains the value of that double. I can't think of any case where this is unsafe. EDIT: There are caveats when the type held by optional<> is bool - see the docs.
This conversion will use this boost::optional constructor:
boost::optional ( T const& v )
where T in this case is double. Note that this constructor is not explicit, and that's been designed precisely to allow the code in your example!
If, elsewhere, the function needs to return an optional object which has not been set, return boost::optional().
References:
http://en.cppreference.com/w/cpp/language/implicit_cast - See bullet 3 about return values.