string whole( "hello" );
string const& part = whole.substr( 0, 2 );

この const& での受け取りって不正?
string に限った話じゃないんだけど、戻り値の一時オブジェクトの寿命が分からないです。