~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/type_traits/is_same.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#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"
 
19
#endif
 
20
// should be the last #include
 
21
#include "boost/type_traits/detail/bool_trait_def.hpp"
 
22
 
 
23
namespace boost {
 
24
 
 
25
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
26
 
 
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)
 
29
#ifdef __BORLANDC__
 
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)
 
33
#endif
 
34
 
 
35
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
36
 
 
37
namespace detail {
 
38
 
 
39
#ifdef BOOST_MSVC
 
40
// the following VC6 specific implementation is *NOT* legal
 
41
// C++, but has the advantage that it works for incomplete
 
42
// types.
 
43
 
 
44
template< typename T1 >
 
45
struct is_same_part_1
 
46
{
 
47
    template<typename T2>  struct part_2     { enum { value = false }; };
 
48
    template<>             struct part_2<T1> { enum { value = true }; };
 
49
};
 
50
 
 
51
template< typename T1, typename T2 >
 
52
struct is_same_impl
 
53
{
 
54
    enum { value = detail::is_same_part_1<T1>::template part_2<T2>::value };
 
55
};
 
56
 
 
57
#else // generic "no-partial-specialization" version
 
58
 
 
59
template <typename T>
 
60
::boost::type_traits::yes_type
 
61
BOOST_TT_DECL is_same_tester(T*, T*);
 
62
 
 
63
::boost::type_traits::no_type
 
64
BOOST_TT_DECL is_same_tester(...);
 
65
 
 
66
template <typename T, typename U>
 
67
struct is_same_impl
 
68
{
 
69
   static T t;
 
70
   static U u;
 
71
 
 
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))
 
77
        >::value));
 
78
};
 
79
 
 
80
#endif // BOOST_MSVC
 
81
 
 
82
} // namespace detail
 
83
 
 
84
BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,(::boost::detail::is_same_impl<T,U>::value))
 
85
 
 
86
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
87
 
 
88
} // namespace boost
 
89
 
 
90
#include "boost/type_traits/detail/bool_trait_undef.hpp"
 
91
 
 
92
#endif  // BOOST_TT_IS_SAME_HPP_INCLUDED
 
93