• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 Peter Dimov
2 // Distributed under the Boost Software License, Version 1.0.
3 // https://www.boost.org/LICENSE_1_0.txt)
4 
5 #include <boost/utility/value_init.hpp>
6 #include <boost/core/lightweight_test.hpp>
7 #include <boost/config.hpp>
8 #include <boost/config/pragma_message.hpp>
9 
10 #if __cplusplus >= 201103L || ( defined(BOOST_MSVC) && BOOST_MSVC >= 1900 )
11 
12 struct X
13 {
14     int a;
15     char b;
16 };
17 
18 struct Y: boost::value_initialized<X>
19 {
20     char c = 42;
21 };
22 
main()23 int main()
24 {
25     Y y;
26 
27     BOOST_TEST_EQ( y.data().a, 0 );
28     BOOST_TEST_EQ( y.data().b, 0 );
29     BOOST_TEST_EQ( y.c, 42 );
30 
31     return boost::report_errors();
32 }
33 
34 #else
35 
36 BOOST_PRAGMA_MESSAGE( "Skipping test because compiler doesn't support in-class member initializers" )
37 
main()38 int main() {}
39 
40 #endif
41