
On Thu, Jan 26, 2012 at 6:14 PM, Michel Morin <mimomorin@gmail.com> wrote:
IIUC, the main concern to implement optimized code is that how to obtain begin and end pointer to CharT from `iter_rng` safely. With C++11-conforming standard library, it is safe to implement
bool operator<<(::boost::iterator_range<std::string::iterator> const& str) { if (!str.empty()) { start = const_cast<CharT*>(&str.front()); finish = start + str.size(); } else { start = 0; finish = 0; } return true; }
because `&*(s.begin() + n) == &*s.begin() + n` (`s` is an object of std::basic_string<…>) is guaranteed.
But, in C++03, the above code is not safe; the standard does not guarantee that std::basic_string<…> is stored contiguously (though many standard library implementations store it contiguously).
What about using c_str() instead of begin()? It does provide that guarantee in C++03. -- Olaf