2 // (C) Copyright Steve Cleary, Beman Dawes, Aleksey Gurtovoy,
3 // Howard Hinnant & John Maddock 2000.
4 // Permission to copy, use, modify, sell and distribute this software is
5 // granted provided this copyright notice appears in all copies. This
6 // software is provided "as is" without express or implied warranty, and
7 // with no claim as to its suitability for any purpose.
9 // See http://www.boost.org for most recent version including documentation.
11 #ifndef BOOST_TT_IS_SAME_HPP_INCLUDED
12 #define BOOST_TT_IS_SAME_HPP_INCLUDED
14 #include "boost/type_traits/config.hpp"
15 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
16 #include "boost/type_traits/detail/yes_no_type.hpp"
17 #include "boost/type_traits/detail/ice_and.hpp"
18 #include "boost/type_traits/is_reference.hpp"
20 // should be the last #include
21 #include "boost/type_traits/detail/bool_trait_def.hpp"
25 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
27 BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,false)
28 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(typename T,is_same,T,T,true)
30 // without this, Borland's compiler gives the wrong answer for
31 // references to arrays:
32 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(typename T,is_same,T&,T&,true)
35 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
40 // the following VC6 specific implementation is *NOT* legal
41 // C++, but has the advantage that it works for incomplete
44 template< typename T1 >
47 template<typename T2> struct part_2 { enum { value = false }; };
48 template<> struct part_2<T1> { enum { value = true }; };
51 template< typename T1, typename T2 >
54 enum { value = detail::is_same_part_1<T1>::template part_2<T2>::value };
57 #else // generic "no-partial-specialization" version
60 ::boost::type_traits::yes_type
61 BOOST_TT_DECL is_same_tester(T*, T*);
63 ::boost::type_traits::no_type
64 BOOST_TT_DECL is_same_tester(...);
66 template <typename T, typename U>
72 BOOST_STATIC_CONSTANT(bool, value =
73 (::boost::type_traits::ice_and<
74 (sizeof(type_traits::yes_type) == sizeof(detail::is_same_tester(&t,&u))),
75 (::boost::is_reference<T>::value == ::boost::is_reference<U>::value),
76 (sizeof(T) == sizeof(U))
84 BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,(::boost::detail::is_same_impl<T,U>::value))
86 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
90 #include "boost/type_traits/detail/bool_trait_undef.hpp"
92 #endif // BOOST_TT_IS_SAME_HPP_INCLUDED