annotate DEPENDENCIES/generic/include/boost/random/detail/ptr_helper.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
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@16 10 * $Id: ptr_helper.hpp 24096 2004-07-27 03:43:34Z dgregor $
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 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Chris@16 36 template<class T>
Chris@16 37 struct ptr_helper<T&>
Chris@16 38 {
Chris@16 39 typedef T value_type;
Chris@16 40 typedef T& reference_type;
Chris@16 41 typedef T& rvalue_type;
Chris@16 42 static reference_type ref(T& r) { return r; }
Chris@16 43 static const T& ref(const T& r) { return r; }
Chris@16 44 };
Chris@16 45
Chris@16 46 template<class T>
Chris@16 47 struct ptr_helper<T*>
Chris@16 48 {
Chris@16 49 typedef T value_type;
Chris@16 50 typedef T& reference_type;
Chris@16 51 typedef T* rvalue_type;
Chris@16 52 static reference_type ref(T * p) { return *p; }
Chris@16 53 static const T& ref(const T * p) { return *p; }
Chris@16 54 };
Chris@16 55 #endif
Chris@16 56
Chris@16 57 } // namespace detail
Chris@16 58 } // namespace random
Chris@16 59 } // namespace boost
Chris@16 60
Chris@16 61 //
Chris@16 62 // BOOST_RANDOM_PTR_HELPER_SPEC --
Chris@16 63 //
Chris@16 64 // Helper macro for broken compilers defines specializations of
Chris@16 65 // ptr_helper.
Chris@16 66 //
Chris@16 67 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Chris@16 68 # define BOOST_RANDOM_PTR_HELPER_SPEC(T) \
Chris@16 69 namespace boost { namespace random { namespace detail { \
Chris@16 70 template<> \
Chris@16 71 struct ptr_helper<T&> \
Chris@16 72 { \
Chris@16 73 typedef T value_type; \
Chris@16 74 typedef T& reference_type; \
Chris@16 75 typedef T& rvalue_type; \
Chris@16 76 static reference_type ref(T& r) { return r; } \
Chris@16 77 static const T& ref(const T& r) { return r; } \
Chris@16 78 }; \
Chris@16 79 \
Chris@16 80 template<> \
Chris@16 81 struct ptr_helper<T*> \
Chris@16 82 { \
Chris@16 83 typedef T value_type; \
Chris@16 84 typedef T& reference_type; \
Chris@16 85 typedef T* rvalue_type; \
Chris@16 86 static reference_type ref(T * p) { return *p; } \
Chris@16 87 static const T& ref(const T * p) { return *p; } \
Chris@16 88 }; \
Chris@16 89 }}}
Chris@16 90 #else
Chris@16 91 # define BOOST_RANDOM_PTR_HELPER_SPEC(T)
Chris@16 92 #endif
Chris@16 93
Chris@16 94 #endif // BOOST_RANDOM_DETAIL_PTR_HELPER_HPP