1 /* Copyright 2003-2007 Joaquín M López Muñoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/multi_index for library home page.
9 #ifndef BOOST_MULTI_INDEX_DETAIL_UINTPTR_TYPE_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_UINTPTR_TYPE_HPP
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17 #include <boost/mpl/bool.hpp>
21 namespace multi_index{
25 /* has_uintptr_type is an MPL integral constant determining whether
26 * there exists an unsigned integral type with the same size as
28 * uintptr_type is such a type if has_uintptr is true, or unsigned int
30 * Note that uintptr_type is more restrictive than C99 uintptr_t,
31 * where an integral type with size greater than that of void *
32 * would be conformant.
35 template<int N>struct uintptr_candidates;
36 template<>struct uintptr_candidates<-1>{typedef unsigned int type;};
37 template<>struct uintptr_candidates<0> {typedef unsigned int type;};
38 template<>struct uintptr_candidates<1> {typedef unsigned short type;};
39 template<>struct uintptr_candidates<2> {typedef unsigned long type;};
41 #if defined(BOOST_HAS_LONG_LONG)
42 template<>struct uintptr_candidates<3> {typedef unsigned long long type;};
44 template<>struct uintptr_candidates<3> {typedef unsigned int type;};
47 #if defined(BOOST_HAS_MS_INT64)
48 template<>struct uintptr_candidates<4> {typedef unsigned __int64 type;};
50 template<>struct uintptr_candidates<4> {typedef unsigned int type;};
55 BOOST_STATIC_CONSTANT(int,index=
56 sizeof(void*)==sizeof(uintptr_candidates<0>::type)?0:
57 sizeof(void*)==sizeof(uintptr_candidates<1>::type)?1:
58 sizeof(void*)==sizeof(uintptr_candidates<2>::type)?2:
59 sizeof(void*)==sizeof(uintptr_candidates<3>::type)?3:
60 sizeof(void*)==sizeof(uintptr_candidates<4>::type)?4:-1);
62 BOOST_STATIC_CONSTANT(bool,has_uintptr_type=(index>=0));
64 typedef uintptr_candidates<index>::type type;
67 typedef mpl::bool_<uintptr_aux::has_uintptr_type> has_uintptr_type;
68 typedef uintptr_aux::type uintptr_type;
70 } /* namespace multi_index::detail */
72 } /* namespace multi_index */
74 } /* namespace boost */