commit 2025-10-23 20:02 add ZtCTypeByNo in ZCppMain/ZMainHead.H

This commit is contained in:
2025-10-23 20:03:01 +09:00
parent ff02649ca3
commit 2ad1e47820
2 changed files with 108 additions and 1 deletions

View File

@ -3645,7 +3645,8 @@ namespace ZNsMain
VO_ZCObjtChain.SetDataRecur<1>(9999);
와, 멤버 변수 변경이 이렇게 깔끔하게 될 수 있다니...
C++ 진짜 멋지다!
C++ 진짜 멋지다! template operator=() 가 있어서 가능했다.
-- 2025-10-22 19:41
@ -3993,6 +3994,85 @@ namespace ZNsMain
/*###################################################################
■ template<typename TDataChain, int TInIndexNo> class ZtCTypeByNo
ZtCTypeChain, ZtCObjtChain 등을 template 인자로 받아, 어떤 index
숫자로부터 type 을 알 수 있게 한다. index 는 0 부터 시작한다.
이러면 ZtCObjtChain 의 활용성이 점점 높어지는 것이다. -- 2025-10-23 19:47
■ 예제 -- 2025-10-23 19:55
typedef ZtCObjtChain
<
char , ZtCObjtChain<
string, ZtCObjtChain<
double, ZtCObjtChain<
int ,
ZCEmpty > > >
> ZCObjtChain; ZCObjtChain VO_ZCObjtChain;
VO_ZCObjtChain.GetChainNext().GetData()="abc";
*VO_ZCObjtChain ='Z' ;
*VO_ZCObjtChain() ="New Str";
*VO_ZCObjtChain()() =0.8 ;
*VO_ZCObjtChain()()() =1234 ;
VO_ZCObjtChain.IterHead(VO_ZCTypeView);
typedef ZtCTypeByNo<ZCObjtChain, 0>::TypeData TypeDataHere0 ;
typedef ZtCTypeByNo<ZCObjtChain, 1>::TypeData TypeDataHere1 ;
typedef ZtCTypeByNo<ZCObjtChain, 2>::TypeData TypeDataHere2 ;
typedef ZtCTypeByNo<ZCObjtChain, 3>::TypeData TypeDataHere3 ;
typedef ZtCTypeByNo<ZCObjtChain, 4>::TypeData TypeDataHere4 ;
typedef ZtCTypeByNo<ZCObjtChain, 0>::TypeChain TypeChainHere0;
typedef ZtCTypeByNo<ZCObjtChain, 1>::TypeChain TypeChainHere1;
typedef ZtCTypeByNo<ZCObjtChain, 2>::TypeChain TypeChainHere2;
typedef ZtCTypeByNo<ZCObjtChain, 3>::TypeChain TypeChainHere3;
typedef ZtCTypeByNo<ZCObjtChain, 4>::TypeChain TypeChainHere4;
cout<<"# TypeDataHere0 ="<<typeid(TypeDataHere0 ).name()<<endl;
cout<<"# TypeDataHere1 ="<<typeid(TypeDataHere1 ).name()<<endl;
cout<<"# TypeDataHere2 ="<<typeid(TypeDataHere2 ).name()<<endl;
cout<<"# TypeDataHere3 ="<<typeid(TypeDataHere3 ).name()<<endl;
cout<<"# TypeDataHere4 ="<<typeid(TypeDataHere4 ).name()<<endl;
cout<<"# TypeChainHere0="<<typeid(TypeChainHere0).name()<<endl;
cout<<"# TypeChainHere1="<<typeid(TypeChainHere1).name()<<endl;
cout<<"# TypeChainHere2="<<typeid(TypeChainHere2).name()<<endl;
cout<<"# TypeChainHere3="<<typeid(TypeChainHere3).name()<<endl;
cout<<"# TypeChainHere4="<<typeid(TypeChainHere4).name()<<endl;
###################################################################*/
template<typename TDataChain, int TInIndexNo> class ZtCTypeByNo
{
public:
typedef ZtCTypeByNo /*++++++++++++++++++++++++++++++++*/
<
typename TDataChain::TypeChainNext, TInIndexNo-1
>
ZCTypeByNoNext ; /*+++++++++++++++++++++++++++++++++++*/
typedef typename ZCTypeByNoNext::TypeData TypeData ;
typedef typename ZCTypeByNoNext::TypeChain TypeChain;
public:
};/*
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
template<typename TDataChain> class ZtCTypeByNo<TDataChain, 0>
{
public:
typedef /*----*/ TDataChain /*----*/ TypeChain;
typedef typename TDataChain::TypeData TypeData ;
public:
};/*
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
/*///////////////////////////////////////////////////////////////////
■ class ZtCMiniValChain<>

View File

@ -220,6 +220,33 @@ namespace ZNsMain
cout<<"************************************"<<endl;
typedef ZtCTypeByNo<ZCObjtChain, 0>::TypeData TypeDataHere0 ;
typedef ZtCTypeByNo<ZCObjtChain, 1>::TypeData TypeDataHere1 ;
typedef ZtCTypeByNo<ZCObjtChain, 2>::TypeData TypeDataHere2 ;
typedef ZtCTypeByNo<ZCObjtChain, 3>::TypeData TypeDataHere3 ;
typedef ZtCTypeByNo<ZCObjtChain, 4>::TypeData TypeDataHere4 ;
typedef ZtCTypeByNo<ZCObjtChain, 0>::TypeChain TypeChainHere0;
typedef ZtCTypeByNo<ZCObjtChain, 1>::TypeChain TypeChainHere1;
typedef ZtCTypeByNo<ZCObjtChain, 2>::TypeChain TypeChainHere2;
typedef ZtCTypeByNo<ZCObjtChain, 3>::TypeChain TypeChainHere3;
typedef ZtCTypeByNo<ZCObjtChain, 4>::TypeChain TypeChainHere4;
cout<<"# TypeDataHere0 ="<<typeid(TypeDataHere0 ).name()<<endl;
cout<<"# TypeDataHere1 ="<<typeid(TypeDataHere1 ).name()<<endl;
cout<<"# TypeDataHere2 ="<<typeid(TypeDataHere2 ).name()<<endl;
cout<<"# TypeDataHere3 ="<<typeid(TypeDataHere3 ).name()<<endl;
cout<<"# TypeDataHere4 ="<<typeid(TypeDataHere4 ).name()<<endl;
cout<<"************************************"<<endl;
cout<<"# TypeChainHere0="<<typeid(TypeChainHere0).name()<<endl;
cout<<"# TypeChainHere1="<<typeid(TypeChainHere1).name()<<endl;
cout<<"# TypeChainHere2="<<typeid(TypeChainHere2).name()<<endl;
cout<<"# TypeChainHere3="<<typeid(TypeChainHere3).name()<<endl;
cout<<"# TypeChainHere4="<<typeid(TypeChainHere4).name()<<endl;
cout<<"************************************"<<endl;
typedef ZtCDataRing<std::string> ZCDataRing;
ZCDataRing VO_CDataRing = string("123");