]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/is_same.hpp
complie fix
[lyx.git] / boost / boost / type_traits / is_same.hpp
1
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.
8 //
9 // See http://www.boost.org for most recent version including documentation.
10
11 #ifndef BOOST_TT_IS_SAME_HPP_INCLUDED
12 #define BOOST_TT_IS_SAME_HPP_INCLUDED
13
14 // should be the last #include
15 #include "boost/type_traits/detail/bool_trait_def.hpp"
16
17 namespace boost {
18
19 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
20
21 BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,false)
22 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(typename T,is_same,T,T,true)
23
24 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
25
26 namespace detail {
27
28 #ifdef BOOST_MSVC
29 // the following VC6 specific implementation is *NOT* legal
30 // C++, but has the advantage that it works for incomplete
31 // types.
32
33 template< typename T1 >
34 struct is_same_part_1
35 {
36     template<typename T2>  struct part_2     { enum { value = false }; };
37     template<>             struct part_2<T1> { enum { value = true }; };
38 };
39
40 template< typename T1, typename T2 >
41 struct is_same_impl
42 {
43     enum { value = detail::is_same_part_1<T1>::template part_2<T2>::value };
44 };
45
46 #else // generic "no-partial-specialization" version
47
48 template <typename T>
49 ::boost::type_traits::yes_type
50 BOOST_TT_DECL is_same_tester(T*, T*);
51
52 ::boost::type_traits::no_type
53 BOOST_TT_DECL is_same_tester(...);
54
55 template <typename T, typename U>
56 struct is_same_impl
57 {
58    static T t;
59    static U u;
60
61    BOOST_STATIC_CONSTANT(bool, value =
62       (::boost::type_traits::ice_and<
63          (sizeof(type_traits::yes_type) == sizeof(detail::is_same_tester(&t,&u))),
64          (::boost::is_reference<T>::value == ::boost::is_reference<U>::value),
65          (sizeof(T) == sizeof(U))
66         >::value));
67 };
68
69 #endif // BOOST_MSVC
70
71 } // namespace detail
72
73 BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,(::boost::detail::is_same_impl<T,U>::value))
74
75 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
76
77 } // namespace boost
78
79 #include "boost/type_traits/detail/bool_trait_undef.hpp"
80
81 #endif  // BOOST_TT_IS_SAME_HPP_INCLUDED