Boost C++ Libraries

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

PrevUpHomeNext
Custom String Types

struct my_string
{
    using      this_type = my_string;
    using     value_type = char;
    using       iterator = value_type*;
    using const_iterator = value_type const*;

    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*);

    private:

    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());


PrevUpHomeNext