mirror of
https://github.com/boostorg/utility.git
synced 2025-05-08 18:34:02 +00:00
Add test/value_init_test3
This commit is contained in:
parent
8faf831bd1
commit
688628f764
@ -37,6 +37,7 @@ run string_view_test_io.cpp ;
|
||||
|
||||
run value_init_test.cpp ;
|
||||
run value_init_test2.cpp ;
|
||||
run value_init_test3.cpp ;
|
||||
run value_init_workaround_test.cpp ;
|
||||
run initialized_test.cpp ;
|
||||
compile-fail value_init_test_fail1.cpp ;
|
||||
|
40
test/value_init_test3.cpp
Normal file
40
test/value_init_test3.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/utility/value_init.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if __cplusplus >= 201103L || ( defined(BOOST_MSVC) && BOOST_MSVC >= 1900 )
|
||||
|
||||
struct X
|
||||
{
|
||||
int a;
|
||||
char b;
|
||||
};
|
||||
|
||||
struct Y: boost::value_initialized<X>
|
||||
{
|
||||
char c = 42;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Y y;
|
||||
|
||||
BOOST_TEST_EQ( y.data().a, 0 );
|
||||
BOOST_TEST_EQ( y.data().b, 0 );
|
||||
BOOST_TEST_EQ( y.c, 42 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test because compiler doesn't support in-class member initializers" )
|
||||
|
||||
int main() {}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user