]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_iterator2.hpp" | |
6 | #include <string> | |
7 | #include <memory> | |
8 | #include <iostream> | |
9 | #include <algorithm> | |
10 | #include <boost/mem_fn.hpp> | |
11 | #include <cassert> | |
12 | ||
13 | int main() | |
14 | { | |
b32b8144 FG |
15 | |
16 | #if defined(BOOST_NO_CXX11_SMART_PTR) | |
17 | ||
7c673cae | 18 | std::auto_ptr<node<int> > nodes(new node<int>(42)); |
f67539c2 | 19 | |
b32b8144 FG |
20 | #else |
21 | ||
22 | std::unique_ptr<node<int> > nodes(new node<int>(42)); | |
f67539c2 | 23 | |
b32b8144 FG |
24 | #endif |
25 | ||
7c673cae FG |
26 | nodes->append(new node<std::string>(" is greater than ")); |
27 | nodes->append(new node<int>(13)); | |
28 | ||
29 | // Check interoperability | |
30 | assert(node_iterator(nodes.get()) == node_const_iterator(nodes.get())); | |
31 | assert(node_const_iterator(nodes.get()) == node_iterator(nodes.get())); | |
f67539c2 | 32 | |
7c673cae FG |
33 | assert(node_iterator(nodes.get()) != node_const_iterator()); |
34 | assert(node_const_iterator(nodes.get()) != node_iterator()); | |
f67539c2 | 35 | |
7c673cae FG |
36 | std::copy( |
37 | node_iterator(nodes.get()), node_iterator() | |
38 | , std::ostream_iterator<node_base>(std::cout, " ") | |
39 | ); | |
40 | std::cout << std::endl; | |
f67539c2 | 41 | |
7c673cae FG |
42 | std::for_each( |
43 | node_iterator(nodes.get()), node_iterator() | |
44 | , boost::mem_fn(&node_base::double_me) | |
45 | ); | |
46 | ||
47 | std::copy( | |
48 | node_const_iterator(nodes.get()), node_const_iterator() | |
49 | , std::ostream_iterator<node_base>(std::cout, "/") | |
50 | ); | |
51 | std::cout << std::endl; | |
52 | return 0; | |
53 | } |