付費(fèi)下載
下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 福建省考荒島求生題目及答案
- 學(xué)校學(xué)籍管理制度
- 煙草初面面試題目及答案
- 養(yǎng)老院入住退住規(guī)定制度
- 養(yǎng)老院老人入住審批制度
- 養(yǎng)老院老人健康飲食服務(wù)質(zhì)量管理制度
- 養(yǎng)老院老年人權(quán)益保障制度
- 中考自擬考試題目及答案
- 長(zhǎng)護(hù)險(xiǎn)護(hù)理人員整改制度
- 銀行的控制制度
- 2026年自動(dòng)駕駛政策法規(guī)報(bào)告
- 醫(yī)療數(shù)據(jù)倫理治理的國(guó)際經(jīng)驗(yàn)借鑒
- 浙江省《檢驗(yàn)檢測(cè)機(jī)構(gòu)技術(shù)負(fù)責(zé)人授權(quán)簽字人》考試題及答案
- 子午流注在護(hù)理中的應(yīng)用
- 新媒體評(píng)論管理制度規(guī)范(3篇)
- 劑量反應(yīng)曲線的統(tǒng)計(jì)分析方法-洞察及研究
- 2025年高職室內(nèi)藝術(shù)設(shè)計(jì)(室內(nèi)設(shè)計(jì))試題及答案
- 2025課堂懲罰 主題班會(huì):馬達(dá)加斯加企鵝課堂懲罰 課件
- 2025年初會(huì)職稱(chēng)《經(jīng)濟(jì)法基礎(chǔ)》真題匯編
- Zippo2024美版年冊(cè)完整版
- 滬教版(2024)七年級(jí)英語(yǔ)下冊(cè)單詞默寫(xiě)單背誦版
評(píng)論
0/150
提交評(píng)論