[ create a new paste ] login | about

Link: http://codepad.org/oNy4Wi0h    [ raw code | output | fork ]

C++, pasted on Aug 27:
#include <iostream>

template < class T, typename void (T::*F)() >
class Hoge
{
private:
  T* owner;

public:
  void set(T* owner) {this->owner = owner;}
  void call() {(owner->*F)();}
};

template < class T, typename void (T::*F)() >
class Piyo :
public Hoge< T, F >
{
};

class Fuga
{
private:
  void f() {std::cout << "Fuga::f" << std::endl;}

public:
  Fuga() {x.set(this);}

    Hoge< Fuga, &Fuga::f > x; // OK
//  Piyo< Fuga, &Fuga::f > x; // NG
};

int main(void)
{
  Fuga fuga;

  fuga.x.call();

  return 0;
}


Output:
1
2
Line 3: error: expected nested-name-specifier before 'void'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: