Skip to content

Commit 5b5caad

Browse files
committed
Introduce std11::addressof, after value now also for error (#70, thanks @DNKpp)
1 parent 88ee08e commit 5b5caad

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

include/nonstd/expected.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -614,24 +614,24 @@ class storage_t_noncopy_nonmove_impl
614614

615615
// void construct_error( error_type const & e )
616616
// {
617-
// // new( &m_error ) error_type( e );
617+
// // new( std11::addressof(m_error) ) error_type( e );
618618
// }
619619

620620
// void construct_error( error_type && e )
621621
// {
622-
// // new( &m_error ) error_type( std::move( e ) );
622+
// // new( std11::addressof(m_error) ) error_type( std::move( e ) );
623623
// }
624624

625625
template< class... Args >
626626
void emplace_error( Args&&... args )
627627
{
628-
new( &m_error ) error_type( std::forward<Args>(args)...);
628+
new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...);
629629
}
630630

631631
template< class U, class... Args >
632632
void emplace_error( std::initializer_list<U> il, Args&&... args )
633633
{
634-
new( &m_error ) error_type( il, std::forward<Args>(args)... );
634+
new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... );
635635
}
636636

637637
void destruct_error()
@@ -760,24 +760,24 @@ class storage_t_impl
760760

761761
void construct_error( error_type const & e )
762762
{
763-
new( &m_error ) error_type( e );
763+
new( std11::addressof(m_error) ) error_type( e );
764764
}
765765

766766
void construct_error( error_type && e )
767767
{
768-
new( &m_error ) error_type( std::move( e ) );
768+
new( std11::addressof(m_error) ) error_type( std::move( e ) );
769769
}
770770

771771
template< class... Args >
772772
void emplace_error( Args&&... args )
773773
{
774-
new( &m_error ) error_type( std::forward<Args>(args)...);
774+
new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...);
775775
}
776776

777777
template< class U, class... Args >
778778
void emplace_error( std::initializer_list<U> il, Args&&... args )
779779
{
780-
new( &m_error ) error_type( il, std::forward<Args>(args)... );
780+
new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... );
781781
}
782782

783783
void destruct_error()
@@ -876,24 +876,24 @@ struct storage_t_impl< void, E >
876876

877877
void construct_error( error_type const & e )
878878
{
879-
new( &m_error ) error_type( e );
879+
new( std11::addressof(m_error) ) error_type( e );
880880
}
881881

882882
void construct_error( error_type && e )
883883
{
884-
new( &m_error ) error_type( std::move( e ) );
884+
new( std11::addressof(m_error) ) error_type( std::move( e ) );
885885
}
886886

887887
template< class... Args >
888888
void emplace_error( Args&&... args )
889889
{
890-
new( &m_error ) error_type( std::forward<Args>(args)...);
890+
new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...);
891891
}
892892

893893
template< class U, class... Args >
894894
void emplace_error( std::initializer_list<U> il, Args&&... args )
895895
{
896-
new( &m_error ) error_type( il, std::forward<Args>(args)... );
896+
new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... );
897897
}
898898

899899
void destruct_error()

0 commit comments

Comments
 (0)