epoc32/include/stdapis/boost/graph/detail/is_same.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/stdapis/boost/type_traits/is_same.hpp@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
williamr@2
     2
//  (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, 
williamr@2
     3
//      Howard Hinnant and John Maddock 2000. 
williamr@2
     4
//  (C) Copyright Mat Marcus, Jesse Jones and Adobe Systems Inc 2001
williamr@2
     5
williamr@2
     6
//  Use, modification and distribution are subject to the Boost Software License,
williamr@2
     7
//  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
williamr@2
     8
//  http://www.boost.org/LICENSE_1_0.txt).
williamr@2
     9
//
williamr@2
    10
//  See http://www.boost.org/libs/type_traits for most recent version including documentation.
williamr@2
    11
williamr@2
    12
//    Fixed is_pointer, is_reference, is_const, is_volatile, is_same, 
williamr@2
    13
//    is_member_pointer based on the Simulated Partial Specialization work 
williamr@2
    14
//    of Mat Marcus and Jesse Jones. See  http://opensource.adobe.com or 
williamr@2
    15
//    http://groups.yahoo.com/group/boost/message/5441 
williamr@2
    16
//    Some workarounds in here use ideas suggested from "Generic<Programming>: 
williamr@2
    17
//    Mappings between Types and Values" 
williamr@2
    18
//    by Andrei Alexandrescu (see http://www.cuj.com/experts/1810/alexandr.html).
williamr@2
    19
williamr@2
    20
williamr@2
    21
#ifndef BOOST_TT_IS_SAME_HPP_INCLUDED
williamr@2
    22
#define BOOST_TT_IS_SAME_HPP_INCLUDED
williamr@2
    23
williamr@2
    24
#include <boost/type_traits/config.hpp>
williamr@2
    25
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
williamr@2
    26
#include <boost/type_traits/detail/yes_no_type.hpp>
williamr@2
    27
#include <boost/type_traits/detail/ice_and.hpp>
williamr@2
    28
#include <boost/type_traits/is_reference.hpp>
williamr@2
    29
#endif
williamr@2
    30
// should be the last #include
williamr@2
    31
#include <boost/type_traits/detail/bool_trait_def.hpp>
williamr@2
    32
williamr@2
    33
namespace boost {
williamr@2
    34
williamr@2
    35
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
williamr@2
    36
williamr@2
    37
BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,false)
williamr@2
    38
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(typename T,is_same,T,T,true)
williamr@2
    39
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
williamr@2
    40
// without this, Borland's compiler gives the wrong answer for
williamr@2
    41
// references to arrays:
williamr@2
    42
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(typename T,is_same,T&,T&,true)
williamr@2
    43
#endif
williamr@2
    44
williamr@2
    45
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
williamr@2
    46
williamr@2
    47
namespace detail {
williamr@2
    48
williamr@2
    49
#ifdef BOOST_MSVC
williamr@2
    50
// the following VC6 specific implementation is *NOT* legal
williamr@2
    51
// C++, but has the advantage that it works for incomplete
williamr@2
    52
// types.
williamr@2
    53
williamr@2
    54
template< typename T1 >
williamr@2
    55
struct is_same_part_1
williamr@2
    56
{
williamr@2
    57
    template<typename T2>  struct part_2     { enum { value = false }; };
williamr@2
    58
    template<>             struct part_2<T1> { enum { value = true }; };
williamr@2
    59
};
williamr@2
    60
williamr@2
    61
template< typename T1, typename T2 >
williamr@2
    62
struct is_same_impl
williamr@2
    63
{
williamr@2
    64
    enum { value = detail::is_same_part_1<T1>::template part_2<T2>::value };
williamr@2
    65
};
williamr@2
    66
williamr@2
    67
#else // generic "no-partial-specialization" version
williamr@2
    68
williamr@2
    69
template <typename T>
williamr@2
    70
::boost::type_traits::yes_type
williamr@2
    71
BOOST_TT_DECL is_same_tester(T*, T*);
williamr@2
    72
williamr@2
    73
::boost::type_traits::no_type
williamr@2
    74
BOOST_TT_DECL is_same_tester(...);
williamr@2
    75
williamr@2
    76
template <typename T, typename U>
williamr@2
    77
struct is_same_impl
williamr@2
    78
{
williamr@2
    79
   static T t;
williamr@2
    80
   static U u;
williamr@2
    81
williamr@2
    82
   BOOST_STATIC_CONSTANT(bool, value =
williamr@2
    83
      (::boost::type_traits::ice_and<
williamr@2
    84
         (sizeof(type_traits::yes_type) == sizeof(detail::is_same_tester(&t,&u))),
williamr@2
    85
         (::boost::is_reference<T>::value == ::boost::is_reference<U>::value),
williamr@2
    86
         (sizeof(T) == sizeof(U))
williamr@2
    87
        >::value));
williamr@2
    88
};
williamr@2
    89
williamr@2
    90
#endif // BOOST_MSVC
williamr@2
    91
williamr@2
    92
} // namespace detail
williamr@2
    93
williamr@2
    94
BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,(::boost::detail::is_same_impl<T,U>::value))
williamr@2
    95
williamr@2
    96
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
williamr@2
    97
williamr@2
    98
} // namespace boost
williamr@2
    99
williamr@2
   100
#include <boost/type_traits/detail/bool_trait_undef.hpp>
williamr@2
   101
williamr@2
   102
#endif  // BOOST_TT_IS_SAME_HPP_INCLUDED
williamr@2
   103