CRTP 奇异递归模板模式
来源:互联网 发布:mac怎么输入法 编辑:程序博客网 时间:2024/05/21 14:52
#include <iostream>template <typename Derived>struct Base { Derived&self() { return static_cast<Derived&>(*this); } const Derived&self() const { return static_cast<const Derived&>(*this); }public: void start() { self().run(); }};class Derived : public Base<Derived> { friend Base<Derived>; void run() { std::cout << "Derived run()" << std::endl; }};父类调用子类, 不过不同的 Base<Derived> 是不同的类, 好像没什么用处
0 0
- CRTP 奇异递归模板模式
- 奇异递归模板模式(Curiously Recurring Template Pattern,CRTP)
- 奇异递归模板模式(CRTP)应用--表达式模板(expression template) 2
- 奇异递归模板模式( Curiously Recurring Template Pattern,CRTP)1
- C++惯用法:奇特的递归模板模式(Curiously Recurring Template Pattern,CRTP,Mixin-from-above)
- C++惯用法:奇特的递归模板模式(Curiously Recurring Template Pattern,CRTP,Mixin-from-above)
- C++惯用法:奇特的递归模板模式(Curiously Recurring Template Pattern,CRTP,Mixin-from-above)
- C++惯用法:奇特的递归模板模式(Curiously Recurring Template Pattern,CRTP,Mixin-from-above)
- 奇异循环模板模式
- 奇特递归模板模式
- 递归模板模式
- 关于c++ template多态——CRTP 模式
- 递归模板实现单例模式
- 递归模板模式--The curiously recurring template pattern
- c++模板递归单例模式进阶版本
- C++惯用法:奇特的递归模板模式
- templates — C++模板的应用<奇特的递归模板模式>
- templates — C++模板的应用<奇特的递归模板模式>
- MySql数据库优化
- 40G应用下的三种光器件介绍
- 设置ImageLoader的图片缓存
- python调参神器hyperopt
- 二维码 ThoughtWorks.QRCode 之 index was outside bounds of the array
- CRTP 奇异递归模板模式
- MemCache超详细解读
- 在Java中使用Jedis操作Redis,在高并发的情况下,应用卡死、报无法获取连接错误的处理方式
- 字典序
- Android:关于mediacodec编码camera yuv数据帧率过低的问题
- webpack入门
- leetcode-150-Evaluate Reverse Polish Notation
- Codeforces 557B Pasha and Tea【二分+思维】
- 树莓派3B安装Chromium