Boost logo

Boost Users :

From: Markus Larsson (larsma_at_[hidden])
Date: 2004-10-08 20:07:24


from the BLL/bind documentaion on the cvs:

struct A {

  // the return type equals the third argument type:
  template<class T1, T2, T3>
  T3 operator()(const T1& t1, const T2& t2, const T3& t3);

  template <class Args>
  class sig {
    // get the third argument type (4th element)
    typedef typename
      boost::tuples::element<3, Args>::type T3;
  public:
    typedef typename
      boost::remove_cv<T3>::type type;
  }
};

To begin with this piece of code has 2 syntax errors.
template<class T1, T2, T3> // should have class before all parameters

struct sig {
...
} // missing semicolon

If a first time user copy/pastes the example, fixes the syntax errors,
defines operator() and tries to call the function with:

int i = 7;
bind( A(), 1, 2, _1) (i);

she gets a hard to parse error because operator() wasn't declared const.

I see two possible solutions:

1) Add const to the declaration
2) mention the non constness and show how to call the function
object using var(func), with a short note on why that is needed.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net