diff --git a/call_traits.htm b/call_traits.htm index d0a0fde..78cb60f 100644 --- a/call_traits.htm +++ b/call_traits.htm @@ -27,10 +27,16 @@ never occur, and that parameters are passed in the most efficient manner possible (see examples). In each case if your existing practice is to use the type defined on the left, then replace it with the call_traits defined type on the -right. Note that for compilers that do not support partial -specialization, no benefit will occur from using call_traits: the -call_traits defined types will always be the same as the existing -practice in this case.

+right.

+ +

Note that for compilers that do not support either partial +specialization or member templates, no benefit will occur from +using call_traits: the call_traits defined types will always be +the same as the existing practice in this case. In addition if +only member templates and not partial template specialisation is +support by the compiler (for example Visual C++ 6) then call_traits +can not be used with array types (although it can be used to +solve the reference to reference problem).

@@ -569,7 +575,9 @@ std::pair< degraded to pointers if the deduced types are arrays, similar situations occur in the standard binders and adapters: in principle in any function that "wraps" a temporary -whose type is deduced.

+whose type is deduced. Note that the function arguments to make_pair +are not expressed in terms of call_traits: doing so would prevent +template argument deduction from functioning.

Example 4 (optimising fill):

@@ -632,6 +640,14 @@ Exactly how much mileage you will get from this depends upon your compiler - we could really use some accurate benchmarking software as part of boost for cases like this.

+

Note that the function arguments to fill are not expressed in +terms of call_traits: doing so would prevent template argument +deduction from functioning. Instead fill acts as a "thin +wrapper" that is there to perform template argument +deduction, the compiler will optimise away the call to fill all +together, replacing it with the call to filler<>::do_fill, +which does use call_traits.

+

Rationale

The following notes are intended to briefly describe the @@ -713,7 +729,7 @@ specialisation).


-

Revised 18 June 2000

+

Revised 01 September 2000

© Copyright boost.org 2000. Permission to copy, use, modify, sell and distribute this document is granted provided this diff --git a/include/boost/detail/ob_call_traits.hpp b/include/boost/detail/ob_call_traits.hpp index 54f2739..a031f17 100644 --- a/include/boost/detail/ob_call_traits.hpp +++ b/include/boost/detail/ob_call_traits.hpp @@ -9,6 +9,14 @@ // Crippled version for crippled compilers: // see libs/utility/call_traits.htm // + +/* 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. +*/ + #ifndef BOOST_OB_CALL_TRAITS_HPP #define BOOST_OB_CALL_TRAITS_HPP @@ -22,6 +30,85 @@ namespace boost{ +#if defined(BOOST_MSVC6_MEMBER_TEMPLATES) || !defined(BOOST_NO_MEMBER_TEMPLATES) +// +// use member templates to emulate +// partial specialisation: +// +namespace detail{ + +template +struct standard_call_traits +{ + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef const T& param_type; +}; +template +struct simple_call_traits +{ + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef const T param_type; +}; +template +struct reference_call_traits +{ + typedef T value_type; + typedef T reference; + typedef T const_reference; + typedef T param_type; +}; +template +struct call_traits_chooser +{ + template + struct rebind + { + typedef standard_call_traits type; + }; +}; +template <> +struct call_traits_chooser +{ + template + struct rebind + { + typedef simple_call_traits type; + }; +}; +template <> +struct call_traits_chooser +{ + template + struct rebind + { + typedef reference_call_traits type; + }; +}; +} // namespace detail +template +struct call_traits +{ +private: + typedef detail::call_traits_chooser<(is_pointer::value || is_arithmetic::value) && sizeof(T) <= sizeof(void*), is_reference::value> chooser; + typedef typename chooser::template rebind bound_type; + typedef typename bound_type::type call_traits_type; +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: +// + template struct call_traits { @@ -31,6 +118,8 @@ struct call_traits typedef const T& param_type; }; +#endif // member templates + } #endif // BOOST_OB_CALL_TRAITS_HPP diff --git a/type_traits.htm b/type_traits.htm index 66c5370..7564443 100644 --- a/type_traits.htm +++ b/type_traits.htm @@ -126,8 +126,7 @@ is always defined as a compile time constant).

- + - + - +

True if T and U are the same type.

P

-
 
is_convertible<T,U>::value
@@ -170,15 +169,13 @@ on a type (see 3.93).

is_const<T>::value True if type T is top-level const qualified.

P

-
 
is_volatile<T>::value True if type T is top-level volatile qualified.

P

-
 
@@ -348,22 +345,19 @@ as defined by the Standard. 

True if T is a regular pointer type - including function pointers - but excluding pointers to member functions (3.9.2 p1 and 8.3.1). -

P

- +   is_member_pointer<T>::value True if T is a pointer to a non-static class member (3.9.2 p1 and 8.3.1). -

P

- +   is_reference<T>::value True if T is a reference type (3.9.2 p1 and 8.3.2). -

P

- +   is_class<T>::value @@ -607,7 +601,7 @@ familiar standard library algorithms.


-

Revised 08th March 2000

+

Revised 01 September 2000

© Copyright boost.org 2000. Permission to copy, use, modify, sell and distribute this document is granted provided this