![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
STL
文章平均质量分 97
ztq小天
sdasas
展开
-
自定义实现的相关STL容器数据结构
https://github.com/TQ5911/program/tree/master/STL原创 2020-02-28 18:17:30 · 165 阅读 · 0 评论 -
处理管理共享对象指针的类—enable_shared_from_this(STL源码)
使用参考:https://blog.csdn.net/caoshangpa/article/details/79392878以下模板函数_Enable_shared被调用处为:智能指针被构造(_Resetp0)的时候template<class _Ty1,class _Ty2> inline void _Do_enable(_Ty1 *_Ptr,enable_shared_...原创 2020-01-28 14:39:13 · 175 阅读 · 0 评论 -
智能指针派生类—unique_ptr(STL源码)
// unique_ptr指针(唯一指向资源的指针,每当赋值、构造时,转让右侧指针数据到左侧,右侧为空,即同一时间只有一个指针指向数据)// 其中,千万别在定义一个unique_ptr指针时出现下述情况已知unique_ptr<int> q(new int(1));q也可以是shared_ptr<int>类型// unique_ptr<int> p(q....原创 2020-01-26 16:39:39 · 779 阅读 · 0 评论 -
智能指针(unique_ptr)的基类—_Unique_ptr_base(STL源码)
// TEMPLATE STRUCT _Get_deleter_pointer_typetemplate<class _Val, class _Ty> struct _Get_deleter_pointer_type _GET_TYPE_OR_DEFAULT(pointer, _Val *);// TEMPLATE CLASS _Uni...原创 2020-01-25 20:46:39 · 396 阅读 · 0 评论 -
智能指针派生类—weak_ptr(STL源码)
// TEMPLATE CLASS weak_ptr// weak_ptr智能指针类模板(指向由智能指针管理的对象,增加弱引用计数,若为shared_ptr不增加的引用计数(非弱))template<class _Ty>class weak_ptr : public _Ptr_base<_Ty>// 继承自智能指针基类{ // class for pointe...原创 2020-01-25 16:42:58 · 284 阅读 · 0 评论 -
引用计数派生类—_Ref_count、_Ref_count_del、_Ref_count_del_alloc(STL源码)
// TEMPLATE CLASS _Ref_counttemplate<class _Ty>class _Ref_count : public _Ref_count_base{ // handle reference counting for object without deleterpublic: _Ref_count(_Ty *_Px) : _Ref_cou...原创 2020-01-24 19:24:35 · 1096 阅读 · 0 评论 -
智能指针派生类—shared_ptr(STL源码)
// shared_ptr虽然能和其他shared_ptr共享同一内存,但是千万不能通过原始指针持有一个即将过期的指针,即2个非共享的share_ptr指向同一个对象,未增加引用计数导对象被析构两次情形如下:std::shared_ptr<int> p= std::make_shared<int>(1);{ std::unique_ptr<int> q(...原创 2020-01-24 18:11:49 · 760 阅读 · 0 评论 -
智能指针(shared_ptr、weak_ptr)的基类—_Ptr_base(STL源码)
// 智能指针模板基类 _Ptr_basetemplate<class _Ty>class _Ptr_base{ // shared_ptr 和 weak_ptr 的基类public: typedef _Ptr_base<_Ty> _Myt; // 定义模板基类 类型 typedef _Ty element_type; // 定义元素类型 _Ptr_ba...原创 2020-01-23 22:04:03 · 428 阅读 · 0 评论 -
引用计数基类—_Ref_count_base(STL源码)
// _MT_INCR 和 _MT_DECR是宏,对应的API函数为InterlockedIncrement/InterlockedDecrement,功能为对变量加一或减一,特点是线程安全,即它们在多线程下能保证执行结果正确。// CLASS _Ref_count_base 引用计数辅助基类(增加、减少引用计数用上述宏实现,而不是单纯的++,--)class _Ref_count_ba...原创 2020-01-23 20:00:18 · 582 阅读 · 0 评论 -
多态
#include <iostream>using namespace std;class A{protected: int a;public: A() :a(1111) {} virtual void Show() { std::cout << a << std::endl; } void ShowInfo() { std::cout &l...原创 2020-01-17 17:44:14 · 122 阅读 · 0 评论 -
访问申明
//#include <iostream>//#include <time.h>//#include <vector>//#include <ostream>//#include <string>//using namespace std;////#define RANDOM_NUM 10//// 随机生成RANDOM_...原创 2020-01-17 17:22:46 · 99 阅读 · 0 评论 -
异常
#include <iostream>using namespace std;class A_except :public std::exception{public: char const* what()const {return "A_except(what())";} void printf()const { std::cout << "A_exce...原创 2020-01-17 17:09:32 · 75 阅读 · 0 评论