我正在创建自己的streambuf子类并使用C++03规范(ISO/IEC14882:2003)作为引用。在第27.5.2.4.2节[lib.streambuf.virt.buffer]中,basic_streambuf::seekoff()和basic_streambuf::seekpos()说:Defaultbehavior:Returnspos_type(off_type(-1)).现在,我认为off_type应该是有符号整数类型而pos_type应该是无符号整数类型,所以在我看来这个表达式必须等同于pos_type(-1)。但假设我弄错了,这些类型可能是有符号和无符号的一些其他
我有以下实现基于例如thisquestionandanswerstructmembuf:std::streambuf{membuf(char*begin,char*end){this->setg(begin,begin,end);}protected:virtualpos_typeseekoff(off_typeoff,std::ios_base::seekdirdir,std::ios_base::openmodewhich=std::ios_base::in){std::istream::pos_typeret;if(dir==std::ios_base::cur){this->g
27.6.3.4.2Buffermanagementandpositioningpos_typeseekoff(off_typeoff,ios_base::seekdirway,ios_base::openmodewhich=ios_base::in|ios_base::out);Effects:Altersthestreampositionswithinoneormoreofthecontrolledsequencesinawaythatisdefinedseparatelyforeachclassderivedfrombasic_streambufinthisClause(27.8
标题几乎说明了一切。我正在实现自己的streambuf类,我想知道委员会在决定同时包含std::streambuf::seekpos()和std::streambuf时的想法::seekoff()(对于相关的pubseekpos()和pubseekoff()也是如此)。在我看来seekpos(x)在我能想象的每一种情况下都应该与seekoff(x,std::ios::beg)具有相同的效果.但也许我的想象力还不够好。那么,当seekpos完全被seekoff包含时,为什么要同时拥有这两者呢?或者至少,你为什么不让前者的默认实现简单地调用后者?如果答案是“因为那是STL所做的”或类似的,
标题几乎说明了一切。我正在实现自己的streambuf类,我想知道委员会在决定同时包含std::streambuf::seekpos()和std::streambuf时的想法::seekoff()(对于相关的pubseekpos()和pubseekoff()也是如此)。在我看来seekpos(x)在我能想象的每一种情况下都应该与seekoff(x,std::ios::beg)具有相同的效果.但也许我的想象力还不够好。那么,当seekpos完全被seekoff包含时,为什么要同时拥有这两者呢?或者至少,你为什么不让前者的默认实现简单地调用后者?如果答案是“因为那是STL所做的”或类似的,
在[filebuf.virtuals]:pos_typeseekoff(off_typeoff,ios_base::seekdirway,ios_base::openmodewhich=ios_base::in|ios_base::out)override;Effects:Letwidthdenotea_codecvt.encoding().Ifis_open()==false,oroff!=0&&width,thenthepositioningoperationfails.Otherwise,ifway!=basic_ios::curoroff!=0,andifthelas