it is destroyed; flushing the buffer means emptying it and appending its contents to it 's underlying container. (It is also possible to flush the buffer manually, by invoking the flush() member function.)
This difference has two implications. First, sequence_buffer is only useful if appending an array of N elements is much more efficient than inserting a single element N times. Second, sequence_buffer assumes that it can insert elements at the end of a container using an append member function. This member function is not part of the Container or Sequence requirements. The sequence_buffer adaptor can be used with rope, but not with any of the other containers in the library. (This is the reason why sequence_buffer is defined in the file rope.h, instead of in iterator.h.)
If you want to build up a string one character at a time, it is much more efficient to use sequence_buffer than to repeatedly add single characters to the end of a rope.
Example int main() {
const char* const s = 'this is a test';
const int N = strlen(s);
crope r;
transform(s, s + N, sequence_buffer<crope>(r), toupper);
cout << 'r = ' << r << endl;
}
Definition Defined in the header rope, and in the backward-compatibility header rope.h. The sequence_buffer class, and the rope header, are SGI extensions; they are not part of the C++ standard.
Template parameters | Parameter | Description | Default |
Container | The type of the underlying container that elements are being written to. [1] | |
buf_sz | Number of elements in the buffer. This is a number, not a type. buf_sz has type size_t. | 100 |
Model of Output Iterator.
Type requirements • Container is a variable-sized Forward Container
• Container 's value type T is a model of Default Constructible, as well as Assignable.
• Container has a member function that appends a range. Specifically: If x is an object of type Container and f and l are of type T*, then x.append(f, l) appends the range [f, l) to x. [1]
Public base classes output_iterator
Members | Member | Where defined | Description |
value_type | sequence_buffer | The underlying container's value type. |
sequence_buffer(Container& C) | sequence_buffer | Create a sequence_buffer whose underlying container is C. |
sequence_buffer() | Default Constructible | The default constructor. The resulting iterator is singular. |
sequence_buffer(const sequence_buffer&) | Assignable | Copy constructor. |
sequence_buffer& operator=(const sequence_buffer& s) | Assignable | Assignment operator. |
sequence_buffer& operator=(sequence_buffer& s) | Assignable | Faster version of assignment operator. |
sequence_buffer& operator=(const value_type&) |