]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/random/detail/ptr_helper.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
d583afe8ed3fabd3292b0135bec183b6e357b2d2
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / random / detail / ptr_helper.hpp
1 /* boost random/detail/ptr_helper.hpp header file\r
2  *\r
3  * Copyright Jens Maurer 2002\r
4  * Distributed under the Boost Software License, Version 1.0. (See\r
5  * accompanying file LICENSE_1_0.txt or copy at\r
6  * http://www.boost.org/LICENSE_1_0.txt)\r
7  *\r
8  * See http://www.boost.org for most recent version including documentation.\r
9  *\r
10  * $Id: ptr_helper.hpp 24096 2004-07-27 03:43:34Z dgregor $\r
11  *\r
12  */\r
13 \r
14 #ifndef BOOST_RANDOM_DETAIL_PTR_HELPER_HPP\r
15 #define BOOST_RANDOM_DETAIL_PTR_HELPER_HPP\r
16 \r
17 #include <boost/config.hpp>\r
18 \r
19 \r
20 namespace boost {\r
21 namespace random {\r
22 namespace detail {\r
23 \r
24 // type_traits could help here, but I don't want to depend on type_traits.\r
25 template<class T>\r
26 struct ptr_helper\r
27 {\r
28   typedef T value_type;\r
29   typedef T& reference_type;\r
30   typedef const T& rvalue_type;\r
31   static reference_type ref(T& r) { return r; }\r
32   static const T& ref(const T& r) { return r; }\r
33 };\r
34 \r
35 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION\r
36 template<class T>\r
37 struct ptr_helper<T&>\r
38 {\r
39   typedef T value_type;\r
40   typedef T& reference_type;\r
41   typedef T& rvalue_type;\r
42   static reference_type ref(T& r) { return r; }\r
43   static const T& ref(const T& r) { return r; }\r
44 };\r
45 \r
46 template<class T>\r
47 struct ptr_helper<T*>\r
48 {\r
49   typedef T value_type;\r
50   typedef T& reference_type;\r
51   typedef T* rvalue_type;\r
52   static reference_type ref(T * p) { return *p; }\r
53   static const T& ref(const T * p) { return *p; }\r
54 };\r
55 #endif\r
56 \r
57 } // namespace detail\r
58 } // namespace random\r
59 } // namespace boost\r
60 \r
61 //\r
62 // BOOST_RANDOM_PTR_HELPER_SPEC --\r
63 //\r
64 //  Helper macro for broken compilers defines specializations of\r
65 //  ptr_helper.\r
66 //\r
67 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION\r
68 # define BOOST_RANDOM_PTR_HELPER_SPEC(T)                \\r
69 namespace boost { namespace random { namespace detail { \\r
70 template<>                                              \\r
71 struct ptr_helper<T&>                                   \\r
72 {                                                       \\r
73   typedef T value_type;                                 \\r
74   typedef T& reference_type;                            \\r
75   typedef T& rvalue_type;                               \\r
76   static reference_type ref(T& r) { return r; }         \\r
77   static const T& ref(const T& r) { return r; }         \\r
78 };                                                      \\r
79                                                         \\r
80 template<>                                              \\r
81 struct ptr_helper<T*>                                   \\r
82 {                                                       \\r
83   typedef T value_type;                                 \\r
84   typedef T& reference_type;                            \\r
85   typedef T* rvalue_type;                               \\r
86   static reference_type ref(T * p) { return *p; }       \\r
87   static const T& ref(const T * p) { return *p; }       \\r
88 };                                                      \\r
89 }}}\r
90 #else\r
91 # define BOOST_RANDOM_PTR_HELPER_SPEC(T)\r
92 #endif \r
93 \r
94 #endif // BOOST_RANDOM_DETAIL_PTR_HELPER_HPP\r