Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
Custom String Types

struct my_string
    typedef my_string              this_type;
    typedef char                  value_type;
    typedef value_type*             iterator;
    typedef value_type const* const_iterator;

    my_string ();
    my_string (const_iterator, const_iterator =0);

    char const*    c_str () const { return storage_; }
    const_iterator begin () const { return storage_; }
    const_iterator   end () const { return storage_ + strlen(storage_); }
    this_type& operator= (char const*);


    static size_t const size_ = 12;
    char storage_[size_];

boost::cnv::strtol cnv;

BOOST_TEST(  "12" == convert<my_string>(12, cnv).value());
BOOST_TEST("0.95" == convert<my_string>(0.95, cnv(arg::precision = 2)).value());