diff --git a/ZCppMain/ZMainHead.H b/ZCppMain/ZMainHead.H index 5e31ed3..57d02de 100644 --- a/ZCppMain/ZMainHead.H +++ b/ZCppMain/ZMainHead.H @@ -1011,6 +1011,8 @@ namespace ZNsMain ZtCCheckRef(TypeData AR_TypeData) : mr_Data(AR_TypeData){} public : TypeData GetData(){return mr_Data;} + public : + static TypeData PassData(TypeData AO_Data){return AO_Data;} };/* template class ZtCCheckRef*/ @@ -1018,14 +1020,20 @@ namespace ZNsMain template class ZtCCheckRef< ZtCRef > { public : - typedef TType& TypeData; - typedef TType TypeRaw ; + typedef TType& TypeData; + typedef TType TypeRaw ; + typedef ZtCRef ZCRef ; private: TypeData mr_Data; public : ZtCCheckRef(TypeData AR_TypeData) : mr_Data(AR_TypeData){} public : TypeData GetData(){return mr_Data;} + public : + static TypeData PassData(TypeData AO_Data){return AO_Data;} + static TypeData PassData(ZCRef& AO_Data){return AO_Data.GetData();} + static TypeData PassData(const ZCRef& AO_Data) + {return (const_cast(AO_Data)).GetData();} };/* template class ZtCCheckRef< ZtCRef >*/ diff --git a/ZCppMain/ZtCArray.H b/ZCppMain/ZtCArray.H index 2b14c46..ef929a4 100644 --- a/ZCppMain/ZtCArray.H +++ b/ZCppMain/ZtCArray.H @@ -424,10 +424,13 @@ namespace ZNsMain __for0(TypeSize, i, ml_UseSize) { ZNsMain::ZtCTypeData:: - GetObjRef(AO_Functor)(*VP_TypeArr); ++VP_TypeArr; + GetObjRef(AO_Functor)( *VP_TypeArr ); - /* 위 코드로 인해서, AO_Functor 이 함수일 때 뿐이 아니라, - operator() 연산자를 가진 object 포인터일 때도 사용할 수 있게 되었다. */ + ++VP_TypeArr; + + /* ZtCTypeData 으로 인해서, AO_Functor 이 함수일 때 뿐이 아니라, + operator() 연산자를 가진 object 포인터일 때도 사용할 수 있게 되었다. + */ }/* __for0(TypeSize, i, ml_UseSize)*/ }/* @@ -455,12 +458,14 @@ namespace ZNsMain 형태를 사용하면 좋을 것 같다. -- 2014-06-16 23:11:00 + + ZCCheckRef::PassData() 으로 인해, 인수를 ZtCRef 클래스를 이용해 인수를 참조 + 로 넘길 수 있게 되었다. -- 2021-03-10 16:56 + /////////////////////////////////////////////////////////////////////////////*/ - typedef ZNsMain:: - ZtCTypeData ZCTypeHelp; - + ZtCCheckRef ZCCheckRef; Type* VP_TypeArr = mp_TypeArr; @@ -468,7 +473,7 @@ namespace ZNsMain { ZNsMain::ZtCTypeData::GetObjRef(AO_Functor) ( - *VP_TypeArr, AO_TypeHelp + *VP_TypeArr, ZCCheckRef::PassData(AO_TypeHelp) ); ++VP_TypeArr; /////////////////////////////////////// }/* @@ -498,15 +503,22 @@ namespace ZNsMain 형태를 사용하면 좋을 것 같다. -- 2014-06-16 23:11:00 + + ZCCheckRef::PassData() 으로 인해, 인수를 ZtCRef 클래스를 이용해 인수를 참조 + 로 넘길 수 있게 되었다. -- 2021-03-10 16:56 + /////////////////////////////////////////////////////////////////////////////*/ + typedef ZNsMain::ZtCCheckRef ZCCheckRef1; + typedef ZNsMain::ZtCCheckRef ZCCheckRef2; + Type* VP_TypeArr = mp_TypeArr; __for0(TypeSize, i, ml_UseSize) { ZNsMain::ZtCTypeData::GetObjRef(AO_Functor) ( - *VP_TypeArr, AO_TypeHelp1, AO_TypeHelp2 + *VP_TypeArr, ZCCheckRef1::PassData(AO_TypeHelp1), ZCCheckRef2(AO_TypeHelp2) ); ++VP_TypeArr; /////////////////////////////////////// }/* diff --git a/ZCppMain/ZtCObjList.H b/ZCppMain/ZtCObjList.H index 6f9a51a..f7bb65a 100644 --- a/ZCppMain/ZtCObjList.H +++ b/ZCppMain/ZtCObjList.H @@ -1526,19 +1526,25 @@ namespace ZNsMain /////////////////////////////////////////////////////////////////////////////*/ + typedef ZNsMain:: + ZtCCheckRef ZCCheckRef; + ZCLink* VP_LoopLink=mp_HeadLink; __for0(int, i, ml_Size) { ZtCTypeData::GetObjRef(AO_Functor) ( - VP_LoopLink->mo_Type, AO_TypeHelp + VP_LoopLink->mo_Type, ZCCheckRef::PassData(AO_TypeHelp) ); //////////////////////////////////////////// /* 위 코드로 인해서, AO_Functor 이 함수일 때 뿐이 아니라, operator() 연산자를 가진 object 포인터일 때도 사용할 수 있게 되었다. */ + /* ZCCheckRef::PassData() 으로 인해, 인수를 ZtCRef 클래스를 이용해 + 인수를 참조로 넘길 수 있게 되었다. -- 2021-03-10 16:56 */ + VP_LoopLink = VP_LoopLink->mp_NextLink ; }/* __for0(int, i, ml_Size)*/ @@ -1569,13 +1575,17 @@ namespace ZNsMain /////////////////////////////////////////////////////////////////////////////*/ + typedef ZNsMain::ZtCCheckRef ZCCheckRef1; + typedef ZNsMain::ZtCCheckRef ZCCheckRef2; + + ZCLink* VP_LoopLink=mp_HeadLink; __for0(int, i, ml_Size) { ZtCTypeData::GetObjRef(AO_Functor) ( - VP_LoopLink->mo_Type, AO_TypeHelp1, AO_TypeHelp2 + VP_LoopLink->mo_Type, ZCCheckRef1::PassData(AO_TypeHelp1), ZCCheckRef2::PassData(AO_TypeHelp2) ); //////////////////////////////////////////// diff --git a/ZCppMain/test.cpp b/ZCppMain/test.cpp index 968e471..1026cf1 100644 --- a/ZCppMain/test.cpp +++ b/ZCppMain/test.cpp @@ -182,6 +182,22 @@ int main(int ArgiCnt, char** AppArgu) (ZTypInt AiInt, ZCTuple* AP_CTuple)*/ _FFC_(ZCShowData4) + _FFS_(ZCShowData5) + (ZTypInt AiInt, int& AiIndex) + { + cout<<"# Elem5 : "<< AiInt << ", nth=" << AiIndex++ << endl; + }/* + (ZTypInt AiInt, int& AiIndex)*/ + _FFC_(ZCShowData5) + + _FFS_(ZCShowData6) + (ZTypInt AiInt, int& AiIndex) + { + cout<<"# Elem6 : "<< AiInt << ", nth=" << AiIndex++ << endl; + }/* + (ZTypInt AiInt, int& AiIndex)*/ + _FFC_(ZCShowData6) + ZNsHide::ZCFunctor1 VO_CFunctor1; /* ZCFunctor1 선언이 main() 바깥에 있어야 하는 문제를 해결할 수 없을까. */ @@ -191,7 +207,9 @@ int main(int ArgiCnt, char** AppArgu) VO_IntList.IterElement(ZCShowData3::Exec, &VO_CTuple); VO_IntList.IterElement(&VO_CFunctor1 ); VO_IntArr .IterElement(&VO_CFunctor1 ); VO_CTuple._1=1 ; - VO_IntArr .IterElement(ZCShowData4::Exec, &VO_CTuple); + VO_IntArr .IterElement(ZCShowData4::Exec, &VO_CTuple); VO_CTuple._1=1 ; + VO_IntArr .IterElement(ZCShowData5::Exec, ZNsMain::ZtCRef(VO_CTuple._1)); + VO_IntList.IterElement(ZCShowData5::Exec, ZNsMain::ZtCRef(VO_CTuple._1)); cout<< "# Press Any Key to exit" << endl; cin.get();