PageRenderTime 57ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/boost_1_57_0/libs/container/test/scoped_allocator_adaptor_test.cpp

http://github.com/MisterTea/HyperNEAT
C++ | 1473 lines | 1253 code | 107 blank | 113 comment | 215 complexity | f2b94d849017758f25a98f231b2c2931 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0, GPL-3.0, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #include <boost/container/detail/config_begin.hpp>
  11. #include <boost/container/scoped_allocator_fwd.hpp>
  12. #include <boost/container/detail/utilities.hpp>
  13. #include <cstddef>
  14. #include <boost/container/detail/mpl.hpp>
  15. #include <boost/move/utility_core.hpp>
  16. #include <memory>
  17. using namespace boost::container;
  18. template<class T, unsigned int Id, bool Propagate = false>
  19. class test_allocator
  20. {
  21. BOOST_COPYABLE_AND_MOVABLE(test_allocator)
  22. public:
  23. template<class U>
  24. struct rebind
  25. {
  26. typedef test_allocator<U, Id, Propagate> other;
  27. };
  28. typedef container_detail::bool_<Propagate> propagate_on_container_copy_assignment;
  29. typedef container_detail::bool_<Propagate> propagate_on_container_move_assignment;
  30. typedef container_detail::bool_<Propagate> propagate_on_container_swap;
  31. typedef T value_type;
  32. test_allocator()
  33. : m_move_contructed(false), m_move_assigned(false)
  34. {}
  35. test_allocator(const test_allocator&)
  36. : m_move_contructed(false), m_move_assigned(false)
  37. {}
  38. test_allocator(BOOST_RV_REF(test_allocator) )
  39. : m_move_contructed(true), m_move_assigned(false)
  40. {}
  41. template<class U>
  42. test_allocator(BOOST_RV_REF_BEG test_allocator<U, Id, Propagate> BOOST_RV_REF_END)
  43. : m_move_contructed(true), m_move_assigned(false)
  44. {}
  45. template<class U>
  46. test_allocator(const test_allocator<U, Id, Propagate> &)
  47. {}
  48. test_allocator & operator=(BOOST_COPY_ASSIGN_REF(test_allocator))
  49. {
  50. return *this;
  51. }
  52. test_allocator & operator=(BOOST_RV_REF(test_allocator))
  53. {
  54. m_move_assigned = true;
  55. return *this;
  56. }
  57. std::size_t max_size() const
  58. { return std::size_t(-1); }
  59. T* allocate(std::size_t n)
  60. { return (T*)::new char[n*sizeof(T)]; }
  61. void deallocate(T*p, std::size_t)
  62. { delete []static_cast<char*>(static_cast<void*>(p)); }
  63. bool m_move_contructed;
  64. bool m_move_assigned;
  65. };
  66. template <class T1, class T2, unsigned int Id, bool Propagate>
  67. bool operator==( const test_allocator<T1, Id, Propagate>&
  68. , const test_allocator<T2, Id, Propagate>&)
  69. { return true; }
  70. template <class T1, class T2, unsigned int Id, bool Propagate>
  71. bool operator!=( const test_allocator<T1, Id, Propagate>&
  72. , const test_allocator<T2, Id, Propagate>&)
  73. { return false; }
  74. template<unsigned int Type>
  75. struct tagged_integer
  76. {};
  77. struct mark_on_destructor
  78. {
  79. mark_on_destructor()
  80. : destroyed(false)
  81. {}
  82. ~mark_on_destructor()
  83. {
  84. destroyed = true;
  85. }
  86. bool destroyed;
  87. };
  88. //This enum lists the construction options
  89. //for an allocator-aware type
  90. enum ConstructionTypeEnum
  91. {
  92. ConstructiblePrefix,
  93. ConstructibleSuffix,
  94. NotUsesAllocator
  95. };
  96. //This base class provices types for
  97. //the derived class to implement each construction
  98. //type. If a construction type does not apply
  99. //the typedef is set to an internal nat
  100. //so that the class is not constructible from
  101. //the user arguments.
  102. template<ConstructionTypeEnum ConstructionType, unsigned int AllocatorTag>
  103. struct uses_allocator_base;
  104. template<unsigned int AllocatorTag>
  105. struct uses_allocator_base<ConstructibleSuffix, AllocatorTag>
  106. {
  107. typedef test_allocator<int, AllocatorTag> allocator_type;
  108. typedef allocator_type allocator_constructor_type;
  109. struct nat{};
  110. typedef nat allocator_arg_type;
  111. };
  112. template<unsigned int AllocatorTag>
  113. struct uses_allocator_base<ConstructiblePrefix, AllocatorTag>
  114. {
  115. typedef test_allocator<int, AllocatorTag> allocator_type;
  116. typedef allocator_type allocator_constructor_type;
  117. typedef allocator_arg_t allocator_arg_type;
  118. };
  119. template<unsigned int AllocatorTag>
  120. struct uses_allocator_base<NotUsesAllocator, AllocatorTag>
  121. {
  122. struct nat{};
  123. typedef nat allocator_constructor_type;
  124. typedef nat allocator_arg_type;
  125. };
  126. template<ConstructionTypeEnum ConstructionType, unsigned int AllocatorTag>
  127. struct mark_on_scoped_allocation
  128. : uses_allocator_base<ConstructionType, AllocatorTag>
  129. {
  130. private:
  131. BOOST_COPYABLE_AND_MOVABLE(mark_on_scoped_allocation)
  132. public:
  133. typedef uses_allocator_base<ConstructionType, AllocatorTag> base_type;
  134. //0 user argument constructors
  135. mark_on_scoped_allocation()
  136. : construction_type(NotUsesAllocator), value(0)
  137. {}
  138. explicit mark_on_scoped_allocation
  139. (typename base_type::allocator_constructor_type)
  140. : construction_type(ConstructibleSuffix), value(0)
  141. {}
  142. explicit mark_on_scoped_allocation
  143. (typename base_type::allocator_arg_type, typename base_type::allocator_constructor_type)
  144. : construction_type(ConstructiblePrefix), value(0)
  145. {}
  146. //1 user argument constructors
  147. explicit mark_on_scoped_allocation(int i)
  148. : construction_type(NotUsesAllocator), value(i)
  149. {}
  150. mark_on_scoped_allocation
  151. (int i, typename base_type::allocator_constructor_type)
  152. : construction_type(ConstructibleSuffix), value(i)
  153. {}
  154. mark_on_scoped_allocation
  155. ( typename base_type::allocator_arg_type
  156. , typename base_type::allocator_constructor_type
  157. , int i)
  158. : construction_type(ConstructiblePrefix), value(i)
  159. {}
  160. //Copy constructors
  161. mark_on_scoped_allocation(const mark_on_scoped_allocation &other)
  162. : construction_type(NotUsesAllocator), value(other.value)
  163. {}
  164. mark_on_scoped_allocation( const mark_on_scoped_allocation &other
  165. , typename base_type::allocator_constructor_type)
  166. : construction_type(ConstructibleSuffix), value(other.value)
  167. {}
  168. mark_on_scoped_allocation( typename base_type::allocator_arg_type
  169. , typename base_type::allocator_constructor_type
  170. , const mark_on_scoped_allocation &other)
  171. : construction_type(ConstructiblePrefix), value(other.value)
  172. {}
  173. //Move constructors
  174. mark_on_scoped_allocation(BOOST_RV_REF(mark_on_scoped_allocation) other)
  175. : construction_type(NotUsesAllocator), value(other.value)
  176. { other.value = 0; other.construction_type = NotUsesAllocator; }
  177. mark_on_scoped_allocation( BOOST_RV_REF(mark_on_scoped_allocation) other
  178. , typename base_type::allocator_constructor_type)
  179. : construction_type(ConstructibleSuffix), value(other.value)
  180. { other.value = 0; other.construction_type = ConstructibleSuffix; }
  181. mark_on_scoped_allocation( typename base_type::allocator_arg_type
  182. , typename base_type::allocator_constructor_type
  183. , BOOST_RV_REF(mark_on_scoped_allocation) other)
  184. : construction_type(ConstructiblePrefix), value(other.value)
  185. { other.value = 0; other.construction_type = ConstructiblePrefix; }
  186. ConstructionTypeEnum construction_type;
  187. int value;
  188. };
  189. namespace boost {
  190. namespace container {
  191. template<unsigned int AllocatorTag>
  192. struct constructible_with_allocator_prefix
  193. < ::mark_on_scoped_allocation<ConstructiblePrefix, AllocatorTag> >
  194. : ::boost::true_type
  195. {};
  196. template<unsigned int AllocatorTag>
  197. struct constructible_with_allocator_suffix
  198. < ::mark_on_scoped_allocation<ConstructibleSuffix, AllocatorTag> >
  199. : ::boost::true_type
  200. {};
  201. } //namespace container {
  202. } //namespace boost {
  203. #include <boost/container/scoped_allocator.hpp>
  204. #include <boost/type_traits/is_same.hpp>
  205. #include <boost/static_assert.hpp>
  206. #include <boost/container/vector.hpp>
  207. #include <boost/container/detail/pair.hpp>
  208. int main()
  209. {
  210. typedef test_allocator<tagged_integer<0>, 0> OuterAlloc;
  211. typedef test_allocator<tagged_integer<0>, 10> Outer10IdAlloc;
  212. typedef test_allocator<tagged_integer<9>, 0> Rebound9OuterAlloc;
  213. typedef test_allocator<tagged_integer<1>, 1> InnerAlloc1;
  214. typedef test_allocator<tagged_integer<2>, 2> InnerAlloc2;
  215. typedef test_allocator<tagged_integer<1>, 11> Inner11IdAlloc1;
  216. typedef test_allocator<tagged_integer<0>, 0, false> OuterAllocFalsePropagate;
  217. typedef test_allocator<tagged_integer<0>, 0, true> OuterAllocTruePropagate;
  218. typedef test_allocator<tagged_integer<1>, 1, false> InnerAlloc1FalsePropagate;
  219. typedef test_allocator<tagged_integer<1>, 1, true> InnerAlloc1TruePropagate;
  220. typedef test_allocator<tagged_integer<2>, 2, false> InnerAlloc2FalsePropagate;
  221. typedef test_allocator<tagged_integer<2>, 2, true> InnerAlloc2TruePropagate;
  222. //
  223. typedef scoped_allocator_adaptor< OuterAlloc > Scoped0Inner;
  224. typedef scoped_allocator_adaptor< OuterAlloc
  225. , InnerAlloc1 > Scoped1Inner;
  226. typedef scoped_allocator_adaptor< OuterAlloc
  227. , InnerAlloc1
  228. , InnerAlloc2 > Scoped2Inner;
  229. typedef scoped_allocator_adaptor
  230. < scoped_allocator_adaptor
  231. <Outer10IdAlloc>
  232. > ScopedScoped0Inner;
  233. typedef scoped_allocator_adaptor
  234. < scoped_allocator_adaptor
  235. <Outer10IdAlloc, Inner11IdAlloc1>
  236. , InnerAlloc1
  237. > ScopedScoped1Inner;
  238. typedef scoped_allocator_adaptor< Rebound9OuterAlloc > Rebound9Scoped0Inner;
  239. typedef scoped_allocator_adaptor< Rebound9OuterAlloc
  240. , InnerAlloc1 > Rebound9Scoped1Inner;
  241. typedef scoped_allocator_adaptor< Rebound9OuterAlloc
  242. , InnerAlloc1
  243. , InnerAlloc2 > Rebound9Scoped2Inner;
  244. //outer_allocator_type
  245. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< OuterAlloc
  246. , Scoped0Inner::outer_allocator_type>::value ));
  247. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< OuterAlloc
  248. , Scoped1Inner::outer_allocator_type>::value ));
  249. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< OuterAlloc
  250. , Scoped2Inner::outer_allocator_type>::value ));
  251. //value_type
  252. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::value_type
  253. , Scoped0Inner::value_type>::value ));
  254. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::value_type
  255. , Scoped1Inner::value_type>::value ));
  256. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::value_type
  257. , Scoped2Inner::value_type>::value ));
  258. //size_type
  259. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::size_type
  260. , Scoped0Inner::size_type>::value ));
  261. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::size_type
  262. , Scoped1Inner::size_type>::value ));
  263. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::size_type
  264. , Scoped2Inner::size_type>::value ));
  265. //difference_type
  266. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::difference_type
  267. , Scoped0Inner::difference_type>::value ));
  268. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::difference_type
  269. , Scoped1Inner::difference_type>::value ));
  270. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::difference_type
  271. , Scoped2Inner::difference_type>::value ));
  272. //pointer
  273. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::pointer
  274. , Scoped0Inner::pointer>::value ));
  275. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::pointer
  276. , Scoped1Inner::pointer>::value ));
  277. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::pointer
  278. , Scoped2Inner::pointer>::value ));
  279. //const_pointer
  280. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::const_pointer
  281. , Scoped0Inner::const_pointer>::value ));
  282. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::const_pointer
  283. , Scoped1Inner::const_pointer>::value ));
  284. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::const_pointer
  285. , Scoped2Inner::const_pointer>::value ));
  286. //void_pointer
  287. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::void_pointer
  288. , Scoped0Inner::void_pointer>::value ));
  289. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::void_pointer
  290. , Scoped1Inner::void_pointer>::value ));
  291. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::void_pointer
  292. , Scoped2Inner::void_pointer>::value ));
  293. //const_void_pointer
  294. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::const_void_pointer
  295. , Scoped0Inner::const_void_pointer>::value ));
  296. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::const_void_pointer
  297. , Scoped1Inner::const_void_pointer>::value ));
  298. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< allocator_traits<OuterAlloc>::const_void_pointer
  299. , Scoped2Inner::const_void_pointer>::value ));
  300. //rebind
  301. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same<Scoped0Inner::rebind< tagged_integer<9> >::other
  302. , Rebound9Scoped0Inner >::value ));
  303. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same<Scoped1Inner::rebind< tagged_integer<9> >::other
  304. , Rebound9Scoped1Inner >::value ));
  305. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same<Scoped2Inner::rebind< tagged_integer<9> >::other
  306. , Rebound9Scoped2Inner >::value ));
  307. //inner_allocator_type
  308. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< Scoped0Inner
  309. , Scoped0Inner::inner_allocator_type>::value ));
  310. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< scoped_allocator_adaptor<InnerAlloc1>
  311. , Scoped1Inner::inner_allocator_type>::value ));
  312. BOOST_STATIC_ASSERT(( boost::container::container_detail::is_same< scoped_allocator_adaptor<InnerAlloc1, InnerAlloc2>
  313. , Scoped2Inner::inner_allocator_type>::value ));
  314. {
  315. //Propagation test
  316. typedef scoped_allocator_adaptor< OuterAllocFalsePropagate > Scoped0InnerF;
  317. typedef scoped_allocator_adaptor< OuterAllocTruePropagate > Scoped0InnerT;
  318. typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
  319. , InnerAlloc1FalsePropagate > Scoped1InnerFF;
  320. typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
  321. , InnerAlloc1TruePropagate > Scoped1InnerFT;
  322. typedef scoped_allocator_adaptor< OuterAllocTruePropagate
  323. , InnerAlloc1FalsePropagate > Scoped1InnerTF;
  324. typedef scoped_allocator_adaptor< OuterAllocTruePropagate
  325. , InnerAlloc1TruePropagate > Scoped1InnerTT;
  326. typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
  327. , InnerAlloc1FalsePropagate
  328. , InnerAlloc2FalsePropagate > Scoped2InnerFFF;
  329. typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
  330. , InnerAlloc1FalsePropagate
  331. , InnerAlloc2TruePropagate > Scoped2InnerFFT;
  332. typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
  333. , InnerAlloc1TruePropagate
  334. , InnerAlloc2FalsePropagate > Scoped2InnerFTF;
  335. typedef scoped_allocator_adaptor< OuterAllocFalsePropagate
  336. , InnerAlloc1TruePropagate
  337. , InnerAlloc2TruePropagate > Scoped2InnerFTT;
  338. typedef scoped_allocator_adaptor< OuterAllocTruePropagate
  339. , InnerAlloc1FalsePropagate
  340. , InnerAlloc2FalsePropagate > Scoped2InnerTFF;
  341. typedef scoped_allocator_adaptor< OuterAllocTruePropagate
  342. , InnerAlloc1FalsePropagate
  343. , InnerAlloc2TruePropagate > Scoped2InnerTFT;
  344. typedef scoped_allocator_adaptor< OuterAllocTruePropagate
  345. , InnerAlloc1TruePropagate
  346. , InnerAlloc2FalsePropagate > Scoped2InnerTTF;
  347. typedef scoped_allocator_adaptor< OuterAllocTruePropagate
  348. , InnerAlloc1TruePropagate
  349. , InnerAlloc2TruePropagate > Scoped2InnerTTT;
  350. //propagate_on_container_copy_assignment
  351. //0 inner
  352. BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_copy_assignment::value ));
  353. BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_copy_assignment::value ));
  354. //1 inner
  355. BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_copy_assignment::value ));
  356. BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_copy_assignment::value ));
  357. BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_copy_assignment::value ));
  358. BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_copy_assignment::value ));
  359. //2 inner
  360. BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_copy_assignment::value ));
  361. BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_copy_assignment::value ));
  362. BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_copy_assignment::value ));
  363. BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_copy_assignment::value ));
  364. BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_copy_assignment::value ));
  365. BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_copy_assignment::value ));
  366. BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_copy_assignment::value ));
  367. BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_copy_assignment::value ));
  368. //propagate_on_container_move_assignment
  369. //0 inner
  370. BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_move_assignment::value ));
  371. BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_move_assignment::value ));
  372. //1 inner
  373. BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_move_assignment::value ));
  374. BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_move_assignment::value ));
  375. BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_move_assignment::value ));
  376. BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_move_assignment::value ));
  377. //2 inner
  378. BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_move_assignment::value ));
  379. BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_move_assignment::value ));
  380. BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_move_assignment::value ));
  381. BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_move_assignment::value ));
  382. BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_move_assignment::value ));
  383. BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_move_assignment::value ));
  384. BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_move_assignment::value ));
  385. BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_move_assignment::value ));
  386. //propagate_on_container_swap
  387. //0 inner
  388. BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_swap::value ));
  389. BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_swap::value ));
  390. //1 inner
  391. BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_swap::value ));
  392. BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_swap::value ));
  393. BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_swap::value ));
  394. BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_swap::value ));
  395. //2 inner
  396. BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_swap::value ));
  397. BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_swap::value ));
  398. BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_swap::value ));
  399. BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_swap::value ));
  400. BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_swap::value ));
  401. BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_swap::value ));
  402. BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_swap::value ));
  403. BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_swap::value ));
  404. }
  405. //Default constructor
  406. {
  407. Scoped0Inner s0i;
  408. Scoped1Inner s1i;
  409. //Swap
  410. {
  411. Scoped0Inner s0i2;
  412. Scoped1Inner s1i2;
  413. boost::container::swap_dispatch(s0i, s0i2);
  414. boost::container::swap_dispatch(s1i, s1i2);
  415. }
  416. }
  417. //Default constructor
  418. {
  419. Scoped0Inner s0i;
  420. Scoped1Inner s1i;
  421. }
  422. //Copy constructor/assignment
  423. {
  424. Scoped0Inner s0i;
  425. Scoped1Inner s1i;
  426. Scoped2Inner s2i;
  427. Scoped0Inner s0i_b(s0i);
  428. Scoped1Inner s1i_b(s1i);
  429. Scoped2Inner s2i_b(s2i);
  430. if(!(s0i == s0i_b) ||
  431. !(s1i == s1i_b) ||
  432. !(s2i == s2i_b)
  433. ){
  434. return 1;
  435. }
  436. s0i_b = s0i;
  437. s1i_b = s1i;
  438. s2i_b = s2i;
  439. if(!(s0i == s0i_b) ||
  440. !(s1i == s1i_b) ||
  441. !(s2i == s2i_b)
  442. ){
  443. return 1;
  444. }
  445. }
  446. //Copy/move constructor/assignment
  447. {
  448. Scoped0Inner s0i;
  449. Scoped1Inner s1i;
  450. Scoped2Inner s2i;
  451. Scoped0Inner s0i_b(::boost::move(s0i));
  452. Scoped1Inner s1i_b(::boost::move(s1i));
  453. Scoped2Inner s2i_b(::boost::move(s2i));
  454. if(!(s0i_b.outer_allocator().m_move_contructed) ||
  455. !(s1i_b.outer_allocator().m_move_contructed) ||
  456. !(s2i_b.outer_allocator().m_move_contructed)
  457. ){
  458. return 1;
  459. }
  460. s0i_b = ::boost::move(s0i);
  461. s1i_b = ::boost::move(s1i);
  462. s2i_b = ::boost::move(s2i);
  463. if(!(s0i_b.outer_allocator().m_move_assigned) ||
  464. !(s1i_b.outer_allocator().m_move_assigned) ||
  465. !(s2i_b.outer_allocator().m_move_assigned)
  466. ){
  467. return 1;
  468. }
  469. }
  470. //inner_allocator()
  471. {
  472. Scoped0Inner s0i;
  473. Scoped1Inner s1i;
  474. Scoped2Inner s2i;
  475. const Scoped0Inner const_s0i;
  476. const Scoped1Inner const_s1i;
  477. const Scoped2Inner const_s2i;
  478. Scoped0Inner::inner_allocator_type &s0i_inner = s0i.inner_allocator();
  479. (void)s0i_inner;
  480. const Scoped0Inner::inner_allocator_type &const_s0i_inner = const_s0i.inner_allocator();
  481. (void)const_s0i_inner;
  482. Scoped1Inner::inner_allocator_type &s1i_inner = s1i.inner_allocator();
  483. (void)s1i_inner;
  484. const Scoped1Inner::inner_allocator_type &const_s1i_inner = const_s1i.inner_allocator();
  485. (void)const_s1i_inner;
  486. Scoped2Inner::inner_allocator_type &s2i_inner = s2i.inner_allocator();
  487. (void)s2i_inner;
  488. const Scoped2Inner::inner_allocator_type &const_s2i_inner = const_s2i.inner_allocator();
  489. (void)const_s2i_inner;
  490. }
  491. //operator==/!=
  492. {
  493. const Scoped0Inner const_s0i;
  494. const Rebound9Scoped0Inner const_rs0i;
  495. if(!(const_s0i == const_s0i) ||
  496. !(const_rs0i == const_s0i)){
  497. return 1;
  498. }
  499. if( const_s0i != const_s0i ||
  500. const_s0i != const_rs0i ){
  501. return 1;
  502. }
  503. const Scoped1Inner const_s1i;
  504. const Rebound9Scoped1Inner const_rs1i;
  505. if(!(const_s1i == const_s1i) ||
  506. !(const_rs1i == const_s1i)){
  507. return 1;
  508. }
  509. if( const_s1i != const_s1i ||
  510. const_s1i != const_rs1i ){
  511. return 1;
  512. }
  513. const Scoped2Inner const_s2i;
  514. const Rebound9Scoped2Inner const_rs2i;
  515. if(!(const_s2i == const_s2i) ||
  516. !(const_s2i == const_rs2i) ){
  517. return 1;
  518. }
  519. if( const_s2i != const_s2i ||
  520. const_s2i != const_rs2i ){
  521. return 1;
  522. }
  523. }
  524. //outer_allocator()
  525. {
  526. Scoped0Inner s0i;
  527. Scoped1Inner s1i;
  528. Scoped2Inner s2i;
  529. const Scoped0Inner const_s0i;
  530. const Scoped1Inner const_s1i;
  531. const Scoped2Inner const_s2i;
  532. Scoped0Inner::outer_allocator_type &s0i_inner = s0i.outer_allocator();
  533. (void)s0i_inner;
  534. const Scoped0Inner::outer_allocator_type &const_s0i_inner = const_s0i.outer_allocator();
  535. (void)const_s0i_inner;
  536. Scoped1Inner::outer_allocator_type &s1i_inner = s1i.outer_allocator();
  537. (void)s1i_inner;
  538. const Scoped1Inner::outer_allocator_type &const_s1i_inner = const_s1i.outer_allocator();
  539. (void)const_s1i_inner;
  540. Scoped2Inner::outer_allocator_type &s2i_inner = s2i.outer_allocator();
  541. (void)s2i_inner;
  542. const Scoped2Inner::outer_allocator_type &const_s2i_inner = const_s2i.outer_allocator();
  543. (void)const_s2i_inner;
  544. }
  545. //max_size()
  546. {
  547. const Scoped0Inner const_s0i;
  548. const Scoped1Inner const_s1i;
  549. const Scoped2Inner const_s2i;
  550. const OuterAlloc const_oa;
  551. const InnerAlloc1 const_ia1;
  552. const InnerAlloc2 const_ia2;
  553. if(const_s0i.max_size() != const_oa.max_size()){
  554. return 1;
  555. }
  556. if(const_s1i.max_size() != const_oa.max_size()){
  557. return 1;
  558. }
  559. if(const_s2i.max_size() != const_oa.max_size()){
  560. return 1;
  561. }
  562. if(const_s1i.inner_allocator().max_size() != const_ia1.max_size()){
  563. return 1;
  564. }
  565. if(const_s2i.inner_allocator().inner_allocator().max_size() != const_ia2.max_size()){
  566. return 1;
  567. }
  568. }
  569. //Copy and move operations
  570. {
  571. //Construction
  572. {
  573. Scoped0Inner s0i_a, s0i_b(s0i_a), s0i_c(::boost::move(s0i_b));
  574. Scoped1Inner s1i_a, s1i_b(s1i_a), s1i_c(::boost::move(s1i_b));
  575. Scoped2Inner s2i_a, s2i_b(s2i_a), s2i_c(::boost::move(s2i_b));
  576. }
  577. //Assignment
  578. {
  579. Scoped0Inner s0i_a, s0i_b;
  580. s0i_a = s0i_b;
  581. s0i_a = ::boost::move(s0i_b);
  582. Scoped1Inner s1i_a, s1i_b;
  583. s1i_a = s1i_b;
  584. s1i_a = ::boost::move(s1i_b);
  585. Scoped2Inner s2i_a, s2i_b;
  586. s2i_a = s2i_b;
  587. s2i_a = ::boost::move(s2i_b);
  588. }
  589. OuterAlloc oa;
  590. InnerAlloc1 ia1;
  591. InnerAlloc2 ia2;
  592. Rebound9OuterAlloc roa;
  593. Rebound9Scoped0Inner rs0i;
  594. Rebound9Scoped1Inner rs1i;
  595. Rebound9Scoped2Inner rs2i;
  596. //Copy from outer
  597. {
  598. Scoped0Inner s0i(oa);
  599. Scoped1Inner s1i(oa, ia1);
  600. Scoped2Inner s2i(oa, ia1, ia2);
  601. }
  602. //Move from outer
  603. {
  604. Scoped0Inner s0i(::boost::move(oa));
  605. Scoped1Inner s1i(::boost::move(oa), ia1);
  606. Scoped2Inner s2i(::boost::move(oa), ia1, ia2);
  607. }
  608. //Copy from rebound outer
  609. {
  610. Scoped0Inner s0i(roa);
  611. Scoped1Inner s1i(roa, ia1);
  612. Scoped2Inner s2i(roa, ia1, ia2);
  613. }
  614. //Move from rebound outer
  615. {
  616. Scoped0Inner s0i(::boost::move(roa));
  617. Scoped1Inner s1i(::boost::move(roa), ia1);
  618. Scoped2Inner s2i(::boost::move(roa), ia1, ia2);
  619. }
  620. //Copy from rebound scoped
  621. {
  622. Scoped0Inner s0i(rs0i);
  623. Scoped1Inner s1i(rs1i);
  624. Scoped2Inner s2i(rs2i);
  625. }
  626. //Move from rebound scoped
  627. {
  628. Scoped0Inner s0i(::boost::move(rs0i));
  629. Scoped1Inner s1i(::boost::move(rs1i));
  630. Scoped2Inner s2i(::boost::move(rs2i));
  631. }
  632. }
  633. {
  634. vector<int, scoped_allocator_adaptor< test_allocator<int, 0> > > dummy;
  635. dummy.push_back(0);
  636. }
  637. //destroy()
  638. {
  639. {
  640. Scoped0Inner s0i;
  641. mark_on_destructor mod;
  642. s0i.destroy(&mod);
  643. if(!mod.destroyed){
  644. return 1;
  645. }
  646. }
  647. {
  648. Scoped1Inner s1i;
  649. mark_on_destructor mod;
  650. s1i.destroy(&mod);
  651. if(!mod.destroyed){
  652. return 1;
  653. }
  654. }
  655. {
  656. Scoped2Inner s2i;
  657. mark_on_destructor mod;
  658. s2i.destroy(&mod);
  659. if(!mod.destroyed){
  660. return 1;
  661. }
  662. }
  663. }
  664. //construct
  665. {
  666. BOOST_STATIC_ASSERT(( !boost::container::uses_allocator
  667. < ::mark_on_scoped_allocation<NotUsesAllocator, 0>
  668. , test_allocator<float, 0>
  669. >::value ));
  670. BOOST_STATIC_ASSERT(( boost::container::uses_allocator
  671. < ::mark_on_scoped_allocation<ConstructiblePrefix, 0>
  672. , test_allocator<float, 0>
  673. >::value ));
  674. BOOST_STATIC_ASSERT(( boost::container::uses_allocator
  675. < ::mark_on_scoped_allocation<ConstructibleSuffix, 0>
  676. , test_allocator<float, 0>
  677. >::value ));
  678. BOOST_STATIC_ASSERT(( boost::container::constructible_with_allocator_prefix
  679. < ::mark_on_scoped_allocation<ConstructiblePrefix, 0> >::value ));
  680. BOOST_STATIC_ASSERT(( boost::container::constructible_with_allocator_suffix
  681. < ::mark_on_scoped_allocation<ConstructibleSuffix, 0> >::value ));
  682. ////////////////////////////////////////////////////////////
  683. //First check scoped allocator with just OuterAlloc.
  684. //In this case OuterAlloc (test_allocator with tag 0) should be
  685. //used to construct types.
  686. ////////////////////////////////////////////////////////////
  687. {
  688. Scoped0Inner s0i;
  689. //Check construction with 0 user arguments
  690. {
  691. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 0> MarkType;
  692. MarkType dummy;
  693. dummy.~MarkType();
  694. s0i.construct(&dummy);
  695. if(dummy.construction_type != NotUsesAllocator ||
  696. dummy.value != 0){
  697. dummy.~MarkType();
  698. return 1;
  699. }
  700. dummy.~MarkType();
  701. }
  702. {
  703. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 0> MarkType;
  704. MarkType dummy;
  705. dummy.~MarkType();
  706. s0i.construct(&dummy);
  707. if(dummy.construction_type != ConstructibleSuffix ||
  708. dummy.value != 0){
  709. dummy.~MarkType();
  710. return 1;
  711. }
  712. dummy.~MarkType();
  713. }
  714. {
  715. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 0> MarkType;
  716. MarkType dummy;
  717. dummy.~MarkType();
  718. s0i.construct(&dummy);
  719. if(dummy.construction_type != ConstructiblePrefix ||
  720. dummy.value != 0){
  721. dummy.~MarkType();
  722. return 1;
  723. }
  724. dummy.~MarkType();
  725. }
  726. //Check construction with 1 user arguments
  727. {
  728. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 0> MarkType;
  729. MarkType dummy;
  730. dummy.~MarkType();
  731. s0i.construct(&dummy, 1);
  732. if(dummy.construction_type != NotUsesAllocator ||
  733. dummy.value != 1){
  734. dummy.~MarkType();
  735. return 1;
  736. }
  737. dummy.~MarkType();
  738. }
  739. {
  740. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 0> MarkType;
  741. MarkType dummy;
  742. dummy.~MarkType();
  743. s0i.construct(&dummy, 2);
  744. if(dummy.construction_type != ConstructibleSuffix ||
  745. dummy.value != 2){
  746. dummy.~MarkType();
  747. return 1;
  748. }
  749. dummy.~MarkType();
  750. }
  751. {
  752. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 0> MarkType;
  753. MarkType dummy;
  754. dummy.~MarkType();
  755. s0i.construct(&dummy, 3);
  756. if(dummy.construction_type != ConstructiblePrefix ||
  757. dummy.value != 3){
  758. dummy.~MarkType();
  759. return 1;
  760. }
  761. dummy.~MarkType();
  762. }
  763. }
  764. ////////////////////////////////////////////////////////////
  765. //Then check scoped allocator with OuterAlloc and InnerAlloc.
  766. //In this case InnerAlloc (test_allocator with tag 1) should be
  767. //used to construct types.
  768. ////////////////////////////////////////////////////////////
  769. {
  770. Scoped1Inner s1i;
  771. //Check construction with 0 user arguments
  772. {
  773. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 1> MarkType;
  774. MarkType dummy;
  775. dummy.~MarkType();
  776. s1i.construct(&dummy);
  777. if(dummy.construction_type != NotUsesAllocator ||
  778. dummy.value != 0){
  779. dummy.~MarkType();
  780. return 1;
  781. }
  782. dummy.~MarkType();
  783. }
  784. {
  785. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 1> MarkType;
  786. MarkType dummy;
  787. dummy.~MarkType();
  788. s1i.construct(&dummy);
  789. if(dummy.construction_type != ConstructibleSuffix ||
  790. dummy.value != 0){
  791. dummy.~MarkType();
  792. return 1;
  793. }
  794. dummy.~MarkType();
  795. }
  796. {
  797. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 1> MarkType;
  798. MarkType dummy;
  799. dummy.~MarkType();
  800. s1i.construct(&dummy);
  801. if(dummy.construction_type != ConstructiblePrefix ||
  802. dummy.value != 0){
  803. dummy.~MarkType();
  804. return 1;
  805. }
  806. dummy.~MarkType();
  807. }
  808. //Check construction with 1 user arguments
  809. {
  810. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 1> MarkType;
  811. MarkType dummy;
  812. dummy.~MarkType();
  813. s1i.construct(&dummy, 1);
  814. if(dummy.construction_type != NotUsesAllocator ||
  815. dummy.value != 1){
  816. dummy.~MarkType();
  817. return 1;
  818. }
  819. dummy.~MarkType();
  820. }
  821. {
  822. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 1> MarkType;
  823. MarkType dummy;
  824. dummy.~MarkType();
  825. s1i.construct(&dummy, 2);
  826. if(dummy.construction_type != ConstructibleSuffix ||
  827. dummy.value != 2){
  828. dummy.~MarkType();
  829. return 1;
  830. }
  831. dummy.~MarkType();
  832. }
  833. {
  834. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 1> MarkType;
  835. MarkType dummy;
  836. dummy.~MarkType();
  837. s1i.construct(&dummy, 3);
  838. if(dummy.construction_type != ConstructiblePrefix ||
  839. dummy.value != 3){
  840. dummy.~MarkType();
  841. return 1;
  842. }
  843. dummy.~MarkType();
  844. }
  845. }
  846. //////////////////////////////////////////////////////////////////////////////////
  847. //Now test recursive OuterAllocator types (OuterAllocator is a scoped_allocator)
  848. //////////////////////////////////////////////////////////////////////////////////
  849. ////////////////////////////////////////////////////////////
  850. //First check scoped allocator with just OuterAlloc.
  851. //In this case OuterAlloc (test_allocator with tag 0) should be
  852. //used to construct types.
  853. ////////////////////////////////////////////////////////////
  854. {
  855. //Check outer_allocator_type is scoped
  856. BOOST_STATIC_ASSERT(( boost::container::is_scoped_allocator
  857. <ScopedScoped0Inner::outer_allocator_type>::value ));
  858. BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
  859. < boost::container::outermost_allocator<ScopedScoped0Inner>::type
  860. , Outer10IdAlloc
  861. >::value ));
  862. BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
  863. < ScopedScoped0Inner::outer_allocator_type
  864. , scoped_allocator_adaptor<Outer10IdAlloc>
  865. >::value ));
  866. BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
  867. < scoped_allocator_adaptor<Outer10IdAlloc>::outer_allocator_type
  868. , Outer10IdAlloc
  869. >::value ));
  870. ScopedScoped0Inner ssro0i;
  871. Outer10IdAlloc & val = boost::container::outermost_allocator<ScopedScoped0Inner>::get(ssro0i);
  872. (void)val;
  873. //Check construction with 0 user arguments
  874. {
  875. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 10> MarkType;
  876. MarkType dummy;
  877. dummy.~MarkType();
  878. ssro0i.construct(&dummy);
  879. if(dummy.construction_type != NotUsesAllocator ||
  880. dummy.value != 0){
  881. dummy.~MarkType();
  882. return 1;
  883. }
  884. dummy.~MarkType();
  885. }
  886. {
  887. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 10> MarkType;
  888. MarkType dummy;
  889. dummy.~MarkType();
  890. ssro0i.construct(&dummy);
  891. if(dummy.construction_type != ConstructibleSuffix ||
  892. dummy.value != 0){
  893. dummy.~MarkType();
  894. return 1;
  895. }
  896. dummy.~MarkType();
  897. }
  898. {
  899. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 10> MarkType;
  900. MarkType dummy;
  901. dummy.~MarkType();
  902. ssro0i.construct(&dummy);
  903. if(dummy.construction_type != ConstructiblePrefix ||
  904. dummy.value != 0){
  905. dummy.~MarkType();
  906. return 1;
  907. }
  908. dummy.~MarkType();
  909. }
  910. //Check construction with 1 user arguments
  911. {
  912. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 10> MarkType;
  913. MarkType dummy;
  914. dummy.~MarkType();
  915. ssro0i.construct(&dummy, 1);
  916. if(dummy.construction_type != NotUsesAllocator ||
  917. dummy.value != 1){
  918. dummy.~MarkType();
  919. return 1;
  920. }
  921. dummy.~MarkType();
  922. }
  923. {
  924. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 10> MarkType;
  925. MarkType dummy;
  926. dummy.~MarkType();
  927. ssro0i.construct(&dummy, 2);
  928. if(dummy.construction_type != ConstructibleSuffix ||
  929. dummy.value != 2){
  930. dummy.~MarkType();
  931. return 1;
  932. }
  933. dummy.~MarkType();
  934. }
  935. {
  936. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 10> MarkType;
  937. MarkType dummy;
  938. dummy.~MarkType();
  939. ssro0i.construct(&dummy, 3);
  940. if(dummy.construction_type != ConstructiblePrefix ||
  941. dummy.value != 3){
  942. dummy.~MarkType();
  943. return 1;
  944. }
  945. dummy.~MarkType();
  946. }
  947. }
  948. ////////////////////////////////////////////////////////////
  949. //Then check scoped allocator with OuterAlloc and InnerAlloc.
  950. //In this case inner_allocator_type is not convertible to
  951. //::mark_on_scoped_allocation<XXX, 10> so uses_allocator
  952. //should be false on all tests.
  953. ////////////////////////////////////////////////////////////
  954. {
  955. //Check outer_allocator_type is scoped
  956. BOOST_STATIC_ASSERT(( boost::container::is_scoped_allocator
  957. <ScopedScoped1Inner::outer_allocator_type>::value ));
  958. BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
  959. < boost::container::outermost_allocator<ScopedScoped1Inner>::type
  960. , Outer10IdAlloc
  961. >::value ));
  962. BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
  963. < ScopedScoped1Inner::outer_allocator_type
  964. , scoped_allocator_adaptor<Outer10IdAlloc, Inner11IdAlloc1>
  965. >::value ));
  966. BOOST_STATIC_ASSERT(( ::boost::container::container_detail::is_same
  967. < scoped_allocator_adaptor<Outer10IdAlloc, Inner11IdAlloc1>::outer_allocator_type
  968. , Outer10IdAlloc
  969. >::value ));
  970. BOOST_STATIC_ASSERT(( !
  971. ::boost::container::uses_allocator
  972. < ::mark_on_scoped_allocation<ConstructibleSuffix, 10>
  973. , ScopedScoped1Inner::inner_allocator_type::outer_allocator_type
  974. >::value ));
  975. ScopedScoped1Inner ssro1i;
  976. Outer10IdAlloc & val = boost::container::outermost_allocator<ScopedScoped1Inner>::get(ssro1i);
  977. (void)val;
  978. //Check construction with 0 user arguments
  979. {
  980. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 10> MarkType;
  981. MarkType dummy;
  982. dummy.~MarkType();
  983. ssro1i.construct(&dummy);
  984. if(dummy.construction_type != NotUsesAllocator ||
  985. dummy.value != 0){
  986. dummy.~MarkType();
  987. return 1;
  988. }
  989. dummy.~MarkType();
  990. }
  991. {
  992. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 10> MarkType;
  993. MarkType dummy;
  994. dummy.~MarkType();
  995. ssro1i.construct(&dummy);
  996. if(dummy.construction_type != NotUsesAllocator ||
  997. dummy.value != 0){
  998. dummy.~MarkType();
  999. return 1;
  1000. }
  1001. dummy.~MarkType();
  1002. }
  1003. {
  1004. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 10> MarkType;
  1005. MarkType dummy;
  1006. dummy.~MarkType();
  1007. ssro1i.construct(&dummy);
  1008. if(dummy.construction_type != NotUsesAllocator ||
  1009. dummy.value != 0){
  1010. dummy.~MarkType();
  1011. return 1;
  1012. }
  1013. dummy.~MarkType();
  1014. }
  1015. //Check construction with 1 user arguments
  1016. {
  1017. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 10> MarkType;
  1018. MarkType dummy;
  1019. dummy.~MarkType();
  1020. ssro1i.construct(&dummy, 1);
  1021. if(dummy.construction_type != NotUsesAllocator ||
  1022. dummy.value != 1){
  1023. dummy.~MarkType();
  1024. return 1;
  1025. }
  1026. dummy.~MarkType();
  1027. }
  1028. {
  1029. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 10> MarkType;
  1030. MarkType dummy;
  1031. dummy.~MarkType();
  1032. ssro1i.construct(&dummy, 2);
  1033. if(dummy.construction_type != NotUsesAllocator ||
  1034. dummy.value != 2){
  1035. dummy.~MarkType();
  1036. return 1;
  1037. }
  1038. dummy.~MarkType();
  1039. }
  1040. {
  1041. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 10> MarkType;
  1042. MarkType dummy;
  1043. dummy.~MarkType();
  1044. ssro1i.construct(&dummy, 3);
  1045. if(dummy.construction_type != NotUsesAllocator ||
  1046. dummy.value != 3){
  1047. dummy.~MarkType();
  1048. return 1;
  1049. }
  1050. dummy.~MarkType();
  1051. }
  1052. }
  1053. ////////////////////////////////////////////////////////////
  1054. //Now check propagation to pair
  1055. ////////////////////////////////////////////////////////////
  1056. //First check scoped allocator with just OuterAlloc.
  1057. //In this case OuterAlloc (test_allocator with tag 0) should be
  1058. //used to construct types.
  1059. ////////////////////////////////////////////////////////////
  1060. {
  1061. using boost::container::container_detail::pair;
  1062. typedef test_allocator< pair< tagged_integer<0>
  1063. , tagged_integer<0> >, 0> OuterPairAlloc;
  1064. //
  1065. typedef scoped_allocator_adaptor < OuterPairAlloc > ScopedPair0Inner;
  1066. ScopedPair0Inner s0i;
  1067. //Check construction with 0 user arguments
  1068. {
  1069. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 0> MarkType;
  1070. typedef pair<MarkType, MarkType> MarkTypePair;
  1071. MarkTypePair dummy;
  1072. dummy.~MarkTypePair();
  1073. s0i.construct(&dummy);
  1074. if(dummy.first.construction_type != NotUsesAllocator ||
  1075. dummy.second.construction_type != NotUsesAllocator ||
  1076. dummy.first.value != 0 ||
  1077. dummy.second.value != 0 ){
  1078. dummy.~MarkTypePair();
  1079. return 1;
  1080. }
  1081. dummy.~MarkTypePair();
  1082. }
  1083. {
  1084. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 0> MarkType;
  1085. typedef pair<MarkType, MarkType> MarkTypePair;
  1086. MarkTypePair dummy;
  1087. dummy.~MarkTypePair();
  1088. s0i.construct(&dummy);
  1089. if(dummy.first.construction_type != ConstructibleSuffix ||
  1090. dummy.second.construction_type != ConstructibleSuffix ||
  1091. dummy.first.value != 0 ||
  1092. dummy.second.value != 0 ){
  1093. dummy.~MarkTypePair();
  1094. return 1;
  1095. }
  1096. dummy.~MarkTypePair();
  1097. }
  1098. {
  1099. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 0> MarkType;
  1100. typedef pair<MarkType, MarkType> MarkTypePair;
  1101. MarkTypePair dummy;
  1102. dummy.~MarkTypePair();
  1103. s0i.construct(&dummy);
  1104. if(dummy.first.construction_type != ConstructiblePrefix ||
  1105. dummy.second.construction_type != ConstructiblePrefix ||
  1106. dummy.first.value != 0 ||
  1107. dummy.second.value != 0 ){
  1108. dummy.~MarkTypePair();
  1109. return 1;
  1110. }
  1111. dummy.~MarkTypePair();
  1112. }
  1113. //Check construction with 1 user arguments for each pair
  1114. {
  1115. typedef ::mark_on_scoped_allocation<NotUsesAllocator, 0> MarkType;
  1116. typedef pair<MarkType, MarkType> MarkTypePair;
  1117. MarkTypePair dummy;
  1118. dummy.~MarkTypePair();
  1119. s0i.construct(&dummy, 1, 1);
  1120. if(dummy.first.construction_type != NotUsesAllocator ||
  1121. dummy.second.construction_type != NotUsesAllocator ||
  1122. dummy.first.value != 1 ||
  1123. dummy.second.value != 1 ){
  1124. dummy.~MarkTypePair();
  1125. return 1;
  1126. }
  1127. dummy.~MarkTypePair();
  1128. }
  1129. {
  1130. typedef ::mark_on_scoped_allocation<ConstructibleSuffix, 0> MarkType;
  1131. typedef pair<MarkType, MarkType> MarkTypePair;
  1132. MarkTypePair dummy;
  1133. dummy.~MarkTypePair();
  1134. s0i.construct(&dummy, 1, 1);
  1135. if(dummy.first.construction_type != ConstructibleSuffix ||
  1136. dummy.second.construction_type != ConstructibleSuffix ||
  1137. dummy.first.value != 1 ||
  1138. dummy.second.value != 1 ){
  1139. dummy.~MarkTypePair();
  1140. return 1;
  1141. }
  1142. dummy.~MarkTypePair();
  1143. }
  1144. {
  1145. typedef ::mark_on_scoped_allocation<ConstructiblePrefix, 0> MarkType;
  1146. typedef pair<MarkType, MarkType> MarkTypePair;
  1147. MarkTypePair dummy;
  1148. dummy.~MarkTypePair();
  1149. s0i.construct(&dummy, 2, 2);

Large files files are truncated, but you can click here to view the full file