Why is `else` omitted after `return` in some libstdc++ `std::expected` methods, but not in others?

I'm reading libstdc++ implementation of std::expected
from master
branch. In the expected
header, on line 864, there's this code:
template<typename _Gr = _Er>
constexpr _Er
error_or(_Gr&& __e) &&
{
static_assert( is_move_constructible_v<_Er> );
static_assert( is_convertible_v<_Gr, _Er> );
if (_M_has_value)
return std::forward<_Gr>(__e);
// <-- Here `else` is omitted.
return std::move(_M_unex);
}
// monadic operations
template<typename _Fn> requires is_constructible_v<_Er, _Er&>
constexpr auto
and_then(_Fn&& __f) &
{
using _Up = __expected::__result<_Fn, _Tp&>;
static_assert(__expected::__is_expected<_Up>,
"the function passed to std::expected<T, E>::and_then "
"must return a std::expected");
static_assert(is_same_v<typename _Up::error_type, _Er>,
"the function passed to std::expected<T, E>::and_then "
"must return a std::expected with the same error_type");
if (has_value())
return std::__invoke(std::forward<_Fn>(__f), _M_val);
else // <-- Here `else` is not omitted.
return _Up(unexpect, _M_unex);
}
As you can see, in error_or
an else
after return is omitted, but in and_then
it isn't. Is this just a style inconsistency? Or is there any other reason that goes beyond code styling?
I tried searching GNU Coding Standards and GCC Coding Conventions but haven't found anything regarding this rule.
Answer
else
after return
is pretty pointless.
If you insist on writing it, that's of course a stylistic choice you can make, but functionally it makes no difference - so why not just leave out the redundant code?
Why a certain implementation chooses one style over another cannot be answered here - you'd have to ask the implementor.
This is simply a case of inconsistent styles used, with no functional differences.