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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.brendan/] [template11.C] - Diff between revs 305 and 338

Only display areas with differences | Details | Blame | View Log

Rev 305 Rev 338
// { dg-do assemble  }
// { dg-do assemble  }
// GROUPS passed templates
// GROUPS passed templates
template 
template 
class aCallback
class aCallback
{
{
public:
public:
  aCallback(Called& obj, int (Called::*met)());
  aCallback(Called& obj, int (Called::*met)());
  int callback();
  int callback();
protected:
protected:
private:
private:
  // the object to call
  // the object to call
  Called&       object;
  Called&       object;
  // the method to apply
  // the method to apply
  int (Called::*method)();
  int (Called::*method)();
};
};
template 
template 
aCallback::aCallback(Called& obj,
aCallback::aCallback(Called& obj,
                             int (Called::*met)()) :
                             int (Called::*met)()) :
object(obj),
object(obj),
method(met)
method(met)
{}
{}
template 
template 
int aCallback::callback()
int aCallback::callback()
{
{
  return (object.*method)();
  return (object.*method)();
}
}
struct myStruct
struct myStruct
{
{
  int action() {return 24;}
  int action() {return 24;}
};
};
int main()
int main()
{
{
  myStruct toto;
  myStruct toto;
  aCallback   cb(toto, &myStruct::action);
  aCallback   cb(toto, &myStruct::action);
  return cb.callback();
  return cb.callback();
}
}
 
 

powered by: WebSVN 2.1.0

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