#include <iostream>
using namespace std;
template<class Self>
struct MemberFunctionParse;
template<class Result, class Self, class... Args>
struct MemberFunctionParse<Result(Self::*)(Args...)>
{
using ResultType = Result;
};
class Test
{
private:
auto SelfTypeNeverUseManually()->std::remove_reference<decltype(*this)>::type;
using SelfTypeNeverUseManuallyClass = MemberFunctionParse<decltype(&SelfTypeNeverUseManually)>::ResultType;
public:
virtual const std::string& GetSelfTypeClassInfo() {
static std::string result = typeid(SelfTypeNeverUseManuallyClass).name();
return result;
}
};
int main()
{
Test t;
std::string str = t.GetSelfTypeClassInfo();
cout << str.c_str() << endl;
system("pause");
}
- struct MemberFunctionParse 用的什么语法,模板特化? Self::* 是什么意思?
- 为什么去掉 template struct MemberFunctionParse; 就报错了?
- auto SelfTypeNeverUseManually()->std::remove_reference::type; 的 SelfTypeNeverUseManually 是什么? auto XX()->int; 是什么语法?