C ++ function pointer as a template

I just started in C ++, so sorry if this is a newbie question. I searched the net and found nothing about it. In fact, I was not even sure how to formulate my search ...

I saw this code somewhere:

template <class T>
struct SomeStruct
{
    SomeStruct() {}
};

And later, this:

int main()
{
    SomeStruct<void (Foo::*)(int test)> mStruct;
}

Compiled above.

So, if I understood correctly, "void (Foo :: *) (int test)" is a pointer to a function that points to some function in Foo that takes an int as an argument and returns void.

How can this be a legal argument for the parameter "class T"?

Any help would be appreciated.

+4
source share
2 answers

void (Foo::*)(int test) - -. - Foo ( void int).

class T - - ( class), , template<class T> template<typename T>,

, .

typename class , , class (, template<template<typename, typename> class> ++ 1z.

+8

. .

; class typename.

, , , ( ).:)

+5

Source: https://habr.com/ru/post/1607014/


All Articles