Boost logo

Boost :

Subject: Re: [boost] determine first arg of callable
From: Peter Dimov (lists_at_[hidden])
Date: 2013-05-15 11:59:46

This still doesn't quite explain it. Let's say that my fn takes a
std::string. How does D know what string to pass? An empty string? "foo"?
"hello world"? Where does the argument value come from?

-----Original Message-----
From: Oliver Kowalke
Sent: Wednesday, May 15, 2013 18:52
To: boost
Subject: Re: [boost] determine first arg of callable

013/5/15 Peter Dimov <lists_at_[hidden]>

> You've omitted the only interesting part.

template< typename Arg >
struct Q {...};

struct B
  virtual void run() = 0;

template< typename Fn, typename Arg >
struct D : public B
  Fn fn;

  D( Fn fn_) : fn( fn_) {}

  void run() {
    Q< Arg > q;
    fn( q)
  } // argument construction omitted

struct X
  B * b;

  template< typename Fn >
  X( Fn fn) : b( 0)
     typedef typename Magic< Fn >::arg1_type arg_type;
     b = new D< Fn, arg_type >( fn);

  void run() { b->run(); }

I want to construct a Q<> in D::run() and pass it to fn.

Magic<> can be specialized for raw function pointers, function<> etc.

Unsubscribe & other changes:

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