上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 89 下一页
摘要: 使用组合的方式实现tuple的功能 #include<iostream> using namespace std; template<typename... Values> class tup; template<> class tup<>{}; // to realize function of 阅读全文
posted @ 2022-02-16 21:32 王清河 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 利用递归继承的方式实现tuple #include<iostream> using namespace std; template<typename... Values> class tuples; template<> class tuples<>{}; template<typename Hea 阅读全文
posted @ 2022-02-13 15:23 王清河 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 如果最后一个元素的处理方式不同于前面的,可以使用以下递归调用 #include<iostream> #include<tuple> #include<bitset> using namespace std; template <int IDX, int MAX, typename... Args> 阅读全文
posted @ 2022-02-13 12:38 王清河 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 循环调用的 max #include<iostream> using namespace std; int maximum(int n) { return n; } template <typename... Args> int maximum(int n, Args... args) { retu 阅读全文
posted @ 2022-02-13 11:51 王清河 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 迭代器的递归调用实现max功能,max函数接受任意参数 #include<iostream> using namespace std; struct _Iter_less_iter { template<typename _Iterator1 , typename _Iterator2> bool 阅读全文
posted @ 2022-02-13 11:45 王清河 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 重写 print 函数 #include<iostream> using namespace std; void printfX(const char *s) { while (*s) { if (*s == '%' && *(++s) != '%') throw "invalid format s 阅读全文
posted @ 2022-01-28 22:24 王清河 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 使用可变参数模板重写print #include<iostream> #include<bitset> using namespace std; void printX() { } template<typename T, typename... Types> void printX(const T 阅读全文
posted @ 2022-01-28 21:17 王清河 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 1. 为什么要使用lambda + 就地匿名的定义一个目标函数或者函数对象,不需要额外的再写一个命名函数或者函数对象,以更直接的方式去写函数,可以调高程序的可读性和可维护性。 + 简洁:不要额外的的再写一个函数或者函数对象,避免了代码膨胀或者功能分散。 + 在需要的时间或者地点实现功能闭包,是程序更 阅读全文
posted @ 2022-01-23 16:13 王清河 阅读(1165) 评论(0) 推荐(0) 编辑
摘要: C++ shared_ptr 使用总结: class Color { public: Color(uint32_t _red, uint32_t _yellow, uint32_t _green) : mRed(_red) , mYellow(_yellow) , mGreen(_green) { 阅读全文
posted @ 2021-12-07 16:06 王清河 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 以 32 bit system 为例: signed char 8 bit 0000 0000 有符号类型,需要最高位表示符号,所以一共 7 bit 表示大小 signed char 能表示的范围为 -2^7 ~ 2^7-1 unsigned char 表示的范围为 0 ~ 2^8-1 依次类推 s 阅读全文
posted @ 2021-11-04 11:27 王清河 阅读(67) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 89 下一页