*** call_traits.htm Sat Feb 24 22:45:38 2001 --- call_traits.htm Sat Feb 24 22:49:00 2001 *************** content="C:\PROGRAM FILES\MICROSOFT OFFI *** 13,19 **** vlink="#800080">
All of the contents of <boost/call_traits.hpp> are defined inside namespace boost.
--- 13,20 ---- vlink="#800080">All of the contents of <boost/call_traits.hpp> are defined inside namespace boost.
*************** solve the reference to reference problem *** 57,63 ****T
(return by value)
call_traits<T>::value_type
T
(return by value)
call_traits<T>::value_type
T&
(return value)
call_traits<T>::reference
T&
(return value)
call_traits<T>::reference
const T&
(return value)
call_traits<T>::const_reference
const T&
(return value)
call_traits<T>::const_reference
const T&
(function parameter)
call_traits<T>::param_type
const T&
(function parameter)
call_traits<T>::param_type
param_type
is defined as T const
, instead of T
const&
. This can improve the ability of the
compiler to optimize loops in the body of the function if
--- 124,131 ----
pointer to an array" rather than the array itself.
This may or may not be a good thing depending upon what
you actually need (in other words take care!).param_type
is defined as T const
, instead of T
const&
. This can improve the ability of the
compiler to optimize loops in the body of the function if
*************** by value (see the Example 3 (the make_pair problem):
! If we pass the name of an array as one (or both) arguments to std::make_pair
,
then template argument deduction deduces the passed parameter as
"const reference to array of T", this also applies to
string literals (which are really array literals). Consequently
--- 561,568 ----
If we pass the name of an array as one (or both) arguments to
! std::make_pair
,
then template argument deduction deduces the passed parameter as
"const reference to array of T", this also applies to
string literals (which are really array literals). Consequently
*************** arguments to make_pair to pointers, but
*** 560,566 ****
better (i.e. automatic) solution (and one that works safely even
in generic code where the cast might do the wrong thing):
template <class T1, class T2> std::pair< typename boost::call_traits<T1>::value_type, typename boost::call_traits<T2>::value_type> --- 573,579 ---- better (i.e. automatic) solution (and one that works safely even in generic code where the cast might do the wrong thing): !template <typename T1, typename T2> std::pair< typename boost::call_traits<T1>::value_type, typename boost::call_traits<T2>::value_type> *************** template argument deduction from functio *** 584,590 ****The call_traits template will "optimize" the passing of a small built-in type as a function parameter, this mainly has an effect when the parameter is used within a loop body. In the ! following example (see algo_opt_examples.cpp), a version of std::fill is optimized in two ways: if the type passed is a single byte built-in type then std::memset is used to effect the fill, otherwise a conventional C++ implemention is --- 597,604 ----
The call_traits template will "optimize" the passing of a small built-in type as a function parameter, this mainly has an effect when the parameter is used within a loop body. In the ! following example (see algo_opt_examples.cpp), a version of std::fill is optimized in two ways: if the type passed is a single byte built-in type then std::memset is used to effect the fill, otherwise a conventional C++ implemention is *************** template <bool opt> *** 597,603 **** struct filler { template <typename I, typename T> ! static void do_fill(I first, I last, typename boost::call_traits<T>::param_type val); { while(first != last) { --- 611,618 ---- struct filler { template <typename I, typename T> ! static void do_fill(I first, I last, typename ! boost::call_traits<T>::param_type val); { while(first != last) { *************** struct filler<true> *** 619,625 **** } ! template <class I, class T> inline void fill(I first, I last, const T& val) { enum{ can_opt = boost::is_pointer<I>::value --- 634,640 ---- } ! template <typename I, typename T> inline void fill(I first, I last, const T& val) { enum{ can_opt = boost::is_pointer<I>::value *************** the type of the actual parameter is diff *** 681,687 **** type, something that can cause endless problems in template code that relies on the declared type of a parameter. For example:
!template <class T> struct A { void foo(T t); --- 696,702 ---- type, something that can cause endless problems in template code that relies on the declared type of a parameter. For example: !template <typename T> struct A { void foo(T t); *************** foo is int[2], but it's actual type is c *** 693,699 **** use the type T within the function body, then there is a strong likelyhood that our code will not compile: !template <class T> void A<T>::foo(T t) { T dup(t); // doesn't compile for case that T is an array. --- 708,714 ---- use the type T within the function body, then there is a strong likelyhood that our code will not compile: !template <typename T> void A<T>::foo(T t) { T dup(t); // doesn't compile for case that T is an array. *************** void A<T>::foo(T t) *** 703,718 **** explicit, and the type of the parameter is the same as it's declared type: !template <class T> struct A { ! void foo(call_traits<T>::value_type t); }; ! template <class T> ! void A<T>::foo(call_traits<T>::value_type t) { ! call_traits<T>::value_type dup(t); // OK even if T is an array type. }For value_type (return by value), again only a pointer may be --- 718,733 ---- explicit, and the type of the parameter is the same as it's declared type:
!template <typename T> struct A { ! void foo(typename call_traits<T>::value_type t); }; ! template <typename T> ! void A<T>::foo(typename call_traits<T>::value_type t) { ! typename call_traits<T>::value_type dup(t); // OK even if T is an array type. }For value_type (return by value), again only a pointer may be *************** Hinnant and John Maddock.
*** 743,749 ****Maintained by John Maddock, the latest version of this file can be found at www.boost.org, and the boost ! discussion list at www.egroups.com/list/boost.
.
--- 758,765 ----Maintained by John Maddock, the latest version of this file can be found at www.boost.org, and the boost ! discussion list at www.egroups.com/list/boost.
.
*************** discussion list at