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 <sysc/packages/boost/config.hpp>
00023 #endif
00024 #include <cstddef>
00025 
00026 #include <sysc/packages/boost/type_traits/is_arithmetic.hpp>
00027 #include <sysc/packages/boost/type_traits/is_pointer.hpp>
00028 #include <sysc/packages/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 T const 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 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__,  BOOST_TESTED_AT( 0x570 ) )
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 #endif
00125 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
00126 template <typename T, std::size_t N>
00127 struct call_traits<T [N]>
00128 {
00129 private:
00130    typedef T array_type[N];
00131 public:
00132    // degrades array to pointer:
00133    typedef const T* value_type;
00134    typedef array_type& reference;
00135    typedef const array_type& const_reference;
00136    typedef const T* const param_type;
00137 };
00138 
00139 template <typename T, std::size_t N>
00140 struct call_traits<const T [N]>
00141 {
00142 private:
00143    typedef const T array_type[N];
00144 public:
00145    // degrades array to pointer:
00146    typedef const T* value_type;
00147    typedef array_type& reference;
00148    typedef const array_type& const_reference;
00149    typedef const T* const param_type;
00150 };
00151 #endif
00152 
00153 }
00154 
00155 #endif // BOOST_DETAIL_CALL_TRAITS_HPP

Generated on Wed Jan 21 15:32:09 2009 for SystemC by  doxygen 1.5.5