Для тех, кому интересно, еще немного кода
class ifstream_pos_returner
{
ifstream& ifs;
unsigned old_pos;
public:
ifstream_pos_returner( ifstream& infs , unsigned pos ) : ifs( infs ) , old_pos( pos )
{
}
void reset( unsigned pos )
{
old_pos = pos;
}
~ifstream_pos_returner()
{
ifs.seekg( old_pos , std::ios::beg );
}
};
...
spOneObject OneObject::load( ifstream& ){
ifstream_pos_returner ret( ifs , ifs.tellg() );
spOneObject res;
...
if( something goes wrong)
return res;
...
ret.reset( ifs.tellg() );
return res;
}