Files
RepoMain/ZCppMainTest/c++_test_006.cpp

273 lines
9.3 KiB
C++

#include <iostream>
#include "ZCppMain/ZMainHead.H"
using namespace std ;
using namespace ZNsMain;
namespace ZNsMain
{
namespace ZNsExam
{
template<typename TType> class ZtCTest
{
public:
template<TType TTypeVar> class ZCTypeVar
{
public:
TType MO_TypeVar;
public:
ZCTypeVar()
{
MO_TypeVar=TTypeVar;
}
public:
};/*
template<TType TTypeVar> class ZCTypeVar*/
public:
};/*
template<typename TType> class ZtCTest*/
template<typename TType, TType TTypeVar> class ZtCTest2
{
public:
TType MO_TypeVar;
public:
ZtCTest2()
{
MO_TypeVar=TTypeVar;
}
public:
};/*
template<typename TType, TType TTypeVar> class ZtCTest2*/
class ZCTypeView
{
public:
ZCTypeView()
{
cout<<"# ZCTypeView()"<<endl;
}
ZCTypeView(const ZCTypeView& rhs)
{
cout<<"ZCTypeView(const ZCTypeView& rhs)"<<endl;
}
template<typename TTypChain> void OnMeetType()
{
cout<<TTypChain::ZETypeNo<<" : "<<typeid(typename TTypChain::TypeData).name()<<endl;
}
template<typename TTypChain, typename TTypHelp> void OnMeetType(TTypHelp& AR_CallNo)
{
cout<<"* Call No="<<++AR_CallNo<<" : "<<TTypChain::ZETypeNo<<" : "<<typeid(typename TTypChain::TypeData).name()<<endl;
}
template<typename TTypChain> void OnMeetTypeVal()
{
cout<<"* Val="<<TTypChain::GetData()<<", ETypeNo="<<TTypChain::ZETypeNo<<" : "<<typeid(typename TTypChain::TypeData).name()<<endl;
}
template<typename TTypChain, typename TTypHelp> void OnMeetTypeVal(TTypHelp& AR_CallNo)
{
cout<<"* Call No="<<++AR_CallNo<<" : Val="<<TTypChain::GetData()<<", ETypeNo="<<TTypChain::ZETypeNo<<" : "<<typeid(typename TTypChain::TypeData).name()<<endl;
}
template<typename TObjtChain> void OnMeetData(TObjtChain& AR_NowChain)
{
cout<<"* Type No="<<AR_NowChain.GetNo()<<" : "<<AR_NowChain.GetData()<<endl;
}
template<typename TObjtChain> void OnMeetData(TObjtChain& AR_NowChain, int& ARI_CallNo)
{
cout<<"# CallNo="<<++ARI_CallNo<<" : Type No="<<AR_NowChain.GetNo()<<" : "<<AR_NowChain.GetData()<<endl;
}
};/*
class ZCTypeView*/
template<typename TType> class ZCShowType
{
public:
ZCShowType()
{
cout<<"# TType typename="<<typeid(TType).name()<<endl;
}
};
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)
{
ZCShowType<int> myShowType1;
ZCShowType<double> myShowType2;
ZCShowType<ZTypLLong> myShowType3;
//ZCShowType<"abc"> myShowType4; //error
const int CI_Var1=10;
const int CI_Var2=20;
const int CI_Var3=30;
ZtCTest<int>::ZCTypeVar<CI_Var1> myintvar1 ;
ZtCTest2<int, CI_Var2> myintvar2 ;
ZtCTest2<ZTypLLong, CI_Var3> myintvar3 ;
cout<<myintvar1.MO_TypeVar<<endl;
cout<<myintvar2.MO_TypeVar<<endl;
cout<<myintvar3.MO_TypeVar<<endl;
typedef ZtCMiniValChain
<
char , 'a' , ZtCMiniValChain<
char , 'b' , ZtCMiniValChain<
char , 'c' , ZtCMiniValChain<
//double, 10.2 , ZtCMiniValChain< // error in linux
//string, string("123") , ZtCMiniValChain< // error
long , 10 , ZtCMiniValChain<
int , 19 ,
ZCEmpty > > > >
> ZCMiniValChain; ZCTypeView VO_ZCTypeView; int VI_CallNo = 0;
cout<<"# ZCMiniValChain.size()="<<ZCMiniValChain::size()<<endl;
ZCMiniValChain::ZtCIterChain<ZCTypeView&>::IterHead(VO_ZCTypeView);
cout<<"************************************"<<endl;
ZCMiniValChain::ZtCIterChain<ZCTypeView&>::IterTail(VO_ZCTypeView);
cout<<"************************************"<<endl;
ZCMiniValChain::ZtCIterChain<ZCTypeView&>::IterHead(VO_ZCTypeView, ZftMCP(VI_CallNo = 0));
cout<<"************************************"<<endl;
ZCMiniValChain::ZtCIterChain<ZCTypeView&>::IterTail(VO_ZCTypeView, ZftMCP(VI_CallNo = 0));
cout<<"************************************"<<endl;
typedef ZtCTypeChain
<
double , ZtCTypeChain<
int , ZtCTypeChain<
wchar_t, ZtCTypeChain<
char ,
ZCEmpty > > >
> ZCTypeChain;
cout<<"tmpl chain size = "<<ZCTypeChain::Size()<<endl;
ZftIterTypeChainTail<ZCTypeChain, ZCTypeView&>(VO_ZCTypeView);
cout<<"@** call start : ZCTypeView(rhs) **********@"<<endl;
ZCTypeChain::ZtCIterChain<ZCTypeView>::IterHead(VO_ZCTypeView);
cout<<"@******************************************@"<<endl;
ZCTypeChain::ZtCIterChain<ZCTypeView>::IterTail(VO_ZCTypeView);
cout<<"@*** call close : ZCTypeView(rhs) *********@"<<endl;
ZftIterTypeChainHead<ZCTypeChain, ZCTypeView&, int&>
( VO_ZCTypeView, (VI_CallNo = 0) );
cout<<"************************************"<<endl;
ZftIterTypeChainTail<ZCTypeChain, ZCTypeView&, int&>
( VO_ZCTypeView, (VI_CallNo = 0) );
cout<<"************************************"<<endl;
ZCTypeChain::ZtCIterChain<ZCTypeView&>::
IterHead(VO_ZCTypeView, ZftMCP(VI_CallNo=0));
cout<<"************************************"<<endl;
ZCTypeChain::ZtCIterChain<ZCTypeView&>::
IterTail(VO_ZCTypeView, ZftMCP(VI_CallNo=0));
return 0;
}/*
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)*/
}/*
namespace ZNsExam*/
}/*
namespace ZNsMain*/
int main(int AI_ArgCnt, char* APP_ArgVal[])
{
return ZNsMain::ZNsExam::Main(AI_ArgCnt, APP_ArgVal);
}/*
int main(int AI_ArgCnt, char* APP_ArgVal[])*/
/*////////////////////////////////////////////////////////////////////////////////////////
■ cygwin 컴파일
// g++ -mno-cygwin -o c++_test_006.exe c++_test_006.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300
// g++ -mno-cygwin -o c++_test_006_D.exe c++_test_006.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300 -D_DEBUG
■ mingw 컴파일
g++.exe -o c++_test_006_mw.exe c++_test_006.cpp -I../
g++.exe -o c++_test_006_mw_D.exe c++_test_006.cpp -I../ -D_DEBUG
./c++_test_006_mw.exe
./c++_test_006_mw_D.exe
Administrator@q381-2673 UCRT64 /e/my_CPP/ZCpp/ZCppMainTest
# date
Sun Aug 24 10:47:09 KST 2025
Administrator@q381-2673 UCRT64 /e/my_CPP/ZCpp/ZCppMainTest
# g++ --version
g++.exe (Rev2, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
■ Linux 컴파일
g++ -std=c++98 -o c++_test_006.exe c++_test_006.cpp -I../
g++ -std=c++98 -o c++_test_006_D.exe c++_test_006.cpp -I../ -D_DEBUG
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ date
Sun Aug 24 00:05:51 DST 2025
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[sauron@q381-2657 ZCppMainTest]$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[sauron@q381-2657 ZCppMainTest]$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
■ 실행
./c++_test_006.exe
./c++_test_006_D.exe
////////////////////////////////////////////////////////////////////////////////////////*/