| 
									
										
										
										
											2017-06-18 07:56:42 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // atomic_sp_constexpr_test.cpp
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2018-01-17 16:46:54 +02:00
										 |  |  | // Copyright 2017, 2018 Peter Dimov
 | 
					
						
							| 
									
										
										
										
											2017-06-18 07:56:42 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Distributed under the Boost Software License, Version 1.0.
 | 
					
						
							|  |  |  | // See accompanying file LICENSE_1_0.txt or copy at
 | 
					
						
							|  |  |  | // http://www.boost.org/LICENSE_1_0.txt
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/config.hpp>
 | 
					
						
							| 
									
										
										
										
											2018-01-17 16:46:54 +02:00
										 |  |  | #include <boost/config/workaround.hpp>
 | 
					
						
							|  |  |  | #include <boost/config/pragma_message.hpp>
 | 
					
						
							| 
									
										
										
										
											2018-01-17 19:17:17 +02:00
										 |  |  | #include <boost/config/helper_macros.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-06-18 07:56:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-25 18:08:57 +03:00
										 |  |  | #if BOOST_WORKAROUND( BOOST_MSVC, < 1930 )
 | 
					
						
							| 
									
										
										
										
											2018-01-17 16:46:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-20 18:15:05 +03:00
										 |  |  | // MSVC does not implement static initialization for constexpr constructors
 | 
					
						
							|  |  |  | BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_MSVC < 1930") | 
					
						
							| 
									
										
										
										
											2018-01-17 16:46:54 +02:00
										 |  |  | int main() {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #elif defined(__clang__) && defined( BOOST_NO_CXX14_CONSTEXPR )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Clang only implements static initialization for constexpr in C++14 mode
 | 
					
						
							|  |  |  | BOOST_PRAGMA_MESSAGE("Skipping test due to __clang__ and BOOST_NO_CXX14_CONSTEXPR") | 
					
						
							|  |  |  | int main() {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-17 19:17:17 +02:00
										 |  |  | #elif defined( _LIBCPP_VERSION ) && ( _LIBCPP_VERSION < 6000 )
 | 
					
						
							| 
									
										
										
										
											2017-06-18 07:56:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-20 06:25:27 +03:00
										 |  |  | // in libc++, atomic_flag has a non-constexpr constructor from bool
 | 
					
						
							| 
									
										
										
										
											2018-01-17 19:17:17 +02:00
										 |  |  | BOOST_PRAGMA_MESSAGE("Skipping test due to _LIBCPP_VERSION " BOOST_STRINGIZE(_LIBCPP_VERSION)) | 
					
						
							| 
									
										
										
										
											2018-01-17 16:46:54 +02:00
										 |  |  | int main() {} | 
					
						
							| 
									
										
										
										
											2017-06-20 06:25:27 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-18 07:56:42 +03:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-20 01:48:28 +03:00
										 |  |  | #include <boost/smart_ptr/atomic_shared_ptr.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-06-18 07:56:42 +03:00
										 |  |  | #include <boost/core/lightweight_test.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct X | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct Z | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Z(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static Z z; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static boost::atomic_shared_ptr<X> p1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Z::Z() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     p1 = boost::shared_ptr<X>( new X ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int main() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-06-20 01:48:28 +03:00
										 |  |  |     boost::shared_ptr<X> p2 = p1; | 
					
						
							| 
									
										
										
										
											2017-06-18 07:56:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     BOOST_TEST( p2.get() != 0 ); | 
					
						
							| 
									
										
										
										
											2017-06-20 01:48:28 +03:00
										 |  |  |     BOOST_TEST_EQ( p2.use_count(), 2 ); | 
					
						
							| 
									
										
										
										
											2017-06-18 07:56:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return boost::report_errors(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-17 16:46:54 +02:00
										 |  |  | #endif
 |