1 /* Boost.MultiIndex test for key extractors.
2 *
3 * Copyright 2003-2020 Joaquin M Lopez Munoz.
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 *
8 * See http://www.boost.org/libs/multi_index for library home page.
9 */
10
11 #include "test_key_extractors.hpp"
12
13 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
14 #include <boost/detail/lightweight_test.hpp>
15 #include "pre_multi_index.hpp"
16 #include <boost/multi_index/key_extractors.hpp>
17 #include <boost/ref.hpp>
18 #include <boost/scoped_ptr.hpp>
19 #include <list>
20
21 using namespace boost::multi_index;
22 using namespace boost::tuples;
23
24 struct test_class
25 {
26 int int_member;
27 const int int_cmember;
28
bool_mem_fun_consttest_class29 bool bool_mem_fun_const()const{return true;}
bool_mem_funtest_class30 bool bool_mem_fun(){return false;}
bool_mem_fun_volatiletest_class31 bool bool_mem_fun_volatile()volatile{return false;}
bool_mem_fun_cvtest_class32 bool bool_mem_fun_cv()const volatile{return true;}
33
34 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
35
bool_mem_fun_creftest_class36 bool bool_mem_fun_cref()const&{return true;}
bool_mem_fun_reftest_class37 bool bool_mem_fun_ref()&{return false;}
bool_mem_fun_vreftest_class38 bool bool_mem_fun_vref()volatile&{return false;}
bool_mem_fun_cvreftest_class39 bool bool_mem_fun_cvref()const volatile&{return true;}
40
41 #endif
42
bool_global_funtest_class43 static bool bool_global_fun(test_class){return true;}
bool_global_fun_const_reftest_class44 static bool bool_global_fun_const_ref(const test_class&){return false;}
bool_global_fun_reftest_class45 static bool bool_global_fun_ref(test_class&){return true;}
46
test_classtest_class47 test_class(int i=0):int_member(i),int_cmember(i){}
test_classtest_class48 test_class(int i,int j):int_member(i),int_cmember(j){}
test_classtest_class49 test_class(const test_class& x):
50 int_member(x.int_member),int_cmember(x.int_cmember){}
51
operator =test_class52 test_class& operator=(const test_class& x)
53 {
54 int_member=x.int_member;
55 return *this;
56 }
57
operator <test_class58 bool operator<(const test_class& x)const
59 {
60 if(int_member<x.int_member)return true;
61 if(x.int_member<int_member)return false;
62 return int_cmember<x.int_cmember;
63 }
64
operator ==test_class65 bool operator==(const test_class& x)const
66 {
67 return int_member==x.int_member&&int_cmember==x.int_cmember;
68 }
69 };
70
71 struct test_derived_class:test_class
72 {
test_derived_classtest_derived_class73 test_derived_class(int i=0):test_class(i){}
test_derived_classtest_derived_class74 test_derived_class(int i,int j):test_class(i,j){}
75 };
76
77 typedef identity<test_class> idn;
78 typedef identity<const test_class> cidn;
79 typedef BOOST_MULTI_INDEX_MEMBER(test_class,int,int_member) key_m;
80 typedef BOOST_MULTI_INDEX_MEMBER(test_class,const int,int_member) ckey_m;
81 typedef BOOST_MULTI_INDEX_MEMBER(test_class,const int,int_cmember) key_cm;
82 typedef BOOST_MULTI_INDEX_MEM_FUN(test_class,bool,bool_mem_fun) key_mf;
83 typedef BOOST_MULTI_INDEX_CONST_MEM_FUN(
84 test_class,bool,bool_mem_fun_const) key_cmf;
85 typedef volatile_mem_fun<
86 test_class,bool,&test_class::bool_mem_fun_volatile> key_vmf;
87 typedef cv_mem_fun<test_class,bool,&test_class::bool_mem_fun_cv> key_cvmf;
88
89 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
90
91 typedef cref_mem_fun<
92 test_class,bool,&test_class::bool_mem_fun_cref> key_crmf;
93 typedef ref_mem_fun<test_class,bool,&test_class::bool_mem_fun_ref> key_rmf;
94 typedef vref_mem_fun<
95 test_class,bool,&test_class::bool_mem_fun_vref> key_vrmf;
96 typedef cvref_mem_fun<
97 test_class,bool,&test_class::bool_mem_fun_cvref> key_cvrmf;
98
99 #endif
100
101 typedef global_fun<test_class,bool,&test_class::bool_global_fun> key_gf;
102 typedef global_fun<
103 const test_class&,bool,
104 &test_class::bool_global_fun_const_ref
105 > key_gcrf;
106 typedef global_fun<
107 test_class&,bool,
108 &test_class::bool_global_fun_ref
109 > key_grf;
110 typedef composite_key<
111 test_class,
112 idn,
113 key_m,
114 key_cm,
115 key_cmf
116 > compkey;
117 typedef composite_key<
118 test_class,
119 cidn,
120 ckey_m
121 > ccompkey;
122 typedef composite_key<
123 boost::reference_wrapper<test_class>,
124 key_mf
125 > ccompw_key;
126
127 #if !defined(BOOST_NO_SFINAE)
128 /* testcases for problems with non-copyable classes reported at
129 * http://lists.boost.org/Archives/boost/2006/04/103065.php
130 */
131
132 struct test_nc_class
133 {
134 int int_member;
135 const int int_cmember;
136
bool_mem_fun_consttest_nc_class137 bool bool_mem_fun_const()const{return true;}
bool_mem_funtest_nc_class138 bool bool_mem_fun(){return false;}
139
bool_global_fun_const_reftest_nc_class140 static bool bool_global_fun_const_ref(const test_nc_class&){return false;}
bool_global_fun_reftest_nc_class141 static bool bool_global_fun_ref(test_nc_class&){return true;}
142
test_nc_classtest_nc_class143 test_nc_class(int i=0):int_member(i),int_cmember(i){}
test_nc_classtest_nc_class144 test_nc_class(int i,int j):int_member(i),int_cmember(j){}
145
operator ==test_nc_class146 bool operator==(const test_nc_class& x)const
147 {
148 return int_member==x.int_member&&int_cmember==x.int_cmember;
149 }
150
151 private:
152 test_nc_class(const test_nc_class&);
153 test_nc_class& operator=(const test_nc_class&);
154 };
155
156 struct test_nc_derived_class:test_nc_class
157 {
test_nc_derived_classtest_nc_derived_class158 test_nc_derived_class(int i=0):test_nc_class(i){}
test_nc_derived_classtest_nc_derived_class159 test_nc_derived_class(int i,int j):test_nc_class(i,j){}
160 };
161
162 typedef identity<test_nc_class> nc_idn;
163 typedef identity<const test_nc_class> nc_cidn;
164 typedef BOOST_MULTI_INDEX_MEMBER(test_nc_class,int,int_member) nc_key_m;
165 typedef BOOST_MULTI_INDEX_MEMBER(
166 test_nc_class,const int,int_member) nc_ckey_m;
167 typedef BOOST_MULTI_INDEX_CONST_MEM_FUN(
168 test_nc_class,bool,bool_mem_fun_const) nc_key_cmf;
169 typedef BOOST_MULTI_INDEX_MEM_FUN(
170 test_nc_class,bool,bool_mem_fun) nc_key_mf;
171 typedef global_fun<
172 const test_nc_class&,bool,
173 &test_nc_class::bool_global_fun_const_ref
174 > nc_key_gcrf;
175 typedef global_fun<
176 test_nc_class&,bool,
177 &test_nc_class::bool_global_fun_ref
178 > nc_key_grf;
179 typedef composite_key<
180 test_nc_class,
181 nc_idn,
182 nc_key_m,
183 nc_ckey_m,
184 nc_key_cmf
185 > nc_compkey;
186 #endif
187
test_key_extractors()188 void test_key_extractors()
189 {
190 idn id;
191 cidn cid;
192 key_m k_m;
193 ckey_m ck_m;
194 key_cm k_cm;
195 key_cmf k_cmf;
196 key_mf k_mf;
197 key_vmf k_vmf;
198 key_cvmf k_cvmf;
199 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
200 key_crmf k_crmf;
201 key_rmf k_rmf;
202 key_vrmf k_vrmf;
203 key_cvrmf k_cvrmf;
204 #endif
205 key_gf k_gf;
206 key_gcrf k_gcrf;
207 key_grf k_grf;
208 compkey cmpk;
209 ccompkey ccmpk;
210 ccompw_key ccmpk_w;
211
212 test_derived_class td(-1,0);
213 const test_derived_class& ctdr=td;
214
215 test_class& tr=td;
216 const test_class& ctr=tr;
217
218 test_derived_class* tdp=&td;
219 const test_derived_class* ctdp=&ctdr;
220
221 test_class* tp=&tr;
222 const test_class* ctp=&tr;
223
224 test_class** tpp=&tp;
225 const test_class** ctpp=&ctp;
226
227 boost::scoped_ptr<test_class*> tap(new test_class*(tp));
228 boost::scoped_ptr<const test_class*> ctap(new const test_class*(ctp));
229
230 boost::reference_wrapper<test_class> tw(tr);
231 boost::reference_wrapper<const test_class> ctw(tr);
232
233 id(tr).int_member=0;
234 BOOST_TEST(id(tr).int_member==0);
235 BOOST_TEST(cid(tr).int_member==0);
236 BOOST_TEST(k_m(tr)==0);
237 BOOST_TEST(ck_m(tr)==0);
238 BOOST_TEST(cmpk(tr)==make_tuple(test_class(0,0),0,0,true));
239 BOOST_TEST(ccmpk(tr)==make_tuple(test_class(0,0),0));
240 BOOST_TEST(id(ctr).int_member==0);
241 BOOST_TEST(cid(ctr).int_member==0);
242 BOOST_TEST(k_m(ctr)==0);
243 BOOST_TEST(ck_m(ctr)==0);
244 BOOST_TEST(cmpk(ctr)==make_tuple(test_class(0,0),0,0,true));
245 BOOST_TEST(ccmpk(ctr)==make_tuple(test_class(0,0),0));
246
247 #if !defined(BOOST_NO_SFINAE)
248 BOOST_TEST(id(td).int_member==0);
249 BOOST_TEST(cid(td).int_member==0);
250 BOOST_TEST(k_m(td)==0);
251 BOOST_TEST(ck_m(td)==0);
252 BOOST_TEST(cmpk(td)==make_tuple(test_class(0,0),0,0,true));
253 BOOST_TEST(ccmpk(td)==make_tuple(test_class(0,0),0));
254 BOOST_TEST(id(ctdr).int_member==0);
255 BOOST_TEST(cid(ctdr).int_member==0);
256 BOOST_TEST(k_m(ctdr)==0);
257 BOOST_TEST(ck_m(ctdr)==0);
258 BOOST_TEST(cmpk(ctdr)==make_tuple(test_class(0,0),0,0,true));
259 BOOST_TEST(ccmpk(ctdr)==make_tuple(test_class(0,0),0));
260 #endif
261
262 k_m(tr)=1;
263 BOOST_TEST(id(tp).int_member==1);
264 BOOST_TEST(cid(tp).int_member==1);
265 BOOST_TEST(k_m(tp)==1);
266 BOOST_TEST(ck_m(tp)==1);
267 BOOST_TEST(cmpk(tp)==make_tuple(test_class(1,0),1,0,true));
268 BOOST_TEST(ccmpk(tp)==make_tuple(test_class(1,0),1));
269 BOOST_TEST(cid(ctp).int_member==1);
270 BOOST_TEST(ck_m(ctp)==1);
271 BOOST_TEST(cmpk(ctp)==make_tuple(test_class(1,0),1,0,true));
272 BOOST_TEST(ccmpk(ctp)==make_tuple(test_class(1,0),1));
273
274 #if !defined(BOOST_NO_SFINAE)
275 BOOST_TEST(id(tdp).int_member==1);
276 BOOST_TEST(cid(tdp).int_member==1);
277 BOOST_TEST(k_m(tdp)==1);
278 BOOST_TEST(ck_m(tdp)==1);
279 BOOST_TEST(cmpk(tdp)==make_tuple(test_class(1,0),1,0,true));
280 BOOST_TEST(ccmpk(tdp)==make_tuple(test_class(1,0),1));
281 BOOST_TEST(cid(ctdp).int_member==1);
282 BOOST_TEST(ck_m(ctdp)==1);
283 BOOST_TEST(cmpk(ctdp)==make_tuple(test_class(1,0),1,0,true));
284 BOOST_TEST(ccmpk(ctdp)==make_tuple(test_class(1,0),1));
285 #endif
286
287 k_m(tp)=2;
288 BOOST_TEST(id(tpp).int_member==2);
289 BOOST_TEST(cid(tpp).int_member==2);
290 BOOST_TEST(k_m(tpp)==2);
291 BOOST_TEST(ck_m(tpp)==2);
292 BOOST_TEST(cmpk(tpp)==make_tuple(test_class(2,0),2,0,true));
293 BOOST_TEST(ccmpk(tpp)==make_tuple(test_class(2,0),2));
294 BOOST_TEST(cid(ctpp).int_member==2);
295 BOOST_TEST(ck_m(ctpp)==2);
296 BOOST_TEST(cmpk(ctpp)==make_tuple(test_class(2,0),2,0,true));
297 BOOST_TEST(ccmpk(ctpp)==make_tuple(test_class(2,0),2));
298
299 k_m(tpp)=3;
300 BOOST_TEST(id(tap).int_member==3);
301 BOOST_TEST(cid(tap).int_member==3);
302 BOOST_TEST(k_m(tap)==3);
303 BOOST_TEST(ck_m(tap)==3);
304 BOOST_TEST(cmpk(tap)==make_tuple(test_class(3,0),3,0,true));
305 BOOST_TEST(ccmpk(tap)==make_tuple(test_class(3,0),3));
306 BOOST_TEST(cid(ctap).int_member==3);
307 BOOST_TEST(ck_m(ctap)==3);
308 BOOST_TEST(cmpk(ctap)==make_tuple(test_class(3,0),3,0,true));
309 BOOST_TEST(ccmpk(ctap)==make_tuple(test_class(3,0),3));
310
311 k_m(tap)=4;
312 BOOST_TEST(id(tw).int_member==4);
313 BOOST_TEST(cid(tw).int_member==4);
314 BOOST_TEST(k_m(tw)==4);
315 BOOST_TEST(ck_m(tw)==4);
316 BOOST_TEST(cmpk(tw)==make_tuple(test_class(4,0),4,0,true));
317 BOOST_TEST(ccmpk(tw)==make_tuple(test_class(4,0),4));
318
319 k_m(tw)=5;
320 BOOST_TEST(id(ctw).int_member==5);
321 BOOST_TEST(cid(ctw).int_member==5);
322 BOOST_TEST(k_m(ctw)==5);
323 BOOST_TEST(ck_m(ctw)==5);
324 BOOST_TEST(cmpk(ctw)==make_tuple(test_class(5,0),5,0,true));
325 BOOST_TEST(ccmpk(ctw)==make_tuple(test_class(5,0),5));
326
327 BOOST_TEST(k_cm(tr)==0);
328 BOOST_TEST(k_cm(ctr)==0);
329
330 #if !defined(BOOST_NO_SFINAE)
331 BOOST_TEST(k_cm(td)==0);
332 BOOST_TEST(k_cm(ctdr)==0);
333 #endif
334
335 BOOST_TEST(k_cm(tp)==0);
336 BOOST_TEST(k_cm(ctp)==0);
337
338 #if !defined(BOOST_NO_SFINAE)
339 BOOST_TEST(k_cm(tdp)==0);
340 BOOST_TEST(k_cm(ctdp)==0);
341 #endif
342
343 BOOST_TEST(k_cm(tpp)==0);
344 BOOST_TEST(k_cm(ctpp)==0);
345 BOOST_TEST(k_cm(tap)==0);
346 BOOST_TEST(k_cm(ctap)==0);
347
348 BOOST_TEST(k_cm(tw)==0);
349 BOOST_TEST(k_cm(ctw)==0);
350
351 BOOST_TEST(k_cmf(tr));
352 BOOST_TEST(k_cmf(ctr));
353 BOOST_TEST(k_cvmf(tr));
354 BOOST_TEST(k_cvmf(ctr));
355
356 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
357 BOOST_TEST(k_crmf(tr));
358 BOOST_TEST(k_crmf(ctr));
359 BOOST_TEST(k_cvrmf(tr));
360 BOOST_TEST(k_cvrmf(ctr));
361 #endif
362
363 #if !defined(BOOST_NO_SFINAE)
364 BOOST_TEST(k_cmf(td));
365 BOOST_TEST(k_cmf(ctdr));
366 BOOST_TEST(k_cvmf(td));
367 BOOST_TEST(k_cvmf(ctdr));
368
369 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
370 BOOST_TEST(k_crmf(td));
371 BOOST_TEST(k_crmf(ctdr));
372 BOOST_TEST(k_cvrmf(td));
373 BOOST_TEST(k_cvrmf(ctdr));
374 #endif
375 #endif
376
377 BOOST_TEST(k_cmf(tp));
378 BOOST_TEST(k_cmf(ctp));
379 BOOST_TEST(k_cvmf(tp));
380 BOOST_TEST(k_cvmf(ctp));
381
382 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
383 BOOST_TEST(k_crmf(tp));
384 BOOST_TEST(k_crmf(ctp));
385 BOOST_TEST(k_cvrmf(tp));
386 BOOST_TEST(k_cvrmf(ctp));
387 #endif
388
389 #if !defined(BOOST_NO_SFINAE)
390 BOOST_TEST(k_cmf(tdp));
391 BOOST_TEST(k_cmf(ctdp));
392 BOOST_TEST(k_cvmf(tdp));
393 BOOST_TEST(k_cvmf(ctdp));
394
395 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
396 BOOST_TEST(k_crmf(tdp));
397 BOOST_TEST(k_crmf(ctdp));
398 BOOST_TEST(k_cvrmf(tdp));
399 BOOST_TEST(k_cvrmf(ctdp));
400 #endif
401 #endif
402
403 BOOST_TEST(k_cmf(tpp));
404 BOOST_TEST(k_cmf(ctpp));
405 BOOST_TEST(k_cmf(tap));
406 BOOST_TEST(k_cmf(ctap));
407 BOOST_TEST(k_cvmf(tpp));
408 BOOST_TEST(k_cvmf(ctpp));
409 BOOST_TEST(k_cvmf(tap));
410 BOOST_TEST(k_cvmf(ctap));
411
412 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
413 BOOST_TEST(k_crmf(tpp));
414 BOOST_TEST(k_crmf(ctpp));
415 BOOST_TEST(k_crmf(tap));
416 BOOST_TEST(k_crmf(ctap));
417 BOOST_TEST(k_cvrmf(tpp));
418 BOOST_TEST(k_cvrmf(ctpp));
419 BOOST_TEST(k_cvrmf(tap));
420 BOOST_TEST(k_cvrmf(ctap));
421 #endif
422
423 BOOST_TEST(k_cmf(tw));
424 BOOST_TEST(k_cmf(ctw));
425 BOOST_TEST(k_cvmf(tw));
426 BOOST_TEST(k_cvmf(ctw));
427
428 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
429 BOOST_TEST(k_crmf(tw));
430 BOOST_TEST(k_crmf(ctw));
431 BOOST_TEST(k_cvrmf(tw));
432 BOOST_TEST(k_cvrmf(ctw));
433 #endif
434
435 BOOST_TEST(!k_mf(tr));
436 BOOST_TEST(!k_vmf(tr));
437
438 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
439 BOOST_TEST(!k_rmf(tr));
440 BOOST_TEST(!k_vrmf(tr));
441 #endif
442
443 #if !defined(BOOST_NO_SFINAE)
444 BOOST_TEST(!k_mf(td));
445 BOOST_TEST(!k_vmf(td));
446
447 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
448 BOOST_TEST(!k_rmf(td));
449 BOOST_TEST(!k_vrmf(td));
450 #endif
451 #endif
452
453 BOOST_TEST(!k_mf(tp));
454 BOOST_TEST(!k_vmf(tp));
455
456 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
457 BOOST_TEST(!k_rmf(tp));
458 BOOST_TEST(!k_vrmf(tp));
459 #endif
460
461 #if !defined(BOOST_NO_SFINAE)
462 BOOST_TEST(!k_mf(tdp));
463 BOOST_TEST(!k_vmf(tdp));
464
465 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
466 BOOST_TEST(!k_rmf(tdp));
467 BOOST_TEST(!k_vrmf(tdp));
468 #endif
469 #endif
470
471 BOOST_TEST(!k_mf(tpp));
472 BOOST_TEST(!k_mf(tap));
473 BOOST_TEST(!k_mf(tw));
474 BOOST_TEST(!k_vmf(tpp));
475 BOOST_TEST(!k_vmf(tap));
476 BOOST_TEST(!k_vmf(tw));
477
478 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
479 BOOST_TEST(!k_rmf(tpp));
480 BOOST_TEST(!k_rmf(tap));
481 BOOST_TEST(!k_rmf(tw));
482 BOOST_TEST(!k_vrmf(tpp));
483 BOOST_TEST(!k_vrmf(tap));
484 BOOST_TEST(!k_vrmf(tw));
485 #endif
486
487 BOOST_TEST(k_gf(tr));
488 BOOST_TEST(k_gf(ctr));
489
490 #if !defined(BOOST_NO_SFINAE)
491 BOOST_TEST(k_gf(td));
492 BOOST_TEST(k_gf(ctdr));
493 #endif
494
495 BOOST_TEST(k_gf(tp));
496 BOOST_TEST(k_gf(ctp));
497
498 #if !defined(BOOST_NO_SFINAE)
499 BOOST_TEST(k_gf(tdp));
500 BOOST_TEST(k_gf(ctdp));
501 #endif
502
503 BOOST_TEST(k_gf(tpp));
504 BOOST_TEST(k_gf(ctpp));
505 BOOST_TEST(k_gf(tap));
506 BOOST_TEST(k_gf(ctap));
507
508 BOOST_TEST(k_gf(tw));
509 BOOST_TEST(k_gf(ctw));
510
511 BOOST_TEST(!k_gcrf(tr));
512 BOOST_TEST(!k_gcrf(ctr));
513
514 #if !defined(BOOST_NO_SFINAE)
515 BOOST_TEST(!k_gcrf(td));
516 BOOST_TEST(!k_gcrf(ctdr));
517 #endif
518
519 BOOST_TEST(!k_gcrf(tp));
520 BOOST_TEST(!k_gcrf(ctp));
521
522 #if !defined(BOOST_NO_SFINAE)
523 BOOST_TEST(!k_gcrf(tdp));
524 BOOST_TEST(!k_gcrf(ctdp));
525 #endif
526
527 BOOST_TEST(!k_gcrf(tpp));
528 BOOST_TEST(!k_gcrf(ctpp));
529 BOOST_TEST(!k_gcrf(tap));
530 BOOST_TEST(!k_gcrf(ctap));
531
532 BOOST_TEST(!k_gcrf(tw));
533 BOOST_TEST(!k_gcrf(ctw));
534
535 BOOST_TEST(k_grf(tr));
536
537 #if !defined(BOOST_NO_SFINAE)
538 BOOST_TEST(k_grf(td));
539 #endif
540
541 BOOST_TEST(k_grf(tp));
542
543 #if !defined(BOOST_NO_SFINAE)
544 BOOST_TEST(k_grf(tdp));
545 #endif
546
547 BOOST_TEST(k_grf(tpp));
548 BOOST_TEST(k_grf(tap));
549 BOOST_TEST(k_grf(tw));
550
551 BOOST_TEST(ccmpk_w(tw)==make_tuple(false));
552
553 #if !defined(BOOST_NO_SFINAE)
554 /* testcases for problems with non-copyable classes reported at
555 * http://lists.boost.org/Archives/boost/2006/04/103065.php
556 */
557
558 nc_idn nc_id;
559 nc_cidn nc_cid;
560 nc_key_m nc_k_m;
561 nc_ckey_m nc_ck_m;
562 nc_key_cmf nc_k_cmf;
563 nc_key_mf nc_k_mf;
564 nc_key_gcrf nc_k_gcrf;
565 nc_key_grf nc_k_grf;
566 nc_compkey nc_cmpk;
567
568 test_nc_derived_class nc_td(-1,0);
569
570 nc_id(nc_td).int_member=0;
571 BOOST_TEST(nc_id(nc_td).int_member==0);
572 BOOST_TEST(nc_cid(nc_td).int_member==0);
573
574 nc_k_m(&nc_td)=1;
575 BOOST_TEST(nc_k_m(&nc_td)==1);
576 BOOST_TEST(nc_ck_m(&nc_td)==1);
577
578 BOOST_TEST(nc_k_cmf(nc_td));
579 BOOST_TEST(!nc_k_mf(nc_td));
580
581 BOOST_TEST(!nc_k_gcrf(nc_td));
582 BOOST_TEST(nc_k_grf(nc_td));
583
584 test_nc_class nc_t(1,0);
585 BOOST_TEST(nc_cmpk(nc_td)==make_tuple(boost::cref(nc_t),1,1,true));
586 #endif
587
588 std::list<test_class> tl;
589 for(int i=0;i<20;++i)tl.push_back(test_class(i));
590
591 int j=0;
592 for(std::list<test_class>::iterator it=tl.begin();it!=tl.end();++it){
593 BOOST_TEST(k_m(it)==j);
594 BOOST_TEST(k_cm(it)==j);
595 BOOST_TEST(k_cmf(it));
596 BOOST_TEST(!k_mf(it));
597 BOOST_TEST(k_gf(it));
598 BOOST_TEST(!k_gcrf(it));
599 BOOST_TEST(k_grf(it));
600 BOOST_TEST(cmpk(it)==make_tuple(test_class(j),j,j,true));
601 BOOST_TEST(ccmpk(it)==make_tuple(test_class(j),j));
602 ++j;
603 }
604 }
605