I wonder how can I pass a pointer to the non-static member function into the template? Here's the simplified code:
template<typename, typename>
struct contains;
template<typename T, typename R, typename... Ts>
struct contains<T, R(Ts...)>
{
static constexpr bool result = std::disjunction_v<std::is_same<T, Ts>...>;
};
class A
{
public:
static void staticFoo(int a, double* b) {}
void foo(int a, double* b) {}
};
void foo(int a, double* b) {}
int main ()
{
//ok, this works
std::cout << std::boolalpha << contains<double*, decltype(foo)>::result;
//this too
std::cout << std::boolalpha << contains<double*, std::remove_pointer_t<decltype(&A::staticFoo)>>::result;
//boom, error
std::cout << std::boolalpha << contains<double*, decltype(&A::foo)>::result;
return 0;
}
Executing this code, I got an error:
incomplete type 'contains<double*, void (A::*)(int, double*)>' used in nested name specifier
As I understood, types are:
void(int, double*)
void(*)(int, double*)
void(A::*)(int, double*)
In the second case I can use std::remove_pointer_t
, but how can I remove (A::*)
from function signature in the third case?
Aucun commentaire:
Enregistrer un commentaire