1 /* boost random/detail/ptr_helper.hpp header file
\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
8 * See http://www.boost.org for most recent version including documentation.
\r
10 * $Id: ptr_helper.hpp 24096 2004-07-27 03:43:34Z dgregor $
\r
14 #ifndef BOOST_RANDOM_DETAIL_PTR_HELPER_HPP
\r
15 #define BOOST_RANDOM_DETAIL_PTR_HELPER_HPP
\r
17 #include <boost/config.hpp>
\r
24 // type_traits could help here, but I don't want to depend on type_traits.
\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
35 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
\r
37 struct ptr_helper<T&>
\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
47 struct ptr_helper<T*>
\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
57 } // namespace detail
\r
58 } // namespace random
\r
59 } // namespace boost
\r
62 // BOOST_RANDOM_PTR_HELPER_SPEC --
\r
64 // Helper macro for broken compilers defines specializations of
\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
71 struct ptr_helper<T&> \
\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
81 struct ptr_helper<T*> \
\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
91 # define BOOST_RANDOM_PTR_HELPER_SPEC(T)
\r
94 #endif // BOOST_RANDOM_DETAIL_PTR_HELPER_HPP
\r