



下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
PAGE
1
TransformI tor
Author: DavidAbrahams,JeremySiek,ThomasWitt
Contact: dave@bo ,
jsiek@,
witt@ive.uni-hannover.de
Organization: BoostConsulting, naUniversityOpenSystemsLab,UniversityofHanoverInstituteforTransportRailwayOperationandConstruction
Date: 2004-11-01
Copyright: CopyrightDavidAbrahams,JeremySiek,andThomasWitt2003.
:Thetransformi toradaptsani torbymodifyingtheoperator*toapplyafunctionobjecttotheresultofdereferencingthei torandreturningtheresult.
TableofContents
transform_i torsynopsistransform_i torrequirementstransform_i tormodelstransform_i toroperationsExample
transform_i torsynopsis
temte<classUnaryFunction,
classI tor,
classReference=use_default,classValue=use_default>
classtransform_i tor
{
public:
typedef/*seebelow*/value_type;typedef/*seebelow*/reference;typedef/*seebelow*/pointer;
typedefi tor_traits<I tor>::difference_typedifference_type;typedef/*seebelow*/i tor_category;
transform_i tor();
transform_i tor(I torconst&x,UnaryFunctionf);
temte<classF2,classI2,classR2,classV2>transform_i tor(
transform_i tor<F2,I2,R2,V2>const&t
PAGE
2
,typenameenable_if_convertible<I2,I tor>::type*=0 //ex-positiononly
,typenameenable_if_convertible<F2,UnaryFunction>::type*=0//ex-positiononly
);
UnaryFunctionfunctor()const;I torconst&base()const;referenceoperator*()const;
transform_i tor&operator++();transform_i tor&operator--();
private:
I torm_i tor;//expositiononlyUnaryFunctionm_f; //expositiononly
};
IfReferenceisuse_defaultthenthereferencememberoftransform_i torisresult_of<UnaryFunction(iteOtherwise,referenceisReference.
IfValueisuse_defaultthenthevalue_typememberisremove_cv<remove_reference<reference>
>::type.Otherwise,value_typeisValue.
IfItormodelsReadableLvalueItorandifItormodelsRandomAccessTraver-salItor,thenitor_categoryisconvertibletorandom_access_itor_tag.Otherwise,ifItormodelsBidirectionalTraversalItor,thenitor_categoryisconvertibletobidi-rectional_itor_tag.Otherwiseitor_categoryisconvertibletoforward_itor_tag.IfItordoesnotmodelReadableLvalueItorthenitor_categoryisconvertibletoin-put_itor_tag.
transform_itorrequirements
ThetypeUnaryFunctionmustbeAssignable,CopyConstructible,andtheexpressionf(*i)mustbevalidwherefisanobjectoftypeUnaryFunction,iisanobjectoftypeItor,andwherethetypeoff(*i)mustberesult_of<UnaryFunction(itor_traits<Itor>::reference)>::type.
TheargumentItorshallmodelReadableItor.
transform_itormodels
Theresultingtransform_itormodelsthemostrefinedofthefollowingthatisalsomodeledby
I tor.
WritableLvalueI toriftransform_i tor::referenceisanon-constreference.
ReadableLvalueI toriftransform_i tor::referenceisaconstreference.
ReadableI torotherwise.
Thetransform_itormodelsthemostrefinedstandardtraversalconceptthatismodeledbytheItorargument.
Iftransform_itorisamodelofReadableLvalueItorthenitmodelsthefollowingoriginalitorconceptsdependingonwhattheItorargumentmodels.
IfI tormodels thentransform_i tormodels
SinglePassI tor InputI tor
ForwardTraversalI tor ForwardI tor
BidirectionalTraversalI tor BidirectionalI torRandomAccessTraversalI tor RandomAccessI tor
PAGE
3
Iftransform_i tormodelsWritableLvalueI torthenitisamutablei tor(asdefinedintheoldi torrequirements).
transform_i tor<F1,X,R1,V1>isinteroperablewithtransform_i tor<F2,Y,R2,V2>
ifandonlyifXisinteroperablewithY.
transform_i toroperations
Inadditiontotheoperationsrequiredbytheconceptsmodeledbytransform_i tor,trans-form_i torprovidesthefollowingoperations.
transform_i tor();
Returns:Aninstanceoftransform_i torwithm_fandm_i tordefaultcon-structed.
transform_i tor(I torconst&x,UnaryFunctionf);
Returns:Aninstanceoftransform_i torwithm_finitializedtofandm_i tor
initializedtox.
temte<classF2,classI2,classR2,classV2>transform_i tor(
transform_i tor<F2,I2,R2,V2>const&t
,typenameenable_if_convertible<I2,I tor>::type*=0 //expo-sitiononly
,typenameenable_if_convertible<F2,UnaryFunction>::type*=0//expo-sitiononly
);
Returns:Aninstanceoftransform_i torwithm_finitializedtot.functor()and
m_i torinitializedtot.base().
Requires:OtherI torisimplicitlyconvertibletoI tor.UnaryFunctionfunctor()const;
Returns:m_f
I torconst&base()const;
Returns:m_i torreferenceoperator*()const;
Returns:m_f(*m_i tor)transform_i tor&operator++();
Effects:++m_i tor
Returns:*this
transform_i tor&operator--();
Effects:--m_i tor
Returns:*this
temte<classUnaryFunction,classI tor>transform_i tor<UnaryFunction,I tor>make_transform_i tor(I torit,UnaryFunctionfun);
Returns:Aninstanceoftransform_i tor<UnaryFunction,I tor>withm_fini-tializedtofandm_i torinitializedtox.
temte<classUnaryFunction,classI tor>transform_i tor<UnaryFunction,I tor>make_transform_i tor(I torit);
Returns:Aninstanceoftransform_i tor<UnaryFunction,I tor>withm_fde-faultconstructedandm_i torinitializedtox.
Example
Thisisasimpleexampleofusingthetransformitorsclasstogenerateitorsthatmultiply(oraddto)thevaluereturnedbydereferencingtheitor.Itwouldbecoolertouselambdalibraryinthiample.
intx[]={1,2,3,4,5,6,7,8};
constintN=sizeof(x)/sizeof(int);
typedefboost::binder1st<std::multiplies<int>>Function;
typedefboost::transform_i tor<Function,int*>doubling_i tor;
doubling_i tori(x,boost::bind1st(std::multiplies<i
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025ktv音響燈光設備租賃與技術支持合同
- 出境旅游AI應用行業跨境出海項目商業計劃書
- 高速飲料灌裝線行業深度調研及發展項目商業計劃書
- 鄉村民宿設計大賽行業跨境出海項目商業計劃書
- 產業園區能源基礎設施的綠色化改造與節能減排報告
- 耐候性建筑隔熱膜行業深度調研及發展項目商業計劃書
- 醫療大數據隱私保護技術在2025年醫療數據安全與隱私保護中的應用案例報告
- 第八屆中學生古詩文閱讀大賽初賽試卷
- 影視編導專業畢業實習心得
- 醫藥行業售后服務承諾書范文
- 枯死松樹清理服務投標方案(完整技術標)
- 2024年四川省水電投資經營集團普格電力有限公司招聘筆試參考題庫含答案解析
- MOOC 針灸學-經絡養生與康復-暨南大學 中國大學慕課答案
- 高考語文常考380個成語
- 初中生心理健康教育在語文學科中的滲透的開題報告
- 2024年中考語文記敘文閱讀理解題型-詞語表達效果題(含解析)
- 國家勵志獎學金宣講
- 四年級下冊小數加減豎式計算400題及答案
- 酒店康樂項目營銷策劃
- 機床推廣策劃方案
- 《雅克·德里達》課件
評論
0/150
提交評論