]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/iterator/example/node_iterator1.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / iterator / example / node_iterator1.cpp
1 // Copyright David Abrahams 2004. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5 #include "node_iterator1.hpp"
6 #include <string>
7 #include <memory>
8 #include <iostream>
9 #include <algorithm>
10 #include <functional>
11
12 int main()
13 {
14
15 #if defined(BOOST_NO_CXX11_SMART_PTR)
16
17 std::auto_ptr<node<int> > nodes(new node<int>(42));
18
19 #else
20
21 std::unique_ptr<node<int> > nodes(new node<int>(42));
22
23 #endif
24
25 nodes->append(new node<std::string>(" is greater than "));
26 nodes->append(new node<int>(13));
27
28 std::copy(
29 node_iterator(nodes.get()), node_iterator()
30 , std::ostream_iterator<node_base>(std::cout, " ")
31 );
32 std::cout << std::endl;
33
34 std::for_each(
35 node_iterator(nodes.get()), node_iterator()
36 , std::mem_fun_ref(&node_base::double_me)
37 );
38
39 std::copy(
40 node_iterator(nodes.get()), node_iterator()
41 , std::ostream_iterator<node_base>(std::cout, "/")
42 );
43 std::cout << std::endl;
44 }