Boost logo

Boost Users :

From: hugo duncan (hugo.duncan_at_[hidden])
Date: 2002-10-31 13:22:09


Hi,

I want to pass the result of a boost::bind as an argument of a
templated function of a class, and am struggling to find a signature
that will let me do this.

Is this possible? if so what signature should the function have ?

Any help much apreciated

Hugo

#include "boost/function/function1.hpp"
#include "boost/bind.hpp"

class another_class
{};

class my_class
{
public:
  typedef another_class ObjectType;

  //! this works fine passing a boost::function object
  template <class ReturnType>
  void add(const boost::function1<ReturnType,ObjectType>& arg)
  {
    boost::function1<ReturnType,ObjectType> fn_obj=arg;
  }

  //! this should work when passed the result of a boost::bind
  template <class ReturnType>
  void add(?what goes here? & arg)
  {
    function1<ReturnType,ObjectType> fn_obj(arg);
  }
};

int fn(another_class,int)
{
  return 1;
}

int main(int, char**)
{
  my_class c;
  c.add(boost::bind(&fn,_1,1));
}


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