这段c++代码语法是什么意思?

#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");
}
  1. struct MemberFunctionParse 用的什么语法,模板特化? Self::* 是什么意思?
  2. 为什么去掉 template struct MemberFunctionParse; 就报错了?
  3. auto SelfTypeNeverUseManually()->std::remove_reference::type; 的 SelfTypeNeverUseManually 是什么? auto XX()->int; 是什么语法?

这个说来话长了,你得去看《C++模板元编程》。大致的意思就是通过模板展开的方式来写程序。

这个好像是获取当前类名称的小功能,运行获取类名称,然后按提示任意键继续,退出。

在C++里面struct也是类的一种,模板类。
Self::*表示是一个指针,这个指针指向的是Self的成员。
template是一个模板,表示一类事物的抽象,这里需要根不同的参数进行不同的创建不同的模板类。
SelfTypeNeverUseManually是一个方法,或者是一个可调用对象,或者是一个函数指针。(我看这个代码在cplusplus里面出现过,应该是别人的代码,不完整吧)
auto xx()->int 表示 xx()->int,xx这个函数的返回值是一个int类型的,和上面的type类似。

不过看这个问题还是先补补template基本内容再说