| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  | Copyright 2012-2015 Glen Joseph Fernandes | 
					
						
							|  |  |  | (glenjofe@gmail.com) | 
					
						
							| 
									
										
										
										
											2015-11-09 22:35:34 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  | Distributed under the Boost Software License, Version 1.0. | 
					
						
							|  |  |  | (http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							| 
									
										
										
										
											2015-11-09 22:35:34 -05:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  | #include <boost/align/is_aligned.hpp>
 | 
					
						
							| 
									
										
										
										
											2015-11-09 22:35:34 -05:00
										 |  |  | #include <boost/core/lightweight_test.hpp>
 | 
					
						
							|  |  |  | #include <boost/smart_ptr/make_shared.hpp>
 | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  | #include <boost/smart_ptr/weak_ptr.hpp>
 | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  | #include <type_traits>
 | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class type { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |     static unsigned instances; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     type() | 
					
						
							|  |  |  |         : value_(0.0) { | 
					
						
							|  |  |  |         ++instances; | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     ~type() { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         --instances; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void set(long double value) { | 
					
						
							|  |  |  |         value_ = value; | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     long double get() const { | 
					
						
							|  |  |  |         return value_; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  | private: | 
					
						
							|  |  |  |     type(const type&); | 
					
						
							|  |  |  |     type& operator=(const type&); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     long double value_; | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  | unsigned type::instances = 0; | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-09 22:35:34 -05:00
										 |  |  | int main() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<int[]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<int[]>(3); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<int>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<int[3]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<int[3]>(); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<int>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<int[][2]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<int[][2]>(2); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<int>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<int[2][2]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<int[2][2]>(); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<int>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<const int[]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<const int[]>(3); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<int>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<const int[3]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<const int[3]>(); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<int>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<const int[][2]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<const int[][2]>(2); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<int>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<const int[2][2]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<const int[2][2]>(); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<int>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<type[]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<type[]>(3); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<type>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 3); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::weak_ptr<type[]> other = result; | 
					
						
							|  |  |  |         result.reset(); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<type[3]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<type[3]>(); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<type>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 3); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::weak_ptr<type[3]> other = result; | 
					
						
							|  |  |  |         result.reset(); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<type[][2]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<type[][2]>(2); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<type>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 4); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::weak_ptr<type[][2]> other = result; | 
					
						
							|  |  |  |         result.reset(); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<type[2][2]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<type[2][2]>(); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<type>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 4); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::weak_ptr<type[2][2]> other = result; | 
					
						
							|  |  |  |         result.reset(); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<const type[]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<const type[]>(3); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<type>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 3); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::weak_ptr<const type[]> other = result; | 
					
						
							|  |  |  |         result.reset(); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<const type[3]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<const type[3]>(); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<type>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 3); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::weak_ptr<const type[3]> other = result; | 
					
						
							|  |  |  |         result.reset(); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<const type[][2]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<const type[][2]>(2); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<type>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 4); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::weak_ptr<const type[][2]> other = result; | 
					
						
							|  |  |  |         result.reset(); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::shared_ptr<const type[2][2]> result = | 
					
						
							|  |  |  |             boost::make_shared_noinit<const type[2][2]>(); | 
					
						
							|  |  |  |         BOOST_TEST(result.get() != 0); | 
					
						
							|  |  |  |         BOOST_TEST(result.use_count() == 1); | 
					
						
							|  |  |  |         BOOST_TEST(boost::alignment::is_aligned(result.get(), | 
					
						
							| 
									
										
										
										
											2024-10-06 18:57:30 +03:00
										 |  |  |             std::alignment_of<type>::value)); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 4); | 
					
						
							| 
									
										
										
										
											2017-03-06 01:18:16 -05:00
										 |  |  |         boost::weak_ptr<const type[2][2]> other = result; | 
					
						
							|  |  |  |         result.reset(); | 
					
						
							| 
									
										
										
										
											2014-01-23 20:40:46 -08:00
										 |  |  |         BOOST_TEST(type::instances == 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return boost::report_errors(); | 
					
						
							|  |  |  | } |