commit 2025-09-07 12:20 edit a bit ZCppMain/ZMainHead.H

This commit is contained in:
2025-09-07 12:21:07 +09:00
parent 1bb328a4bb
commit 2e5c90155f
2 changed files with 76 additions and 11 deletions

View File

@ -1237,6 +1237,70 @@ namespace ZNsMain
int VariMy=0; ZtStTuple<int&> myt1 = ZftMakeTuple(ZftMCP(VariMy));
■ std::tuple<> 용례-1 -- 2025-09-07 12:08
#include <tuple>
#include <iostream>
int main() {
int nownum=42;
// Creating a tuple
std::tuple<int&, std::string, double> myTuple(nownum, "Hello", 3.14);
// Accessing elements
std::cout << std::get<0>(myTuple) << "\n"; // Outputs: 42
std::cout << std::get<1>(myTuple) << "\n"; // Outputs: Hello
std::cout << std::get<2>(myTuple) << "\n"; // Outputs: 3.14
// Modifying elements
std::get<1>(myTuple) = "World";
std::cout << std::get<1>(myTuple) << "\n"; // Outputs: World
return 0;
}
■ std::tuple<> 용례-2 -- 2025-09-07 12:09
#include <tuple>
#include <iostream>
std::tuple<int, double, std::string> getValues() {
return {42, 3.14, "Hello"};
}
int main() {
auto [x, y, z] = getValues(); // Structured binding (C++17)
std::cout << x << ", " << y << ", " << z << "\n"; // Outputs: 42, 3.14, Hello
return 0;
}
■ std::tuple<> 용례-3 -- 2025-09-07 12:11
#include <iostream>
#include <tuple>
#include <string>
int main() {
// 기본 생성 및 값 할당
std::tuple<std::string, int, double> tpl;
std::get<0>(tpl) = "Example";
std::get<1>(tpl) = 42 ;
std::get<2>(tpl) = 3.14 ;
// make_tuple을 사용한 초기화
auto tpl2 = std::make_tuple("Hello", 100, 1.23);
// 구조적 바인딩 (C++17 이상)
auto [str, num, val] = tpl2;
std::cout << "Tuple 1: " << std::get<0>(tpl) << ", " << std::get<1>(tpl) << ", " << std::get<2>(tpl) << '\n';
std::cout << "Tuple 2: " << str << ", " << num << ", " << val << '\n';
return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////*/
template< typename Type1 =void, typename Type2 =void,

View File

@ -23,8 +23,9 @@ namespace ZNsMain
ZCStringStd VO_BuffCStr("myBuff") ;
ZTypInt VI_NowCnt = 0 ;
cout<<"# __cplusplus : "<<__cplusplus<<endl;
#ifdef __CPP_1998__
#if defined(__CPLUSPLUS_VER__) && __CPLUSPLUS_VER__<=199800
cout<<"# Use C++ 98 Spec"<<endl;
@ -48,10 +49,10 @@ namespace ZNsMain
myt9 = ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr));
ZtStTuple<int, int, char, ZCStringStd&, bool, const char*, double, float, ZCStringStd&, int&>
myt10= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt));
ZtStTuple<int, int, char, ZCStringStd&, bool, const char*, double, float, ZCStringStd&, int&, int>
myt11= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt), 20250906);
ZtStTuple<int, int, char, ZCStringStd&, bool, const char*, double, float, ZCStringStd&, int&, int, wchar_t>
myt12= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt), 20250906, wchar_t(0));
ZtStTuple<int, int, char, ZCStringStd&, bool, const char*, double, float, ZCStringStd&, int&, long>
myt11= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt), (long)20250906);
ZtStTuple<int, int, char, ZCStringStd&, bool, const char*, double, float, ZCStringStd&, int&, long, wchar_t>
myt12= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt), (long)20250906, wchar_t(0));
#else
cout<<"# Use auto keyword for ZtStTuple<> variable"<<endl;
@ -65,8 +66,8 @@ namespace ZNsMain
auto myt8 = ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43));
auto myt9 = ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr));
auto myt10= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt));
auto myt11= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt), 20250906);
auto myt12= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt), 20250906, wchar_t(0));
auto myt11= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt), (long)20250906);
auto myt12= ZftMakeTuple(1, 34, 'C', ZftMCP(VO_BuffCStr), true, "AB", double(0.34), float(24.43), ZftMCP(VO_BuffCStr), ZftMCP(VI_NowCnt), (long)20250906, wchar_t(0));
#endif
myt10._10 = 1200;
@ -135,8 +136,8 @@ int main(int AI_ArgCnt, char* APP_ArgVal[])*/
■ mingw 컴파일
g++.exe -std=c++98 -o ZftMakeTuple_000_mw_98.exe ZftMakeTuple_000.cpp -I../ -D__CPP_1998__
g++.exe -std=c++98 -o ZftMakeTuple_000_mw_98_D.exe ZftMakeTuple_000.cpp -I../ -D__CPP_1998__ -D_DEBUG
g++.exe -std=c++98 -o ZftMakeTuple_000_mw_98.exe ZftMakeTuple_000.cpp -I../ -D__CPLUSPLUS_VER__=199800
g++.exe -std=c++98 -o ZftMakeTuple_000_mw_98_D.exe ZftMakeTuple_000.cpp -I../ -D__CPLUSPLUS_VER__=199800 -D_DEBUG
g++.exe -o ZftMakeTuple_000_mw.exe ZftMakeTuple_000.cpp -I../
g++.exe -o ZftMakeTuple_000_mw_D.exe ZftMakeTuple_000.cpp -I../ -D_DEBUG
@ -168,8 +169,8 @@ int main(int AI_ArgCnt, char* APP_ArgVal[])*/
g++ -o ZftMakeTuple_000.exe ZftMakeTuple_000.cpp -I../
g++ -o ZftMakeTuple_000_D.exe ZftMakeTuple_000.cpp -I../ -D_DEBUG
g++ -o ZftMakeTuple_000_98.exe ZftMakeTuple_000.cpp -I../ -D__CPP_1998__
g++ -o ZftMakeTuple_000_98_D.exe ZftMakeTuple_000.cpp -I../ -D__CPP_1998__ -D_DEBUG
g++ -o ZftMakeTuple_000_98.exe ZftMakeTuple_000.cpp -I../ -D__CPLUSPLUS_VER__=199800
g++ -o ZftMakeTuple_000_98_D.exe ZftMakeTuple_000.cpp -I../ -D__CPLUSPLUS_VER__=199800 -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