Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:41

0001 //  (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
0002 //  Use, modification and distribution are subject to the Boost Software License,
0003 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt).
0005 //
0006 //  See http://www.boost.org/libs/utility for most recent version including documentation.
0007 
0008 // call_traits: defines typedefs for function usage
0009 // (see libs/utility/call_traits.htm)
0010 
0011 /* Release notes:
0012    23rd July 2000:
0013       Fixed array specialization. (JM)
0014       Added Borland specific fixes for reference types
0015       (issue raised by Steve Cleary).
0016 */
0017 
0018 #ifndef BOOST_DETAIL_CALL_TRAITS_HPP
0019 #define BOOST_DETAIL_CALL_TRAITS_HPP
0020 
0021 #ifndef BOOST_CONFIG_HPP
0022 #include <boost/config.hpp>
0023 #endif
0024 #include <cstddef>
0025 
0026 #include <boost/type_traits/is_arithmetic.hpp>
0027 #include <boost/type_traits/is_enum.hpp>
0028 #include <boost/type_traits/is_pointer.hpp>
0029 #include <boost/detail/workaround.hpp>
0030 
0031 namespace boost{
0032 
0033 namespace detail{
0034 
0035 template <typename T, bool small_>
0036 struct ct_imp2
0037 {
0038    typedef const T& param_type;
0039 };
0040 
0041 template <typename T>
0042 struct ct_imp2<T, true>
0043 {
0044    typedef const T param_type;
0045 };
0046 
0047 template <typename T, bool isp, bool b1, bool b2>
0048 struct ct_imp
0049 {
0050    typedef const T& param_type;
0051 };
0052 
0053 template <typename T, bool isp, bool b2>
0054 struct ct_imp<T, isp, true, b2>
0055 {
0056    typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
0057 };
0058 
0059 template <typename T, bool isp, bool b1>
0060 struct ct_imp<T, isp, b1, true>
0061 {
0062    typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
0063 };
0064 
0065 template <typename T, bool b1, bool b2>
0066 struct ct_imp<T, true, b1, b2>
0067 {
0068    typedef const T param_type;
0069 };
0070 
0071 }
0072 
0073 template <typename T>
0074 struct call_traits
0075 {
0076 public:
0077    typedef T value_type;
0078    typedef T& reference;
0079    typedef const T& const_reference;
0080    //
0081    // C++ Builder workaround: we should be able to define a compile time
0082    // constant and pass that as a single template parameter to ct_imp<T,bool>,
0083    // however compiler bugs prevent this - instead pass three bool's to
0084    // ct_imp<T,bool,bool,bool> and add an extra partial specialisation
0085    // of ct_imp to handle the logic. (JM)
0086    typedef typename boost::detail::ct_imp<
0087       T,
0088       ::boost::is_pointer<T>::value,
0089       ::boost::is_arithmetic<T>::value,
0090       ::boost::is_enum<T>::value
0091    >::param_type param_type;
0092 };
0093 
0094 template <typename T>
0095 struct call_traits<T&>
0096 {
0097    typedef T& value_type;
0098    typedef T& reference;
0099    typedef const T& const_reference;
0100    typedef T& param_type;  // hh removed const
0101 };
0102 
0103 #if BOOST_WORKAROUND( BOOST_BORLANDC,  < 0x5A0 )
0104 // these are illegal specialisations; cv-qualifies applied to
0105 // references have no effect according to [8.3.2p1],
0106 // C++ Builder requires them though as it treats cv-qualified
0107 // references as distinct types...
0108 template <typename T>
0109 struct call_traits<T&const>
0110 {
0111    typedef T& value_type;
0112    typedef T& reference;
0113    typedef const T& const_reference;
0114    typedef T& param_type;  // hh removed const
0115 };
0116 template <typename T>
0117 struct call_traits<T&volatile>
0118 {
0119    typedef T& value_type;
0120    typedef T& reference;
0121    typedef const T& const_reference;
0122    typedef T& param_type;  // hh removed const
0123 };
0124 template <typename T>
0125 struct call_traits<T&const volatile>
0126 {
0127    typedef T& value_type;
0128    typedef T& reference;
0129    typedef const T& const_reference;
0130    typedef T& param_type;  // hh removed const
0131 };
0132 
0133 template <typename T>
0134 struct call_traits< T * >
0135 {
0136    typedef T * value_type;
0137    typedef T * & reference;
0138    typedef T * const & const_reference;
0139    typedef T * const param_type;  // hh removed const
0140 };
0141 #endif
0142 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
0143 template <typename T, std::size_t N>
0144 struct call_traits<T [N]>
0145 {
0146 private:
0147    typedef T array_type[N];
0148 public:
0149    // degrades array to pointer:
0150    typedef const T* value_type;
0151    typedef array_type& reference;
0152    typedef const array_type& const_reference;
0153    typedef const T* const param_type;
0154 };
0155 
0156 template <typename T, std::size_t N>
0157 struct call_traits<const T [N]>
0158 {
0159 private:
0160    typedef const T array_type[N];
0161 public:
0162    // degrades array to pointer:
0163    typedef const T* value_type;
0164    typedef array_type& reference;
0165    typedef const array_type& const_reference;
0166    typedef const T* const param_type;
0167 };
0168 #endif
0169 
0170 }
0171 
0172 #endif // BOOST_DETAIL_CALL_TRAITS_HPP