#include <memory>
#include <iostream>
class Manager
{
public:
Manager() {}
virtual ~Manager() {}
int funcA(std::shared_ptr<int> a, float b) { return *a + b; }
int funcA(std::shared_ptr<double> a) { return *a; }
};
template <typename T, typename... Args>
auto resolver(int (Manager::*func)(std::shared_ptr<T>, Args...)) -> decltype(func) {
return func;
}
int main(int, char **)
{
Manager m;
Manager *ptr = &m;
auto var = std::make_shared<int>(1);
int result = (ptr->*resolver<int>(&Manager::funcA))(var, 2.0);
std::cout << result << std::endl;
return 0;
}
This code fail to compile with gcc but is fine with clang. (gcc 5.3.1 and 6.0.0 20151220).
Do you know if there is any solution to make it compile with gcc ? I tried with template specialization and explicit instantiation.
Aucun commentaire:
Enregistrer un commentaire