commit 2025-09-05 17:34 edit a bit ZCppMain/ZMainHead.H
This commit is contained in:
@ -1148,6 +1148,76 @@ namespace ZNsMain
|
||||
namespace ZNsType*/
|
||||
|
||||
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
|
||||
■ 가끔 템플릿으로 클래스 설계를 하다보면 템플릿의 parameter 가
|
||||
포인터나 참조일 경우, 무엇의 포인터나 참조형인지 알고 싶을 때
|
||||
가 있다. 이런 경우에 ZtCTypeData<> 를 사용한다.
|
||||
|
||||
cf)
|
||||
|
||||
cout<<typeid(std::ZtCTypeData<ZTypIntI >::TypeData).name()<<endl;
|
||||
cout<<typeid(std::ZtCTypeData<ZTypIntI*>::TypeData).name()<<endl;
|
||||
cout<<typeid(std::ZtCTypeData<ZTypIntI&>::TypeData).name()<<endl;
|
||||
|
||||
-- 2010-01-15 00:11:00
|
||||
|
||||
■ ZtCTypeData<>::GetObjRef(~) 는 아래처럼 주로 포인터 자료형을
|
||||
(null 이 아닌 경우) 항상 참조형으로 다루고 싶을 때 사용한다.
|
||||
템플릿 Parameter 가 포인터형인데, 무엇의 포인터 형인지 알아
|
||||
내어, 참조형으로 만들어 다른 함수의 인수로 사용하거나, 해당
|
||||
멤버의 호출을 포인터 참조 표기 -> 말고 참조 표기(.)로 하면 편
|
||||
할 것이다.
|
||||
|
||||
typedef std::CStringBase_T<char> CStringData ;
|
||||
typedef CStringData* CStringDataPtr;
|
||||
|
||||
CStringData VO_CStringData("My");
|
||||
CStringDataPtr VP_CStringData=&VO_CStringData;
|
||||
|
||||
(*VP_CStringData)("Data");
|
||||
|
||||
cout<<ZtCTypeData<CStringDataPtr>::GetObjRef(VP_CStringData)<<endl;
|
||||
|
||||
■ --
|
||||
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
typedef void (*ZfpNone)(void*); void ZfNone(void* AP_Void=0){};
|
||||
|
||||
template<typename TType> class ZtCTypeData
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType& AR_Type){return AR_Type ;}};
|
||||
template<typename TType> class ZtCTypeData<TType*>
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType* AP_Type){return *AP_Type;}};
|
||||
template<typename TType> class ZtCTypeData<TType&>
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType& AR_Type){return AR_Type ;}};
|
||||
template< /*########*/ > class ZtCTypeData<void* >
|
||||
{ public: typedef ZfpNone TypeData;
|
||||
static ZfpNone GetObjRef(void* AP_Void){return ZfNone ;}};
|
||||
|
||||
template<typename TType> class ZtCTD
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType& AR_Type){return AR_Type ;}
|
||||
static TType& GOR (TType& AR_Type){return AR_Type ;}};
|
||||
template<typename TType> class ZtCTD<TType*>
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType* AP_Type){return *AP_Type;}
|
||||
static TType& GOR (TType* AP_Type){return *AP_Type;}};
|
||||
template<typename TType> class ZtCTD<TType&>
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType& AR_Type){return AR_Type ;}
|
||||
static TType& GOR (TType& AR_Type){return AR_Type ;}};
|
||||
template< /*########*/ > class ZtCTD<void* >
|
||||
{ public: typedef ZfpNone TypeData;
|
||||
static ZfpNone GetObjRef(void* AP_Void){return ZfNone ;}
|
||||
static ZfpNone GOR (void* AP_Void){return ZfNone ;}};
|
||||
|
||||
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
■ template 인수가 Type11 까지 있음에 주의한다. 그러면 Type10 까지 전문화할 수 있는 것이다.
|
||||
@ -1163,7 +1233,6 @@ namespace ZNsMain
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
template< typename Type1 , typename Type2 =void,
|
||||
typename Type3=void, typename Type4 =void,
|
||||
typename Type5=void, typename Type6 =void,
|
||||
@ -2443,73 +2512,6 @@ namespace ZNsMain
|
||||
class ZCAllocClass : public ZCAllocator*/
|
||||
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
|
||||
■ 가끔 템플릿으로 클래스 설계를 하다보면 템플릿의 parameter 가
|
||||
포인터나 참조일 경우, 무엇의 포인터나 참조형인지 알고 싶을 때
|
||||
가 있다. 이런 경우에 ZtCTypeData<> 를 사용한다.
|
||||
|
||||
cf)
|
||||
|
||||
cout<<typeid(std::ZtCTypeData<ZTypIntI >::TypeData).name()<<endl;
|
||||
cout<<typeid(std::ZtCTypeData<ZTypIntI*>::TypeData).name()<<endl;
|
||||
cout<<typeid(std::ZtCTypeData<ZTypIntI&>::TypeData).name()<<endl;
|
||||
|
||||
-- 2010-01-15 00:11:00
|
||||
|
||||
■ ZtCTypeData<>::GetObjRef(~) 는 아래처럼 주로 포인터 자료형을
|
||||
(null 이 아닌 경우) 항상 참조형으로 다루고 싶을 때 사용한다.
|
||||
템플릿 Parameter 가 포인터형인데, 무엇의 포인터 형인지 알아
|
||||
내어, 참조형으로 만들어 다른 함수의 인수로 사용하거나, 해당
|
||||
멤버의 호출을 포인터 참조 표기 -> 말고 참조 표기(.)로 하면 편
|
||||
할 것이다.
|
||||
|
||||
typedef std::CStringBase_T<char> CStringData ;
|
||||
typedef CStringData* CStringDataPtr;
|
||||
|
||||
CStringData VO_CStringData("My");
|
||||
CStringDataPtr VP_CStringData=&VO_CStringData;
|
||||
|
||||
(*VP_CStringData)("Data");
|
||||
|
||||
cout<<ZtCTypeData<CStringDataPtr>::GetObjRef(VP_CStringData)<<endl;
|
||||
|
||||
■ --
|
||||
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
typedef void (*ZfpNone)(void*); void ZfNone(void* AP_Void=0){};
|
||||
|
||||
template<typename TType> class ZtCTypeData
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType& AR_Type){return AR_Type ;}};
|
||||
template<typename TType> class ZtCTypeData<TType*>
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType* AP_Type){return *AP_Type;}};
|
||||
template<typename TType> class ZtCTypeData<TType&>
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType& AR_Type){return AR_Type ;}};
|
||||
template< /*########*/ > class ZtCTypeData<void* >
|
||||
{ public: typedef ZfpNone TypeData;
|
||||
static ZfpNone GetObjRef(void* AP_Void){return ZfNone ;}};
|
||||
|
||||
template<typename TType> class ZtCTD
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType& AR_Type){return AR_Type ;}
|
||||
static TType& GOR (TType& AR_Type){return AR_Type ;}};
|
||||
template<typename TType> class ZtCTD<TType*>
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType* AP_Type){return *AP_Type;}
|
||||
static TType& GOR (TType* AP_Type){return *AP_Type;}};
|
||||
template<typename TType> class ZtCTD<TType&>
|
||||
{ public: typedef TType TypeData;
|
||||
static TType& GetObjRef(TType& AR_Type){return AR_Type ;}
|
||||
static TType& GOR (TType& AR_Type){return AR_Type ;}};
|
||||
template< /*########*/ > class ZtCTD<void* >
|
||||
{ public: typedef ZfpNone TypeData;
|
||||
static ZfpNone GetObjRef(void* AP_Void){return ZfNone ;}
|
||||
static ZfpNone GOR (void* AP_Void){return ZfNone ;}};
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Reference in New Issue
Block a user