-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathnode_iterator1.cpp
More file actions
44 lines (33 loc) · 1.06 KB
/
node_iterator1.cpp
File metadata and controls
44 lines (33 loc) · 1.06 KB
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
// Copyright David Abrahams 2004. Use, modification and distribution is
// subject to 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)
#include "node_iterator1.hpp"
#include <string>
#include <memory>
#include <iostream>
#include <algorithm>
#include <functional>
int main()
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<node<int> > nodes(new node<int>(42));
#else
std::unique_ptr<node<int> > nodes(new node<int>(42));
#endif
nodes->append(new node<std::string>(" is greater than "));
nodes->append(new node<int>(13));
std::copy(
node_iterator(nodes.get()), node_iterator()
, std::ostream_iterator<node_base>(std::cout, " ")
);
std::cout << std::endl;
std::for_each(
node_iterator(nodes.get()), node_iterator()
, std::mem_fun_ref(&node_base::double_me)
);
std::copy(
node_iterator(nodes.get()), node_iterator()
, std::ostream_iterator<node_base>(std::cout, "/")
);
std::cout << std::endl;
}