toStringT str() { toStringT out; stringT newstuff(convertstreambuf_initT::buf()->str()); if(newstuff.length() == 0) return out; // convert it here const std::codecvt<charT, toCharT, typename traitsT::state_type>& cvt = std::use_facet<std::codecvt<charT, toCharT, typename traitsT::state_type> >(this->getloc()); if(cvt.always_noconv()) out.append(no_conversion(newstuff)); else { // we must do code conversion const charT* from_next = newstuff.data(); typename std::codecvt_base::result r; typename traitsT::state_type state; do { toCharT* to_next; r = cvt.out(state, from_next, newstuff.data() + newstuff.length(), from_next, to_, to_ + toSize_, to_next); if(r == std::codecvt_base::noconv) { out.append(no_conversion(newstuff)); break; } out.append(to_, (to_next - to_)); } while(r == std::codecvt_base::partial); // naughty! ignore (r == std::codecvt_base::error) } // if(cvt.always_noconv()) convertstreambuf_initT::buf()->str(stringT()); return out; } // str
int main() { newstuff(); }