
C++
_vegetable_
这个作者很懒,什么都没留下…
展开
-
ThreadSafeSharedPtr
【代码】线程安全的shared_ptr。原创 2023-07-18 12:58:28 · 136 阅读 · 0 评论 -
C++ sort函数的使用注意事项及潜在bug
严格弱序的定义:如果两个元素具备任何一个元素都不小于另一个元素的性质,那么就视为它们是具备某种程度之等价关系是合理的。(x<y) &&!(y<x) , 广义上!op(x,y) &&!op(y,x) (op(x,y) 表示比较x和y)而不能是 <= 或者 >= ,(实际上等于号加了也是毫无意义,sort是不稳定的排序),否则可能会出现段错误。sort函数的cmp必须按照规定来写,即必须只是 > 或者 <比如: return a > b;《c++标准程序库》 P176。《泛型编程与STL》第六章。原创 2023-05-02 14:06:01 · 762 阅读 · 0 评论 -
C++静态多态
C++静态多态技术 Curiously Recurring Template Pattern (CRTP)原创 2022-07-20 17:46:18 · 413 阅读 · 0 评论 -
std::swap的使用陷阱
#include <iostream>#include <memory>class struct1{public: static int sta_ ; struct1() = default; struct1(int x):aa(x){} struct1(const struct1 &s):int2_1(s.int2_1){cout << "kaobeigouzao2" << endl;} struct.原创 2022-03-03 01:01:19 · 404 阅读 · 0 评论