```c++
#include <stdio.h>
typedef char YES[0];
typedef char NO[1];
template <class T>
struct HasFunction {
template <class>
static NO& test(...);
template <class U>
static YES& test(decltype(&U::function));
static const bool value = sizeof(test<T>(0)) == sizeof(YES);
};
struct WithFunction {
void function() {}
};
struct NoFunction {
};
int main () {
if (HasFunction<WithFunction>::value) {
printf("WithFunction has function.\n");
} else {
printf("WithFunction hasn't function.\n");
}
if (HasFunction<NoFunction>::value) {
printf("NoFunction has function.\n");
} else {
printf("NoFunction hasn't function.\n");
}
return 0;
}
```
- 目录
- 基础知识
- 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
