
template <typename T> ::boost::type_traits::yes_type BOOST_TT_DECL is_same_tester(T*, T*); ::boost::type_traits::no_type BOOST_TT_DECL is_same_tester(...); template <typename T, typename U> struct is_same_impl { static T t; static U u; BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_and< (sizeof(type_traits::yes_type) == sizeof(detail::is_same_tester(&t,&u))), (::boost::is_reference<T>::value == ::boost::is_reference<U>::value), (sizeof(T) == sizeof(U)) >::value)); }; Would it be any better to do is_same_tester with just one arg, like this: template <typename T> ::boost::type_traits::yes_type BOOST_TT_DECL is_same_tester(T*); template <typename T> ::boost::type_traits::no_type BOOST_TT_DECL is_same_tester(...); and then the call is:. (sizeof(type_traits::yes_type) == sizeof(detail::is_same_tester<T>(&u))), (and then not need a 'static T t' at all?) And does it make any difference to declare the U as a pointer: static U *u; // and/or leave off the static and then not pass it in by address: (sizeof(type_traits::yes_type) == sizeof(detail::is_same_tester<T>(u))), Or not bother with a U at all, but just cast 0 into a U*: (sizeof(type_traits::yes_type) == sizeof(detail::is_same_tester<T>(static_cast<U *>(0)))), Or does none of it really make a difference? And while I am at it, what would the value of 'same' be: struct A { int x; }; struct B : A; static bool same = boost::type_traits::is_same<A, B>::value; I suspect same == true, as B is castable to an A, and sizeof(B) == sizeof(A). checking both is_same_tester<T>(u) and is_same_tester<U>(t) might be better?

Or does none of it really make a difference?
As things stand probably not: the code that you're looking at there is only used by compilers which * do not support partial specialisation. * and are not MSVC. Are there any compilers still left in that category any more? Certainly none that we test with. John.

"John Maddock" <john@johnmaddock.co.uk> writes:
Or does none of it really make a difference?
As things stand probably not: the code that you're looking at there is only used by compilers which
* do not support partial specialisation. * and are not MSVC.
Are there any compilers still left in that category any more? Certainly none that we test with.
Were there ever any compilers in that category? -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (3)
-
David Abrahams
-
Gottlob Frege
-
John Maddock