This class implements the minimal string interface and is intended to be used as a base class for xstring<>, which provides the full string interface.
More...
|
| var_char_buf (allocator_type const &a=allocator_type()) |
|
| var_char_buf (var_char_buf const &s) |
|
var_char_buf & | operator= (var_char_buf const &s) |
|
template<class InputIter > |
void | insert (iterator pos, InputIter first, InputIter last) |
|
iterator | erase (iterator first, iterator last) |
|
const allocator_type & | get_allocator () const |
| (Replace can be defined in terms of erase and insert, so the minimal interface can skip it.) More...
|
|
iterator | begin () |
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
void | clear () |
|
size_t | max_size () const |
| Proper thing to do is probably to return _allocator.max_size(), but this causes problems: My default allocator returns 0xFFFFFFFF, and in fact will allocate a block of that size, but the memory returned is not actually accessible. More...
|
|
bool | empty () const |
|
size_type | size () const |
|
void | swap (var_char_buf &s) |
|
void | reserve (size_type requested_chars=0) |
|
size_type | capacity () const |
|
const CharT * | c_str () const |
|
const CharT * | data () const |
|
template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
class var_char_buf< SIZE, CharT, Traits, Alloc >
This class implements the minimal string interface and is intended to be used as a base class for xstring<>, which provides the full string interface.
template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
const allocator_type& var_char_buf< SIZE, CharT, Traits, Alloc >::get_allocator |
( |
| ) |
const |
|
inline |
template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
size_t var_char_buf< SIZE, CharT, Traits, Alloc >::max_size |
( |
| ) |
const |
|
inline |
Proper thing to do is probably to return _allocator.max_size(), but this causes problems: My default allocator returns 0xFFFFFFFF, and in fact will allocate a block of that size, but the memory returned is not actually accessible.
This causes problems for test code that wants to stress test the string (it breaks std::string too). Thus the following hack.
References var_char_buf< SIZE, CharT, Traits, Alloc >::_allocator, and var_char_buf< SIZE, CharT, Traits, Alloc >::_buffer.
Referenced by var_char_buf< SIZE, CharT, Traits, Alloc >::reserve().
template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
void var_char_buf< SIZE, CharT, Traits, Alloc >::reserve |
( |
size_type |
requested_chars = 0 | ) |
|
|
inline |
TODO: Smarter reallocation strategy
Everything else should be nothrow:
References var_char_buf< SIZE, CharT, Traits, Alloc >::_allocator, var_char_buf< SIZE, CharT, Traits, Alloc >::_buffer, and var_char_buf< SIZE, CharT, Traits, Alloc >::max_size().
template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
Definition of _allocator instance, shared between all strings of a given type:
Referenced by var_char_buf< SIZE, CharT, Traits, Alloc >::get_allocator(), var_char_buf< SIZE, CharT, Traits, Alloc >::max_size(), and var_char_buf< SIZE, CharT, Traits, Alloc >::reserve().