CppCon 2017: Klaus Iglberger “Free Your Functions!”
Free funciton
指非类的成员方法(method),而是独立存在的自由函数(function)。
Reuse (OCP) [13:18]
- Free funciton可以重用已有的处理逻辑
std::copy
: good example of free function
std::copy
满足了 The SOLID Principles 的其中四个原则:
- Single Responsibility Principle
- Open/Closed Principle
- Interface Segregation Principle
- Dependency Inversion Principle
不过,它不满足 Liskov Substitution Principle;