PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/multi_index/detail/uintptr_type.hpp

http://hadesmem.googlecode.com/
C++ Header | 76 lines | 42 code | 18 blank | 16 comment | 0 complexity | 78f817ee4336d1df283daa27788d40d3 MD5 | raw file
 1/* Copyright 2003-2008 Joaquin M Lopez Munoz.
 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)
 5 *
 6 * See http://www.boost.org/libs/multi_index for library home page.
 7 */
 8
 9#ifndef BOOST_MULTI_INDEX_DETAIL_UINTPTR_TYPE_HPP
10#define BOOST_MULTI_INDEX_DETAIL_UINTPTR_TYPE_HPP
11
12#if defined(_MSC_VER)&&(_MSC_VER>=1200)
13#pragma once
14#endif
15
16#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17#include <boost/mpl/bool.hpp>
18
19namespace boost{
20
21namespace multi_index{
22
23namespace detail{
24
25/* has_uintptr_type is an MPL integral constant determining whether
26 * there exists an unsigned integral type with the same size as
27 * void *.
28 * uintptr_type is such a type if has_uintptr is true, or unsigned int
29 * otherwise.
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.
33 */
34
35template<int N>struct uintptr_candidates;
36template<>struct uintptr_candidates<-1>{typedef unsigned int           type;};
37template<>struct uintptr_candidates<0> {typedef unsigned int           type;};
38template<>struct uintptr_candidates<1> {typedef unsigned short         type;};
39template<>struct uintptr_candidates<2> {typedef unsigned long          type;};
40
41#if defined(BOOST_HAS_LONG_LONG)
42template<>struct uintptr_candidates<3> {typedef boost::ulong_long_type type;};
43#else
44template<>struct uintptr_candidates<3> {typedef unsigned int           type;};
45#endif
46
47#if defined(BOOST_HAS_MS_INT64)
48template<>struct uintptr_candidates<4> {typedef unsigned __int64       type;};
49#else
50template<>struct uintptr_candidates<4> {typedef unsigned int           type;};
51#endif
52
53struct uintptr_aux
54{
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);
61
62  BOOST_STATIC_CONSTANT(bool,has_uintptr_type=(index>=0));
63
64  typedef uintptr_candidates<index>::type type;
65};
66
67typedef mpl::bool_<uintptr_aux::has_uintptr_type> has_uintptr_type;
68typedef uintptr_aux::type                         uintptr_type;
69
70} /* namespace multi_index::detail */
71
72} /* namespace multi_index */
73
74} /* namespace boost */
75
76#endif