mirror of
https://github.com/boostorg/optional.git
synced 2025-07-15 21:32:17 +02:00
Added test to ensure proper binding of optional references (in reference to Ticket 1301)
[SVN r40707]
This commit is contained in:
@ -337,12 +337,30 @@ void test_with_class_type()
|
||||
BOOST_CHECK ( X::count == 0 ) ;
|
||||
}
|
||||
|
||||
void test_binding()
|
||||
{
|
||||
int i = 0 ;
|
||||
optional<int&> ori1 = i ;
|
||||
BOOST_CHECK( &(*ori1) == &i ) ;
|
||||
|
||||
optional<int&> ori2(i) ;
|
||||
BOOST_CHECK( &(*ori2) == &i ) ;
|
||||
|
||||
int const ci = 0 ;
|
||||
optional<int const&> orci1 = ci ;
|
||||
BOOST_CHECK( &(*orci1) == &ci ) ;
|
||||
|
||||
optional<int const&> orci2 = ci ;
|
||||
BOOST_CHECK( &(*orci2) == &ci ) ;
|
||||
}
|
||||
|
||||
int test_main( int, char* [] )
|
||||
{
|
||||
try
|
||||
{
|
||||
test_with_class_type();
|
||||
test_with_builtin_types();
|
||||
test_binding();
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
|
Reference in New Issue
Block a user