commit 2025-10-05 20:29 add ZCppMainTest/ZtCLinkList_000.cpp
This commit is contained in:
@ -4487,7 +4487,38 @@ namespace ZNsMain
|
||||
|
||||
public :
|
||||
};/*
|
||||
template<typename TType> class ZtCObjPtr */
|
||||
template
|
||||
<typename TType, typename TTypArgu=const TType&>
|
||||
class ZtCObjPtr
|
||||
*/
|
||||
|
||||
|
||||
template<typename TType> class ZtCObjOpt // C++ 17 에 추가된 optional 구현
|
||||
{
|
||||
public :
|
||||
typedef TType TypeData;
|
||||
protected:
|
||||
TypeData* mp_TypeData ;
|
||||
public :
|
||||
|
||||
ZtCObjOpt(TypeData& AR_CData) : mp_TypeData(&AR_CData ){}
|
||||
ZtCObjOpt(TypeData* AP_CData) : mp_TypeData( AP_CData ){}
|
||||
ZtCObjOpt(ZtCObjOpt& AR_Rhs ) : mp_TypeData(AR_Rhs.mp_TypeData){}
|
||||
|
||||
TypeData* operator->(){return mp_TypeData;}
|
||||
TypeData& operator* (){return *mp_TypeData;}
|
||||
operator TypeData& (){return *mp_TypeData;}
|
||||
|
||||
ZtCObjOpt& operator=(const ZtCObjOpt& rhs)
|
||||
{ mp_TypeData=rhs.mp_TypeData; return *this; }
|
||||
|
||||
bool has_value() const{return mp_TypeData!=0;}
|
||||
|
||||
TypeData& value() const{return *mp_TypeData ;}
|
||||
|
||||
public :
|
||||
};/*
|
||||
template<typename TType> class ZtCObjOpt */
|
||||
|
||||
|
||||
/*///////////////////////////////////////////////////////////
|
||||
|
File diff suppressed because it is too large
Load Diff
173
ZCppMainTest/ZtCLinkList_000.cpp
Normal file
173
ZCppMainTest/ZtCLinkList_000.cpp
Normal file
@ -0,0 +1,173 @@
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "ZCppMain/ZtCLinkList.H"
|
||||
|
||||
|
||||
using namespace std ;
|
||||
using namespace ZNsMain ;
|
||||
|
||||
|
||||
namespace ZNsMain
|
||||
{
|
||||
|
||||
namespace ZNsExam
|
||||
{
|
||||
|
||||
template<typename TDummy=void*> class ZtCExamCLinkList
|
||||
{
|
||||
public:
|
||||
typedef ZNsIFaceEx::ZtCLink<string, ZCEmpty> ZCLinkCStr ;
|
||||
typedef ZtCLinkList<ZCLinkCStr> ZCLinkStrList;
|
||||
typedef ZCLinkStrList::ZCObjOpt ZCStrLinkOpt ;
|
||||
public:
|
||||
|
||||
static void ShowNode0(ZCLinkCStr& AR_CLink, ZTypLong& ARRI_CallCnt)
|
||||
{
|
||||
++ARRI_CallCnt;
|
||||
|
||||
cout<<ARRI_CallCnt<<" * Node Curr : "<<(AR_CLink)()<<endl;
|
||||
}/*
|
||||
static void ShowNode0(ZCLinkCStr& AR_CLink, ZTypLong& ARRI_CallCnt)*/
|
||||
|
||||
static void ShowNode1(ZCLinkCStr& AR_CLink, ZTypLong& ARRI_CallCnt)
|
||||
{
|
||||
++ARRI_CallCnt;
|
||||
|
||||
cout<<ARRI_CallCnt<<" * Node Prev : "<<(AR_CLink-1)()<<endl;
|
||||
cout<<ARRI_CallCnt<<" * Node Curr : " <<(AR_CLink )()<<endl;
|
||||
cout<<ARRI_CallCnt<<" * Node Next : "<<(AR_CLink+1)()<<endl;
|
||||
}/*
|
||||
static void ShowNode1(ZCLinkCStr& AR_CLink, ZTypLong& ARRI_CallCnt)*/
|
||||
|
||||
|
||||
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)
|
||||
{
|
||||
ZTypLong VI_CallCnt = 0 ;
|
||||
ZCLinkStrList VO_ZCLinkStrLis;
|
||||
ZCStrLinkOpt VO_StrLinkOpt = VO_ZCLinkStrLis.GetObjOpt(1);
|
||||
|
||||
cout<<"# VO_StrLinkOpt.has_value()="<<VO_StrLinkOpt.has_value()<<endl;
|
||||
|
||||
VO_ZCLinkStrLis.AddTail()()=string("123");
|
||||
VO_ZCLinkStrLis.AddTail()()=string("ABC");
|
||||
VO_ZCLinkStrLis.AddTail()()=string("xyz");
|
||||
|
||||
VO_StrLinkOpt = VO_ZCLinkStrLis.GetObjOpt(1);
|
||||
|
||||
cout<<"# VO_StrLinkOpt.GetObjOpt(1) : has_value()="<<VO_StrLinkOpt.has_value()<<endl;
|
||||
|
||||
if(VO_StrLinkOpt.has_value())
|
||||
cout<<"# value by VO_StrLinkOpt : "<<VO_StrLinkOpt.value()<<endl;
|
||||
|
||||
VO_StrLinkOpt = VO_ZCLinkStrLis.GetTailOpt();
|
||||
|
||||
cout<<"# VO_StrLinkOpt.GetTailOpt() : has_value()="<<VO_StrLinkOpt.has_value()<<endl;
|
||||
|
||||
if(VO_StrLinkOpt.has_value())
|
||||
cout<<"# value by VO_StrLinkOpt : "<<VO_StrLinkOpt.value()<<endl;
|
||||
|
||||
|
||||
VO_ZCLinkStrLis.IterElement(&ShowNode0, ZftMCP(VI_CallCnt=0));
|
||||
cout<<"***********************************************"<<endl;
|
||||
VO_ZCLinkStrLis.IterElement(&ShowNode1, ZftMCP(VI_CallCnt=0));
|
||||
|
||||
|
||||
return 0;
|
||||
}/*
|
||||
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)*/
|
||||
|
||||
|
||||
public:
|
||||
};/*
|
||||
template<typename TDummy=void*> class ZtCExamCLinkList*/
|
||||
|
||||
}/*
|
||||
namespace ZNsExam*/
|
||||
|
||||
}/*
|
||||
namespace ZNsMain*/
|
||||
|
||||
|
||||
int main(int AI_ArgCnt, char* APP_ArgVal[])
|
||||
{
|
||||
return ZNsMain::ZNsExam::
|
||||
|
||||
ZtCExamCLinkList<>::Main(AI_ArgCnt, APP_ArgVal);
|
||||
}/*
|
||||
int main(int AI_ArgCnt, char* APP_ArgVal[])*/
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
<EFBFBD><EFBFBD> cygwin <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// g++ -mno-cygwin -o ZtCLinkList_000.exe ZtCLinkList_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300
|
||||
// g++ -mno-cygwin -o ZtCLinkList_000_D.exe ZtCLinkList_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300 -D_DEBUG
|
||||
|
||||
<EFBFBD><EFBFBD> mingw <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
g++.exe -o ZtCLinkList_000_mw.exe ZtCLinkList_000.cpp -I../ -lWs2_32
|
||||
g++.exe -o ZtCLinkList_000_mw_D.exe ZtCLinkList_000.cpp -I../ -lWs2_32 -D_DEBUG
|
||||
|
||||
./ZtCLinkList_000_mw.exe
|
||||
./ZtCLinkList_000_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.
|
||||
|
||||
|
||||
<EFBFBD><EFBFBD> Linux <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
g++ -std=c++98 -o ZtCLinkList_000.exe ZtCLinkList_000.cpp -I../
|
||||
g++ -std=c++98 -o ZtCLinkList_000_D.exe ZtCLinkList_000.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.
|
||||
|
||||
<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
./ZtCLinkList_000.exe
|
||||
./ZtCLinkList_000_D.exe
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
Reference in New Issue
Block a user