call_traits.hpp
Go to the documentation of this file.
00001 //  (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
00002 //  Use, modification and distribution are subject to the Boost Software License,
00003 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00004 //  http://www.boost.org/LICENSE_1_0.txt).
00005 //
00006 //  See http://www.boost.org/libs/utility for most recent version including documentation.
00007 
00008 // call_traits: defines typedefs for function usage
00009 // (see libs/utility/call_traits.htm)
00010 
00011 /* Release notes:
00012    23rd July 2000:
00013       Fixed array specialization. (JM)
00014       Added Borland specific fixes for reference types
00015       (issue raised by Steve Cleary).
00016 */
00017 
00018 #ifndef BOOST_DETAIL_CALL_TRAITS_HPP
00019 #define BOOST_DETAIL_CALL_TRAITS_HPP
00020 
00021 #ifndef BOOST_CONFIG_HPP
00022 #include <boost/config.hpp>
00023 #endif
00024 #include <cstddef>
00025 
00026 #include <boost/type_traits/is_arithmetic.hpp>
00027 #include <boost/type_traits/is_pointer.hpp>
00028 #include <boost/detail/workaround.hpp>
00029 
00030 namespace boost{
00031 
00032 namespace detail{
00033 
00034 template <typename T, bool small_>
00035 struct ct_imp2
00036 {
00037    typedef const T& param_type;
00038 };
00039 
00040 template <typename T>
00041 struct ct_imp2<T, true>
00042 {
00043    typedef const T param_type;
00044 };
00045 
00046 template <typename T, bool isp, bool b1>
00047 struct ct_imp
00048 {
00049    typedef const T& param_type;
00050 };
00051 
00052 template <typename T, bool isp>
00053 struct ct_imp<T, isp, true>
00054 {
00055    typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
00056 };
00057 
00058 template <typename T, bool b1>
00059 struct ct_imp<T, true, b1>
00060 {
00061    typedef const T param_type;
00062 };
00063 
00064 }
00065 
00066 template <typename T>
00067 struct call_traits
00068 {
00069 public:
00070    typedef T value_type;
00071    typedef T& reference;
00072    typedef const T& const_reference;
00073    //
00074    // C++ Builder workaround: we should be able to define a compile time
00075    // constant and pass that as a single template parameter to ct_imp<T,bool>,
00076    // however compiler bugs prevent this - instead pass three bool's to
00077    // ct_imp<T,bool,bool,bool> and add an extra partial specialisation
00078    // of ct_imp to handle the logic. (JM)
00079    typedef typename boost::detail::ct_imp<
00080       T,
00081       ::boost::is_pointer<T>::value,
00082       ::boost::is_arithmetic<T>::value
00083    >::param_type param_type;
00084 };
00085 
00086 template <typename T>
00087 struct call_traits<T&>
00088 {
00089    typedef T& value_type;
00090    typedef T& reference;
00091    typedef const T& const_reference;
00092    typedef T& param_type;  // hh removed const
00093 };
00094 
00095 #if BOOST_WORKAROUND( __BORLANDC__,  < 0x5A0 )
00096 // these are illegal specialisations; cv-qualifies applied to
00097 // references have no effect according to [8.3.2p1],
00098 // C++ Builder requires them though as it treats cv-qualified
00099 // references as distinct types...
00100 template <typename T>
00101 struct call_traits<T&const>
00102 {
00103    typedef T& value_type;
00104    typedef T& reference;
00105    typedef const T& const_reference;
00106    typedef T& param_type;  // hh removed const
00107 };
00108 template <typename T>
00109 struct call_traits<T&volatile>
00110 {
00111    typedef T& value_type;
00112    typedef T& reference;
00113    typedef const T& const_reference;
00114    typedef T& param_type;  // hh removed const
00115 };
00116 template <typename T>
00117 struct call_traits<T&const volatile>
00118 {
00119    typedef T& value_type;
00120    typedef T& reference;
00121    typedef const T& const_reference;
00122    typedef T& param_type;  // hh removed const
00123 };
00124 
00125 template <typename T>
00126 struct call_traits< T * >
00127 {
00128    typedef T * value_type;
00129    typedef T * & reference;
00130    typedef T * const & const_reference;
00131    typedef T * const param_type;  // hh removed const
00132 };
00133 #endif
00134 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
00135 template <typename T, std::size_t N>
00136 struct call_traits<T [N]>
00137 {
00138 private:
00139    typedef T array_type[N];
00140 public:
00141    // degrades array to pointer:
00142    typedef const T* value_type;
00143    typedef array_type& reference;
00144    typedef const array_type& const_reference;
00145    typedef const T* const param_type;
00146 };
00147 
00148 template <typename T, std::size_t N>
00149 struct call_traits<const T [N]>
00150 {
00151 private:
00152    typedef const T array_type[N];
00153 public:
00154    // degrades array to pointer:
00155    typedef const T* value_type;
00156    typedef array_type& reference;
00157    typedef const array_type& const_reference;
00158    typedef const T* const param_type;
00159 };
00160 #endif
00161 
00162 }
00163 
00164 #endif // BOOST_DETAIL_CALL_TRAITS_HPP


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:28