epoc32/include/stdapis/boost/random/detail/ptr_helper.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     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: ptr_helper.hpp,v 1.3 2004/07/27 03:43:32 dgregor Exp $
    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 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
    36 template<class T>
    37 struct ptr_helper<T&>
    38 {
    39   typedef T value_type;
    40   typedef T& reference_type;
    41   typedef T& rvalue_type;
    42   static reference_type ref(T& r) { return r; }
    43   static const T& ref(const T& r) { return r; }
    44 };
    45 
    46 template<class T>
    47 struct ptr_helper<T*>
    48 {
    49   typedef T value_type;
    50   typedef T& reference_type;
    51   typedef T* rvalue_type;
    52   static reference_type ref(T * p) { return *p; }
    53   static const T& ref(const T * p) { return *p; }
    54 };
    55 #endif
    56 
    57 } // namespace detail
    58 } // namespace random
    59 } // namespace boost
    60 
    61 //
    62 // BOOST_RANDOM_PTR_HELPER_SPEC --
    63 //
    64 //  Helper macro for broken compilers defines specializations of
    65 //  ptr_helper.
    66 //
    67 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
    68 # define BOOST_RANDOM_PTR_HELPER_SPEC(T)                \
    69 namespace boost { namespace random { namespace detail { \
    70 template<>                                              \
    71 struct ptr_helper<T&>                                   \
    72 {                                                       \
    73   typedef T value_type;                                 \
    74   typedef T& reference_type;                            \
    75   typedef T& rvalue_type;                               \
    76   static reference_type ref(T& r) { return r; }         \
    77   static const T& ref(const T& r) { return r; }         \
    78 };                                                      \
    79                                                         \
    80 template<>                                              \
    81 struct ptr_helper<T*>                                   \
    82 {                                                       \
    83   typedef T value_type;                                 \
    84   typedef T& reference_type;                            \
    85   typedef T* rvalue_type;                               \
    86   static reference_type ref(T * p) { return *p; }       \
    87   static const T& ref(const T * p) { return *p; }       \
    88 };                                                      \
    89 }}}
    90 #else
    91 # define BOOST_RANDOM_PTR_HELPER_SPEC(T)
    92 #endif 
    93 
    94 #endif // BOOST_RANDOM_DETAIL_PTR_HELPER_HPP