template<typename char_t, typename traits_t = std::char_traits<char_t>>
class seqan3::detail::fast_ostreambuf_iterator< char_t, traits_t >
Functionally the same as std::ostreambuf_iterator, but offers writing a range more efficiently.
- Template Parameters
-
char_t | The stream's character type. |
traits_t | The stream's traits type. |
The functions seqan3::fast_ostreambuf_iterator::write_range and seqan3::fast_ostreambuf_iterator::write_n allow more efficient writing of ranges by writing in chunks that avoiding overflow checks.
int main()
{
stream_it = '>';
*stream_it = ' ';
while (it != std::ranges::end(
sequence))
{
auto current_end = it;
size_t steps = std::ranges::advance(current_end, 10u, std::ranges::end(
sequence));
using subrange_t = std::ranges::subrange<decltype(it), decltype(current_end), std::ranges::subrange_kind::sized>;
it = stream_it.write_range(subrange_t{it, current_end, 10u - steps});
stream_it = ' ';
}
}
Functionally the same as std::ostreambuf_iterator, but offers writing a range more efficiently.
Definition: fast_ostreambuf_iterator.hpp:39
auto write_range(range_type &&rng)
Writes a range to the associated output.
Definition: fast_ostreambuf_iterator.hpp:145
Provides seqan3::detail::fast_ostreambuf_iterator.
The generic concept for a (biological) sequence.
template<typename char_t , typename traits_t = std::char_traits<char_t>>
template<std::ranges::forward_range range_type>
Writes a range to the associated output.
- Template Parameters
-
range_type | The type of range to write; Must model std::ranges::forward_range. |
- Parameters
-
[in] | rng | The range to write. |
- Returns
- If
range_type
models std::ranges::borrowed_range
returns an iterator pointing to end of the range (rng) else returns void
.
This function avoids the buffer-at-end check by writing the range in chunks, where a chunks has the size of the remaining space in the put area of the buffer. If the range type models std::ranges::sized_range
the chunks are written using std::ranges::copy_n
, which may use memcpy if applicable. Otherwise, a simple for loop iterates over the chunk.
- Attention
- You can only use the return value (end iterator) if your range type models
std::ranges::borrowed_range
.
Example:
int main()
{
stream_it = '>';
*stream_it = ' ';
while (it != std::ranges::end(
sequence))
{
auto current_end = it;
size_t steps = std::ranges::advance(current_end, 10u, std::ranges::end(
sequence));
using subrange_t = std::ranges::subrange<decltype(it), decltype(current_end), std::ranges::subrange_kind::sized>;
it = stream_it.write_range(subrange_t{it, current_end, 10u - steps});
stream_it = ' ';
}
}