]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/doc/qi/num_list2.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / doc / qi / num_list2.qbk
1 [/==============================================================================
2 Copyright (C) 2001-2011 Joel de Guzman
3 Copyright (C) 2001-2011 Hartmut Kaiser
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ===============================================================================/]
8
9 [section Number List - stuffing numbers into a std::vector]
10
11 This sample demonstrates a parser for a comma separated list of numbers. The
12 numbers are inserted in a vector using phoenix.
13
14 [import ../../example/qi/num_list2.cpp]
15
16 [tutorial_numlist2]
17
18 The full cpp file for this example can be found here: [@../../example/qi/num_list2.cpp]
19
20 This, again, is the same parser as before. This time, instead of summing up the
21 numbers, we stuff them in a `std::vector`. `push_back` is supplied by
22 __phoenix__. The expression:
23
24 push_back(ref(v), _1)
25
26 appends the parsed number. Like before, `_1` is a __phoenix__ placeholder for
27 the parsed result attribute. Also, like before, `ref(v)` tells __phoenix__ that
28 `v`, the `std::vector`, is a mutable reference.
29
30 [endsect]