lundi 5 octobre 2015

Overloading variadic-templated member function and variadic-templated functions

Is there easy way to overload variadic-templated function with a common function, like shown for constructors here c++ variadic template constructor and common constructors (c++11 - c++14)

#include <iostream>

struct S {};

class C
{
  public:
  void fun(S const&) { std::cout << " fun(S const& ) " << std::endl; } // 1

  template<typename ... T>
  void fun(T&&...) { std::cout << " fun(T&&...) " << std::endl; } // 2
};

int main ()
{
    S s{};
    C c{};

    c.fun(s);
    c.fun(5); // call 1 - ?
}

Aucun commentaire:

Enregistrer un commentaire