Click here to Skip to main content
16,021,911 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So the following works..
C++
typename<void T()>
class Example
{
public:
  void operator()()
  {
    T();
  }
};

void Example2()
{
  fputs("Example!\n", stdout);
}

int main()
{
  Example<Example2> example;
  example();

  return 0;
}


But what I was trying is..
C++
void Example2(char* text)
{
  printf("%s!\n", text);
}
void Example3(char* text, int number)
{
  printf("%s and %i!\n", text, number);
}

int main()
{
  Example<Example2> example2;
  Example<Example3> example3;
  example2("Example");
  example3("Example", 123);

  return 0;
}


What I have tried:

C++
template<typename... T, void U(T...)>
class Example
{
public:
  void operator()(T... parameters)
  {
    U(parameters...);
  }
};

// OR

template<void U(T...), typename... T>
class Example
{
public:
  void operator()(T... parameters)
  {
    U(parameters...);
  }
};

// OR

template<typename... T>
template<void U(T...)>
class Example
{
public:
  void operator()(T... parameters)
  {
    U(parameters...);
  }
};


These don't compile.
Posted
Comments
jeron1 18hrs ago    
Could you post the compilation errors?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900