@@ -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
- |
+ |