]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/same_traits.hpp
update from boost cvs
[lyx.git] / boost / boost / type_traits / same_traits.hpp
1 //  (C) Copyright Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant & John Maddock 2000.
2 //  Permission to copy, use, modify, sell and
3 //  distribute this software is granted provided this copyright notice appears
4 //  in all copies. This software is provided "as is" without express or implied
5 //  warranty, and with no claim as to its suitability for any purpose.
6 //
7 //  See http://www.boost.org for most recent version including documentation.
8 //
9 //  defines is_same:
10
11 // Revision History
12 // 19 Feb 2001 Fixed for MSVC (David Abrahams)
13
14 #ifndef BOOST_SAME_TRAITS_HPP
15 #define BOOST_SAME_TRAITS_HPP
16
17 #ifndef BOOST_ICE_TYPE_TRAITS_HPP
18 #include <boost/type_traits/ice.hpp>
19 #endif
20 #ifndef BOOST_FWD_TYPE_TRAITS_HPP
21 #include <boost/type_traits/fwd.hpp>
22 #endif
23 #if !defined(BOOST_COMPOSITE_TYPE_TRAITS_HPP) && defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC)
24 #include <boost/type_traits/composite_traits.hpp>
25 #endif
26
27 namespace boost{
28
29 /**********************************************
30  *
31  * is_same
32  *
33  **********************************************/
34 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
35
36 template <typename T, typename U>
37 struct is_same
38 { BOOST_STATIC_CONSTANT(bool, value = false); };
39
40 template <typename T>
41 struct is_same<T, T>
42 { BOOST_STATIC_CONSTANT(bool, value = true); };
43
44 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
45
46 #ifdef BOOST_MSVC
47 //
48 // the following VC6 specific implementation is *NOT* legal
49 // C++, but has the advantage that it works for incomplete
50 // types.
51 //
52 namespace detail{
53
54 template<class T1>
55 struct is_same_part_1 {
56   template<class T2>  struct part_2     { enum { value = false }; };
57   template<>          struct part_2<T1> { enum { value = true }; };
58 };
59
60 } // namespace detail
61
62 template<class T1, class T2>
63 struct is_same {
64     enum { value = detail::is_same_part_1<T1>::template part_2<T2>::value };
65 };
66
67 #else // BOOST_MSVC
68
69 namespace detail{
70    template <class T>
71    ::boost::type_traits::yes_type is_same_helper(T*, T*);
72    ::boost::type_traits::no_type is_same_helper(...);
73 }
74
75 template <typename T, typename U>
76 struct is_same
77 {
78 private:
79    static T t;
80    static U u;
81 public:
82    BOOST_STATIC_CONSTANT(bool, value =
83       (::boost::type_traits::ice_and<
84          (sizeof(type_traits::yes_type) == sizeof(detail::is_same_helper(&t,&u))),
85          (::boost::is_reference<T>::value == ::boost::is_reference<U>::value),
86          (sizeof(T) == sizeof(U))
87         >::value));
88 };
89
90 #endif // BOOST_MSVC
91
92 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
93
94 } // namespace boost
95
96 #endif  // BOOST_SAME_TRAITS_HPP
97  
98
99