Add Boost.Test karmic valgrind suppressions
[senf.git] / boost_ext / boost / multi_index / detail / uintptr_type.hpp
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)
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
19 namespace boost{
20
21 namespace multi_index{
22
23 namespace 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
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;};
40
41 #if defined(BOOST_HAS_LONG_LONG)
42 template<>struct uintptr_candidates<3> {typedef unsigned long long type;};
43 #else
44 template<>struct uintptr_candidates<3> {typedef unsigned int       type;};
45 #endif
46
47 #if defined(BOOST_HAS_MS_INT64)
48 template<>struct uintptr_candidates<4> {typedef unsigned __int64   type;};
49 #else
50 template<>struct uintptr_candidates<4> {typedef unsigned int       type;};
51 #endif
52
53 struct 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
67 typedef mpl::bool_<uintptr_aux::has_uintptr_type> has_uintptr_type;
68 typedef uintptr_aux::type                         uintptr_type;
69
70 } /* namespace multi_index::detail */
71
72 } /* namespace multi_index */
73
74 } /* namespace boost */
75
76 #endif