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