emplace_test.hpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2008-2012. 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/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_INTERPROCESS_TEST_EMPLACE_TEST_HPP
  11. #define BOOST_INTERPROCESS_TEST_EMPLACE_TEST_HPP
  12. #include <iostream>
  13. #include <typeinfo>
  14. #include <boost/interprocess/detail/config_begin.hpp>
  15. #include <boost/interprocess/detail/workaround.hpp>
  16. #include <boost/interprocess/detail/mpl.hpp>
  17. #include <boost/move/utility_core.hpp>
  18. #include <boost/interprocess/detail/utilities.hpp>
  19. #include <boost/move/detail/type_traits.hpp> //make_unsigned, alignment_of
  20. namespace boost{
  21. namespace interprocess{
  22. namespace test{
  23. class EmplaceInt
  24. {
  25. private:
  26. BOOST_MOVABLE_BUT_NOT_COPYABLE(EmplaceInt)
  27. public:
  28. EmplaceInt()
  29. : a_(0), b_(0), c_(0), d_(0), e_(0)
  30. {}
  31. EmplaceInt(int a, int b = 0, int c = 0, int d = 0, int e = 0)
  32. : a_(a), b_(b), c_(c), d_(d), e_(e)
  33. {}
  34. EmplaceInt(BOOST_RV_REF(EmplaceInt) o)
  35. : a_(o.a_), b_(o.b_), c_(o.c_), d_(o.d_), e_(o.e_)
  36. {}
  37. EmplaceInt& operator=(BOOST_RV_REF(EmplaceInt) o)
  38. {
  39. this->a_ = o.a_;
  40. this->b_ = o.b_;
  41. this->c_ = o.c_;
  42. this->d_ = o.d_;
  43. this->e_ = o.e_;
  44. return *this;
  45. }
  46. friend bool operator==(const EmplaceInt &l, const EmplaceInt &r)
  47. {
  48. return l.a_ == r.a_ &&
  49. l.b_ == r.b_ &&
  50. l.c_ == r.c_ &&
  51. l.d_ == r.d_ &&
  52. l.e_ == r.e_;
  53. }
  54. friend bool operator<(const EmplaceInt &l, const EmplaceInt &r)
  55. { return l.sum() < r.sum(); }
  56. friend bool operator>(const EmplaceInt &l, const EmplaceInt &r)
  57. { return l.sum() > r.sum(); }
  58. friend bool operator!=(const EmplaceInt &l, const EmplaceInt &r)
  59. { return !(l == r); }
  60. friend std::ostream &operator <<(std::ostream &os, const EmplaceInt &v)
  61. {
  62. os << "EmplaceInt: " << v.a_ << ' ' << v.b_ << ' ' << v.c_ << ' ' << v.d_ << ' ' << v.e_;
  63. return os;
  64. }
  65. //private:
  66. int sum() const
  67. { return this->a_ + this->b_ + this->c_ + this->d_ + this->e_; }
  68. int a_, b_, c_, d_, e_;
  69. int padding[6];
  70. };
  71. } //namespace test {
  72. namespace test {
  73. enum EmplaceOptions{
  74. EMPLACE_BACK = 1 << 0,
  75. EMPLACE_FRONT = 1 << 1,
  76. EMPLACE_BEFORE = 1 << 2,
  77. EMPLACE_AFTER = 1 << 3,
  78. EMPLACE_ASSOC = 1 << 4,
  79. EMPLACE_HINT = 1 << 5,
  80. EMPLACE_ASSOC_PAIR = 1 << 6,
  81. EMPLACE_HINT_PAIR = 1 << 7
  82. };
  83. template<class Container>
  84. bool test_expected_container(const Container &ec, const EmplaceInt *Expected, unsigned int only_first_n)
  85. {
  86. typedef typename Container::const_iterator const_iterator;
  87. const_iterator itb(ec.begin()), ite(ec.end());
  88. unsigned int cur = 0;
  89. if(only_first_n > ec.size()){
  90. return false;
  91. }
  92. for(; itb != ite && only_first_n--; ++itb, ++cur){
  93. const EmplaceInt & cr = *itb;
  94. if(cr != Expected[cur]){
  95. return false;
  96. }
  97. }
  98. return true;
  99. }
  100. template<class Container>
  101. bool test_expected_container(const Container &ec, const std::pair<EmplaceInt, EmplaceInt> *Expected, unsigned int only_first_n)
  102. {
  103. typedef typename Container::const_iterator const_iterator;
  104. const_iterator itb(ec.begin()), ite(ec.end());
  105. unsigned int cur = 0;
  106. if(only_first_n > ec.size()){
  107. return false;
  108. }
  109. for(; itb != ite && only_first_n--; ++itb, ++cur){
  110. if(itb->first != Expected[cur].first){
  111. std::cout << "Error in first: " << itb->first << ' ' << Expected[cur].first << std::endl;
  112. return false;
  113. }
  114. else if(itb->second != Expected[cur].second){
  115. std::cout << "Error in second: " << itb->second << ' ' << Expected[cur].second << std::endl;
  116. return false;
  117. }
  118. }
  119. return true;
  120. }
  121. static EmplaceInt expected [10];
  122. typedef std::pair<EmplaceInt, EmplaceInt> EmplaceIntPair;
  123. static boost::container::dtl::aligned_storage<sizeof(EmplaceIntPair)*10>::type pair_storage;
  124. static EmplaceIntPair* initialize_emplace_int_pair()
  125. {
  126. EmplaceIntPair* ret = reinterpret_cast<EmplaceIntPair*>(&pair_storage);
  127. for(unsigned int i = 0; i != 10; ++i){
  128. new(&ret->first)EmplaceInt();
  129. new(&ret->second)EmplaceInt();
  130. }
  131. return ret;
  132. }
  133. static EmplaceIntPair * expected_pair = initialize_emplace_int_pair();
  134. template<class Container>
  135. bool test_emplace_back(ipcdetail::true_)
  136. {
  137. std::cout << "Starting test_emplace_back." << std::endl << " Class: "
  138. << typeid(Container).name() << std::endl;
  139. {
  140. new(&expected [0]) EmplaceInt();
  141. new(&expected [1]) EmplaceInt(1);
  142. new(&expected [2]) EmplaceInt(1, 2);
  143. new(&expected [3]) EmplaceInt(1, 2, 3);
  144. new(&expected [4]) EmplaceInt(1, 2, 3, 4);
  145. new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5);
  146. Container c;
  147. c.emplace_back();
  148. if(!test_expected_container(c, &expected[0], 1))
  149. return false;
  150. c.emplace_back(1);
  151. if(!test_expected_container(c, &expected[0], 2))
  152. return false;
  153. c.emplace_back(1, 2);
  154. if(!test_expected_container(c, &expected[0], 3))
  155. return false;
  156. c.emplace_back(1, 2, 3);
  157. if(!test_expected_container(c, &expected[0], 4))
  158. return false;
  159. c.emplace_back(1, 2, 3, 4);
  160. if(!test_expected_container(c, &expected[0], 5))
  161. return false;
  162. c.emplace_back(1, 2, 3, 4, 5);
  163. if(!test_expected_container(c, &expected[0], 6))
  164. return false;
  165. }
  166. return true;
  167. }
  168. template<class Container>
  169. bool test_emplace_back(ipcdetail::false_)
  170. { return true; }
  171. template<class Container>
  172. bool test_emplace_front(ipcdetail::true_)
  173. {
  174. std::cout << "Starting test_emplace_front." << std::endl << " Class: "
  175. << typeid(Container).name() << std::endl;
  176. {
  177. new(&expected [0]) EmplaceInt(1, 2, 3, 4, 5);
  178. new(&expected [1]) EmplaceInt(1, 2, 3, 4);
  179. new(&expected [2]) EmplaceInt(1, 2, 3);
  180. new(&expected [3]) EmplaceInt(1, 2);
  181. new(&expected [4]) EmplaceInt(1);
  182. new(&expected [5]) EmplaceInt();
  183. Container c;
  184. c.emplace_front();
  185. if(!test_expected_container(c, &expected[0] + 5, 1))
  186. return false;
  187. c.emplace_front(1);
  188. if(!test_expected_container(c, &expected[0] + 4, 2))
  189. return false;
  190. c.emplace_front(1, 2);
  191. if(!test_expected_container(c, &expected[0] + 3, 3))
  192. return false;
  193. c.emplace_front(1, 2, 3);
  194. if(!test_expected_container(c, &expected[0] + 2, 4))
  195. return false;
  196. c.emplace_front(1, 2, 3, 4);
  197. if(!test_expected_container(c, &expected[0] + 1, 5))
  198. return false;
  199. c.emplace_front(1, 2, 3, 4, 5);
  200. if(!test_expected_container(c, &expected[0] + 0, 6))
  201. return false;
  202. }
  203. return true;
  204. }
  205. template<class Container>
  206. bool test_emplace_front(ipcdetail::false_)
  207. { return true; }
  208. template<class Container>
  209. bool test_emplace_before(ipcdetail::true_)
  210. {
  211. std::cout << "Starting test_emplace_before." << std::endl << " Class: "
  212. << typeid(Container).name() << std::endl;
  213. {
  214. new(&expected [0]) EmplaceInt();
  215. new(&expected [1]) EmplaceInt(1);
  216. new(&expected [2]) EmplaceInt();
  217. Container c;
  218. c.emplace(c.cend(), 1);
  219. c.emplace(c.cbegin());
  220. if(!test_expected_container(c, &expected[0], 2))
  221. return false;
  222. c.emplace(c.cend());
  223. if(!test_expected_container(c, &expected[0], 3))
  224. return false;
  225. }
  226. {
  227. new(&expected [0]) EmplaceInt();
  228. new(&expected [1]) EmplaceInt(1);
  229. new(&expected [2]) EmplaceInt(1, 2);
  230. new(&expected [3]) EmplaceInt(1, 2, 3);
  231. new(&expected [4]) EmplaceInt(1, 2, 3, 4);
  232. new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5);
  233. //emplace_front-like
  234. Container c;
  235. c.emplace(c.cbegin(), 1, 2, 3, 4, 5);
  236. c.emplace(c.cbegin(), 1, 2, 3, 4);
  237. c.emplace(c.cbegin(), 1, 2, 3);
  238. c.emplace(c.cbegin(), 1, 2);
  239. c.emplace(c.cbegin(), 1);
  240. c.emplace(c.cbegin());
  241. if(!test_expected_container(c, &expected[0], 6))
  242. return false;
  243. c.clear();
  244. //emplace_back-like
  245. typename Container::const_iterator i = c.emplace(c.cend());
  246. if(!test_expected_container(c, &expected[0], 1))
  247. return false;
  248. i = c.emplace(++i, 1);
  249. if(!test_expected_container(c, &expected[0], 2))
  250. return false;
  251. i = c.emplace(++i, 1, 2);
  252. if(!test_expected_container(c, &expected[0], 3))
  253. return false;
  254. i = c.emplace(++i, 1, 2, 3);
  255. if(!test_expected_container(c, &expected[0], 4))
  256. return false;
  257. i = c.emplace(++i, 1, 2, 3, 4);
  258. if(!test_expected_container(c, &expected[0], 5))
  259. return false;
  260. i = c.emplace(++i, 1, 2, 3, 4, 5);
  261. if(!test_expected_container(c, &expected[0], 6))
  262. return false;
  263. c.clear();
  264. //emplace in the middle
  265. c.emplace(c.cbegin());
  266. i = c.emplace(c.cend(), 1, 2, 3, 4, 5);
  267. i = c.emplace(i, 1, 2, 3, 4);
  268. i = c.emplace(i, 1, 2, 3);
  269. i = c.emplace(i, 1, 2);
  270. i = c.emplace(i, 1);
  271. if(!test_expected_container(c, &expected[0], 6))
  272. return false;
  273. }
  274. return true;
  275. }
  276. template<class Container>
  277. bool test_emplace_before(ipcdetail::false_)
  278. { return true; }
  279. template<class Container>
  280. bool test_emplace_after(ipcdetail::true_)
  281. {
  282. std::cout << "Starting test_emplace_after." << std::endl << " Class: "
  283. << typeid(Container).name() << std::endl;
  284. {
  285. new(&expected [0]) EmplaceInt();
  286. new(&expected [1]) EmplaceInt(1);
  287. new(&expected [2]) EmplaceInt();
  288. Container c;
  289. typename Container::const_iterator i = c.emplace_after(c.cbefore_begin(), 1);
  290. c.emplace_after(c.cbefore_begin());
  291. if(!test_expected_container(c, &expected[0], 2))
  292. return false;
  293. c.emplace_after(i);
  294. if(!test_expected_container(c, &expected[0], 3))
  295. return false;
  296. }
  297. {
  298. new(&expected [0]) EmplaceInt();
  299. new(&expected [1]) EmplaceInt(1);
  300. new(&expected [2]) EmplaceInt(1, 2);
  301. new(&expected [3]) EmplaceInt(1, 2, 3);
  302. new(&expected [4]) EmplaceInt(1, 2, 3, 4);
  303. new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5);
  304. //emplace_front-like
  305. Container c;
  306. c.emplace_after(c.cbefore_begin(), 1, 2, 3, 4, 5);
  307. c.emplace_after(c.cbefore_begin(), 1, 2, 3, 4);
  308. c.emplace_after(c.cbefore_begin(), 1, 2, 3);
  309. c.emplace_after(c.cbefore_begin(), 1, 2);
  310. c.emplace_after(c.cbefore_begin(), 1);
  311. c.emplace_after(c.cbefore_begin());
  312. if(!test_expected_container(c, &expected[0], 6))
  313. return false;
  314. c.clear();
  315. //emplace_back-like
  316. typename Container::const_iterator i = c.emplace_after(c.cbefore_begin());
  317. if(!test_expected_container(c, &expected[0], 1))
  318. return false;
  319. i = c.emplace_after(i, 1);
  320. if(!test_expected_container(c, &expected[0], 2))
  321. return false;
  322. i = c.emplace_after(i, 1, 2);
  323. if(!test_expected_container(c, &expected[0], 3))
  324. return false;
  325. i = c.emplace_after(i, 1, 2, 3);
  326. if(!test_expected_container(c, &expected[0], 4))
  327. return false;
  328. i = c.emplace_after(i, 1, 2, 3, 4);
  329. if(!test_expected_container(c, &expected[0], 5))
  330. return false;
  331. i = c.emplace_after(i, 1, 2, 3, 4, 5);
  332. if(!test_expected_container(c, &expected[0], 6))
  333. return false;
  334. c.clear();
  335. //emplace_after in the middle
  336. i = c.emplace_after(c.cbefore_begin());
  337. c.emplace_after(i, 1, 2, 3, 4, 5);
  338. c.emplace_after(i, 1, 2, 3, 4);
  339. c.emplace_after(i, 1, 2, 3);
  340. c.emplace_after(i, 1, 2);
  341. c.emplace_after(i, 1);
  342. if(!test_expected_container(c, &expected[0], 6))
  343. return false;
  344. }
  345. return true;
  346. }
  347. template<class Container>
  348. bool test_emplace_after(ipcdetail::false_)
  349. { return true; }
  350. template<class Container>
  351. bool test_emplace_assoc(ipcdetail::true_)
  352. {
  353. std::cout << "Starting test_emplace_assoc." << std::endl << " Class: "
  354. << typeid(Container).name() << std::endl;
  355. new(&expected [0]) EmplaceInt();
  356. new(&expected [1]) EmplaceInt(1);
  357. new(&expected [2]) EmplaceInt(1, 2);
  358. new(&expected [3]) EmplaceInt(1, 2, 3);
  359. new(&expected [4]) EmplaceInt(1, 2, 3, 4);
  360. new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5);
  361. {
  362. Container c;
  363. c.emplace();
  364. if(!test_expected_container(c, &expected[0], 1))
  365. return false;
  366. c.emplace(1);
  367. if(!test_expected_container(c, &expected[0], 2))
  368. return false;
  369. c.emplace(1, 2);
  370. if(!test_expected_container(c, &expected[0], 3))
  371. return false;
  372. c.emplace(1, 2, 3);
  373. if(!test_expected_container(c, &expected[0], 4))
  374. return false;
  375. c.emplace(1, 2, 3, 4);
  376. if(!test_expected_container(c, &expected[0], 5))
  377. return false;
  378. c.emplace(1, 2, 3, 4, 5);
  379. if(!test_expected_container(c, &expected[0], 6))
  380. return false;
  381. }
  382. return true;
  383. }
  384. template<class Container>
  385. bool test_emplace_assoc(ipcdetail::false_)
  386. { return true; }
  387. template<class Container>
  388. bool test_emplace_hint(ipcdetail::true_)
  389. {
  390. std::cout << "Starting test_emplace_hint." << std::endl << " Class: "
  391. << typeid(Container).name() << std::endl;
  392. new(&expected [0]) EmplaceInt();
  393. new(&expected [1]) EmplaceInt(1);
  394. new(&expected [2]) EmplaceInt(1, 2);
  395. new(&expected [3]) EmplaceInt(1, 2, 3);
  396. new(&expected [4]) EmplaceInt(1, 2, 3, 4);
  397. new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5);
  398. {
  399. Container c;
  400. typename Container::const_iterator it;
  401. it = c.emplace_hint(c.begin());
  402. if(!test_expected_container(c, &expected[0], 1))
  403. return false;
  404. it = c.emplace_hint(it, 1);
  405. if(!test_expected_container(c, &expected[0], 2))
  406. return false;
  407. it = c.emplace_hint(it, 1, 2);
  408. if(!test_expected_container(c, &expected[0], 3))
  409. return false;
  410. it = c.emplace_hint(it, 1, 2, 3);
  411. if(!test_expected_container(c, &expected[0], 4))
  412. return false;
  413. it = c.emplace_hint(it, 1, 2, 3, 4);
  414. if(!test_expected_container(c, &expected[0], 5))
  415. return false;
  416. it = c.emplace_hint(it, 1, 2, 3, 4, 5);
  417. if(!test_expected_container(c, &expected[0], 6))
  418. return false;
  419. }
  420. return true;
  421. }
  422. template<class Container>
  423. bool test_emplace_hint(ipcdetail::false_)
  424. { return true; }
  425. template<class Container>
  426. bool test_emplace_assoc_pair(ipcdetail::true_)
  427. {
  428. std::cout << "Starting test_emplace_assoc_pair." << std::endl << " Class: "
  429. << typeid(Container).name() << std::endl;
  430. new(&expected_pair[0].first) EmplaceInt();
  431. new(&expected_pair[0].second) EmplaceInt();
  432. new(&expected_pair[1].first) EmplaceInt(1);
  433. new(&expected_pair[1].second) EmplaceInt();
  434. new(&expected_pair[2].first) EmplaceInt(2);
  435. new(&expected_pair[2].second) EmplaceInt(2);
  436. // new(&expected_pair[3].first) EmplaceInt(3);
  437. // new(&expected_pair[3].second) EmplaceInt(2, 3);
  438. // new(&expected_pair[4].first) EmplaceInt(4);
  439. // new(&expected_pair[4].second) EmplaceInt(2, 3, 4);
  440. // new(&expected_pair[5].first) EmplaceInt(5);
  441. // new(&expected_pair[5].second) EmplaceInt(2, 3, 4, 5);
  442. { //piecewise construct missing
  443. /*
  444. Container c;
  445. c.emplace();
  446. if(!test_expected_container(c, &expected_pair[0], 1)){
  447. std::cout << "Error after c.emplace();\n";
  448. return false;
  449. }
  450. c.emplace(1);
  451. if(!test_expected_container(c, &expected_pair[0], 2)){
  452. std::cout << "Error after c.emplace(1);\n";
  453. return false;
  454. }
  455. c.emplace(2, 2);
  456. if(!test_expected_container(c, &expected_pair[0], 3)){
  457. std::cout << "Error after c.emplace(2, 2);\n";
  458. return false;
  459. }
  460. c.emplace(3, 2, 3);
  461. if(!test_expected_container(c, &expected_pair[0], 4)){
  462. std::cout << "Error after c.emplace(3, 2, 3);\n";
  463. return false;
  464. }
  465. c.emplace(4, 2, 3, 4);
  466. if(!test_expected_container(c, &expected_pair[0], 5)){
  467. std::cout << "Error after c.emplace(4, 2, 3, 4);\n";
  468. return false;
  469. }
  470. c.emplace(5, 2, 3, 4, 5);
  471. if(!test_expected_container(c, &expected_pair[0], 6)){
  472. std::cout << "Error after c.emplace(5, 2, 3, 4, 5);\n";
  473. return false;
  474. }*/
  475. }
  476. return true;
  477. }
  478. template<class Container>
  479. bool test_emplace_assoc_pair(ipcdetail::false_)
  480. { return true; }
  481. template<class Container>
  482. bool test_emplace_hint_pair(ipcdetail::true_)
  483. {
  484. std::cout << "Starting test_emplace_hint_pair." << std::endl << " Class: "
  485. << typeid(Container).name() << std::endl;
  486. new(&expected_pair[0].first) EmplaceInt();
  487. new(&expected_pair[0].second) EmplaceInt();
  488. new(&expected_pair[1].first) EmplaceInt(1);
  489. new(&expected_pair[1].second) EmplaceInt();
  490. new(&expected_pair[2].first) EmplaceInt(2);
  491. new(&expected_pair[2].second) EmplaceInt(2);/*
  492. new(&expected_pair[3].first) EmplaceInt(3);
  493. new(&expected_pair[3].second) EmplaceInt(2, 3);
  494. new(&expected_pair[4].first) EmplaceInt(4);
  495. new(&expected_pair[4].second) EmplaceInt(2, 3, 4);
  496. new(&expected_pair[5].first) EmplaceInt(5);
  497. new(&expected_pair[5].second) EmplaceInt(2, 3, 4, 5);*/
  498. {/*
  499. Container c;
  500. typename Container::const_iterator it;
  501. it = c.emplace_hint(c.begin());
  502. if(!test_expected_container(c, &expected_pair[0], 1)){
  503. std::cout << "Error after c.emplace(1);\n";
  504. return false;
  505. }
  506. it = c.emplace_hint(it, 1);
  507. if(!test_expected_container(c, &expected_pair[0], 2)){
  508. std::cout << "Error after c.emplace(it, 1);\n";
  509. return false;
  510. }
  511. it = c.emplace_hint(it, 2, 2);
  512. if(!test_expected_container(c, &expected_pair[0], 3)){
  513. std::cout << "Error after c.emplace(it, 2, 2);\n";
  514. return false;
  515. }
  516. it = c.emplace_hint(it, 3, 2, 3);
  517. if(!test_expected_container(c, &expected_pair[0], 4)){
  518. std::cout << "Error after c.emplace(it, 3, 2, 3);\n";
  519. return false;
  520. }
  521. it = c.emplace_hint(it, 4, 2, 3, 4);
  522. if(!test_expected_container(c, &expected_pair[0], 5)){
  523. std::cout << "Error after c.emplace(it, 4, 2, 3, 4);\n";
  524. return false;
  525. }
  526. it = c.emplace_hint(it, 5, 2, 3, 4, 5);
  527. if(!test_expected_container(c, &expected_pair[0], 6)){
  528. std::cout << "Error after c.emplace(it, 5, 2, 3, 4, 5);\n";
  529. return false;
  530. }*/
  531. }
  532. return true;
  533. }
  534. template<class Container>
  535. bool test_emplace_hint_pair(ipcdetail::false_)
  536. { return true; }
  537. template <EmplaceOptions O, EmplaceOptions Mask>
  538. struct emplace_active
  539. {
  540. static const bool value = (0 != (O & Mask));
  541. typedef ipcdetail::bool_<value> type;
  542. operator type() const{ return type(); }
  543. };
  544. template<class Container, EmplaceOptions O>
  545. bool test_emplace()
  546. {
  547. if(!test_emplace_back<Container>(emplace_active<O, EMPLACE_BACK>()))
  548. return false;
  549. if(!test_emplace_front<Container>(emplace_active<O, EMPLACE_FRONT>()))
  550. return false;
  551. if(!test_emplace_before<Container>(emplace_active<O, EMPLACE_BEFORE>()))
  552. return false;
  553. if(!test_emplace_after<Container>(emplace_active<O, EMPLACE_AFTER>()))
  554. return false;
  555. if(!test_emplace_assoc<Container>(emplace_active<O, EMPLACE_ASSOC>()))
  556. return false;
  557. if(!test_emplace_hint<Container>(emplace_active<O, EMPLACE_HINT>()))
  558. return false;
  559. if(!test_emplace_assoc_pair<Container>(emplace_active<O, EMPLACE_ASSOC_PAIR>()))
  560. return false;
  561. if(!test_emplace_hint_pair<Container>(emplace_active<O, EMPLACE_HINT_PAIR>()))
  562. return false;
  563. return true;
  564. }
  565. } //namespace test{
  566. } //namespace interprocess{
  567. } //namespace boost{
  568. #include <boost/interprocess/detail/config_end.hpp>
  569. #endif //#ifndef BOOST_INTERPROCESS_TEST_EMPLACE_TEST_HPP