C++结构采用模板签名?

C++ structure taking template signature?

我被要求做这个“事情”工作:

FunctSignature<int(const std::string &str)>::type f= &thisIsAFunction;
f("coucou");

为了实现这一点,他们要求我做:

First : Declare a structure taking a template

Then : Declare the same structure as before but this time you must specialize it partially.

Finaly : This specialisation will have the form of the signature of the above function. The declaration part which is templated will declare each of its signature members.

如果有人知道如何做这件事情...帮助 !!!

在此先致谢。

它遵循不涉及可变参数模板的基本实现:

#include <string>
#include <iostream>

template<class T>
struct FunctSignature { };

template<class Ret, class Arg>
struct FunctSignature<Ret(Arg)> {
    using type = Ret(*)(Arg);
};

int thisIsAFunction(const std::string &str) {
    std::cout << str << std::endl;
}

int main() {
    FunctSignature<int(const std::string &str)>::type f= &thisIsAFunction;
    f("cocou");
}

这里是基于一个可变参数模板:

template<typename T>
struct FunctSignature { };

template<typename Ret, typename... Args>
struct FunctSignature<Ret(Args...)> {
    using type = Ret(*)(Args...);
};