epoc32/include/stdapis/boost/call_traits.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/stdapis/boost/detail/call_traits.hpp@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
//  (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
williamr@2
     2
//  Use, modification and distribution are subject to the Boost Software License,
williamr@2
     3
//  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
williamr@2
     4
//  http://www.boost.org/LICENSE_1_0.txt).
williamr@2
     5
//
williamr@2
     6
//  See http://www.boost.org/libs/utility for most recent version including documentation.
williamr@2
     7
williamr@2
     8
// call_traits: defines typedefs for function usage
williamr@2
     9
// (see libs/utility/call_traits.htm)
williamr@2
    10
williamr@2
    11
/* Release notes:
williamr@2
    12
   23rd July 2000:
williamr@2
    13
      Fixed array specialization. (JM)
williamr@2
    14
      Added Borland specific fixes for reference types
williamr@2
    15
      (issue raised by Steve Cleary).
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
#ifndef BOOST_DETAIL_CALL_TRAITS_HPP
williamr@2
    19
#define BOOST_DETAIL_CALL_TRAITS_HPP
williamr@2
    20
williamr@2
    21
#ifndef BOOST_CONFIG_HPP
williamr@2
    22
#include <boost/config.hpp>
williamr@2
    23
#endif
williamr@2
    24
#include <cstddef>
williamr@2
    25
williamr@2
    26
#include <boost/type_traits/is_arithmetic.hpp>
williamr@2
    27
#include <boost/type_traits/is_pointer.hpp>
williamr@2
    28
#include <boost/detail/workaround.hpp>
williamr@2
    29
williamr@2
    30
namespace boost{
williamr@2
    31
williamr@2
    32
namespace detail{
williamr@2
    33
williamr@2
    34
template <typename T, bool small_>
williamr@2
    35
struct ct_imp2
williamr@2
    36
{
williamr@2
    37
   typedef const T& param_type;
williamr@2
    38
};
williamr@2
    39
williamr@2
    40
template <typename T>
williamr@2
    41
struct ct_imp2<T, true>
williamr@2
    42
{
williamr@2
    43
   typedef const T param_type;
williamr@2
    44
};
williamr@2
    45
williamr@2
    46
template <typename T, bool isp, bool b1>
williamr@2
    47
struct ct_imp
williamr@2
    48
{
williamr@2
    49
   typedef const T& param_type;
williamr@2
    50
};
williamr@2
    51
williamr@2
    52
template <typename T, bool isp>
williamr@2
    53
struct ct_imp<T, isp, true>
williamr@2
    54
{
williamr@2
    55
   typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
williamr@2
    56
};
williamr@2
    57
williamr@2
    58
template <typename T, bool b1>
williamr@2
    59
struct ct_imp<T, true, b1>
williamr@2
    60
{
williamr@2
    61
   typedef const T param_type;
williamr@2
    62
};
williamr@2
    63
williamr@2
    64
}
williamr@2
    65
williamr@2
    66
template <typename T>
williamr@2
    67
struct call_traits
williamr@2
    68
{
williamr@2
    69
public:
williamr@2
    70
   typedef T value_type;
williamr@2
    71
   typedef T& reference;
williamr@2
    72
   typedef const T& const_reference;
williamr@2
    73
   //
williamr@2
    74
   // C++ Builder workaround: we should be able to define a compile time
williamr@2
    75
   // constant and pass that as a single template parameter to ct_imp<T,bool>,
williamr@2
    76
   // however compiler bugs prevent this - instead pass three bool's to
williamr@2
    77
   // ct_imp<T,bool,bool,bool> and add an extra partial specialisation
williamr@2
    78
   // of ct_imp to handle the logic. (JM)
williamr@2
    79
   typedef typename boost::detail::ct_imp<
williamr@2
    80
      T,
williamr@2
    81
      ::boost::is_pointer<T>::value,
williamr@2
    82
      ::boost::is_arithmetic<T>::value
williamr@2
    83
   >::param_type param_type;
williamr@2
    84
};
williamr@2
    85
williamr@2
    86
template <typename T>
williamr@2
    87
struct call_traits<T&>
williamr@2
    88
{
williamr@2
    89
   typedef T& value_type;
williamr@2
    90
   typedef T& reference;
williamr@2
    91
   typedef const T& const_reference;
williamr@2
    92
   typedef T& param_type;  // hh removed const
williamr@2
    93
};
williamr@2
    94
williamr@2
    95
#if BOOST_WORKAROUND( __BORLANDC__,  BOOST_TESTED_AT( 0x581 ) )
williamr@2
    96
// these are illegal specialisations; cv-qualifies applied to
williamr@2
    97
// references have no effect according to [8.3.2p1],
williamr@2
    98
// C++ Builder requires them though as it treats cv-qualified
williamr@2
    99
// references as distinct types...
williamr@2
   100
template <typename T>
williamr@2
   101
struct call_traits<T&const>
williamr@2
   102
{
williamr@2
   103
   typedef T& value_type;
williamr@2
   104
   typedef T& reference;
williamr@2
   105
   typedef const T& const_reference;
williamr@2
   106
   typedef T& param_type;  // hh removed const
williamr@2
   107
};
williamr@2
   108
template <typename T>
williamr@2
   109
struct call_traits<T&volatile>
williamr@2
   110
{
williamr@2
   111
   typedef T& value_type;
williamr@2
   112
   typedef T& reference;
williamr@2
   113
   typedef const T& const_reference;
williamr@2
   114
   typedef T& param_type;  // hh removed const
williamr@2
   115
};
williamr@2
   116
template <typename T>
williamr@2
   117
struct call_traits<T&const volatile>
williamr@2
   118
{
williamr@2
   119
   typedef T& value_type;
williamr@2
   120
   typedef T& reference;
williamr@2
   121
   typedef const T& const_reference;
williamr@2
   122
   typedef T& param_type;  // hh removed const
williamr@2
   123
};
williamr@2
   124
williamr@2
   125
template <typename T>
williamr@2
   126
struct call_traits< T * >
williamr@2
   127
{
williamr@2
   128
   typedef T * value_type;
williamr@2
   129
   typedef T * & reference;
williamr@2
   130
   typedef T * const & const_reference;
williamr@2
   131
   typedef T * const param_type;  // hh removed const
williamr@2
   132
};
williamr@2
   133
#endif
williamr@2
   134
#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
williamr@2
   135
template <typename T, std::size_t N>
williamr@2
   136
struct call_traits<T [N]>
williamr@2
   137
{
williamr@2
   138
private:
williamr@2
   139
   typedef T array_type[N];
williamr@2
   140
public:
williamr@2
   141
   // degrades array to pointer:
williamr@2
   142
   typedef const T* value_type;
williamr@2
   143
   typedef array_type& reference;
williamr@2
   144
   typedef const array_type& const_reference;
williamr@2
   145
   typedef const T* const param_type;
williamr@2
   146
};
williamr@2
   147
williamr@2
   148
template <typename T, std::size_t N>
williamr@2
   149
struct call_traits<const T [N]>
williamr@2
   150
{
williamr@2
   151
private:
williamr@2
   152
   typedef const T array_type[N];
williamr@2
   153
public:
williamr@2
   154
   // degrades array to pointer:
williamr@2
   155
   typedef const T* value_type;
williamr@2
   156
   typedef array_type& reference;
williamr@2
   157
   typedef const array_type& const_reference;
williamr@2
   158
   typedef const T* const param_type;
williamr@2
   159
};
williamr@2
   160
#endif
williamr@2
   161
williamr@2
   162
}
williamr@2
   163
williamr@2
   164
#endif // BOOST_DETAIL_CALL_TRAITS_HPP