Skip to content

Commit

Permalink
Introduce std11::addressof, after value now also for error (#70, thanks
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmoene committed Oct 18, 2024
1 parent 88ee08e commit 5b5caad
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions include/nonstd/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,24 +614,24 @@ class storage_t_noncopy_nonmove_impl

// void construct_error( error_type const & e )
// {
// // new( &m_error ) error_type( e );
// // new( std11::addressof(m_error) ) error_type( e );
// }

// void construct_error( error_type && e )
// {
// // new( &m_error ) error_type( std::move( e ) );
// // new( std11::addressof(m_error) ) error_type( std::move( e ) );
// }

template< class... Args >
void emplace_error( Args&&... args )
{
new( &m_error ) error_type( std::forward<Args>(args)...);
new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...);
}

template< class U, class... Args >
void emplace_error( std::initializer_list<U> il, Args&&... args )
{
new( &m_error ) error_type( il, std::forward<Args>(args)... );
new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... );
}

void destruct_error()
Expand Down Expand Up @@ -760,24 +760,24 @@ class storage_t_impl

void construct_error( error_type const & e )
{
new( &m_error ) error_type( e );
new( std11::addressof(m_error) ) error_type( e );
}

void construct_error( error_type && e )
{
new( &m_error ) error_type( std::move( e ) );
new( std11::addressof(m_error) ) error_type( std::move( e ) );
}

template< class... Args >
void emplace_error( Args&&... args )
{
new( &m_error ) error_type( std::forward<Args>(args)...);
new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...);
}

template< class U, class... Args >
void emplace_error( std::initializer_list<U> il, Args&&... args )
{
new( &m_error ) error_type( il, std::forward<Args>(args)... );
new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... );
}

void destruct_error()
Expand Down Expand Up @@ -876,24 +876,24 @@ struct storage_t_impl< void, E >

void construct_error( error_type const & e )
{
new( &m_error ) error_type( e );
new( std11::addressof(m_error) ) error_type( e );
}

void construct_error( error_type && e )
{
new( &m_error ) error_type( std::move( e ) );
new( std11::addressof(m_error) ) error_type( std::move( e ) );
}

template< class... Args >
void emplace_error( Args&&... args )
{
new( &m_error ) error_type( std::forward<Args>(args)...);
new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...);
}

template< class U, class... Args >
void emplace_error( std::initializer_list<U> il, Args&&... args )
{
new( &m_error ) error_type( il, std::forward<Args>(args)... );
new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... );
}

void destruct_error()
Expand Down

0 comments on commit 5b5caad

Please sign in to comment.