File: formatted.qbk

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (51 lines) | stat: -rw-r--r-- 2,059 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
[/
    Copyright 2014 Neil Groves
    Distributed under the Boost Software License, Version 1.0.
    (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]
[section:formatted formatted]

[table
    [[Syntax] [Code]]
    [[Pipe] [`rng | boost::adaptors::formatted()`]]
    [[Pipe] [`rng | boost::adaptors::formatted(sep)`]]
    [[Pipe] [`rng | boost::adaptors::formatted(sep, prefix)`]]
    [[Pipe] [`rng | boost::adaptors::formatted(sep, prefix, postfix)`]]
    [[Function] [`boost::adaptors::format(rng)`]]
    [[Function] [`boost::adaptors::format(rng, sep)`]]
    [[Function] [`boost::adaptors::format(rng, sep, prefix)`]]
    [[Function] [`boost::adaptors::format(rng, sep, prefix, postfix)`]]
]

This adaptor produces a range that can be output streamed to a
`std::basic_ostream` to produce the output string formatted output. With the
default paramters given numbers 1 to 5 inclusively in a range the output when
streamed would be "{0,1,2,3,4,5}". The prefix, separator and postfix may be
passed as parameters.

The general format of the output is thus:
<prefix><element_1><sep><element_2><sep>...<element_n><postfix>

* [*Precondition:]
    * `0 <= n`.
    * `sep` has a type that is CopyConstructible and able to be streamed to `std::basic_ostream<Char,Traits>`
    * `prefix` has a type that is CopyConstructible and able to be streamed to `std::basic_ostream<Char,Traits>`
    * `postfix` has a type that is CopyConstructible and able to be streamed to `std::basic_ostream<Char,Traits>`
* [*Returns:] `boost::range::formatted_range<Iter, Sep, Prefix, Postfix>` where
`Iter` is `typename boost::range_iterator<Rng>::type`, `Sep` is the separator
type, `Prefix` is the prefix type and `Postfix` is the postfix type.
* [*Range Category:] __single_pass_range__
* [*Returned Range Category:] The range category of `rng`.

[section:formatted_example formatted example]
[import ../../../test/adaptor_test/formatted_example.cpp]
[separated_example]
[endsect]

This would produce the output:
``
{1,2,3,4,5}
``
[endsect]