error C2823: a typedef template is illegal - function pointer

alias5000

I want to define a function pointer type using templates. However, VS 2013 me that 'a typedef template is illegal'. I am trying to write something like this:

template<typename SD>
typedef void(*FuncPtr)(void *object, SD *data);

Unfortunately this does not compile. I'd like to keep this thing short. Basically I need to define a type for a function pointer, whose argument is of a template class.

Ben Voigt

Since C++11, you can use the using keyword for an effect very much like typedef, and it allows templates:

template<typename SD>
using FuncPtr = void (*)(void*, SD*);

Before that, you had to separate the template from the typedef:

template<typename SD>
struct FuncPtr
{
     typedef void (*type)(void*, SD*);
};

(and the type name is FuncPtr<U>::type instead of just FuncPtr<U>)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to typedef template function pointer?

typedef and pointer to function in C

C function pointer and typedef

How to typedef a function pointer with template arguments

Illegal operand error on a function pointer iterator

How to use declare a function template pointer typedef without specifying template?

Typedef pointer in a Class Template

How do i use typedef in c++ on a function pointer that must return an class template?

Typedef for a pointer to a C function inside C++

How to create a "typedef to a function pointer" in C#?

Typedef function pointer?

C++ typedef function pointer and declare a pointer in one statement

Typedef function vs function pointer

C++ function pointer as template

c++ template function pointer

C++ function pointer in template

Working function pointer template gives Netbeans error

Template function pointer of template class - C++

c++ passing a pointer to a template function as template

pointer to function to structure, pointer to function to typedef

Passing a typedef method as pointer function

Function pointer IAR ( typedef void )

Is `typedef` of a function standard C syntax, and how does it differ from a `typedef` of a function pointer?

using C function that takes pointer to C struct typedef in Rust

typedef with pointer in C

C typedef: pointer to struct

Interaction between const pointer and typedef and function declaration in c

C: Pass an typedef'd enum value to a function as a pointer

How do I declare a function that returns a pointer to a function that returns a function pointer without using a typedef in C?