/* * Copyright: JessMA Open Source (ldcsaa@gmail.com) * * Version : 2.3.15 * Author : Bruce Liang * Website : http://www.jessma.org * Project : https://github.com/ldcsaa * Blog : http://www.cnblogs.com/ldcsaa * Wiki : http://www.oschina.net/p/hp-socket * QQ Group : 75375912 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "GeneralHelper.h" #include #include #include #include #include #include #include #include #include #include #include #if _MSC_VER >= 1500 #include #include #define hash_set unordered_set #define hash_map unordered_map #define hash_multimap unordered_multimap #else #include #include #define unordered_set hash_set #define unordered_map hash_map #define unordered_multimap hash_multimap #endif using namespace std; using namespace stdext; using namespace std::tr1; typedef wstring CStdStringW; typedef string CStdStringA; #ifdef _UNICODE typedef CStdStringW CStdString; #else typedef CStdStringA CStdString; #endif typedef list short_list; typedef list int_list; typedef list long_list; typedef list<__int64> int64_list; typedef list ushort_list; typedef list uint_list; typedef list ulong_list; typedef list uint64_list; typedef list float_list; typedef list double_list; typedef stack short_stack; typedef stack int_stack; typedef stack long_stack; typedef stack<__int64> int64_stack; typedef stack ushort_stack; typedef stack uint_stack; typedef stack ulong_stack; typedef stack uint64_stack; typedef stack float_stack; typedef stack double_stack; typedef queue short_queue; typedef queue int_queue; typedef queue long_queue; typedef queue<__int64> int64_queue; typedef queue ushort_queue; typedef queue uint_queue; typedef queue ulong_queue; typedef queue uint64_queue; typedef queue float_queue; typedef queue double_queue; typedef deque short_deque; typedef deque int_deque; typedef deque long_deque; typedef deque<__int64> int64_deque; typedef deque ushort_deque; typedef deque uint_deque; typedef deque ulong_deque; typedef deque uint64_deque; typedef deque float_deque; typedef deque double_deque; typedef vector short_vector; typedef vector int_vector; typedef vector long_vector; typedef vector<__int64> int64_vector; typedef vector ushort_vector; typedef vector uint_vector; typedef vector ulong_vector; typedef vector uint64_vector; typedef vector float_vector; typedef vector double_vector; typedef set short_set; typedef set int_set; typedef set long_set; typedef set<__int64> int64_set; typedef set ushort_set; typedef set uint_set; typedef set ulong_set; typedef set uint64_set; typedef set float_set; typedef set double_set; typedef hash_set short_hash_set; typedef hash_set int_hash_set; typedef hash_set long_hash_set; typedef hash_set<__int64> int64_hash_set; typedef hash_set ushort_hash_set; typedef hash_set uint_hash_set; typedef hash_set ulong_hash_set; typedef hash_set uint64_hash_set; typedef hash_set float_hash_set; typedef hash_set double_hash_set; typedef unordered_set short_unordered_set; typedef unordered_set int_unordered_set; typedef unordered_set long_unordered_set; typedef unordered_set<__int64> int64_unordered_set; typedef unordered_set ushort_unordered_set; typedef unordered_set uint_unordered_set; typedef unordered_set ulong_unordered_set; typedef unordered_set uint64_unordered_set; typedef unordered_set float_unordered_set; typedef unordered_set double_unordered_set; typedef list int_ptr_list; typedef list long_ptr_list; typedef list uint_ptr_list; typedef list ulong_ptr_list; typedef stack int_ptr_stack; typedef stack long_ptr_stack; typedef stack uint_ptr_stack; typedef stack ulong_ptr_stack; typedef queue int_ptr_queue; typedef queue long_ptr_queue; typedef queue uint_ptr_queue; typedef queue ulong_ptr_queue; typedef deque int_ptr_deque; typedef deque long_ptr_deque; typedef deque uint_ptr_deque; typedef deque ulong_ptr_deque; typedef vector int_ptr_vector; typedef vector long_ptr_vector; typedef vector uint_ptr_vector; typedef vector ulong_ptr_vector; typedef set int_ptr_set; typedef set long_ptr_set; typedef set uint_ptr_set; typedef set ulong_ptr_set; typedef hash_set int_ptr_hash_set; typedef hash_set long_ptr_hash_set; typedef hash_set uint_ptr_hash_set; typedef hash_set ulong_ptr_hash_set; typedef unordered_set int_ptr_unordered_set; typedef unordered_set long_ptr_unordered_set; typedef unordered_set uint_ptr_unordered_set; typedef unordered_set ulong_ptr_unordered_set; /*****************************************************************************/ /******************************** 容器操作函数 *******************************/ /********************************** 描述: 清除普通集合 , 适用于 vector / list 参数: v : vector / list / set 返回值: **********************************/ template void ClearSet(Set& v) { v.clear(); } template struct Set_Cleaner { static void Clear(Set& v) {ClearSet(v);} }; /********************************** 描述: 清除指针集合 (清除前先释放指针), 适用于 vector / list 参数: v : vector / list / set 返回值: **********************************/ template void ClearPtrSet(PtrSet& v) { for(PtrSet::iterator it = v.begin(), end = v.end(); it != end; ++it) delete (*it); v.clear(); } template struct PtrSet_Cleaner { static void Clear(PtrSet& v) {ClearPtrSet(v);} }; /********************************** 描述: 清除指针集合 (指针同时又指向数组), 适用于 vector / list 参数: v : vector / list / set 返回值: **********************************/ template void ClearPtrArraySet(PtrArraySet& v) { for(PtrArraySet::iterator it = v.begin(), end = v.end(); it != end; ++it) delete[] (*it); v.clear(); } template struct PtrArraySet_Cleaner { static void Clear(PtrArraySet& v) {ClearPtrArraySet(v);} }; /********************************** 描述: 清除普通影射 , 适用于 map 参数: v : map 返回值: **********************************/ template void ClearMap(Map& v) { v.clear(); } template struct Map_Cleaner { static void Clear(Map& v) {ClearMap(v);} }; /********************************** 描述: 清除指针影射 (清除前先释放指针), 适用于 map 参数: v : map 返回值: **********************************/ template void ClearPtrMap(PtrMap& v) { for(PtrMap::iterator it = v.begin(), end = v.end(); it != end; ++it) delete it->second; v.clear(); } template struct PtrMap_Cleaner { static void Clear(PtrMap& v) {ClearPtrMap(v);} }; /********************************** 描述: 清除指针影射 (指针同时又指向数组), 适用于 map 参数: v : map 返回值: **********************************/ template void ClearPtrArrayMap(PtrArrayMap& v) { for(PtrArrayMap::iterator it = v.begin(), end = v.end(); it != end; ++it) delete[] it->second; v.clear(); } template struct PtrArrayMap_Cleaner { static void Clear(PtrArrayMap& v) {ClearPtrArrayMap(v);} }; /********************************** 描述: 清除集合-集合 (清除前先清除内部集合), 适用于 set*> 参数: v : vector / list / set 返回值: **********************************/ template void ClearSetSet(SetSet& v) { for(SetSet::iterator it = v.begin(), end = v.end(); it != end; ++it) { (*it)->clear(); delete (*it); } v.clear(); } template struct SetSet_Cleaner { static void Clear(SetSet& v) {ClearSetSet(v);} }; /********************************** 描述: 清除指针集合-集合 (清除前先清除内部指针集合), 适用于 set*> 参数: v : vector / list / set 返回值: **********************************/ template void ClearPtrSetSet(PtrSetSet& v) { for(PtrSetSet::iterator it = v.begin(), end = v.end(); it != end; ++it) { ClearPtrSet(**it); delete (*it); } v.clear(); } template struct PtrSetSet_Cleaner { static void Clear(PtrSetSet& v) {ClearPtrSetSet(v);} }; /********************************** 描述: 清除指针数组集合影射 (清除前先清除指针数组集合), 适用于 map*> 参数: v : vector / list / set 返回值: **********************************/ template void ClearPtrArraySetSet(PtrArraySetSet& v) { for(PtrArraySetSet::iterator it = v.begin(), end = v.end(); it != end; ++it) { ClearPtrArraySet(**it); delete (*it); } v.clear(); } template struct PtrArraySetSet_Cleaner { static void Clear(PtrArraySetSet& v) {ClearPtrArraySetSet(v);} }; /********************************** 描述: 清除集合影射 (清除前先清除集合), 适用于 map*> 参数: v : map 返回值: **********************************/ template void ClearSetMap(SetMap& v) { for(SetMap::iterator it = v.begin(), end = v.end(); it != end; ++it) { it->second->clear(); delete it->second; } v.clear(); } template struct SetMap_Cleaner { static void Clear(SetMap& v) {ClearSetMap(v);} }; /********************************** 描述: 清除指针集合影射 (清除前先清除指针集合), 适用于 map*> 参数: v : map 返回值: **********************************/ template void ClearPtrSetMap(PtrSetMap& v) { for(PtrSetMap::iterator it = v.begin(), end = v.end(); it != end; ++it) { ClearPtrSet(*(it->second)); delete it->second; } v.clear(); } template struct PtrSetMap_Cleaner { static void Clear(PtrSetMap& v) {ClearPtrSetMap(v);} }; /********************************** 描述: 清除指针数组集合影射 (清除前先清除指针数组集合), 适用于 map*> 参数: v : map 返回值: **********************************/ template void ClearPtrArraySetMap(PtrArraySetMap& v) { for(PtrArraySetMap::iterator it = v.begin(), end = v.end(); it != end; ++it) { ClearPtrArraySet(*(it->second)); delete it->second; } v.clear(); } template struct PtrArraySetMap_Cleaner { static void Clear(PtrArraySetMap& v) {ClearPtrArraySetMap(v);} }; /********************************** 描述: 清除映射-影射 (清除前先清除内部映射), 适用于 map*> 参数: v : map 返回值: **********************************/ template void ClearMapMap(MapMap& v) { for(MapMap::iterator it = v.begin(), end = v.end(); it != end; ++it) { it->second->clear(); delete it->second; } v.clear(); } template struct MapMap_Cleaner { static void Clear(MapMap& v) {ClearMapMap(v);} }; /********************************** 描述: 清除指针映射-影射 (清除前先清除指针内部映射), 适用于 map*> 参数: v : map 返回值: **********************************/ template void ClearPtrMapMap(PtrMapMap& v) { for(PtrMapMap::iterator it = v.begin(), end = v.end(); it != end; ++it) { ClearPtrMap(*(it->second)); delete it->second; } v.clear(); } template struct PtrMapMap_Cleaner { static void Clear(PtrMapMap& v) {ClearPtrMapMap(v);} }; /********************************** 描述: 清除指针映射-影射 (清除前先清除指针数组内部映射), 适用于 map*> 参数: v : map 返回值: **********************************/ template void ClearPtrArrayMapMap(PtrArrayMapMap& v) { for(PtrArrayMapMap::iterator it = v.begin(), end = v.end(); it != end; ++it) { ClearPtrArrayMap(*(it->second)); delete it->second; } v.clear(); } template struct PtrArrayMapMap_Cleaner { static void Clear(PtrArrayMapMap& v) {ClearPtrArrayMapMap(v);} }; /************************************************************************/ /* 指针集合容器 */ /************************************************************************/ template struct SetWrapper { typedef typename Set::iterator iterator; typedef typename Set::const_iterator const_iterator; typedef typename Set::value_type value_type; typedef typename Set::reference reference; typedef typename Set::const_reference const_reference; typedef typename Set::pointer pointer; typedef typename Set::const_pointer const_pointer; typedef typename Set::size_type size_type; typedef typename Set::difference_type difference_type; SetWrapper() { } virtual ~SetWrapper() { Clear(); } void Clear() { if(!IsEmpty()) { Cleaner::Clear(m_set); } } Set& operator * () {return m_set;} const Set& operator * () const {return m_set;} Set* operator -> () {return &m_set;} const Set* operator -> () const {return &m_set;} Set& Get () {return m_set;} operator Set& () {return m_set;} bool IsEmpty () const {return m_set.empty();} size_t Size () const {return m_set.size();} protected: Set m_set; DECLARE_NO_COPY_CLASS(SetWrapper) }; template struct VectorWrapper : public SetWrapper { VectorWrapper() { } reference operator [] (size_type i) {return m_set[i];} const_reference operator [] (size_type i) const {return m_set[i];} DECLARE_NO_COPY_CLASS(VectorWrapper) }; /************************************************************************/ /* 指针数组集合容器 */ /************************************************************************/ /************************************************************************/ /* 指针映射容器 */ /************************************************************************/ template struct MapWrapper { typedef typename Map::iterator iterator; typedef typename Map::const_iterator const_iterator; typedef typename Map::key_type key_type; typedef typename Map::mapped_type mapped_type; typedef typename Map::value_type value_type; typedef typename Map::reference reference; typedef typename Map::const_reference const_reference; typedef typename Map::pointer pointer; typedef typename Map::size_type size_type; typedef typename Map::difference_type difference_type; MapWrapper() { } ~MapWrapper() { Clear(); } void Clear() { if(!IsEmpty()) { Cleaner::Clear(m_map); } } Map& operator * () {return m_map;} const Map& operator * () const {return m_map;} Map* operator -> () {return &m_map;} const Map* operator -> () const {return &m_map;} mapped_type& operator [] (const key_type& key) {return m_map[key];} const mapped_type& operator [] (const key_type& key) const {return m_map[key];} Map& Get () {return m_map;} operator Map& () {return m_map;} bool IsEmpty () const {return m_map.empty();} size_t Size () const {return m_map.size();} private: Map m_map; DECLARE_NO_COPY_CLASS(MapWrapper) }; /************************************************************************/ /* 比较仿函数 */ /************************************************************************/ struct bool_comp_func { bool operator() (bool v1, bool v2) const { if(!v1) return false; if(v1 == v2) return false; return true; } }; template // T -> (signed / unsigned) short / int / long / __int64 struct integer_comp_func { bool operator() (T v1, T v2) const { return v1 < v2; } }; typedef integer_comp_func short_comp_func; typedef integer_comp_func int_comp_func; typedef integer_comp_func long_comp_func; typedef integer_comp_func<__int64> int64_comp_func; typedef integer_comp_func ushort_comp_func; typedef integer_comp_func uint_comp_func; typedef integer_comp_func ulong_comp_func; typedef integer_comp_func uint64_comp_func; struct float_comp_func { bool operator() (float v1, float v2) const { float disc = v1 - v2; if(fabsf(disc) < 1E-5) return false; return disc < 0; } }; struct double_comp_func { bool operator() (double v1, double v2) const { double disc = v1 - v2; if(fabs(disc) < 1E-8) return false; return disc < 0; } }; template // T -> (unsigned) char / wchar_t struct character_comp_func { bool operator() (T v1, T v2) const { if(!CASE) { if(v1 >= 'A' && v1 <= 'Z') v1 += 32; if(v2 >= 'A' && v2 <= 'Z') v2 += 32; } return v1 < v2; } }; typedef character_comp_func char_case_comp_func; typedef character_comp_func uchar_case_comp_func; typedef character_comp_func wchar_case_comp_func; typedef character_comp_func char_ucase_comp_func; typedef character_comp_func uchar_ucase_comp_func; typedef character_comp_func wchar_ucase_comp_func; template // T -> TCHAR* / CString struct str_comp_func { //比较函数。 bool operator() (const T &A, const T &B) const { if(!CASE) return lstrcmpi((LPCTSTR)A, (LPCTSTR)B) < 0; else return lstrcmp((LPCTSTR)A, (LPCTSTR)B) < 0; } }; typedef str_comp_func case_tchar_comp_func; typedef str_comp_func uncase_tchar_comp_func; typedef str_comp_func case_string_comp_func; typedef str_comp_func uncase_string_comp_func; typedef case_tchar_comp_func tchar_ptr_case_comp_func; typedef uncase_tchar_comp_func tchar_ptr_ucase_comp_func; typedef case_string_comp_func string_case_comp_func; typedef uncase_string_comp_func string_ucase_comp_func; /************************************************************************/ /* 排序仿函数 */ /************************************************************************/ template struct bool_sort_func { bool operator() (bool v1, bool v2) const { if(v1 == v2) return false; bool result = !v1; return ASC ? result : !result; } }; typedef bool_sort_func bool_asc_sort_func; typedef bool_sort_func bool_desc_sort_func; template // T -> (signed / unsigned) short / int / long / __int64 struct integer_sort_func { bool operator() (T v1, T v2) const { if(v1 == v2) return false; bool result = v1 < v2; return ASC ? result : !result; } }; typedef integer_sort_func short_asc_sort_func; typedef integer_sort_func ushort_asc_sort_func; typedef integer_sort_func int_asc_sort_func; typedef integer_sort_func uint_asc_sort_func; typedef integer_sort_func long_asc_sort_func; typedef integer_sort_func ulong_asc_sort_func; typedef integer_sort_func<__int64, true> int64_asc_sort_func; typedef integer_sort_func uint64_asc_sort_func; typedef integer_sort_func short_desc_sort_func; typedef integer_sort_func ushort_desc_sort_func; typedef integer_sort_func int_desc_sort_func; typedef integer_sort_func uint_desc_sort_func; typedef integer_sort_func long_desc_sort_func; typedef integer_sort_func ulong_desc_sort_func; typedef integer_sort_func<__int64, false> int64_desc_sort_func; typedef integer_sort_func uint64_desc_sort_func; template struct float_sort_func { bool operator() (float v1, float v2) const { float disc = v1 - v2; if(fabsf(disc) < 1E-5) return false; bool result = disc < 0; return ASC ? result : !result; } }; typedef float_sort_func float_asc_sort_func; typedef float_sort_func float_desc_sort_func; template struct double_sort_func { bool operator() (double v1, double v2) const { double disc = v1 - v2; if(fabs(disc) < 1E-8) return false; bool result = disc < 0; return ASC ? result : !result; } }; typedef double_sort_func double_asc_sort_func; typedef double_sort_func double_desc_sort_func; template // T -> (unsigned) char / wchar_t struct character_sort_func { bool operator() (T v1, T v2) const { if(!CASE) { if(v1 >= 'A' && v1 <= 'Z') v1 += 32; if(v2 >= 'A' && v2 <= 'Z') v2 += 32; } if(v1 == v2) return false; bool result = v1 < v2; return ASC ? result : !result; } }; typedef character_sort_func char_asc_case_sort_func; typedef character_sort_func uchar_asc_case_sort_func; typedef character_sort_func wchar_asc_case_sort_func; typedef character_sort_func char_asc_ucase_sort_func; typedef character_sort_func uchar_asc_ucase_sort_func; typedef character_sort_func wchar_asc_ucase_sort_func; typedef character_sort_func char_desc_case_sort_func; typedef character_sort_func uchar_desc_case_sort_func; typedef character_sort_func wchar_desc_case_sort_func; typedef character_sort_func char_desc_ucase_sort_func; typedef character_sort_func uchar_desc_ucase_sort_func; typedef character_sort_func wchar_desc_ucase_sort_func; template // T -> TCHAR* / CString struct str_sort_func { bool operator() (const T& v1, const T& v2) const { bool result; if(CASE) { int v = lstrcmp((LPCTSTR)v1, (LPCTSTR)v2); if(v == 0) result = false; else result = v < 0; } else { int v = lstrcmpi((LPCTSTR)v1, (LPCTSTR)v2); if(v == 0) result = false; else result = v < 0; } return ASC ? result : !result; } }; typedef str_sort_func tchar_ptr_asc_case_sort_func; typedef str_sort_func string_asc_case_sort_func; typedef str_sort_func tchar_ptr_asc_ucase_sort_func; typedef str_sort_func string_asc_ucase_sort_func; typedef str_sort_func tchar_ptr_desc_case_sort_func; typedef str_sort_func string_desc_case_sort_func; typedef str_sort_func tchar_ptr_desc_ucase_sort_func; typedef str_sort_func string_desc_ucase_sort_func; /************************************************************************/ /* smart_ptr 单实体或数组智能指针 */ /************************************************************************/ template struct simple_deleter { static void delete_ptr(_Ty* pv) {delete pv;} }; template struct global_simple_deleter { static void delete_ptr(_Ty* pv) {::delete pv;} }; template struct array_deleter { static void delete_ptr(_Ty* pv) {delete[] pv;} }; template struct global_array_deleter { static void delete_ptr(_Ty* pv) {::delete[] pv;} }; template class smart_ptr { public: smart_ptr(_Ty* _Ptr = 0) : _Myptr(_Ptr) {} smart_ptr(smart_ptr<_Ty, _Deleter>& _Right) : _Myptr(_Right.release()) {} ~smart_ptr() { reset(); } smart_ptr<_Ty, _Deleter>& reset(_Ty* _Ptr = 0) { if (_Ptr != _Myptr) { if(_Myptr) _Deleter::delete_ptr(_Myptr); _Myptr = _Ptr; } return *this; } smart_ptr<_Ty, _Deleter>& reset(smart_ptr<_Ty, _Deleter>& _Right) { if (this != &_Right) reset(_Right.release()); return *this; } _Ty* release() { _Ty* _Ptr = _Myptr; _Myptr = 0; return _Ptr; } smart_ptr<_Ty, _Deleter>& operator = (_Ty* _Ptr) {return reset(_Ptr);} smart_ptr<_Ty, _Deleter>& operator = (smart_ptr<_Ty, _Deleter>& _Right) {return reset(_Right);} bool is_valid () const {return _Myptr != 0;} _Ty& operator * () const {return *_Myptr;} _Ty* get () const {return _Myptr;} _Ty* operator -> () const {return _Myptr;} operator _Ty* () const {return _Myptr;} private: template smart_ptr<_Ty, _Deleter> (const smart_ptr<_Ty, _Other>&); template smart_ptr<_Ty, _Deleter>& reset (const smart_ptr<_Ty, _Other>&); template smart_ptr<_Ty, _Deleter>& operator = (const smart_ptr<_Ty, _Other>&); template smart_ptr<_Ty, _Deleter> (const smart_ptr<_Other, _Deleter>&); template smart_ptr<_Ty, _Deleter>& reset (const smart_ptr<_Other, _Deleter>&); template smart_ptr<_Ty, _Deleter>& operator = (const smart_ptr<_Other, _Deleter>&); protected: _Ty* _Myptr; }; /************************************************************************/ /* smart_simple_ptr 单实体智能指针 */ /************************************************************************/ template class smart_simple_ptr : public smart_ptr<_Ty, simple_deleter<_Ty>> { public: smart_simple_ptr(_Ty* _Ptr = 0) : smart_ptr(_Ptr) {} smart_simple_ptr(smart_simple_ptr<_Ty>& _Right) : smart_ptr(_Right) {} smart_simple_ptr(smart_ptr<_Ty, simple_deleter<_Ty>>& _Right) : smart_ptr(_Right) {} smart_simple_ptr<_Ty>& operator = (smart_ptr<_Ty, simple_deleter<_Ty>>& _Right) {return (smart_simple_ptr<_Ty>&)__super::operator = (_Right);} smart_simple_ptr<_Ty>& operator = (smart_simple_ptr<_Ty>& _Right) {return (smart_simple_ptr<_Ty>&)__super::operator = (_Right);} smart_simple_ptr<_Ty>& operator = (_Ty* _Ptr) {return (smart_simple_ptr<_Ty>&)__super::operator = (_Ptr);} private: template smart_simple_ptr<_Ty> (const smart_ptr<_Ty, _Other>&); template smart_simple_ptr<_Ty>& operator = (const smart_ptr<_Ty, _Other>&); template smart_simple_ptr<_Ty> (const smart_simple_ptr<_Other>&); template smart_simple_ptr<_Ty>& operator = (const smart_simple_ptr<_Other>&); }; /************************************************************************/ /* smart_gd_simple_ptr 单实体智能指针 (使用全局 delete) */ /************************************************************************/ template class smart_gd_simple_ptr : public smart_ptr<_Ty, global_simple_deleter<_Ty>> { public: smart_gd_simple_ptr(_Ty* _Ptr = 0) : smart_ptr(_Ptr) {} smart_gd_simple_ptr(smart_gd_simple_ptr<_Ty>& _Right) : smart_ptr(_Right) {} smart_gd_simple_ptr(smart_ptr<_Ty, global_simple_deleter<_Ty>>& _Right) : smart_ptr(_Right) {} smart_gd_simple_ptr<_Ty>& operator = (smart_ptr<_Ty, global_simple_deleter<_Ty>>& _Right) {return (smart_gd_simple_ptr<_Ty>&)__super::operator = (_Right);} smart_gd_simple_ptr<_Ty>& operator = (smart_gd_simple_ptr<_Ty>& _Right) {return (smart_gd_simple_ptr<_Ty>&)__super::operator = (_Right);} smart_gd_simple_ptr<_Ty>& operator = (_Ty* _Ptr) {return (smart_gd_simple_ptr<_Ty>&)__super::operator = (_Ptr);} private: template smart_gd_simple_ptr<_Ty> (const smart_ptr<_Ty, _Other>&); template smart_gd_simple_ptr<_Ty>& operator = (const smart_ptr<_Ty, _Other>&); template smart_gd_simple_ptr<_Ty> (const smart_gd_simple_ptr<_Other>&); template smart_gd_simple_ptr<_Ty>& operator = (const smart_gd_simple_ptr<_Other>&); }; /************************************************************************/ /* smart_array_ptr 数组智能指针 */ /************************************************************************/ template class smart_array_ptr : public smart_ptr<_Ty, array_deleter<_Ty>> { public: smart_array_ptr(_Ty* _Ptr = 0) : smart_ptr(_Ptr) {} smart_array_ptr(smart_simple_ptr<_Ty>& _Right) : smart_ptr(_Right) {} smart_array_ptr(smart_ptr<_Ty, array_deleter<_Ty>>& _Right) : smart_ptr(_Right) {} smart_array_ptr<_Ty>& operator = (smart_ptr<_Ty, array_deleter<_Ty>>& _Right) {return (smart_array_ptr<_Ty>&)__super::operator = (_Right);} smart_array_ptr<_Ty>& operator = (smart_array_ptr<_Ty>& _Right) {return (smart_array_ptr<_Ty>&)__super::operator = (_Right);} smart_array_ptr<_Ty>& operator = (_Ty* _Ptr) {return (smart_array_ptr<_Ty>&)__super::operator = (_Ptr);} private: template smart_array_ptr<_Ty> (const smart_ptr<_Ty, _Other>&); template smart_array_ptr<_Ty>& operator = (const smart_ptr<_Ty, _Other>&); template smart_array_ptr<_Ty> (const smart_array_ptr<_Other>&); template smart_array_ptr<_Ty>& operator = (const smart_array_ptr<_Other>&); }; /************************************************************************/ /* smart_gd_array_ptr 单实体智能指针 (使用全局 delete) */ /************************************************************************/ template class smart_gd_array_ptr : public smart_ptr<_Ty, global_array_deleter<_Ty>> { public: smart_gd_array_ptr(_Ty* _Ptr = 0) : smart_ptr(_Ptr) {} smart_gd_array_ptr(smart_gd_array_ptr<_Ty>& _Right) : smart_ptr(_Right) {} smart_gd_array_ptr(smart_ptr<_Ty, global_array_deleter<_Ty>>& _Right) : smart_ptr(_Right) {} smart_gd_array_ptr<_Ty>& operator = (smart_ptr<_Ty, global_array_deleter<_Ty>>& _Right) {return (smart_gd_array_ptr<_Ty>&)__super::operator = (_Right);} smart_gd_array_ptr<_Ty>& operator = (smart_gd_array_ptr<_Ty>& _Right) {return (smart_gd_array_ptr<_Ty>&)__super::operator = (_Right);} smart_gd_array_ptr<_Ty>& operator = (_Ty* _Ptr) {return (smart_gd_array_ptr<_Ty>&)__super::operator = (_Ptr);} private: template smart_gd_array_ptr<_Ty> (const smart_ptr<_Ty, _Other>&); template smart_gd_array_ptr<_Ty>& operator = (const smart_ptr<_Ty, _Other>&); template smart_gd_array_ptr<_Ty> (const smart_gd_array_ptr<_Other>&); template smart_gd_array_ptr<_Ty>& operator = (const smart_gd_array_ptr<_Other>&); };