Files
iterator/example/node_iterator1.cpp
Frank Birbacher 47b3f8b73c Created branch to extend PropertyMap:
add a readable functor map that calls a given functor or function upon lookup.
Ideas from: http://comments.gmane.org/gmane.comp.lib.boost.user/54397
and: http://comments.gmane.org/gmane.comp.lib.boost.user/73358


[SVN r77438]
2012-03-20 20:11:17 +00:00

35 lines
972 B
C++

// 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()
{
std::auto_ptr<node<int> > nodes(new node<int>(42));
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;
}