You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move-constructor expected( U && value of expected calls contained.construct_value( std::forward<U>( value ) );
which leads to new(&m_value) value_type(std::forward<Args>(args)...);
which degrades to calling new(&m_value) bool(std::forward<Args>(args)...);
in the case of E=bool.
This means that if the expected object passed as rvalue has a value of false, the bool operator will still return true as it only checks has_value().
The text was updated successfully, but these errors were encountered:
A specialized version of storage_t seems to resolve this issue.
I may have provided more member functions than required, but this is a fast fix as an inspiration. Also, I do not think we need placement new in such a trivial case.
Upd.: No idea what gh does with code formatting here...
/// discriminated union to hold bool and 'error'.
template< typename E >
union storage_t<bool, E>
{
friend class expected<bool,E>;
Move-constructor
expected( U && value
of expected callscontained.construct_value( std::forward<U>( value ) );
which leads to
new(&m_value) value_type(std::forward<Args>(args)...);
which degrades to calling
new(&m_value) bool(std::forward<Args>(args)...);
in the case of E=bool.
This means that if the expected object passed as rvalue has a value of false, the bool operator will still return true as it only checks
has_value()
.The text was updated successfully, but these errors were encountered: