00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef BOOST_OB_CALL_TRAITS_HPP
00021 #define BOOST_OB_CALL_TRAITS_HPP
00022
00023 #ifndef BOOST_CONFIG_HPP
00024 #include <sysc/packages/boost/config.hpp>
00025 #endif
00026
00027 #ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
00028 #include <sysc/packages/boost/type_traits/arithmetic_traits.hpp>
00029 #endif
00030 #ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
00031 #include <sysc/packages/boost/type_traits/composite_traits.hpp>
00032 #endif
00033
00034 namespace boost{
00035
00036 #ifdef BOOST_MSVC6_MEMBER_TEMPLATES
00037
00038
00039
00040
00041 namespace detail{
00042
00043 template <class T>
00044 struct standard_call_traits
00045 {
00046 typedef T value_type;
00047 typedef T& reference;
00048 typedef const T& const_reference;
00049 typedef const T& param_type;
00050 };
00051 template <class T>
00052 struct simple_call_traits
00053 {
00054 typedef T value_type;
00055 typedef T& reference;
00056 typedef const T& const_reference;
00057 typedef const T param_type;
00058 };
00059 template <class T>
00060 struct reference_call_traits
00061 {
00062 typedef T value_type;
00063 typedef T reference;
00064 typedef T const_reference;
00065 typedef T param_type;
00066 };
00067
00068 template <bool pointer, bool arithmetic, bool reference>
00069 struct call_traits_chooser
00070 {
00071 template <class T>
00072 struct rebind
00073 {
00074 typedef standard_call_traits<T> type;
00075 };
00076 };
00077
00078 template <>
00079 struct call_traits_chooser<true, false, false>
00080 {
00081 template <class T>
00082 struct rebind
00083 {
00084 typedef simple_call_traits<T> type;
00085 };
00086 };
00087
00088 template <>
00089 struct call_traits_chooser<false, false, true>
00090 {
00091 template <class T>
00092 struct rebind
00093 {
00094 typedef reference_call_traits<T> type;
00095 };
00096 };
00097
00098 template <bool size_is_small>
00099 struct call_traits_sizeof_chooser2
00100 {
00101 template <class T>
00102 struct small_rebind
00103 {
00104 typedef simple_call_traits<T> small_type;
00105 };
00106 };
00107
00108 template<>
00109 struct call_traits_sizeof_chooser2<false>
00110 {
00111 template <class T>
00112 struct small_rebind
00113 {
00114 typedef standard_call_traits<T> small_type;
00115 };
00116 };
00117
00118 template <>
00119 struct call_traits_chooser<false, true, false>
00120 {
00121 template <class T>
00122 struct rebind
00123 {
00124 enum { sizeof_choice = (sizeof(T) <= sizeof(void*)) };
00125 typedef call_traits_sizeof_chooser2<(sizeof(T) <= sizeof(void*))> chooser;
00126 typedef typename chooser::template small_rebind<T> bound_type;
00127 typedef typename bound_type::small_type type;
00128 };
00129 };
00130
00131 }
00132 template <typename T>
00133 struct call_traits
00134 {
00135 private:
00136 typedef detail::call_traits_chooser<
00137 ::boost::is_pointer<T>::value,
00138 ::boost::is_arithmetic<T>::value,
00139 ::boost::is_reference<T>::value
00140 > chooser;
00141 typedef typename chooser::template rebind<T> bound_type;
00142 typedef typename bound_type::type call_traits_type;
00143 public:
00144 typedef typename call_traits_type::value_type value_type;
00145 typedef typename call_traits_type::reference reference;
00146 typedef typename call_traits_type::const_reference const_reference;
00147 typedef typename call_traits_type::param_type param_type;
00148 };
00149
00150 #else
00151
00152
00153
00154
00155
00156 template <typename T>
00157 struct call_traits
00158 {
00159 typedef T value_type;
00160 typedef T& reference;
00161 typedef const T& const_reference;
00162 typedef const T& param_type;
00163 };
00164
00165 #endif // member templates
00166
00167 }
00168
00169 #endif // BOOST_OB_CALL_TRAITS_HPP