mercredi 6 juillet 2016

Deduction of the function

Let's say we have a class template like this:

template<typename F>
class A
{
public:
  template<typename... Args>
  A(F f, Args... args)
  { /* Do something... */ }
};

And now I want to use it in something way like this one:

A<int(int)> a(::close, 1);

Now the question: is there any way to omit the <int(int)> because a compiler can know this information for the ::close? There is no need to save the "design" of the template.

As for concrete task, I need to design a template of a class. Objects of this class could take a function and parameters for this function at construction time and call this function later.

Aucun commentaire:

Enregistrer un commentaire