OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.brendan/] [template11.C] - Rev 699

Compare with Previous | Blame | View Log

// { dg-do assemble  }
// GROUPS passed templates
template <class Called>
class aCallback
{
public:
  aCallback(Called& obj, int (Called::*met)());

  int callback();
  
protected:

private:
  // the object to call
  Called&       object;
  
  // the method to apply
  int (Called::*method)();
  
};

template <class Called>
aCallback<Called>::aCallback(Called& obj,
                             int (Called::*met)()) :
object(obj),
method(met)
{}

template <class Called>
int aCallback<Called>::callback()
{
  return (object.*method)();
}

struct myStruct
{
  int action() {return 24;}
};

int main()
{
  myStruct toto;

  aCallback<myStruct>   cb(toto, &myStruct::action);

  return cb.callback();
}

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.