Chris@16
|
1 /* boost random/detail/ptr_helper.hpp header file
|
Chris@16
|
2 *
|
Chris@16
|
3 * Copyright Jens Maurer 2002
|
Chris@16
|
4 * Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
5 * accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 *
|
Chris@16
|
8 * See http://www.boost.org for most recent version including documentation.
|
Chris@16
|
9 *
|
Chris@101
|
10 * $Id$
|
Chris@16
|
11 *
|
Chris@16
|
12 */
|
Chris@16
|
13
|
Chris@16
|
14 #ifndef BOOST_RANDOM_DETAIL_PTR_HELPER_HPP
|
Chris@16
|
15 #define BOOST_RANDOM_DETAIL_PTR_HELPER_HPP
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/config.hpp>
|
Chris@16
|
18
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost {
|
Chris@16
|
21 namespace random {
|
Chris@16
|
22 namespace detail {
|
Chris@16
|
23
|
Chris@16
|
24 // type_traits could help here, but I don't want to depend on type_traits.
|
Chris@16
|
25 template<class T>
|
Chris@16
|
26 struct ptr_helper
|
Chris@16
|
27 {
|
Chris@16
|
28 typedef T value_type;
|
Chris@16
|
29 typedef T& reference_type;
|
Chris@16
|
30 typedef const T& rvalue_type;
|
Chris@16
|
31 static reference_type ref(T& r) { return r; }
|
Chris@16
|
32 static const T& ref(const T& r) { return r; }
|
Chris@16
|
33 };
|
Chris@16
|
34
|
Chris@16
|
35 template<class T>
|
Chris@16
|
36 struct ptr_helper<T&>
|
Chris@16
|
37 {
|
Chris@16
|
38 typedef T value_type;
|
Chris@16
|
39 typedef T& reference_type;
|
Chris@16
|
40 typedef T& rvalue_type;
|
Chris@16
|
41 static reference_type ref(T& r) { return r; }
|
Chris@16
|
42 static const T& ref(const T& r) { return r; }
|
Chris@16
|
43 };
|
Chris@16
|
44
|
Chris@16
|
45 template<class T>
|
Chris@16
|
46 struct ptr_helper<T*>
|
Chris@16
|
47 {
|
Chris@16
|
48 typedef T value_type;
|
Chris@16
|
49 typedef T& reference_type;
|
Chris@16
|
50 typedef T* rvalue_type;
|
Chris@16
|
51 static reference_type ref(T * p) { return *p; }
|
Chris@16
|
52 static const T& ref(const T * p) { return *p; }
|
Chris@16
|
53 };
|
Chris@16
|
54
|
Chris@16
|
55 } // namespace detail
|
Chris@16
|
56 } // namespace random
|
Chris@16
|
57 } // namespace boost
|
Chris@16
|
58
|
Chris@16
|
59 //
|
Chris@16
|
60 // BOOST_RANDOM_PTR_HELPER_SPEC --
|
Chris@16
|
61 //
|
Chris@16
|
62 // Helper macro for broken compilers defines specializations of
|
Chris@16
|
63 // ptr_helper.
|
Chris@16
|
64 //
|
Chris@16
|
65 # define BOOST_RANDOM_PTR_HELPER_SPEC(T)
|
Chris@16
|
66
|
Chris@16
|
67 #endif // BOOST_RANDOM_DETAIL_PTR_HELPER_HPP
|