```c++
#include <stdio.h>
template <class T>
struct ArgTypes {};
template<class P, class R, class A0>
struct ArgTypes<R (P::*)(A0)> {
typedef R returns;
typedef A0 first;
const static int ArgNum = 2;
};
template<class R, class A0, class A1>
struct ArgTypes<R (*)(A0, A1)> {
typedef R returns;
typedef A0 first;
typedef A1 second;
const static int ArgNum = 2;
};
struct Node {
void m_func(int a);
static int s_func(int a, float b);
};
void g_func(int a, char c) {}
int main () {
ArgTypes<decltype(&Node::m_func)>::first a = 1;
ArgTypes<decltype(&Node::s_func)>::second b = 0.1;
ArgTypes<decltype(&g_func)>::second c = '1';
ArgTypes<int> at;
return 0;
}
```
静态成员函数匹配 `*` 而不是 `P::*`,原因详见:https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
- 目录
- 基础知识
- 1、变量和基础类型
- 1.1、内置类型
- 1.2、变量
- 1.3、复合类型
- 1.4、类型修饰符
- 1.5、类型处理
- 1.6、自定义结构
- 1.7、数组
- 2、表达式和语句
- 2.1、运算符
- 2.2、语句
- 3、函数
- 1、语法相关
- 2、资源管理
- 3、面向对象
- 4、模板与泛型编程
- Problem01:判断类中是否包含函数
- Problem02:解析函数的参数类型
- 5、系统库
- Problem01:多线程维护最大值
- Problem02:介绍一下strcpy、strncpy、memcpy、memmove
- Problem03:介绍一下网络编程
- Problem04:select、poll、epoll的区别
- 未整理
- Problem11:实现在main函数前、后执行的函数
- Problem12:可变参函数的实现
- Problem13:全局变量初始化顺序问题
- Problem14:介绍一下隐式转换
- Problem07:实现一个不能被拷贝的类
- Problem08:实现一个只能通过动态、静态分配的类
- 开源项目
- redis
- 第一部分 数据结构与对象
- redis 底层数据结构
- redis 对象
- taskflow
- 数据结构
- Executor
