• 【c++智能指针】模拟带有weak_ptr的shared_ptr


    【查询x86指令集,原子操作】

    删除器

    template<class _Ty>
    class MyDeletor
    {
     public:
    	 MyDeletor() = default;
    	 void operator()(_Ty* ptr) const
    	 {
    		 if (ptr != NULL)
    		 {
    			 delete ptr;
    		 }
    	 }
    };
    template<class _Ty>
    class MyDeletor<_Ty[]>
    {
    public:
    	MyDeletor() = default;
    	void operator()(_Ty* ptr) const
    	{
    		if (ptr != NULL)
    		{
    			delete[] ptr;
    		}
    	}
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    引用计数类型

    成员变量:
    1、指向对象的指针
    2、强引用计数 //当其值为1的时候,说明对象存在
    3、弱引用计数

    template<class _Ty>
    class RefCnt
    {
    public:
    	_Ty* _Ptr;                    //Obj
    	std::atomic_int _Uses;       //shared_ptr; 
    	std::atomic_int _Weaks;      //weak_ptr  弱引用
    public:
    	RefCnt(_Ty* p) :_Ptr(p), _Uses(1), _Weaks(1); {}
    	~RefCnt() {}
    	void _Incref() { _Uses += 1; }
    	void _Incwef() { _Weaks += 1; }
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    my_shared_ptr类的设计

    template<class _Ty,class _Dx = MyDeletor<_Ty> >
    class my_shared_ptr
    {
    private:
    	_Ty* _Ptr;  //指向object对象
    	RefCnt<_Ty>* Rep;   //指向引用计数类
    	_Dx _mDeletor;   //删除器
    public:
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    构造函数:

    my_shared_ptr(_Ty* p = nullptr) :_Ptr(nullptr), Rep(nullptr)
    	{
    		if (p != nullptr)
    		{
    			_Ptr = p;
    			Rep = new RefCnt<_Ty>(p);
    		}
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    请添加图片描述

    析构函数

    ~my_shared_ptr()
    	{
    		if (Rep != nullptr && --Rep->_Uses == 0)
    		{
    			_mDeletor(_Ptr);
    			if (--Rep->_Weaks == 0)
    			{
    				delete Rep;
    			}
    		}
    		_Ptr = nullptr;
    		Rep = nullptr;
    	
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    拷贝构造函数

    my_shared_ptr(const my_shared_ptr& _Y):_Ptr(_Y._Ptr),Rep(_Y.Rep)
     	{
    		if (Rep != nullptr)
    		{
    			Rep->_Incref();//  _Uses++
    		}
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    移动构造函数

    my_shared_ptr(my_shared_ptr&& _Y) :_Ptr(_Y._Ptr), Rep(_Y.Rep)
    	{
    		_Y._Ptr = nullptr;
    		_Y.Rep = nullptr;
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5

    普通赋值

    my_shared_ptr& operator=(const my_shared_ptr& r)
    	{
    		if (this == *r || this->_Ptr == r._Ptr) return *this;
    		if (_Ptr != nullptr && --Rep->_Uses == 0)
    		{
    			_mDeletor(_Ptr);
    			if (--Rep->_Weaks == 0)
    			{
    				delete Rep;
    			}
    		}
    		_Ptr = r._Ptr;
    		Rep = r.Rep;
    		if (_Ptr != nullptr)
    		{
    			Rep->_Incref();
    		}
    		return *this;
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    请添加图片描述

    移动赋值

    my_shared_ptr& operator=(my_shared_ptr&& r)
    {
    	if (this == &r)return *this;
    	if (_Ptr != nullptr && r._Ptr != nullptr && _Ptr == r._Ptr)
    	{
    		this->Rep->_Uses -= 1;
    		r._Ptr = nullptr;
    		r.Rep = nullptr;
    		return *this;
    	}
    	if (_Ptr != nullptr && --Rep->_Uses == 0)
    	{
    		_mDeletor(_Ptr);
    		if (--Rep->_Weaks == 0)
    		{
    			delete Rep;
    		}
    	}
    	_Ptr = r._Ptr;
    	Rep = r.Rep;
    	r._Ptr = nullptr;
    	r.Rep = nullptr;
    	return *this;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    请添加图片描述

    解引用和指向运算符重载

    _Ty* get()
    {
    	return _Ptr;
    }
    	_Ty& operator*()const
    	{
    		return *get();
    	 }
    	_Ty* operator->()const
    	{
    		return get();
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    返回持有当前资源的指针个数

    size_t use_cout()const
    {
    	if (Rep == nullptr) return 0;
    	return Rep->_Uses;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5

    交换资源函数

    void swap(my_shared_ptr& r)
    {
    	std::swap(_Ptr, r._Ptr);
    	std::swap(Rep, r.Rep);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5

    bool运算符重载

    operator bool()
    {
    	return _Ptr != nullptr;
    }
    
    • 1
    • 2
    • 3
    • 4

    模拟my_weak_ptr

    只有一个Rep指针,指向引用计数

    template<class _Ty>
    class my_weak_ptr
    {
    private:
    	RefCnt<_Ty>* _Rep;
    public:
    	my_weak_ptr() :_Rep(nullptr) {}
    
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    拷贝构造(强引用拷贝给弱引用)

    my_weak_ptr(const my_shared_ptr<_Ty>& other):_Rep(other.Rep)
    	{
    		if (_Rep != nullptr)
    		{
    			_Rep->_Incwef();//weaks
    		}
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    拷贝构造

    my_weak_ptr(const my_weak_ptr& other) :_Rep(other._Rep)
    {
    	if (_Rep != nullptr)
    	{
    		_Rep->_Incwef();//weaks
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    移动拷贝

    my_weak_ptr(my_weak_ptr&& other) :_Rep(other._Rep)
    	{
    		other._Rep = nullptr;
    	}
    	~my_weak_ptr()
    	{
    		if (_Rep != nullptr)  //弱引用只能析构计数
    		{
    			delete _Rep;
    		}
    		_Rep = nullptr;
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    普通赋值

    my_weak_ptr& operator=(const my_weak_ptr&other)
    	{
    		if (this == &other || this->_Rep == other._Rep) return *this;
    		if (this->_Rep != nullptr && --_Rep->_Weaks == 0)
    		{
    			delete _Rep;
    		}
    		_Rep = other._Rep;
    		if (_Rep != nullptr)
    		{
    			_Rep->_Incwef();
    		}
    		return *this;
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    移动赋值

    1.防止自赋值
    2.在_Rep和Other._Rep都不为空,且相等时,将弱引用计数-1,并将参数指针置为空。
    3.如果_Rep 不为空,且对弱引用计数-1为0,则删除弱引用计数结构。
    4.将参数赋值给_Rep,并将参数置为空

    my_weak_ptr& operator=( my_weak_ptr &&other)
    {
    	if (this == other) return *this;
    	if (this->_Rep != nullptr && other._Rep!=nullptr && _Rep==other._Rep)
    	{
    		this->_Rep->_Weaks -= 1;
    		other._Rep = nullptr;
    		return *this;
    	}
    	if (_Rep != nullptr && --_Rep->_Weaks==0)
    	{
    		delete _Rep;
    	}
    	_Rep = other._Rep;
    	other._Rep = nullptr;
    	return *this;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    my_shared_ptr给my_weak_ptr赋值

    1.对弱引用做判断,如果减为0,删除引用计数结构
    2.将_Rep指向my_shared_ptr<_Ty>中Rep指向的引用计数结构
    3.如果此时_Rep不为空就 _weak+1

    my_weak_ptr& operator=(const my_shared_ptr<_Ty>& other)
    {
    	if (_Rep != nullptr && --_Rep->_Weaks == 0)
    	{
    		delete _Rep;
    	}
    	_Rep = other.Rep;
    	if (_Rep != nullptr)
    	{
    		_Rep->_Incwef();
    	}
    	return *this;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    检查引用对象是否被删除

    bool expired() const
    {
    	return this->_Rep->_Uses == 0; //当强引用计数为0的时候,说明对象已经被删除
    }
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5

    >**
    不能使用移动拷贝和移动赋值的方式,强引用拷贝或赋值给弱引用,因为弱引用只能指向引用计数,不能拥有资源,弱引用指针,没有重载,解引用,指向,因为它只有一个指针,指向的是引用计数。**
    请添加图片描述

    锁 会让对象的生存期变长

    my_shared_ptr<_Ty>lock()const
    	{
    		my_shared_ptr<_Ty>_Ret;
    		_Ret._Ptr = _Rep->_Ptr;
    		_Ret.Rep = _Rep;
    		_Ret.Rep->_Incref();
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    测试

    class Object
    {
    private:
    	int value;
    public:
    	Object(int x = 0) :value(x) { cout << "Obejct" << endl; }
    	~Object() { cout << "~Object:" << endl; }
    
    	void Print() const { cout << "value: " << value << endl; }
    };
    void fun()
    {
    	my_shared_ptr<Object> op1(new Object(10));
    	my_weak_ptr<Object> wp1(op1);//强指针拷贝给弱指针
    	my_weak_ptr<Object> wp2(op1);
    }
    int main()
    {
    	fun();
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    请添加图片描述

    void Print() const { cout << "value: " << value << endl; }
    };
    void fun1()
    {
    		my_weak_ptr<Object> wp;
    		{
    			my_shared_ptr<Object> op1(new Object(10));
    			wp = op1;
    		}//块内成员,快结束,就会被析构
    		if (!wp.expired())
    		{
    			wp.lock()->Print();   //Object已经被析构,所以无法打印10
    		}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    请添加图片描述

    请添加图片描述

    完整代码;

    #include
    #include
    using namespace std;
    
    template<class _Ty>
    class MyDeletor
    {
     public:
    	 MyDeletor() = default;
    	 void operator()(_Ty* ptr) const
    	 {
    		 if (ptr != NULL)
    		 {
    			 delete ptr;
    		 }
    	 }
    };
    template<class _Ty>
    class MyDeletor<_Ty[]>
    {
    public:
    	MyDeletor() = default;
    	void operator()(_Ty* ptr) const
    	{
    		if (ptr != NULL)
    		{
    			delete[] ptr;
    		}
    	}
    };
    
    template<class _Ty>
    class RefCnt
    {
    public:
    	_Ty* _Ptr;                    //Obj
    	std::atomic_int _Uses;       //shared_ptr; 
    	std::atomic_int _Weaks;      //weak_ptr  弱引用
    public:
    	RefCnt(_Ty* p) :_Ptr(p), _Uses(1), _Weaks(1){}
    	~RefCnt() {}
    	void _Incref() { _Uses += 1; }
    	void _Incwef() { _Weaks += 1; }
    };
    
    template<class _Ty,class _Dx = MyDeletor<_Ty> >
    class my_shared_ptr
    {
    private:
    	_Ty* _Ptr;  //指向object对象
    	RefCnt<_Ty>* Rep;   //指向引用计数类
    	_Dx _mDeletor;   //删除器
    public:
    	my_shared_ptr(_Ty* p = nullptr) :_Ptr(nullptr), Rep(nullptr)
    	{
    		if (p != nullptr)
    		{
    			_Ptr = p;
    			Rep = new RefCnt<_Ty>(p);
    		}
    	}
    	~my_shared_ptr()  
    	{
    		if (Rep != nullptr && --Rep->_Uses == 0)
    		{                         //在析构的时候不仅要减强引用个数还要减弱引用个数
    			_mDeletor(_Ptr);   
    			if (--Rep->_Weaks == 0)
    			{
    				delete Rep;
    			}
    		}
    		_Ptr = nullptr;
    		Rep = nullptr;
    	}
    	my_shared_ptr(const my_shared_ptr& _Y):_Ptr(_Y._Ptr),Rep(_Y.Rep)
     	{
    		if (Rep != nullptr)
    		{
    			Rep->_Incref();//  _Uses++
    		}
    	}
    	my_shared_ptr(my_shared_ptr&& _Y) :_Ptr(_Y._Ptr), Rep(_Y.Rep)
    	{
    		_Y._Ptr = nullptr;
    		_Y.Rep = nullptr;
    	}
    	my_shared_ptr& operator=(const my_shared_ptr& r)
    	{
    		if (this == *r || this->_Ptr == r._Ptr) return *this;
    		if (_Ptr != nullptr && --_Ptr->_Uses == 0)
    		{
    			_mDeletor(_Ptr);
    			if (--Rep->_Weaks == 0)
    			{
    				delete Rep;
    			}
    		}
    		_Ptr = r._Ptr;
    		Rep = r.Rep;
    		if (_Ptr != nullptr)
    		{
    			Rep->_Incref();
    		}
    		return *this;
    	}
    	my_shared_ptr& operator=(my_shared_ptr&& r)
    	{
    		if (this == &r)return *this;
    		if (_Ptr != nullptr && r._Ptr != nullptr && _Ptr == r._Ptr)
    		{
    			this->Rep->_Uses -= 1;
    			r._Ptr = nullptr;
    			r.Rep = nullptr;
    			return *this;
    		}
    		if (_Ptr != nullptr && --Rep->_Uses == 0)
    		{
    			_mDeletor(_Ptr);
    			if (--Rep->_Weaks == 0)
    			{
    				delete Rep;
    			}
    		}
    		_Ptr = r._Ptr;
    		Rep = r.Rep;
    		r._Ptr = nullptr;
    		r.Rep = nullptr;
    		return *this;
    	}
    	_Ty* get()
    	{
    		return _Ptr;
    	}
    	_Ty& operator*()const
    	{
    		return *get();
    	 }
    	_Ty* operator->()const
    	{
    		return get();
    	}
    	size_t use_cout()const
    	{
    		if (Rep == nullptr) return 0;
    		return Rep->_Uses;
    	}
    	void swap(my_shared_ptr& r)
    	{
    		std::swap(_Ptr, r._Ptr);
    		std::swap(Rep, r.Rep);
    	}
    	operator bool()
    	{
    		return _Ptr != nullptr;
    	}
    	template<class _Ty>
    	friend class my_weak_ptr;
    };
    template<class _Ty>
    class my_weak_ptr
    {
    private:                   //弱指针不拥有资源
    	RefCnt<_Ty>* _Rep;   //只负责弱引用计数,没有权限释放对象,共享性只能指针才有权限释放对象
    public:
    	my_weak_ptr() :_Rep(nullptr) {}
    	//强指针拷贝给弱指针
    	my_weak_ptr(const my_shared_ptr<_Ty>& other):_Rep(other.Rep)
    	{
    		if (_Rep != nullptr)
    		{
    			_Rep->_Incwef();//weaks
    		}
    	}
    	my_weak_ptr(const my_weak_ptr& other) :_Rep(other._Rep)
    	{
    		if (_Rep != nullptr)
    		{
    			_Rep->_Incwef();//weaks
    		}
    	}
    	my_weak_ptr(my_weak_ptr&& other) :_Rep(other._Rep)
    	{
    		other._Rep = nullptr;
    	}
    	~my_weak_ptr()
    	{
    		if (_Rep != nullptr)  //弱引用只能析构计数
    		{
    			delete _Rep;
    		}
    		_Rep = nullptr;
    	}
    	my_weak_ptr& operator=(const my_weak_ptr&other)
    	{
    		if (this == &other || this->_Rep == other._Rep) return *this;
    		if (this->_Rep != nullptr && --_Rep->_Weaks == 0)
    		{
    			delete _Rep;
    		}
    		_Rep = other._Rep;
    		if (_Rep != nullptr)
    		{
    			_Rep->_Incwef();
    		}
    		return *this;
    	}
    	my_weak_ptr& operator=( my_weak_ptr &&other)
    	{
    		if (this == other) return *this;
    		if (this->_Rep != nullptr && other._Rep!=nullptr && _Rep==other._Rep)
    		{
    			this->_Rep->_Weaks -= 1;
    			other._Rep = nullptr;
    			return *this;
    		}
    		if (_Rep != nullptr && --_Rep->_Weaks==0)
    		{
    			delete _Rep;
    		}
    		_Rep = other._Rep;
    		other._Rep = nullptr;
    		return *this;
    	}
    	my_weak_ptr& operator=(const my_shared_ptr<_Ty>& other)
    	{
    		if (_Rep != nullptr && --_Rep->_Weaks == 0)
    		{
    			delete _Rep;
    		}
    		_Rep = other.Rep;
    		if (_Rep != nullptr)
    		{
    			_Rep->_Incwef();
    		}
    		return *this;
    	}
    	//不能使用移动拷贝和移动赋值的方式,强引用拷贝或赋值给弱引用,因为弱引用只能指向引用计数,不能拥有资源。
    	bool expired() const
    	{
    		return this->_Rep->_Uses == 0; //当强引用计数为0的时候,说明对象已经被删除
    	}
       //弱引用指针,没有重载,解引用,指向,因为它只有一个指针,指向的是引用计数。
    	//锁  会让对象的生存期变长
    	my_shared_ptr<_Ty>lock()const
    	{
    		my_shared_ptr<_Ty>_Ret;
    		_Ret._Ptr = _Rep->_Ptr;
    		_Ret.Rep = _Rep;
    		_Ret.Rep->_Incref();
    	}
    };
    class Object
    {
    private:
    	int value;
    public:
    	Object(int x = 0) :value(x) { cout << "Obejct" << endl; }
    	~Object() { cout << "~Object:" << endl; }
    
    	void Print() const { cout << "value: " << value << endl; }
    };
    void fun()
    {
    	my_shared_ptr<Object> op1(new Object(10));
    	my_weak_ptr<Object> wp1(op1);//强指针拷贝给弱指针
    	my_weak_ptr<Object> wp2(op1);
    }
    int main()
    {
    	fun();
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
  • 相关阅读:
    5、Linux文件系统
    Golang原理分析:切片(slice)原理及扩容机制
    美团悄悄上线社群团购“团买买”
    Redis实战——短信登录
    explain的执行结果:Impossible WHERE
    Java -- 定时任务实现方式
    Nginx: 413 – Request Entity Too Large Error and Solution
    WebAssembly中simd使用调研
    力扣大厂热门面试算法题 27-29
    DFT简介(TODO)
  • 原文地址:https://blog.csdn.net/weixin_52958292/article/details/127673785