Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this template argument?

Tags:

c++

templates

So I came across with this today about C++ template programming, can anyone explain to me what A(*)(B) as a template argument?

template <class X, class Y, class A, class B>
struct replace_type_impl<A(*)(B),X,Y,false>
{
  typedef typename replace_type<A,X,Y>::type (*type)(typename replace_type<B,X,Y>::type);
};
like image 641
will Avatar asked Dec 09 '22 04:12

will


1 Answers

The type A (*)(B) is the type of a pointer to a function taking one argument of type B and returning a value of type A.

It's just another type. Your code is an instance of partial specialization of the class template replace_type_impl.

like image 142
Kerrek SB Avatar answered Dec 14 '22 23:12

Kerrek SB