Boost logo

Boost :

From: Robin.Hu (huxw_at_[hidden])
Date: 2002-12-09 12:55:14

Hi Boosters:

   In the document of boost::lambda (ar01s05.html#sect:nested_stl_algorithms),
it says:
------------------>cited begin<-------------------
   Some aid for common special cases can be provided though. The BLL defines two
   helper function object classes, call_begin and call_end, which wrap a
   call to the begin and, respectively, end functions of a container,
   and return the const_iterator type of the container. With these
   helper templates, the above code becomes:

   std::for_each(a.begin(), a.end(),
         bind(call_begin(), _1), bind(call_end(), _1),
         protect(sum += _1)));
------------------->cited end<---------------------

   But I failed to compile this example with gcc 3.2 and vc 2003 beta.
I think the problem is, both struct call_begin and struct call_end dont
provide a result_type.

------------------->cited begin<-------------------
#define CALL_MEMBER(X) \
struct call_##X { \
template <class Args> \
  struct sig { \
    typedef typename boost::remove_const< \
        typename boost::tuples::element<1, Args>::type \
>::type::const_iterator type; \
  }; \
  template<class T> \
  typename T::const_iterator \
  operator()(const T& t) const \
  { \
    return t.X(); \
  } \
------------------->cited end<---------------------
  Is there anything I missed? And is there a possibel way to make these
call_xxx run?


Boost list run by bdawes at, gregod at, cpdaniel at, john at