Boost logo

Boost Users :

From: Michael Fawcett (michael.fawcett_at_[hidden])
Date: 2006-05-02 11:12:48

On 5/2/06, Oliver.Kowalke_at_[hidden] <Oliver.Kowalke_at_[hidden]> wrote:
> how can I define a function<> object which returns a value of
> the same type:

This was taken from GotW article 57:

  struct FuncPtr_;
  typedef FuncPtr_ (*FuncPtr)();

  struct FuncPtr_
    FuncPtr_( FuncPtr pp ) : p( pp ) { }
    operator FuncPtr() { return p; }
    FuncPtr p;

Now we can declare, define, and use f() naturally:

  FuncPtr_ f() { return f; } // natural return syntax

  int main()
    FuncPtr p = f(); // natural usage syntax


Michael Fawcett

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at