@@ -266,13 +266,13 @@ namespace classdesc
266
266
template <class T > struct enable_if_c <false ,T> {};
267
267
// / controlled template specialisation: stolen from boost::enable_if.
268
268
/* *
269
- \a Cond is a condition class inheriting from \c
270
- std::tr1::true_type or std::tr1::false_type
269
+ \a Cond is a condition class inheriting from \c
270
+ std::tr1::true_type or std::tr1::false_type
271
271
*/
272
272
template <class Cond , class T =void > struct enable_if :
273
273
public enable_if_c<Cond::value,T> {};
274
274
275
- #undef True
275
+ #undef True
276
276
// NB - implementation of C++11 std::conditional
277
277
template <bool C, class True , class F >
278
278
struct conditional
@@ -316,7 +316,7 @@ namespace classdesc
316
316
template <class K , class V , class C , class A >
317
317
struct is_associative_container <std::map<K,V,C,A> > {
318
318
static const bool value=true ;};
319
- template <class T , class C , class A >
319
+ template <class T , class C , class A >
320
320
struct is_associative_container <std::multiset<T,C,A> > {
321
321
static const bool value=true ;};
322
322
template <class K , class V , class C , class A >
@@ -348,7 +348,7 @@ namespace classdesc
348
348
// / determines if T is a container
349
349
template <class T > struct is_container {
350
350
static const bool value=
351
- is_sequence<T>::value||is_associative_container<T>::value;
351
+ is_sequence<T>::value||is_associative_container<T>::value;
352
352
};
353
353
354
354
// / true_type if T is a StringKeyMap
@@ -418,16 +418,28 @@ namespace classdesc
418
418
{static const bool value=X==Y;};
419
419
// /@}
420
420
421
+ // / transfer the constness property of T to U
422
+ template <class T , class U , bool c=std::is_const<T>::value> struct transfer_const ;
423
+ template <class T , class U > struct transfer_const <T,U,true >
424
+ {
425
+ typedef typename std::add_const<U>::type type;
426
+ };
427
+
428
+ template <class T , class U > struct transfer_const <T,U,false >
429
+ {
430
+ typedef typename std::remove_const<U>::type type;
431
+ };
432
+
421
433
// / utility macro for declaring if a type has a particular member of
422
434
// / type \a Sig
423
- #define CLASSDESC_HAS_MEMBER (mem ) \
424
- template <class T , class Sig > \
425
- struct has_member_ ##mem \
426
- { \
427
- template <class U , Sig> struct SFINAE {}; \
428
- template <class U > static char test (SFINAE<U,&U::mem>*); \
429
- template <class U > static int test (...); \
430
- const static bool value=sizeof (test<T>(0 ))==sizeof (char ); \
435
+ #define CLASSDESC_HAS_MEMBER (mem ) \
436
+ template <class T , class Sig > \
437
+ struct has_member_ ##mem \
438
+ { \
439
+ template <class U , Sig> struct SFINAE {}; \
440
+ template <class U > static char test (SFINAE<U,&U::mem>*); \
441
+ template <class U > static int test (...); \
442
+ const static bool value=sizeof (test<T>(0 ))==sizeof (char ); \
431
443
};
432
444
433
445
// handle resize on nonresizable containers such as std::array
@@ -467,21 +479,21 @@ namespace classdesc
467
479
468
480
469
481
470
- // template <class T>
471
- // typename enable_if<is_sequence<T>,void>::T
472
- // resize(T& x, std::size_t n) {x.resize(n);}
473
- // #if defined(__cplusplus) && __cplusplus>=201103L
474
- // template <class T, std::size_t N>
475
- // void resize(std::array<T,N>& x, std::size_t n) {}
476
- // #endif
482
+ // template <class T>
483
+ // typename enable_if<is_sequence<T>,void>::T
484
+ // resize(T& x, std::size_t n) {x.resize(n);}
485
+ // #if defined(__cplusplus) && __cplusplus>=201103L
486
+ // template <class T, std::size_t N>
487
+ // void resize(std::array<T,N>& x, std::size_t n) {}
488
+ // #endif
477
489
478
490
479
491
// / has default constructor, and is copiable
480
492
481
493
// is_assignable doesn't seem to be working correctly yet
482
- // template <class T> struct is_dca:
483
- // public And<And<is_default_constructible<T>, is_copy_constructible<T> >,
484
- // is_assignable<T,T> > {};
494
+ // template <class T> struct is_dca:
495
+ // public And<And<is_default_constructible<T>, is_copy_constructible<T> >,
496
+ // is_assignable<T,T> > {};
485
497
template <class T > struct is_dca :
486
498
public And<is_default_constructible<T>, is_copy_constructible<T> > {};
487
499
@@ -502,7 +514,7 @@ namespace classdesc
502
514
503
515
template <class T > struct is_rvalue <const T&>: public is_rvalue<T> {};
504
516
505
- // / @}
517
+ // / @}
506
518
507
519
// / base class for exceptions thrown by classdesc
508
520
struct exception : std::runtime_error
@@ -513,13 +525,13 @@ namespace classdesc
513
525
#if defined(__cplusplus) && __cplusplus>=201103L
514
526
template <class Tp , class EqualTo >
515
527
struct has_equality_operator_impl
516
- {
517
- template <class U , class V >
518
- static auto test (U*) -> decltype(std::declval<U>() == std::declval<V>());
519
- template <typename , typename >
520
- static auto test (...) -> std::false_type;
521
- using type=typename std::is_same<bool , decltype(test<Tp, EqualTo>(0 ))>::type;
522
- };
528
+ {
529
+ template <class U , class V >
530
+ static auto test (U*) -> decltype(std::declval<U>() == std::declval<V>());
531
+ template <typename , typename >
532
+ static auto test (...) -> std::false_type;
533
+ using type=typename std::is_same<bool , decltype(test<Tp, EqualTo>(0 ))>::type;
534
+ };
523
535
template <class T , class EqualTo =T>
524
536
struct has_equality_operator : public has_equality_operator_impl <T,EqualTo>::type {};
525
537
@@ -535,15 +547,15 @@ namespace classdesc
535
547
template <class T >
536
548
typename enable_if<
537
549
And<Not<is_function<T> >, Not<is_member_function_pointer<T> > >,
538
- std::string>::T typeName ();
550
+ std::string>::T typeName ();
539
551
540
552
#if defined(__cplusplus) && __cplusplus>=201103L
541
553
// handle variadic arguments
542
554
template <class T , class ... A> std::string varTn () {return typeName<T>()+" ," +varTn<A...>();}
543
555
template <class T > std::string varTn () {return typeName<T>();}
544
556
#endif
545
557
546
- // /@{ a string representation of the type
558
+ // /@{ a string representation of the type
547
559
template <> inline std::string typeName<void >() {return " void" ;}
548
560
template <> inline std::string typeName<bool >() {return " bool" ;}
549
561
template <> inline std::string typeName<char >() {return " char" ;}
@@ -644,7 +656,7 @@ namespace classdesc
644
656
};
645
657
#endif
646
658
647
- template <class T ,class A > struct tn <std::vector<T,A> >
659
+ template <class T ,class A > struct tn <std::vector<T,A> >
648
660
{
649
661
static std::string name ()
650
662
{return " std::vector<" +typeName<T>()+" >" ;}
@@ -1002,7 +1014,7 @@ namespace classdesc
1002
1014
typename enable_if<is_integral<U>,const T*>::T
1003
1015
operator +(U x) const {return val+x;}
1004
1016
std::ptrdiff_t operator -(const T* x) const {return val-x;}
1005
- };
1017
+ };
1006
1018
1007
1019
template <class T , class U >
1008
1020
typename enable_if<is_integral<U>,T*>::T
0 commit comments