#include #include #include #include #include #include class my_string { public: my_string(char const* ptr) : str_(ptr) { std::cout << "Constructed" << std::endl; } my_string(my_string const& other) : str_(other.str_) { std::cout << "Copy-constructed" << std::endl; } ~my_string() { std::cout << "Destructed" << std::endl; } typedef std::string::iterator iterator; typedef std::string::const_iterator const_iterator; iterator begin() { return str_.begin(); } const_iterator begin() const { return str_.begin(); } iterator end() { return str_.end(); } const_iterator end() const { return str_.end(); } private: std::string str_; }; int main (int argc, char* argv[]) { using namespace boost::adaptors; BOOST_ADAPTED_FOREACH( char ch , my_string("Boost C++ Libraries") , reversed | sliced(15, 19) | replaced('B', 'p') | replaced('s', 'L')) { std::cout << "----- " << ch << " -----" << std::endl; } return 0; }