blob: 58a03c43c3b38f6b06f98bca2e5bdcf596f5902e [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
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
Jeff Thompson2277ce52013-08-01 17:34:11 -070024#include <ndnboost/type_traits/config.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070025#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompson2277ce52013-08-01 17:34:11 -070026#include <ndnboost/type_traits/detail/yes_no_type.hpp>
27#include <ndnboost/type_traits/detail/ice_and.hpp>
28#include <ndnboost/type_traits/is_reference.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070029#endif
30// should be the last #include
Jeff Thompson2277ce52013-08-01 17:34:11 -070031#include <ndnboost/type_traits/detail/bool_trait_def.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070032
33namespace ndnboost {
34
35#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
36
37BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,false)
38BOOST_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:
42BOOST_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
47namespace 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
54template< typename T1 >
55struct 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
61template< typename T1, typename T2 >
62struct is_same_impl
63{
64 enum { value = ndnboost::detail::is_same_part_1<T1>::template part_2<T2>::value };
65};
66
67#else // generic "no-partial-specialization" version
68
69template <typename T>
70::ndnboost::type_traits::yes_type
71BOOST_TT_DECL is_same_tester(T*, T*);
72
73::ndnboost::type_traits::no_type
74BOOST_TT_DECL is_same_tester(...);
75
76template <typename T, typename U>
77struct is_same_impl
78{
79 static T t;
80 static U u;
81
82 BOOST_STATIC_CONSTANT(bool, value =
83 (::ndnboost::type_traits::ice_and<
84 (sizeof(type_traits::yes_type) == sizeof(ndnboost::detail::is_same_tester(&t,&u))),
85 (::ndnboost::is_reference<T>::value == ::ndnboost::is_reference<U>::value),
86 (sizeof(T) == sizeof(U))
87 >::value));
88};
89
90#endif // BOOST_MSVC
91
92} // namespace detail
93
94BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,(::ndnboost::detail::is_same_impl<T,U>::value))
95
96#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
97
98} // namespace ndnboost
99
Jeff Thompson2277ce52013-08-01 17:34:11 -0700100#include <ndnboost/type_traits/detail/bool_trait_undef.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700101
102#endif // BOOST_TT_IS_SAME_HPP_INCLUDED
103