| 
									
										
										
										
											2000-07-07 16:04:40 +00:00
										 |  |  | //  (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
 | 
					
						
							| 
									
										
										
										
											2003-12-03 13:34:11 +00:00
										 |  |  | //  Use, modification and distribution are subject to the Boost Software License,
 | 
					
						
							|  |  |  | //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 | 
					
						
							|  |  |  | //  http://www.boost.org/LICENSE_1_0.txt).
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //  See http://www.boost.org/libs/utility for most recent version including documentation.
 | 
					
						
							| 
									
										
										
										
											2000-07-07 16:04:40 +00:00
										 |  |  | //
 | 
					
						
							|  |  |  | //  Crippled version for crippled compilers:
 | 
					
						
							| 
									
										
										
										
											2000-08-02 10:58:59 +00:00
										 |  |  | //  see libs/utility/call_traits.htm
 | 
					
						
							| 
									
										
										
										
											2000-07-07 16:04:40 +00:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Release notes:
 | 
					
						
							|  |  |  |    01st October 2000: | 
					
						
							|  |  |  |       Fixed call_traits on VC6, using "poor man's partial specialisation", | 
					
						
							|  |  |  |       using ideas taken from "Generative programming" by Krzysztof Czarnecki  | 
					
						
							|  |  |  |       & Ulrich Eisenecker. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-07-07 16:04:40 +00:00
										 |  |  | #ifndef BOOST_OB_CALL_TRAITS_HPP
 | 
					
						
							|  |  |  | #define BOOST_OB_CALL_TRAITS_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef BOOST_CONFIG_HPP
 | 
					
						
							|  |  |  | #include <boost/config.hpp>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-19 12:52:30 +00:00
										 |  |  | #ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
 | 
					
						
							| 
									
										
										
										
											2001-02-18 11:43:01 +00:00
										 |  |  | #include <boost/type_traits/arithmetic_traits.hpp>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-02-19 12:52:30 +00:00
										 |  |  | #ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
 | 
					
						
							| 
									
										
										
										
											2001-02-18 11:43:01 +00:00
										 |  |  | #include <boost/type_traits/composite_traits.hpp>
 | 
					
						
							| 
									
										
										
										
											2000-07-07 16:04:40 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace boost{ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-02 18:36:12 +00:00
										 |  |  | #ifdef BOOST_MSVC6_MEMBER_TEMPLATES
 | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | //
 | 
					
						
							|  |  |  | // use member templates to emulate
 | 
					
						
							|  |  |  | // partial specialisation:
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | namespace detail{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T> | 
					
						
							|  |  |  | struct standard_call_traits | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    typedef T value_type; | 
					
						
							|  |  |  |    typedef T& reference; | 
					
						
							|  |  |  |    typedef const T& const_reference; | 
					
						
							|  |  |  |    typedef const T& param_type; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | template <class T> | 
					
						
							|  |  |  | struct simple_call_traits | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    typedef T value_type; | 
					
						
							|  |  |  |    typedef T& reference; | 
					
						
							|  |  |  |    typedef const T& const_reference; | 
					
						
							|  |  |  |    typedef const T param_type; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | template <class T> | 
					
						
							|  |  |  | struct reference_call_traits | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    typedef T value_type; | 
					
						
							|  |  |  |    typedef T reference; | 
					
						
							|  |  |  |    typedef T const_reference; | 
					
						
							|  |  |  |    typedef T param_type; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | template <bool pointer, bool arithmetic, bool reference> | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | struct call_traits_chooser | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    template <class T> | 
					
						
							|  |  |  |    struct rebind | 
					
						
							|  |  |  |    { | 
					
						
							|  |  |  |       typedef standard_call_traits<T> type; | 
					
						
							|  |  |  |    }; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | template <> | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  | struct call_traits_chooser<true, false, false> | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | { | 
					
						
							|  |  |  |    template <class T> | 
					
						
							|  |  |  |    struct rebind | 
					
						
							|  |  |  |    { | 
					
						
							|  |  |  |       typedef simple_call_traits<T> type; | 
					
						
							|  |  |  |    }; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | template <> | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  | struct call_traits_chooser<false, false, true> | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | { | 
					
						
							|  |  |  |    template <class T> | 
					
						
							|  |  |  |    struct rebind | 
					
						
							|  |  |  |    { | 
					
						
							|  |  |  |       typedef reference_call_traits<T> type; | 
					
						
							|  |  |  |    }; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | template <bool size_is_small>  | 
					
						
							|  |  |  | struct call_traits_sizeof_chooser2 | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2002-05-10 11:35:38 +00:00
										 |  |  |    template <class T> | 
					
						
							|  |  |  |    struct small_rebind | 
					
						
							|  |  |  |    { | 
					
						
							|  |  |  |       typedef simple_call_traits<T> small_type; | 
					
						
							|  |  |  |    }; | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<>  | 
					
						
							|  |  |  | struct call_traits_sizeof_chooser2<false> | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2002-05-10 11:35:38 +00:00
										 |  |  |    template <class T> | 
					
						
							|  |  |  |    struct small_rebind | 
					
						
							|  |  |  |    { | 
					
						
							|  |  |  |       typedef standard_call_traits<T> small_type; | 
					
						
							|  |  |  |    }; | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <> | 
					
						
							|  |  |  | struct call_traits_chooser<false, true, false> | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    template <class T> | 
					
						
							|  |  |  |    struct rebind | 
					
						
							|  |  |  |    { | 
					
						
							| 
									
										
										
										
											2002-05-10 11:35:38 +00:00
										 |  |  |       enum { sizeof_choice = (sizeof(T) <= sizeof(void*)) }; | 
					
						
							|  |  |  |       typedef call_traits_sizeof_chooser2<(sizeof(T) <= sizeof(void*))> chooser; | 
					
						
							|  |  |  |       typedef typename chooser::template small_rebind<T> bound_type; | 
					
						
							|  |  |  |       typedef typename bound_type::small_type type; | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  |    }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | } // namespace detail
 | 
					
						
							|  |  |  | template <typename T> | 
					
						
							|  |  |  | struct call_traits | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2002-02-14 12:54:57 +00:00
										 |  |  |     typedef detail::call_traits_chooser< | 
					
						
							|  |  |  |          ::boost::is_pointer<T>::value, | 
					
						
							|  |  |  |          ::boost::is_arithmetic<T>::value,  | 
					
						
							|  |  |  |          ::boost::is_reference<T>::value | 
					
						
							|  |  |  |       > chooser; | 
					
						
							| 
									
										
										
										
											2002-05-10 11:35:38 +00:00
										 |  |  |    typedef typename chooser::template rebind<T> bound_type; | 
					
						
							|  |  |  |    typedef typename bound_type::type call_traits_type; | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | public: | 
					
						
							|  |  |  |    typedef typename call_traits_type::value_type       value_type; | 
					
						
							|  |  |  |    typedef typename call_traits_type::reference        reference; | 
					
						
							|  |  |  |    typedef typename call_traits_type::const_reference  const_reference; | 
					
						
							|  |  |  |    typedef typename call_traits_type::param_type       param_type; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // sorry call_traits is completely non-functional
 | 
					
						
							|  |  |  | // blame your broken compiler:
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-07-07 16:04:40 +00:00
										 |  |  | template <typename T> | 
					
						
							|  |  |  | struct call_traits | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    typedef T value_type; | 
					
						
							|  |  |  |    typedef T& reference; | 
					
						
							|  |  |  |    typedef const T& const_reference; | 
					
						
							|  |  |  |    typedef const T& param_type; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-01 11:48:27 +00:00
										 |  |  | #endif // member templates
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-07-07 16:04:40 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // BOOST_OB_CALL_TRAITS_HPP
 |