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