Began tutorial and examples.

[SVN r21584]
This commit is contained in:
Dave Abrahams
2004-01-11 01:02:36 +00:00
parent 6c62f31f0a
commit 59340bca4c
9 changed files with 340 additions and 6 deletions

34
example/node_iterator1.cpp Executable file
View File

@ -0,0 +1,34 @@
// 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::twice)
);
std::copy(
node_iterator(nodes.get()), node_iterator()
, std::ostream_iterator<node_base>(std::cout, "/")
);
std::cout << std::endl;
}