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