]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // |
2 | // atomic_sp_constexpr_test.cpp | |
3 | // | |
11fdf7f2 | 4 | // Copyright 2017, 2018 Peter Dimov |
b32b8144 FG |
5 | // |
6 | // Distributed under the Boost Software License, Version 1.0. | |
7 | // See accompanying file LICENSE_1_0.txt or copy at | |
8 | // http://www.boost.org/LICENSE_1_0.txt | |
9 | // | |
10 | ||
11 | #include <boost/config.hpp> | |
11fdf7f2 TL |
12 | #include <boost/config/workaround.hpp> |
13 | #include <boost/config/pragma_message.hpp> | |
14 | #include <boost/config/helper_macros.hpp> | |
b32b8144 FG |
15 | |
16 | #if defined( BOOST_NO_CXX11_CONSTEXPR ) | |
b32b8144 | 17 | |
11fdf7f2 TL |
18 | BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_NO_CXX11_CONSTEXPR") |
19 | int main() {} | |
b32b8144 | 20 | |
11fdf7f2 TL |
21 | #elif BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) |
22 | ||
23 | // MSVC does not implement static initialization for constexpr | |
24 | BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_MSVC < 1920") | |
25 | int main() {} | |
26 | ||
27 | #elif defined(__clang__) && defined( BOOST_NO_CXX14_CONSTEXPR ) | |
28 | ||
29 | // Clang only implements static initialization for constexpr in C++14 mode | |
30 | BOOST_PRAGMA_MESSAGE("Skipping test due to __clang__ and BOOST_NO_CXX14_CONSTEXPR") | |
31 | int main() {} | |
32 | ||
33 | #elif defined( _LIBCPP_VERSION ) && ( _LIBCPP_VERSION < 6000 ) | |
b32b8144 | 34 | |
b32b8144 | 35 | // in libc++, atomic_flag has a non-constexpr constructor from bool |
11fdf7f2 TL |
36 | BOOST_PRAGMA_MESSAGE("Skipping test due to _LIBCPP_VERSION " BOOST_STRINGIZE(_LIBCPP_VERSION)) |
37 | int main() {} | |
b32b8144 | 38 | |
11fdf7f2 | 39 | #elif defined( BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX ) |
b32b8144 | 40 | |
11fdf7f2 TL |
41 | BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX") |
42 | int main() {} | |
b32b8144 FG |
43 | |
44 | #else | |
45 | ||
46 | #include <boost/smart_ptr/atomic_shared_ptr.hpp> | |
47 | #include <boost/core/lightweight_test.hpp> | |
48 | ||
49 | struct X | |
50 | { | |
51 | }; | |
52 | ||
53 | struct Z | |
54 | { | |
55 | Z(); | |
56 | }; | |
57 | ||
58 | static Z z; | |
59 | ||
60 | static boost::atomic_shared_ptr<X> p1; | |
61 | ||
62 | Z::Z() | |
63 | { | |
64 | p1 = boost::shared_ptr<X>( new X ); | |
65 | } | |
66 | ||
67 | int main() | |
68 | { | |
69 | boost::shared_ptr<X> p2 = p1; | |
70 | ||
71 | BOOST_TEST( p2.get() != 0 ); | |
72 | BOOST_TEST_EQ( p2.use_count(), 2 ); | |
73 | ||
74 | return boost::report_errors(); | |
75 | } | |
76 | ||
11fdf7f2 | 77 | #endif |