Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76204 - in sandbox: tree_node/boost tree_node/boost/detail tree_node/boost/detail/function tree_node/boost/detail/metafunction tree_node/boost/tree_node tree_node/boost/tree_node/algorithm tree_node/libs/tree_node/example utility-container_gen/boost/detail/metafunction utility-container_gen/boost/utility
From: sponage_at_[hidden]
Date: 2011-12-27 15:11:19


Author: expaler
Date: 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
New Revision: 76204
URL: http://svn.boost.org/trac/boost/changeset/76204

Log:
Updated Boost.Utility.ContainerGen and Boost.TreeNode to work with Boost 1.48.0
Added:
   sandbox/tree_node/boost/detail/base_pointee.hpp (contents, props changed)
   sandbox/tree_node/boost/detail/metafunction/container_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/detail/metafunction/has_first_type.hpp (contents, props changed)
   sandbox/tree_node/boost/detail/metafunction/has_second_type.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/algorithm/
   sandbox/tree_node/boost/tree_node/algorithm/dereference_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/algorithm/equal.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/algorithm/lexicographical_compare.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/associative_node.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/base.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/binary_node.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/breadth_first_desc_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/breadth_first_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/depth_first_desc_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/depth_first_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/in_order_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/nary_node.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/post_order_desc_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/post_order_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/pre_order_desc_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/pre_order_iterator.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/traversal_state.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/typeof.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_depth.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_position.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_red_black_flag.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/associative_node.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/binary_node.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/default_unconstruct_type.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/default_unconstruct_type.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/nary_node.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/show_functions.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/show_functions.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/showcase_desc_iterators.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/showcase_iterators.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/has_const_iterator.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/has_const_pointer.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/has_const_reference.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/has_difference_type.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/has_pointer.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/has_reference.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/has_size_type.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/has_value_type.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/is_container.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/detail/metafunction/is_input_iterator.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/associative_container_gen.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/container_gen.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/container_selector.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/has_stable_iters_selector.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/is_associative_selector.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/is_multiple_assoc_selector.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/is_random_access_selector.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/is_unique_assoc_selector.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/is_unordered_selector.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/ptr_assoc_container_gen.hpp (contents, props changed)
   sandbox/utility-container_gen/boost/utility/ptr_container_gen.hpp (contents, props changed)
Removed:
   sandbox/tree_node/boost/detail/function/
   sandbox/tree_node/boost/detail/metafunction/element_type.hpp
   sandbox/tree_node/boost/tree_node/dereference_iterator.hpp
   sandbox/tree_node/boost/tree_node/factory.hpp
   sandbox/tree_node/boost/tree_node/raw_associative_node.hpp
   sandbox/tree_node/boost/tree_node/raw_binary_node.hpp
   sandbox/tree_node/boost/tree_node/raw_node.hpp
   sandbox/tree_node/boost/tree_node/shared_base.hpp
   sandbox/tree_node/boost/tree_node/simple_associative_node.hpp
   sandbox/tree_node/boost/tree_node/simple_node.hpp
   sandbox/tree_node/boost/tree_node/with_child_range_access.hpp
   sandbox/tree_node/libs/tree_node/example/default_unconstructible_type.cpp
   sandbox/tree_node/libs/tree_node/example/default_unconstructible_type.hpp
   sandbox/tree_node/libs/tree_node/example/raw_associative_node.cpp
   sandbox/tree_node/libs/tree_node/example/raw_binary_node.cpp
   sandbox/tree_node/libs/tree_node/example/raw_node.cpp
   sandbox/tree_node/libs/tree_node/example/showcase_descendant_iterators.hpp
   sandbox/tree_node/libs/tree_node/example/simple_associative_node.cpp
   sandbox/tree_node/libs/tree_node/example/simple_node.cpp

Added: sandbox/tree_node/boost/detail/base_pointee.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/detail/base_pointee.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_BASE_POINTEE_HPP_INCLUDED
+#define BOOST_DETAIL_BASE_POINTEE_HPP_INCLUDED
+
+namespace boost { namespace detail {
+
+ template <typename Derived>
+ struct base_pointee
+ {
+ typedef Derived const* const_pointer;
+ typedef Derived* pointer;
+
+ const_pointer get_derived() const;
+
+ pointer get_derived();
+ };
+
+ template <typename Derived>
+ inline typename base_pointee<Derived>::const_pointer
+ base_pointee<Derived>::get_derived() const
+ {
+ return static_cast<const_pointer>(this);
+ }
+
+ template <typename Derived>
+ inline typename base_pointee<Derived>::pointer
+ base_pointee<Derived>::get_derived()
+ {
+ return static_cast<pointer>(this);
+ }
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_BASE_POINTEE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/detail/metafunction/container_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/detail/metafunction/container_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,35 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_CONTAINER_ITERATOR_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_CONTAINER_ITERATOR_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T>
+ struct container_iterator
+ {
+ private:
+ typedef typename ::std::tr1::remove_const<T>::type
+ C;
+
+ public:
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_const<T>
+ , typename C::const_iterator
+ , typename C::iterator
+ >::type
+ type;
+
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,container_iterator,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_CONTAINER_ITERATOR_HPP_INCLUDED
+

Deleted: sandbox/tree_node/boost/detail/metafunction/element_type.hpp
==============================================================================
--- sandbox/tree_node/boost/detail/metafunction/element_type.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,23 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_DETAIL_METAFUNCTION_ELEMENT_TYPE_HPP_INCLUDED
-#define BOOST_DETAIL_METAFUNCTION_ELEMENT_TYPE_HPP_INCLUDED
-
-#include <boost/mpl/aux_/lambda_support.hpp>
-
-namespace boost { namespace detail {
-
- template <typename T>
- struct element_type
- {
- typedef typename T::element_type type;
-
- BOOST_MPL_AUX_LAMBDA_SUPPORT(1,element_type,(T))
- };
-}} // namespace boost::detail
-
-#endif // BOOST_DETAIL_METAFUNCTION_ELEMENT_TYPE_HPP_INCLUDED
-

Added: sandbox/tree_node/boost/detail/metafunction/has_first_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/detail/metafunction/has_first_type.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_FIRST_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_FIRST_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_first_type metafunction will determine whether or not
+ // the specified type has a nested 'first_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(first_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_FIRST_TYPE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/detail/metafunction/has_second_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/detail/metafunction/has_second_type.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_SECOND_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_SECOND_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_second_argument_type metafunction will determine whether or not
+ // the specified type has a nested 'second_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(second_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_SECOND_TYPE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,31 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_HPP_INCLUDED
+#define BOOST_TREE_NODE_HPP_INCLUDED
+
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/breadth_first_iterator.hpp>
+#include <boost/tree_node/breadth_first_desc_iterator.hpp>
+#include <boost/tree_node/pre_order_iterator.hpp>
+#include <boost/tree_node/pre_order_desc_iterator.hpp>
+#include <boost/tree_node/post_order_iterator.hpp>
+#include <boost/tree_node/post_order_desc_iterator.hpp>
+#include <boost/tree_node/in_order_iterator.hpp>
+#include <boost/tree_node/depth_first_iterator.hpp>
+#include <boost/tree_node/depth_first_desc_iterator.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/binary_node.hpp>
+#include <boost/tree_node/nary_node.hpp>
+#include <boost/tree_node/associative_node.hpp>
+#include <boost/tree_node/with_depth.hpp>
+#include <boost/tree_node/with_position.hpp>
+#include <boost/tree_node/with_red_black_flag.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/tree_node/algorithm/equal.hpp>
+#include <boost/tree_node/algorithm/lexicographical_compare.hpp>
+
+#endif // BOOST_TREE_NODE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/algorithm/dereference_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/algorithm/dereference_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,115 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_ALGORITHM_DEREFERENCE_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_ALGORITHM_DEREFERENCE_ITERATOR_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/ref.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/detail/metafunction/has_first_type.hpp>
+#include <boost/detail/metafunction/has_second_type.hpp>
+
+//[reference__dereference_iterator
+namespace boost { namespace tree_node {
+ //<-
+ namespace _detail {
+
+ template <typename Iterator>
+ class dereference_iterator_helper
+ {
+ typedef typename ::boost::iterator_value<Iterator>::type
+ _value_type;
+ typedef typename ::boost::mpl::and_<
+ typename ::boost::detail::has_first_type<_value_type>::type
+ , typename ::boost::detail::has_second_type<
+ _value_type
+ >::type
+ >::type
+ _is_associative;
+
+ struct _associative_result
+ {
+ typedef typename ::boost::unwrap_reference<
+ BOOST_TYPEOF_TPL(::boost::ref(Iterator()->second))
+ >::type&
+ type;
+ };
+
+ public:
+ typedef Iterator
+ argument_type;
+ typedef typename ::boost::mpl::eval_if<
+ _is_associative
+ , _associative_result
+ , ::boost::iterator_reference<Iterator>
+ >::type
+ result_type;
+
+ result_type operator()(argument_type itr) const;
+
+ private:
+ static result_type _evaluate(Iterator itr, ::boost::mpl::true_);
+
+ static result_type _evaluate(Iterator itr, ::boost::mpl::false_);
+ };
+
+ template <typename Iterator>
+ inline typename dereference_iterator_helper<Iterator>::result_type
+ dereference_iterator_helper<Iterator>::operator()(
+ argument_type itr
+ ) const
+ {
+ return _evaluate(itr, _is_associative());
+ }
+
+ template <typename Iterator>
+ inline typename dereference_iterator_helper<Iterator>::result_type
+ dereference_iterator_helper<Iterator>::_evaluate(
+ Iterator itr
+ , ::boost::mpl::true_
+ )
+ {
+ return itr->second;
+ }
+
+ template <typename Iterator>
+ inline typename dereference_iterator_helper<Iterator>::result_type
+ dereference_iterator_helper<Iterator>::_evaluate(
+ Iterator itr
+ , ::boost::mpl::false_
+ )
+ {
+ return *itr;
+ }
+ } // namespace _detail
+ //->
+
+//<-
+#if 0
+//->
+ template <typename Iterator>
+ implementation_defined dereference_iterator(Iterator itr);
+//<-
+#endif
+//->
+
+ //<-
+ template <typename Iterator>
+ inline typename _detail::dereference_iterator_helper<Iterator>::result_type
+ dereference_iterator(Iterator itr)
+ {
+ return _detail::dereference_iterator_helper<Iterator>()(itr);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_ALGORITHM_DEREFERENCE_ITERATOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/algorithm/equal.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/algorithm/equal.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,149 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_ALGORITHM_EQUAL_HPP_INCLUDED
+#define BOOST_TREE_NODE_ALGORITHM_EQUAL_HPP_INCLUDED
+
+#include <functional>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/detail/metafunction/has_first_type.hpp>
+#include <boost/detail/metafunction/has_second_type.hpp>
+
+//[reference__equal__with_comparators
+namespace boost { namespace tree_node {
+
+ template <typename Iterator, typename KeyCompare, typename ValueCompare>
+ bool
+ equal(
+ Iterator itr1
+ , Iterator itr2
+ , KeyCompare key_comp
+ , ValueCompare value_comp
+ );
+
+ //<-
+ template <typename Iterator, typename KeyCompare, typename ValueCompare>
+ bool
+ equal(
+ Iterator itr1
+ , Iterator itr2
+ , KeyCompare key_comp
+ , ValueCompare value_comp
+ )
+ {
+ while (itr1)
+ {
+ if (
+ itr2
+ && key_comp(itr1->first, itr2->first)
+ && value_comp(itr1->second.get_data(), itr2->second.get_data())
+ )
+ {
+ ++itr1;
+ ++itr2;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ return !itr2;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__equal__with_comparator
+namespace boost { namespace tree_node {
+
+ template <typename Iterator, typename BinaryPredicate>
+ bool equal(Iterator itr1, Iterator itr2, BinaryPredicate comp);
+
+ //<-
+ template <typename Iterator, typename BinaryPredicate>
+ bool equal(Iterator itr1, Iterator itr2, BinaryPredicate comp)
+ {
+ while (itr1)
+ {
+ if (itr2 && comp(itr1->get_data(), itr2->get_data()))
+ {
+ ++itr1;
+ ++itr2;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ return !itr2;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__equal
+namespace boost { namespace tree_node {
+ //<-
+ namespace _detail {
+
+ template <typename Iterator>
+ inline bool equal(Iterator itr1, Iterator itr2, ::boost::mpl::true_)
+ {
+ typedef typename ::boost::iterator_value<Iterator>::type _value_type;
+
+ return ::boost::tree_node::equal(
+ itr1
+ , itr2
+ , ::std::equal_to<typename _value_type::first_type>()
+ , ::std::equal_to<
+ typename _value_type::second_type::traits::data_type
+ >()
+ );
+ }
+
+ template <typename Iterator>
+ inline bool equal(Iterator itr1, Iterator itr2, ::boost::mpl::false_)
+ {
+ return ::boost::tree_node::equal(
+ itr1
+ , itr2
+ , ::std::equal_to<
+ typename ::boost::iterator_value<
+ Iterator
+ >::type::traits::data_type
+ >()
+ );
+ }
+ } // namespace _detail
+ //->
+
+ template <typename Iterator>
+ bool equal(Iterator itr1, Iterator itr2);
+
+ //<-
+ template <typename Iterator>
+ inline bool equal(Iterator itr1, Iterator itr2)
+ {
+ typedef typename ::boost::iterator_value<Iterator>::type _value_type;
+
+ return _detail::equal(
+ itr1
+ , itr2
+ , typename ::boost::mpl::and_<
+ typename ::boost::detail::has_first_type<_value_type>::type
+ , typename ::boost::detail::has_second_type<_value_type>::type
+ >::type()
+ );
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_ALGORITHM_EQUAL_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/algorithm/lexicographical_compare.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/algorithm/lexicographical_compare.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,206 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
+#define BOOST_TREE_NODE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
+
+#include <functional>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/detail/metafunction/has_first_type.hpp>
+#include <boost/detail/metafunction/has_second_type.hpp>
+
+//[reference__lexicographical_compare__with_comparators
+namespace boost { namespace tree_node {
+
+ template <typename Iterator, typename KeyCompare, typename ValueCompare>
+ bool
+ lexicographical_compare(
+ Iterator itr1
+ , Iterator itr2
+ , KeyCompare key_comp
+ , ValueCompare value_comp
+ );
+
+ //<-
+ template <typename Iterator, typename KeyCompare, typename ValueCompare>
+ bool
+ lexicographical_compare(
+ Iterator itr1
+ , Iterator itr2
+ , KeyCompare key_comp
+ , ValueCompare value_comp
+ )
+ {
+ while (itr2)
+ {
+ if (itr1)
+ {
+ if (key_comp(itr1->first, itr2->first))
+ {
+ return true;
+ }
+
+ if (key_comp(itr2->first, itr1->first))
+ {
+ return false;
+ }
+
+ if (
+ value_comp(
+ itr1->second.get_data()
+ , itr2->second.get_data()
+ )
+ )
+ {
+ return true;
+ }
+
+ if (
+ value_comp(
+ itr2->second.get_data()
+ , itr1->second.get_data()
+ )
+ )
+ {
+ return false;
+ }
+
+ ++itr1;
+ ++itr2;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__lexicographical_compare__with_comparator
+namespace boost { namespace tree_node {
+
+ template <typename Iterator, typename BinaryPredicate>
+ bool
+ lexicographical_compare(
+ Iterator itr1
+ , Iterator itr2
+ , BinaryPredicate comp
+ );
+
+ //<-
+ template <typename Iterator, typename BinaryPredicate>
+ bool
+ lexicographical_compare(
+ Iterator itr1
+ , Iterator itr2
+ , BinaryPredicate comp
+ )
+ {
+ while (itr2)
+ {
+ if (itr1)
+ {
+ if (comp(itr1->get_data(), itr2->get_data()))
+ {
+ return true;
+ }
+ else if (comp(itr2->get_data(), itr1->get_data()))
+ {
+ return false;
+ }
+ else
+ {
+ ++itr1;
+ ++itr2;
+ }
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__lexicographical_compare
+namespace boost { namespace tree_node {
+ //<-
+ namespace _detail {
+
+ template <typename Iterator>
+ inline bool
+ lexicographical_compare(
+ Iterator itr1
+ , Iterator itr2
+ , ::boost::mpl::true_
+ )
+ {
+ typedef typename ::boost::iterator_value<Iterator>::type _value_type;
+
+ return ::boost::tree_node::lexicographical_compare(
+ itr1
+ , itr2
+ , ::std::less<typename _value_type::first_type>()
+ , ::std::less<
+ typename _value_type::second_type::traits::data_type
+ >()
+ );
+ }
+
+ template <typename Iterator>
+ inline bool
+ lexicographical_compare(
+ Iterator itr1
+ , Iterator itr2
+ , ::boost::mpl::false_
+ )
+ {
+ return ::boost::tree_node::lexicographical_compare(
+ itr1
+ , itr2
+ , ::std::less<
+ typename ::boost::iterator_value<
+ Iterator
+ >::type::traits::data_type
+ >()
+ );
+ }
+ } // namespace _detail
+ //->
+
+ template <typename Iterator>
+ bool lexicographical_compare(Iterator itr1, Iterator itr2);
+
+ //<-
+ template <typename Iterator>
+ bool lexicographical_compare(Iterator itr1, Iterator itr2)
+ {
+ typedef typename ::boost::iterator_value<Iterator>::type _value_type;
+
+ return _detail::lexicographical_compare(
+ itr1
+ , itr2
+ , typename ::boost::mpl::and_<
+ typename ::boost::detail::has_first_type<_value_type>::type
+ , typename ::boost::detail::has_second_type<_value_type>::type
+ >::type()
+ );
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/associative_node.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/associative_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,802 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_ASSOCIATIVE_NODE_HPP_INCLUDED
+#define BOOST_TREE_NODE_ASSOCIATIVE_NODE_HPP_INCLUDED
+
+#include <utility>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/move/move.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/utility/associative_container_gen.hpp>
+#include <boost/utility/is_unordered_selector.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/depth_first_desc_iterator.hpp>
+#include <boost/tree_node/breadth_first_desc_iterator.hpp>
+#include <boost/tree_node/algorithm/equal.hpp>
+#include <boost/tree_node/algorithm/lexicographical_compare.hpp>
+
+//[reference__associative_node_base
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename AssociativeContainerSelector
+ >
+ class associative_node_base : public tree_node_base<Derived>
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(associative_node_base);
+ typedef typename ::boost::mpl::apply_wrap2<
+ associative_container_gen<
+ AssociativeContainerSelector
+ >
+ , Key
+ , Derived
+ >::type
+ children;
+ //->
+
+ public:
+ struct traits
+ {
+ typedef Key key_type;
+ typedef Data data_type;
+ };
+
+ typedef typename tree_node_base<Derived>::pointer
+ pointer;
+ typedef typename tree_node_base<Derived>::const_pointer
+ const_pointer;
+ typedef // implementation_defined
+ //<-
+ typename children::iterator
+ //->
+ iterator;
+ typedef // implementation_defined
+ //<-
+ typename children::const_iterator
+ //->
+ const_iterator;
+
+ //<-
+ private:
+ children _children;
+ pointer _parent;
+ typename traits::data_type _data;
+
+ public:
+ //->
+ associative_node_base();
+
+ explicit associative_node_base(
+ typename traits::data_type const& data
+ );
+
+ associative_node_base(associative_node_base const& copy);
+
+//<-
+#if 0
+//->
+ associative_node_base(associative_node_base&& source);
+
+ associative_node_base& operator=(associative_node_base const& copy);
+
+ associative_node_base& operator=(associative_node_base&& source);
+//<-
+#endif
+
+ associative_node_base(BOOST_RV_REF(associative_node_base) source);
+
+ associative_node_base&
+ operator=(BOOST_COPY_ASSIGN_REF(associative_node_base) copy);
+
+ associative_node_base&
+ operator=(BOOST_RV_REF(associative_node_base) source);
+//->
+
+ typename traits::data_type const& get_data() const;
+
+ typename traits::data_type& get_data();
+
+ const_pointer get_parent_ptr() const;
+
+ pointer get_parent_ptr();
+
+ iterator
+ add_child(
+ typename traits::key_type const& key
+ , typename traits::data_type const& data
+ );
+
+ iterator add_child(typename traits::key_type const& key);
+
+ iterator
+ add_child_copy(
+ typename traits::key_type const& key
+ , Derived const& copy
+ );
+
+ const_iterator begin() const;
+
+ iterator begin();
+
+ const_iterator end() const;
+
+ iterator end();
+
+ bool empty() const;
+
+ void clear();
+
+ const_iterator
+ find_child(typename traits::key_type const& key) const;
+
+ iterator find_child(typename traits::key_type const& key);
+
+ ::std::pair<const_iterator,const_iterator>
+ find_children(typename traits::key_type const& key) const;
+
+ ::std::pair<iterator,iterator>
+ find_children(typename traits::key_type const& key);
+
+ ::std::size_t remove_children(typename traits::key_type const& key);
+
+ //<-
+ private:
+ template <typename Arg>
+ iterator
+ _add_child(
+ typename traits::key_type const& key
+ , Arg const& arg
+ );
+
+ template <typename Arg>
+ iterator
+ _add_child(
+ typename traits::key_type const& key
+ , Arg const& arg
+ , ::boost::mpl::true_
+ );
+
+ template <typename Arg>
+ iterator
+ _add_child(
+ typename traits::key_type const& key
+ , Arg const& arg
+ , ::boost::mpl::false_
+ );
+
+ iterator _add_child_def(typename traits::key_type const& key);
+
+ iterator
+ _add_child_def(
+ typename traits::key_type const& key
+ , ::boost::mpl::true_
+ );
+
+ iterator
+ _add_child_def(
+ typename traits::key_type const& key
+ , ::boost::mpl::false_
+ );
+ // We shouldn't need all of these, but we do.
+
+ void _initialize(iterator& itr);
+
+ void _clone(associative_node_base const& copy);
+ //->
+ };
+
+ //<-
+ template <typename Derived, typename K, typename D, typename A>
+ associative_node_base<Derived,K,D,A>::associative_node_base()
+ : _children(), _parent(), _data()
+ {
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ associative_node_base<Derived,K,D,A>::associative_node_base(
+ typename traits::data_type const& data
+ ) : _children(), _parent(), _data(data)
+ {
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ associative_node_base<Derived,K,D,A>::associative_node_base(
+ associative_node_base const& copy
+ ) : _children(), _parent(), _data(copy._data)
+ {
+ _clone(copy);
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ associative_node_base<Derived,K,D,A>::associative_node_base(
+ BOOST_RV_REF(associative_node_base) source
+ ) : _children(::boost::move(source._children))
+ , _parent()
+ , _data(::boost::move(source._data))
+ {
+ this->shallow_update_derived();
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ associative_node_base<Derived,K,D,A>&
+ associative_node_base<Derived,K,D,A>::operator=(
+ BOOST_COPY_ASSIGN_REF(associative_node_base) copy
+ )
+ {
+ if (this != &copy)
+ {
+ associative_node_base twin(copy);
+
+ _children = ::boost::move(twin._children);
+ _data = ::boost::move(twin._data);
+
+ for (iterator itr = begin(); itr != end(); ++itr)
+ {
+ itr->second._parent = this->get_derived();
+ }
+
+ this->shallow_update_derived();
+ }
+
+ return *this;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ associative_node_base<Derived,K,D,A>&
+ associative_node_base<Derived,K,D,A>::operator=(
+ BOOST_RV_REF(associative_node_base) source
+ )
+ {
+ if (this != &source)
+ {
+ _children = ::boost::move(source._children);
+ _data = ::boost::move(source._data);
+
+ for (iterator itr = begin(); itr != end(); ++itr)
+ {
+ itr->second._parent = this->get_derived();
+ }
+
+ this->shallow_update_derived();
+ }
+
+ return *this;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<
+ Derived
+ , K
+ , D
+ , A
+ >::traits::data_type const&
+ associative_node_base<Derived,K,D,A>::get_data() const
+ {
+ return _data;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<
+ Derived
+ , K
+ , D
+ , A
+ >::traits::data_type&
+ associative_node_base<Derived,K,D,A>::get_data()
+ {
+ return _data;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<Derived,K,D,A>::const_pointer
+ associative_node_base<Derived,K,D,A>::get_parent_ptr() const
+ {
+ return _parent;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<Derived,K,D,A>::pointer
+ associative_node_base<Derived,K,D,A>::get_parent_ptr()
+ {
+ return _parent;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::add_child(
+ typename traits::key_type const& key
+ , typename traits::data_type const& data
+ )
+ {
+ iterator result = _add_child(key, data);
+ this->shallow_update_derived();
+ return result;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::add_child(
+ typename traits::key_type const& key
+ )
+ {
+ iterator result = _add_child_def(key);
+ this->shallow_update_derived();
+ return result;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::add_child_copy(
+ typename traits::key_type const& key
+ , Derived const& copy
+ )
+ {
+ iterator result = _add_child(key, copy);
+ this->shallow_update_derived();
+ return result;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<
+ Derived
+ , K
+ , D
+ , A
+ >::const_iterator
+ associative_node_base<Derived,K,D,A>::begin() const
+ {
+ return _children.begin();
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::begin()
+ {
+ return _children.begin();
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<
+ Derived
+ , K
+ , D
+ , A
+ >::const_iterator
+ associative_node_base<Derived,K,D,A>::end() const
+ {
+ return _children.end();
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::end()
+ {
+ return _children.end();
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline bool associative_node_base<Derived,K,D,A>::empty() const
+ {
+ return _children.empty();
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline void associative_node_base<Derived,K,D,A>::clear()
+ {
+ _children.clear();
+ this->shallow_update_derived();
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<Derived,K,D,A>::const_iterator
+ associative_node_base<Derived,K,D,A>::find_child(
+ typename traits::key_type const& key
+ ) const
+ {
+ return _children.find(key);
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::find_child(
+ typename traits::key_type const& key
+ )
+ {
+ return _children.find(key);
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline ::std::pair<
+ typename associative_node_base<Derived,K,D,A>::const_iterator
+ , typename associative_node_base<Derived,K,D,A>::const_iterator
+ >
+ associative_node_base<Derived,K,D,A>::find_children(
+ typename traits::key_type const& key
+ ) const
+ {
+ return _children.equal_range(key);
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline ::std::pair<
+ typename associative_node_base<Derived,K,D,A>::iterator
+ , typename associative_node_base<Derived,K,D,A>::iterator
+ >
+ associative_node_base<Derived,K,D,A>::find_children(
+ typename traits::key_type const& key
+ )
+ {
+ return _children.equal_range(key);
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ ::std::size_t
+ associative_node_base<Derived,K,D,A>::remove_children(
+ typename traits::key_type const& key
+ )
+ {
+ ::std::size_t result = _children.erase(key);
+
+ this->shallow_update_derived();
+ return result;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ template <typename Arg>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::_add_child(
+ typename traits::key_type const& key
+ , Arg const& arg
+ )
+ {
+ return _add_child(key, arg, ::boost::is_unordered_selector<A>());
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ template <typename Arg>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::_add_child(
+ typename traits::key_type const& key
+ , Arg const& arg
+ , ::boost::mpl::true_
+ )
+ {
+#ifdef BOOST_MSVC
+ ::std::pair<iterator,bool> p = _children.emplace(
+ ::boost::move(::std::make_pair(key, arg))
+ );
+
+ if (p.second)
+ {
+ _initialize(p.first);
+ }
+
+ return p.first;
+#else
+ iterator child_itr = _children.emplace(key, Derived(arg));
+ _initialize(child_itr);
+ return child_itr;
+#endif
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ template <typename Arg>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::_add_child(
+ typename traits::key_type const& key
+ , Arg const& arg
+ , ::boost::mpl::false_
+ )
+ {
+ iterator child_itr = _children.emplace(key, arg);
+ _initialize(child_itr);
+ return child_itr;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::_add_child_def(
+ typename traits::key_type const& key
+ )
+ {
+ return _add_child_def(key, ::boost::is_unordered_selector<A>());
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::_add_child_def(
+ typename traits::key_type const& key
+ , ::boost::mpl::true_
+ )
+ {
+#ifdef BOOST_MSVC
+ ::std::pair<iterator,bool> p = _children.emplace(
+ ::boost::move(::std::make_pair(key, D()))
+ );
+
+ if (p.second)
+ {
+ _initialize(p.first);
+ }
+
+ return p.first;
+#else
+ iterator child_itr = _children.emplace(key, Derived());
+ _initialize(child_itr);
+ return child_itr;
+#endif
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ typename associative_node_base<Derived,K,D,A>::iterator
+ associative_node_base<Derived,K,D,A>::_add_child_def(
+ typename traits::key_type const& key
+ , ::boost::mpl::false_
+ )
+ {
+ iterator child_itr = _children.emplace(key);
+ _initialize(child_itr);
+ return child_itr;
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ inline void
+ associative_node_base<Derived,K,D,A>::_initialize(iterator& itr)
+ {
+ itr->second._parent = this->get_derived();
+ itr->second.set_position_derived(itr, ::boost::mpl::false_());
+ }
+
+ template <typename Derived, typename K, typename D, typename A>
+ void
+ associative_node_base<Derived,K,D,A>::_clone(
+ associative_node_base const& copy
+ )
+ {
+ pointer p = this->get_derived();
+
+ for (
+ depth_first_descendant_iterator<Derived const> copy_itr(
+ *copy.get_derived()
+ );
+ copy_itr;
+ ++copy_itr
+ )
+ {
+ switch (traversal_state(copy_itr))
+ {
+ case pre_order_traversal:
+ {
+ p = &p->_add_child(
+ copy_itr->first
+ , copy_itr->second.get_data()
+ )->second;
+ break;
+ }
+
+ case post_order_traversal:
+ {
+ p = p->_parent;
+ break;
+ }
+ }
+ }
+
+ this->deep_update_derived();
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__nary_node_base__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename K, typename D, typename A>
+ bool
+ operator==(
+ associative_node_base<Derived,K,D,A> const& lhs
+ , associative_node_base<Derived,K,D,A> const& rhs
+ );
+
+ //<-
+ template <typename Derived, typename K, typename D, typename A>
+ bool
+ operator==(
+ associative_node_base<Derived,K,D,A> const& lhs
+ , associative_node_base<Derived,K,D,A> const& rhs
+ )
+ {
+ if (lhs.get_data() == rhs.get_data())
+ {
+ return ::boost::tree_node::equal(
+ breadth_first_descendant_iterator<Derived const>(
+ *lhs.get_derived()
+ )
+ , breadth_first_descendant_iterator<Derived const>(
+ *rhs.get_derived()
+ )
+ );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__nary_node_base__operator_less_than
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename K, typename D, typename A>
+ bool
+ operator<(
+ associative_node_base<Derived,K,D,A> const& lhs
+ , associative_node_base<Derived,K,D,A> const& rhs
+ );
+
+ //<-
+ template <typename Derived, typename K, typename D, typename A>
+ bool
+ operator<(
+ associative_node_base<Derived,K,D,A> const& lhs
+ , associative_node_base<Derived,K,D,A> const& rhs
+ )
+ {
+ if (lhs.get_data() < rhs.get_data())
+ {
+ return true;
+ }
+
+ if (lhs.get_data() == rhs.get_data())
+ {
+ return ::boost::tree_node::lexicographical_compare(
+ breadth_first_descendant_iterator<Derived const>(
+ *lhs.get_derived()
+ )
+ , breadth_first_descendant_iterator<Derived const>(
+ *rhs.get_derived()
+ )
+ );
+ }
+
+ return false;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__associative_node
+namespace boost { namespace tree_node {
+
+ template <
+ typename Key
+ , typename Data
+ , typename AssociativeContainerSelector = ::boost::mapS
+ >
+ class associative_node
+ : public associative_node_base<
+ associative_node<Key,Data,AssociativeContainerSelector>
+ , Key
+ , Data
+ , AssociativeContainerSelector
+ >
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(associative_node);
+ //->
+ typedef associative_node_base<
+ associative_node
+ , Key
+ , Data
+ , AssociativeContainerSelector
+ >
+ super_t;
+
+ public:
+ typedef typename super_t::traits
+ traits;
+ typedef typename super_t::pointer
+ pointer;
+ typedef typename super_t::const_pointer
+ const_pointer;
+ typedef typename super_t::iterator
+ iterator;
+ typedef typename super_t::const_iterator
+ const_iterator;
+
+ associative_node();
+
+ explicit associative_node(typename traits::data_type const& data);
+
+//<-
+#if 0
+//->
+ associative_node(associative_node const& copy);
+
+ associative_node(associative_node&& source);
+
+ associative_node& operator=(associative_node const& copy);
+
+ associative_node& operator=(associative_node&& source);
+//<-
+#endif
+
+ associative_node(BOOST_RV_REF(associative_node) source);
+
+ associative_node&
+ operator=(BOOST_COPY_ASSIGN_REF(associative_node) copy);
+
+ associative_node& operator=(BOOST_RV_REF(associative_node) source);
+//->
+ };
+
+ //<-
+ template <typename K, typename D, typename A>
+ associative_node<K,D,A>::associative_node() : super_t()
+ {
+ }
+
+ template <typename K, typename D, typename A>
+ associative_node<K,D,A>::associative_node(
+ typename traits::data_type const& data
+ ) : super_t(data)
+ {
+ }
+
+ template <typename K, typename D, typename A>
+ associative_node<K,D,A>::associative_node(
+ BOOST_RV_REF(associative_node) source
+ ) : super_t(::boost::move(static_cast<super_t&>(source)))
+ {
+ }
+
+ template <typename K, typename D, typename A>
+ inline associative_node<K,D,A>&
+ associative_node<K,D,A>::operator=(
+ BOOST_COPY_ASSIGN_REF(associative_node) copy
+ )
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ return *this;
+ }
+
+ template <typename K, typename D, typename A>
+ inline associative_node<K,D,A>&
+ associative_node<K,D,A>::operator=(
+ BOOST_RV_REF(associative_node) source
+ )
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ return *this;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__associative_node_gen
+namespace boost { namespace tree_node {
+
+ template <typename Selector = ::boost::mapS>
+ struct associative_node_gen
+ {
+ template <typename Derived, typename Key, typename Data>
+ struct apply
+ {
+ typedef associative_node_base<Derived,Key,Data,Selector> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_ASSOCIATIVE_NODE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/base.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/base.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,116 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_BASE_HPP_INCLUDED
+#define BOOST_TREE_NODE_BASE_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/detail/base_pointee.hpp>
+
+//[reference__tree_node_base
+namespace boost { namespace tree_node {
+
+ template <typename Derived>
+ struct tree_node_base
+ //<-
+ : public ::boost::detail::base_pointee<Derived>
+ //->
+ {
+ typedef // implementation_defined
+ //<-
+ typename ::boost::detail::base_pointee<Derived>::pointer
+ //->
+ pointer;
+ typedef // implementation_defined
+ //<-
+ typename ::boost::detail::base_pointee<Derived>::const_pointer
+ //->
+ const_pointer;
+
+ protected:
+ void shallow_update_impl();
+
+ void deep_update_impl();
+
+ template <typename Iterator>
+ void set_position_impl(Iterator position, ::boost::mpl::true_);
+
+ template <typename Iterator>
+ void set_position_impl(Iterator position, ::boost::mpl::false_);
+
+ void shallow_update_derived();
+
+ void deep_update_derived();
+
+ template <typename Iterator, typename BooleanIntegralConstant>
+ void
+ set_position_derived(
+ Iterator position
+ , BooleanIntegralConstant invalidates_sibling_positions
+ );
+ };
+
+ //<-
+ template <typename Derived>
+ inline void tree_node_base<Derived>::shallow_update_impl()
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::deep_update_impl()
+ {
+ }
+
+ template <typename Derived>
+ template <typename Iterator>
+ inline void
+ tree_node_base<Derived>::set_position_impl(
+ Iterator position
+ , ::boost::mpl::true_
+ )
+ {
+ }
+
+ template <typename Derived>
+ template <typename Iterator>
+ inline void
+ tree_node_base<Derived>::set_position_impl(
+ Iterator position
+ , ::boost::mpl::false_
+ )
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::shallow_update_derived()
+ {
+ this->get_derived()->shallow_update_impl();
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::deep_update_derived()
+ {
+ this->get_derived()->deep_update_impl();
+ }
+
+ template <typename Derived>
+ template <typename Iterator, typename BooleanIntegralConstant>
+ inline void
+ tree_node_base<Derived>::set_position_derived(
+ Iterator position
+ , BooleanIntegralConstant invalidates_sibling_positions
+ )
+ {
+ this->get_derived()->set_position_impl(
+ position
+ , invalidates_sibling_positions
+ );
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_BASE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/binary_node.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/binary_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,867 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_BINARY_NODE_HPP_INCLUDED
+#define BOOST_TREE_NODE_BINARY_NODE_HPP_INCLUDED
+
+#include <iterator>
+#include <boost/config.hpp>
+#include <boost/mpl/bool.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/move/move.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/depth_first_desc_iterator.hpp>
+#include <boost/tree_node/in_order_iterator.hpp>
+#include <boost/tree_node/algorithm/equal.hpp>
+#include <boost/tree_node/algorithm/lexicographical_compare.hpp>
+
+//[reference__binary_node_base
+namespace boost { namespace tree_node {
+ //<-
+ namespace _detail {
+
+ template <typename Node>
+ class binary_child_iterator
+ {
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ public:
+ typedef ::std::bidirectional_iterator_tag iterator_category;
+ typedef Node value_type;
+ typedef ::std::ptrdiff_t difference_type;
+ typedef value_type* pointer;
+ typedef value_type& reference;
+
+// private:
+ pointer _current;
+
+ public:
+ binary_child_iterator();
+
+ binary_child_iterator(pointer const& p, bool p_is_child);
+
+ template <typename N>
+ binary_child_iterator(
+ binary_child_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+ );
+
+ reference operator*() const;
+
+ pointer operator->() const;
+
+ binary_child_iterator& operator++();
+
+ binary_child_iterator operator++(int);
+
+ binary_child_iterator& operator--();
+
+ binary_child_iterator operator--(int);
+
+ private:
+ void _iterate(pointer const& sibling);
+
+ template <typename N1, typename N2>
+ friend bool
+ operator==(
+ binary_child_iterator<N1> const& lhs
+ , binary_child_iterator<N2> const& rhs
+ );
+ };
+
+ template <typename Node>
+ binary_child_iterator<Node>::binary_child_iterator() : _current(0)
+ {
+ }
+
+ template <typename Node>
+ binary_child_iterator<Node>::binary_child_iterator(
+ pointer const& p
+ , bool p_is_child
+ ) : _current(
+ p_is_child
+ ? p
+ : p->get_left_child_ptr()
+ ? p->get_left_child_ptr()
+ : p->get_right_child_ptr()
+ )
+ {
+ }
+
+ template <typename Node>
+ template <typename N>
+ binary_child_iterator<Node>::binary_child_iterator(
+ binary_child_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+ ) : _current(other._current)
+ {
+ }
+
+ template <typename Node>
+ inline typename binary_child_iterator<Node>::reference
+ binary_child_iterator<Node>::operator*() const
+ {
+ return *_current;
+ }
+
+ template <typename Node>
+ inline typename binary_child_iterator<Node>::pointer
+ binary_child_iterator<Node>::operator->() const
+ {
+ return _current;
+ }
+
+ template <typename Node>
+ inline binary_child_iterator<Node>&
+ binary_child_iterator<Node>::operator++()
+ {
+ _iterate(_current->get_parent_ptr()->get_right_child_ptr());
+ return *this;
+ }
+
+ template <typename Node>
+ binary_child_iterator<Node> binary_child_iterator<Node>::operator++(int)
+ {
+ binary_child_iterator itr(*this);
+ ++(*this);
+ return itr;
+ }
+
+ template <typename Node>
+ inline binary_child_iterator<Node>&
+ binary_child_iterator<Node>::operator--()
+ {
+ _iterate(_current->get_parent_ptr()->get_left_child_ptr());
+ return *this;
+ }
+
+ template <typename Node>
+ binary_child_iterator<Node> binary_child_iterator<Node>::operator--(int)
+ {
+ binary_child_iterator itr(*this);
+ --(*this);
+ return itr;
+ }
+
+ template <typename Node>
+ inline void binary_child_iterator<Node>::_iterate(pointer const& sibling)
+ {
+ _current = (_current == sibling) ? 0 : sibling;
+ }
+
+ template <typename N1, typename N2>
+ inline bool
+ operator==(
+ binary_child_iterator<N1> const& lhs
+ , binary_child_iterator<N2> const& rhs
+ )
+ {
+ return lhs._current == rhs._current;
+ }
+
+ template <typename N1, typename N2>
+ inline bool
+ operator!=(
+ binary_child_iterator<N1> const& lhs
+ , binary_child_iterator<N2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ } // namespace _detail
+ //->
+
+ template <typename Derived, typename T>
+ class binary_node_base : public tree_node_base<Derived>
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(binary_node_base);
+ //->
+
+ public:
+ struct traits
+ {
+ typedef T data_type;
+ };
+
+ typedef typename tree_node_base<Derived>::pointer
+ pointer;
+ typedef typename tree_node_base<Derived>::const_pointer
+ const_pointer;
+ typedef // implementation_defined
+ //<-
+ _detail::binary_child_iterator<Derived>
+ //->
+ iterator;
+ typedef // implementation_defined
+ //<-
+ _detail::binary_child_iterator<Derived const>
+ //->
+ const_iterator;
+
+ //<-
+ private:
+ pointer _left_child;
+ pointer _right_child;
+ pointer _parent;
+ typename traits::data_type _data;
+
+ public:
+ //->
+ binary_node_base();
+
+ explicit binary_node_base(typename traits::data_type const& data);
+
+ binary_node_base(binary_node_base const& copy);
+
+//<-
+#if 0
+//->
+ binary_node_base(binary_node_base&& source);
+
+ binary_node_base& operator=(binary_node_base const& copy);
+
+ binary_node_base& operator=(binary_node_base&& source);
+//<-
+#endif
+
+ binary_node_base(BOOST_RV_REF(binary_node_base) source);
+
+ binary_node_base&
+ operator=(BOOST_COPY_ASSIGN_REF(binary_node_base) copy);
+
+ binary_node_base& operator=(BOOST_RV_REF(binary_node_base) source);
+//->
+
+ ~binary_node_base();
+
+ typename traits::data_type const& get_data() const;
+
+ typename traits::data_type& get_data();
+
+ const_pointer get_parent_ptr() const;
+
+ pointer get_parent_ptr();
+
+ iterator add_left_child(typename traits::data_type const& data);
+
+ iterator add_left_child();
+
+ iterator add_left_child_copy(Derived const& copy);
+
+ iterator add_right_child(typename traits::data_type const& data);
+
+ iterator add_right_child();
+
+ iterator add_right_child_copy(Derived const& copy);
+
+ const_pointer get_left_child_ptr() const;
+
+ pointer get_left_child_ptr();
+
+ const_pointer get_right_child_ptr() const;
+
+ pointer get_right_child_ptr();
+
+ const_iterator begin() const;
+
+ iterator begin();
+
+ const_iterator end() const;
+
+ iterator end();
+
+ bool empty() const;
+
+ void clear();
+
+ pointer rotate_left();
+
+ pointer rotate_right();
+
+ void remove_left_child();
+
+ void remove_right_child();
+
+ //<-
+ private:
+ iterator _add_child(pointer const& child);
+
+ void _clone(binary_node_base const& copy);
+ //->
+ };
+
+ //<-
+ template <typename Derived, typename T>
+ binary_node_base<Derived,T>::binary_node_base()
+ : _left_child(), _right_child(), _parent(), _data()
+ {
+ }
+
+ template <typename Derived, typename T>
+ binary_node_base<Derived,T>::binary_node_base(
+ typename traits::data_type const& data
+ ) : _left_child(), _right_child(), _parent(), _data(data)
+ {
+ }
+
+ template <typename Derived, typename T>
+ binary_node_base<Derived,T>::binary_node_base(
+ binary_node_base const& copy
+ ) : _left_child(), _right_child(), _parent(), _data(copy._data)
+ {
+ _clone(copy);
+ }
+
+ template <typename Derived, typename T>
+ binary_node_base<Derived,T>::binary_node_base(
+ BOOST_RV_REF(binary_node_base) source
+ ) : _left_child(source._left_child)
+ , _right_child(source._right_child)
+ , _parent()
+ , _data(::boost::move(source._data))
+ {
+ this->shallow_update_derived();
+ source._left_child = source._right_child = 0;
+ }
+
+ template <typename Derived, typename T>
+ binary_node_base<Derived,T>&
+ binary_node_base<Derived,T>::operator=(
+ BOOST_COPY_ASSIGN_REF(binary_node_base) copy
+ )
+ {
+ if (this != &copy)
+ {
+ binary_node_base twin(copy);
+
+ delete _left_child;
+ delete _right_child;
+ _left_child = twin._left_child;
+ _right_child = twin._right_child;
+ _left_child->_parent = _right_child->_parent = this->get_derived();
+ _data = ::boost::move(twin._data);
+ this->shallow_update_derived();
+ twin._left_child = twin._right_child = 0;
+ }
+
+ return *this;
+ }
+
+ template <typename Derived, typename T>
+ inline binary_node_base<Derived,T>&
+ binary_node_base<Derived,T>::operator=(
+ BOOST_RV_REF(binary_node_base) source
+ )
+ {
+ if (this != &source)
+ {
+ _left_child = source._left_child;
+ _right_child = source._right_child;
+ _left_child->_parent = _right_child->_parent = this->get_derived();
+ _data = ::boost::move(source._data);
+ this->shallow_update_derived();
+ source._left_child = source._right_child = 0;
+ }
+
+ return *this;
+ }
+
+ template <typename Derived, typename T>
+ binary_node_base<Derived,T>::~binary_node_base()
+ {
+ delete _left_child;
+ delete _right_child;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::traits::data_type const&
+ binary_node_base<Derived,T>::get_data() const
+ {
+ return _data;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::traits::data_type&
+ binary_node_base<Derived,T>::get_data()
+ {
+ return _data;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::const_pointer
+ binary_node_base<Derived,T>::get_parent_ptr() const
+ {
+ return _parent;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::pointer
+ binary_node_base<Derived,T>::get_parent_ptr()
+ {
+ return _parent;
+ }
+
+ template <typename Derived, typename T>
+ typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::add_left_child(
+ typename traits::data_type const& data
+ )
+ {
+ if (_left_child)
+ {
+ return end();
+ }
+ else
+ {
+ return _add_child(_left_child = new Derived(data));
+ }
+ }
+
+ template <typename Derived, typename T>
+ typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::add_left_child()
+ {
+ if (_left_child)
+ {
+ return end();
+ }
+ else
+ {
+ return _add_child(_left_child = new Derived());
+ }
+ }
+
+ template <typename Derived, typename T>
+ typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::add_left_child_copy(Derived const& copy)
+ {
+ if (_left_child)
+ {
+ return end();
+ }
+ else
+ {
+ return _add_child(_left_child = new Derived(copy));
+ }
+ }
+
+ template <typename Derived, typename T>
+ typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::add_right_child(
+ typename traits::data_type const& data
+ )
+ {
+ if (_right_child)
+ {
+ return end();
+ }
+ else
+ {
+ return _add_child(_right_child = new Derived(data));
+ }
+ }
+
+ template <typename Derived, typename T>
+ typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::add_right_child()
+ {
+ if (_right_child)
+ {
+ return end();
+ }
+ else
+ {
+ return _add_child(_right_child = new Derived());
+ }
+ }
+
+ template <typename Derived, typename T>
+ typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::add_right_child_copy(Derived const& copy)
+ {
+ if (_right_child)
+ {
+ return end();
+ }
+ else
+ {
+ return _add_child(_right_child = new Derived(copy));
+ }
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::const_pointer
+ binary_node_base<Derived,T>::get_left_child_ptr() const
+ {
+ return _left_child;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::pointer
+ binary_node_base<Derived,T>::get_left_child_ptr()
+ {
+ return _left_child;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::const_pointer
+ binary_node_base<Derived,T>::get_right_child_ptr() const
+ {
+ return _right_child;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::pointer
+ binary_node_base<Derived,T>::get_right_child_ptr()
+ {
+ return _right_child;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::const_iterator
+ binary_node_base<Derived,T>::begin() const
+ {
+ return const_iterator(this->get_derived(), false);
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::begin()
+ {
+ return iterator(this->get_derived(), false);
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::const_iterator
+ binary_node_base<Derived,T>::end() const
+ {
+ return const_iterator();
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::end()
+ {
+ return iterator();
+ }
+
+ template <typename Derived, typename T>
+ inline bool binary_node_base<Derived,T>::empty() const
+ {
+ return !_left_child && !_right_child;
+ }
+
+ template <typename Derived, typename T>
+ void binary_node_base<Derived,T>::clear()
+ {
+ delete _left_child;
+ delete _right_child;
+ _left_child = _right_child = 0;
+ this->shallow_update_derived();
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::pointer
+ binary_node_base<Derived,T>::rotate_left()
+ {
+ pointer pivot = _right_child;
+
+ pivot->_parent = _parent;
+ _right_child = pivot->_left_child;
+ _right_child->_parent = pivot->_left_child = this->get_derived();
+
+ if (_parent)
+ {
+ if (_parent->_left_child == this->get_derived())
+ {
+ _parent->_left_child = pivot;
+ }
+ else // if (_parent->_right_child == this->get_derived())
+ {
+ _parent->_right_child = pivot;
+ }
+ }
+
+ _parent = pivot;
+ this->shallow_update_derived();
+ return pivot;
+ }
+
+ template <typename Derived, typename T>
+ inline typename binary_node_base<Derived,T>::pointer
+ binary_node_base<Derived,T>::rotate_right()
+ {
+ pointer pivot = _left_child;
+
+ pivot->_parent = _parent;
+ _left_child = pivot->_right_child;
+ _left_child->_parent = pivot->_right_child = this->get_derived();
+
+ if (_parent)
+ {
+ if (_parent->_right_child == this->get_derived())
+ {
+ _parent->_right_child = pivot;
+ }
+ else // if (_parent->_left_child == this->get_derived())
+ {
+ _parent->_left_child = pivot;
+ }
+ }
+
+ _parent = pivot;
+ this->shallow_update_derived();
+ return pivot;
+ }
+
+ template <typename Derived, typename T>
+ void binary_node_base<Derived,T>::remove_left_child()
+ {
+ delete _left_child;
+ _left_child = 0;
+ this->shallow_update_derived();
+ }
+
+ template <typename Derived, typename T>
+ void binary_node_base<Derived,T>::remove_right_child()
+ {
+ delete _right_child;
+ _right_child = 0;
+ this->shallow_update_derived();
+ }
+
+ template <typename Derived, typename T>
+ typename binary_node_base<Derived,T>::iterator
+ binary_node_base<Derived,T>::_add_child(pointer const& child)
+ {
+ iterator result(child, true);
+
+ result->_parent = this->get_derived();
+ result->set_position_derived(result, ::boost::mpl::false_());
+ this->shallow_update_derived();
+ return result;
+ }
+
+ template <typename Derived, typename T>
+ void binary_node_base<Derived,T>::_clone(binary_node_base const& copy)
+ {
+ pointer p = this->get_derived();
+
+ for (
+ depth_first_descendant_iterator<Derived const> copy_itr(
+ *copy.get_derived()
+ );
+ copy_itr;
+ ++copy_itr
+ )
+ {
+ switch (traversal_state(copy_itr))
+ {
+ case pre_order_traversal:
+ {
+ if (copy_itr->_parent->_left_child == &*copy_itr)
+ {
+ p->_left_child = new Derived(copy_itr->get_data());
+ p->_left_child->_parent = p;
+ p = p->_left_child;
+ }
+ else // if (copy_itr->_parent->_right_child == &*copy_itr)
+ {
+ p->_right_child = new Derived(copy_itr->get_data());
+ p->_right_child->_parent = p;
+ p = p->_right_child;
+ }
+
+ p->set_position_derived(
+ iterator(p, true)
+ , ::boost::mpl::false_()
+ );
+ break;
+ }
+
+ case post_order_traversal:
+ {
+ p = p->_parent;
+ break;
+ }
+ }
+ }
+
+ this->deep_update_derived();
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__binary_node_base__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T>
+ bool
+ operator==(
+ binary_node_base<Derived,T> const& lhs
+ , binary_node_base<Derived,T> const& rhs
+ );
+
+ //<-
+ template <typename Derived, typename T>
+ inline bool
+ operator==(
+ binary_node_base<Derived,T> const& lhs
+ , binary_node_base<Derived,T> const& rhs
+ )
+ {
+ return ::boost::tree_node::equal(
+ in_order_iterator<Derived const>(*lhs.get_derived())
+ , in_order_iterator<Derived const>(*rhs.get_derived())
+ );
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__binary_node_base__operator_less_than
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T>
+ bool
+ operator<(
+ binary_node_base<Derived,T> const& lhs
+ , binary_node_base<Derived,T> const& rhs
+ );
+
+ //<-
+ template <typename Derived, typename T>
+ inline bool
+ operator<(
+ binary_node_base<Derived,T> const& lhs
+ , binary_node_base<Derived,T> const& rhs
+ )
+ {
+ return ::boost::tree_node::lexicographical_compare(
+ in_order_iterator<Derived const>(*lhs.get_derived())
+ , in_order_iterator<Derived const>(*rhs.get_derived())
+ );
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__binary_node
+namespace boost { namespace tree_node {
+
+ template <typename T>
+ class binary_node : public binary_node_base<binary_node<T>,T>
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(binary_node);
+ //->
+ typedef binary_node_base<binary_node<T>,T> super_t;
+
+ public:
+ typedef typename super_t::traits traits;
+ typedef typename super_t::pointer pointer;
+ typedef typename super_t::const_pointer const_pointer;
+ typedef typename super_t::iterator iterator;
+ typedef typename super_t::const_iterator const_iterator;
+
+ binary_node();
+
+ explicit binary_node(typename traits::data_type const& data);
+
+//<-
+#if 0
+//->
+ binary_node(binary_node const& copy);
+
+ binary_node(binary_node&& source);
+
+ binary_node& operator=(binary_node const& copy);
+
+ binary_node& operator=(binary_node&& source);
+//<-
+#endif
+
+ binary_node(BOOST_RV_REF(binary_node) source);
+
+ binary_node& operator=(BOOST_COPY_ASSIGN_REF(binary_node) copy);
+
+ binary_node& operator=(BOOST_RV_REF(binary_node) source);
+//->
+ };
+
+ //<-
+ template <typename T>
+ binary_node<T>::binary_node() : super_t()
+ {
+ }
+
+ template <typename T>
+ binary_node<T>::binary_node(typename traits::data_type const& data)
+ : super_t(data)
+ {
+ }
+
+ template <typename T>
+ binary_node<T>::binary_node(BOOST_RV_REF(binary_node) source)
+ : super_t(::boost::move(static_cast<super_t&>(source)))
+ {
+ }
+
+ template <typename T>
+ inline binary_node<T>&
+ binary_node<T>::operator=(
+ BOOST_COPY_ASSIGN_REF(binary_node) copy
+ )
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ return *this;
+ }
+
+ template <typename T>
+ inline binary_node<T>&
+ binary_node<T>::operator=(BOOST_RV_REF(binary_node) source)
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ return *this;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__binary_node_gen
+namespace boost { namespace tree_node {
+
+ struct binary_node_gen
+ {
+ template <typename Derived, typename T>
+ struct apply
+ {
+ typedef binary_node_base<Derived,T> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_BINARY_NODE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/breadth_first_desc_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/breadth_first_desc_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,266 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_BREADTH_FIRST_DESC_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_BREADTH_FIRST_DESC_ITERATOR_HPP_INCLUDED
+
+#include <deque>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+
+//[reference__breadth_first_descendant_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class breadth_first_descendant_iterator
+ : public ::boost::iterator_adaptor<
+ breadth_first_descendant_iterator<Node>
+ //, typename Node::iterator or typename Node::const_iterator
+ //<-
+ , typename ::boost::detail::container_iterator<Node>::type
+ //->
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ {
+ //<-
+ typedef typename ::boost::detail::container_iterator<Node>::type
+ child_iterator;
+ typedef ::boost::iterator_adaptor<
+ breadth_first_descendant_iterator<Node>
+ , child_iterator
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ ::std::deque<child_iterator> _queue;
+ traversal_state _state;
+ //->
+
+ public:
+ breadth_first_descendant_iterator();
+
+ explicit breadth_first_descendant_iterator(Node& node);
+
+ template <typename N>
+ breadth_first_descendant_iterator(
+ breadth_first_descendant_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ private:
+ void _push_children(Node&);
+
+ void _pop();
+
+ template <typename Node1, typename Node2>
+ friend bool
+ operator==(
+ breadth_first_descendant_iterator<Node1> const& lhs
+ , breadth_first_descendant_iterator<Node2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename N>
+ breadth_first_descendant_iterator<N>::breadth_first_descendant_iterator()
+ : super_t(), _queue(), _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ breadth_first_descendant_iterator<Node>::breadth_first_descendant_iterator(
+ Node& node
+ ) : super_t(), _queue(), _state(breadth_first_traversal)
+ {
+ _push_children(node);
+ _pop();
+ }
+
+ template <typename Node>
+ template <typename N>
+ breadth_first_descendant_iterator<Node>::breadth_first_descendant_iterator(
+ breadth_first_descendant_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+ ) : super_t(other.base())
+ , _queue(other._queue.begin(), other._queue.end())
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline breadth_first_descendant_iterator<Node>::operator
+ traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ inline void breadth_first_descendant_iterator<Node>::increment()
+ {
+ _push_children(dereference_iterator(this->base()));
+ _pop();
+ }
+
+ template <typename Node>
+ void breadth_first_descendant_iterator<Node>::_push_children(Node& node)
+ {
+ child_iterator itr_end = node.end();
+
+ for (child_iterator itr = node.begin(); itr != itr_end; ++itr)
+ {
+ _queue.push_back(itr);
+ }
+ }
+
+ template <typename Node>
+ inline void breadth_first_descendant_iterator<Node>::_pop()
+ {
+ if (_queue.empty())
+ {
+ _state = no_traversal;
+ }
+ else
+ {
+ this->base_reference() = _queue.front();
+ _queue.pop_front();
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__breadth_first_descendant_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator==(
+ breadth_first_descendant_iterator<Node1> const& lhs
+ , breadth_first_descendant_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator==(
+ breadth_first_descendant_iterator<Node1> const& lhs
+ , breadth_first_descendant_iterator<Node2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (lhs.base() == rhs.base()) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__breadth_first_descendant_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator!=(
+ breadth_first_descendant_iterator<Node1> const& lhs
+ , breadth_first_descendant_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator!=(
+ breadth_first_descendant_iterator<Node1> const& lhs
+ , breadth_first_descendant_iterator<Node2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_breadth_first_descendant_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ breadth_first_descendant_iterator<Node>
+ make_breadth_first_descendant_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline breadth_first_descendant_iterator<Node>
+ make_breadth_first_descendant_iterator(Node& node)
+ {
+ return breadth_first_descendant_iterator<Node>(node);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__breadth_first_iterate_descendants
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename UnaryFunction>
+ void breadth_first_iterate_descendants(Node& node, UnaryFunction function);
+
+ //<-
+ template <typename Node, typename UnaryFunction>
+ void breadth_first_iterate_descendants(Node& node, UnaryFunction function)
+ {
+ for (breadth_first_descendant_iterator<Node> itr(node); itr; ++itr)
+ {
+ function(*itr);
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_BREADTH_FIRST_DESC_ITERATOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/breadth_first_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/breadth_first_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,249 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_BREADTH_FIRST_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_BREADTH_FIRST_ITERATOR_HPP_INCLUDED
+
+#include <deque>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+
+//[reference__breadth_first_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class breadth_first_iterator
+ : public ::boost::iterator_adaptor<
+ breadth_first_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ {
+ //<-
+ typedef ::boost::iterator_adaptor<
+ breadth_first_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ ::std::deque<Node*> _queue;
+ traversal_state _state;
+ //->
+
+ public:
+ breadth_first_iterator();
+
+ explicit breadth_first_iterator(Node& node);
+
+ template <typename N>
+ breadth_first_iterator(
+ breadth_first_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ private:
+ void _push_children(Node&);
+
+ void _pop();
+
+ template <typename Node1, typename Node2>
+ friend bool
+ operator==(
+ breadth_first_iterator<Node1> const& lhs
+ , breadth_first_iterator<Node2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename Node>
+ breadth_first_iterator<Node>::breadth_first_iterator()
+ : super_t(), _queue(), _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ breadth_first_iterator<Node>::breadth_first_iterator(Node& node)
+ : super_t(&node)
+ , _queue()
+ , _state(breadth_first_traversal)
+ {
+ }
+
+ template <typename Node>
+ template <typename N>
+ breadth_first_iterator<Node>::breadth_first_iterator(
+ breadth_first_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+ ) : super_t(other.base())
+ , _queue(other._queue.begin(), other._queue.end())
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline breadth_first_iterator<Node>::operator traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ void breadth_first_iterator<Node>::increment()
+ {
+ typedef typename ::boost::detail::container_iterator<Node>::type
+ child_iterator;
+
+ child_iterator itr_end = this->base()->end();
+
+ for (child_iterator itr = this->base()->begin(); itr != itr_end; ++itr)
+ {
+ _queue.push_back(&dereference_iterator(itr));
+ }
+
+ if (_queue.empty())
+ {
+ _state = no_traversal;
+ }
+ else
+ {
+ this->base_reference() = _queue.front();
+ _queue.pop_front();
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__breadth_first_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator==(
+ breadth_first_iterator<Node1> const& lhs
+ , breadth_first_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator==(
+ breadth_first_iterator<Node1> const& lhs
+ , breadth_first_iterator<Node2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (lhs.base() == rhs.base()) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__breadth_first_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator!=(
+ breadth_first_iterator<Node1> const& lhs
+ , breadth_first_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator!=(
+ breadth_first_iterator<Node1> const& lhs
+ , breadth_first_iterator<Node2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_breadth_first_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ breadth_first_iterator<Node> make_breadth_first_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline breadth_first_iterator<Node> make_breadth_first_iterator(Node& node)
+ {
+ return breadth_first_iterator<Node>(node);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__breadth_first_iterate
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename UnaryFunction>
+ void breadth_first_iterate(Node& node, UnaryFunction function);
+
+ //<-
+ template <typename Node, typename UnaryFunction>
+ void breadth_first_iterate(Node& node, UnaryFunction function)
+ {
+ for (breadth_first_iterator<Node> itr(node); itr; ++itr)
+ {
+ function(*itr);
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_BREADTH_FIRST_ITERATOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/depth_first_desc_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/depth_first_desc_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,312 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_DEPTH_FIRST_DESC_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_DEPTH_FIRST_DESC_ITERATOR_HPP_INCLUDED
+
+#include <deque>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+
+//[reference__depth_first_descendant_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class depth_first_descendant_iterator
+ : public ::boost::iterator_adaptor<
+ depth_first_descendant_iterator<Node>
+ //, typename Node::iterator or typename Node::const_iterator
+ //<-
+ , typename ::boost::detail::container_iterator<Node>::type
+ //->
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ {
+ //<-
+ typedef typename ::boost::detail::container_iterator<Node>::type
+ child_iterator;
+ typedef ::boost::iterator_adaptor<
+ depth_first_descendant_iterator<Node>
+ , child_iterator
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ ::std::deque<Node*> _node_stack;
+ ::std::deque<child_iterator> _itr_stack;
+ Node* _node_ptr;
+ traversal_state _state;
+ //->
+
+ public:
+ depth_first_descendant_iterator();
+
+ explicit depth_first_descendant_iterator(Node& node);
+
+ template <typename N>
+ depth_first_descendant_iterator(
+ depth_first_descendant_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ template <typename Node1, typename Node2>
+ friend bool
+ operator==(
+ depth_first_descendant_iterator<Node1> const& lhs
+ , depth_first_descendant_iterator<Node2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename Node>
+ depth_first_descendant_iterator<Node>::depth_first_descendant_iterator()
+ : super_t()
+ , _node_stack()
+ , _itr_stack()
+ , _node_ptr()
+ , _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ depth_first_descendant_iterator<Node>::depth_first_descendant_iterator(
+ Node& node
+ ) : super_t()
+ , _node_stack()
+ , _itr_stack()
+ , _node_ptr(&node)
+ , _state(pre_order_traversal)
+ {
+ _itr_stack.push_back(node.begin());
+ increment();
+ }
+
+ template <typename Node>
+ template <typename N>
+ depth_first_descendant_iterator<Node>::depth_first_descendant_iterator(
+ depth_first_descendant_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+ ) : super_t(other.base())
+ , _node_stack(other._node_stack.begin(), other._node_stack.end())
+ , _itr_stack(other._itr_stack.begin(), other._itr_stack.end())
+ , _node_ptr(other._node_ptr)
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline depth_first_descendant_iterator<Node>::operator
+ traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ void depth_first_descendant_iterator<Node>::increment()
+ {
+ if (_state == post_order_traversal)
+ {
+ if (_node_stack.empty())
+ {
+ _state = no_traversal;
+ _itr_stack.clear();
+ }
+ else
+ {
+ _itr_stack.pop_back();
+ _node_ptr = _node_stack.back();
+ _node_stack.pop_back();
+
+ if (++this->base_reference() == _node_ptr->end())
+ {
+ if (_node_stack.empty())
+ {
+ _itr_stack.clear();
+ _state = no_traversal;
+ }
+ else
+ {
+ child_iterator itr = _itr_stack.back();
+
+ _itr_stack.pop_back();
+
+ if (!_itr_stack.empty())
+ {
+ this->base_reference() = _itr_stack.back();
+ }
+
+ _itr_stack.push_back(itr);
+ _state = post_order_traversal;
+ }
+ }
+ else
+ {
+ _itr_stack.pop_back();
+ _node_stack.push_back(_node_ptr);
+ _itr_stack.push_back(this->base());
+ _node_ptr = &dereference_iterator(this->base());
+ _state = pre_order_traversal;
+ _itr_stack.push_back(_node_ptr->begin());
+ }
+ }
+ }
+ else
+ {
+ child_iterator& itr = _itr_stack.back();
+
+ if (itr == _node_ptr->end())
+ {
+ _state = (
+ _node_stack.empty() ? no_traversal : post_order_traversal
+ );
+ }
+ else
+ {
+ _node_stack.push_back(_node_ptr);
+ _node_ptr = &dereference_iterator(
+ this->base_reference() = itr
+ );
+ _state = pre_order_traversal;
+ _itr_stack.push_back(_node_ptr->begin());
+ }
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__depth_first_descendant_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator==(
+ depth_first_descendant_iterator<Node1> const& lhs
+ , depth_first_descendant_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator==(
+ depth_first_descendant_iterator<Node1> const& lhs
+ , depth_first_descendant_iterator<Node2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (*lhs == *rhs) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__depth_first_descendant_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator!=(
+ depth_first_descendant_iterator<Node1> const& lhs
+ , depth_first_descendant_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator!=(
+ depth_first_descendant_iterator<Node1> const& lhs
+ , depth_first_descendant_iterator<Node2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_depth_first_descendant_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ depth_first_descendant_iterator<Node>
+ make_depth_first_descendant_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline depth_first_descendant_iterator<Node>
+ make_depth_first_descendant_iterator(Node& node)
+ {
+ return depth_first_descendant_iterator<Node>(node);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__depth_first_iterate_descendants
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename BinaryFunction>
+ void depth_first_iterate_descendants(Node& node, BinaryFunction function);
+
+ //<-
+ template <typename Node, typename BinaryFunction>
+ void depth_first_iterate_descendants(Node& node, BinaryFunction function)
+ {
+ for (depth_first_iterator<Node> itr(node); itr; ++itr)
+ {
+ function(*itr, traversal_state(itr));
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_DEPTH_FIRST_DESC_ITERATOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/depth_first_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/depth_first_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,298 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_DEPTH_FIRST_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_DEPTH_FIRST_ITERATOR_HPP_INCLUDED
+
+#include <deque>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+
+//[reference__depth_first_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class depth_first_iterator
+ : public ::boost::iterator_adaptor<
+ depth_first_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ {
+ //<-
+ typedef typename ::boost::detail::container_iterator<Node>::type
+ child_iterator;
+ typedef ::boost::iterator_adaptor<
+ depth_first_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ ::std::deque<Node*> _node_stack;
+ ::std::deque<child_iterator> _itr_stack;
+ child_iterator _current_itr;
+ traversal_state _state;
+
+ public:
+ //->
+ depth_first_iterator();
+
+ explicit depth_first_iterator(Node& node);
+
+ template <typename N>
+ depth_first_iterator(
+ depth_first_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ template <typename Node1, typename Node2>
+ friend bool
+ operator==(
+ depth_first_iterator<Node1> const& lhs
+ , depth_first_iterator<Node2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename Node>
+ depth_first_iterator<Node>::depth_first_iterator()
+ : super_t()
+ , _node_stack()
+ , _itr_stack()
+ , _current_itr()
+ , _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ depth_first_iterator<Node>::depth_first_iterator(Node& node)
+ : super_t(&node)
+ , _node_stack()
+ , _itr_stack()
+ , _current_itr()
+ , _state(pre_order_traversal)
+ {
+ _itr_stack.push_back(node.begin());
+ }
+
+ template <typename Node>
+ template <typename N>
+ depth_first_iterator<Node>::depth_first_iterator(
+ depth_first_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+ ) : super_t(other.base())
+ , _node_stack(other._node_stack.begin(), other._node_stack.end())
+ , _itr_stack(other._itr_stack.begin(), other._itr_stack.end())
+ , _current_itr(other._current_itr)
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline depth_first_iterator<Node>::operator traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ void depth_first_iterator<Node>::increment()
+ {
+ if (_state == post_order_traversal)
+ {
+ _itr_stack.pop_back();
+
+ if (_node_stack.empty())
+ {
+ _state = no_traversal;
+ _itr_stack.clear();
+ }
+ else
+ {
+ this->base_reference() = _node_stack.back();
+ _node_stack.pop_back();
+
+ if (++_current_itr == this->base()->end())
+ {
+ child_iterator itr = _itr_stack.back();
+
+ _itr_stack.pop_back();
+
+ if (!_itr_stack.empty())
+ {
+ _current_itr = _itr_stack.back();
+ }
+
+ _itr_stack.push_back(itr);
+ _state = post_order_traversal;
+ }
+ else
+ {
+ _itr_stack.pop_back();
+ _node_stack.push_back(this->base());
+ _itr_stack.push_back(_current_itr);
+ this->base_reference() = &dereference_iterator(
+ _current_itr
+ );
+ _state = pre_order_traversal;
+ _itr_stack.push_back(this->base()->begin());
+ }
+ }
+ }
+ else
+ {
+ child_iterator& itr = _itr_stack.back();
+
+ if (itr == this->base()->end())
+ {
+ _state = post_order_traversal;
+ }
+ else
+ {
+ _node_stack.push_back(this->base());
+ this->base_reference() = &dereference_iterator(
+ _current_itr = itr
+ );
+ _state = pre_order_traversal;
+ _itr_stack.push_back(this->base()->begin());
+ }
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__depth_first_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator==(
+ depth_first_iterator<Node1> const& lhs
+ , depth_first_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator==(
+ depth_first_iterator<Node1> const& lhs
+ , depth_first_iterator<Node2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (*lhs == *rhs) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__depth_first_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator!=(
+ depth_first_iterator<Node1> const& lhs
+ , depth_first_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator!=(
+ depth_first_iterator<Node1> const& lhs
+ , depth_first_iterator<Node2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_depth_first_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ depth_first_iterator<Node> make_depth_first_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline depth_first_iterator<Node> make_depth_first_iterator(Node& node)
+ {
+ return depth_first_iterator<Node>(node);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__depth_first_iterate
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename BinaryFunction>
+ void depth_first_iterate(Node& node, BinaryFunction function);
+
+ //<-
+ template <typename Node, typename BinaryFunction>
+ void depth_first_iterate(Node& node, BinaryFunction function)
+ {
+ for (depth_first_iterator<Node> itr(node); itr; ++itr)
+ {
+ function(*itr, traversal_state(itr));
+ }
+ }
+ //->
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_DEPTH_FIRST_ITERATOR_HPP_INCLUDED
+

Deleted: sandbox/tree_node/boost/tree_node/dereference_iterator.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/dereference_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,110 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_DEREFERENCE_ITERATOR_HPP_INCLUDED
-#define BOOST_TREE_NODE_DEREFERENCE_ITERATOR_HPP_INCLUDED
-
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/fusion/adapted/std_pair.hpp>
-#include <boost/fusion/support/is_sequence.hpp>
-#include <boost/iterator/iterator_traits.hpp>
-
-//[reference__dereference_iterator
-namespace boost { namespace tree_node {
- //<-
- namespace _detail {
-
- template <typename Iterator>
- class dereference_iterator_helper
- {
- typedef typename ::boost::iterator_value<Iterator>::type
- _value_type;
- typedef typename ::boost::fusion::traits::is_sequence<
- _value_type
- >::type
- _is_associative;
-
- struct _associative_result
- {
- typedef typename _value_type::second_type type;
- };
-
- struct _non_associative_result
- {
- typedef _value_type type;
- };
-
- public:
- typedef Iterator
- argument_type;
- typedef typename ::boost::mpl::eval_if<
- _is_associative
- , _associative_result
- , _non_associative_result
- >::type
- result_type;
-
- result_type operator()(argument_type itr) const;
-
- private:
- static result_type _evaluate(Iterator itr, ::boost::mpl::true_);
-
- static result_type _evaluate(Iterator itr, ::boost::mpl::false_);
- };
-
- template <typename Iterator>
- inline typename dereference_iterator_helper<Iterator>::result_type
- dereference_iterator_helper<Iterator>::operator()(
- argument_type itr
- ) const
- {
- return _evaluate(itr, _is_associative());
- }
-
- template <typename Iterator>
- inline typename dereference_iterator_helper<Iterator>::result_type
- dereference_iterator_helper<Iterator>::_evaluate(
- Iterator itr
- , ::boost::mpl::true_
- )
- {
- return itr->second;
- }
-
- template <typename Iterator>
- inline typename dereference_iterator_helper<Iterator>::result_type
- dereference_iterator_helper<Iterator>::_evaluate(
- Iterator itr
- , ::boost::mpl::false_
- )
- {
- return *itr;
- }
- } // namespace _detail
- //->
-
-//<-
-#if 0
-//->
- template <typename Iterator>
- implementation_defined dereference_iterator(Iterator itr);
-//<-
-#endif
-//->
-
- //<-
- template <typename Iterator>
- inline typename _detail::dereference_iterator_helper<Iterator>::result_type
- dereference_iterator(Iterator itr)
- {
- return _detail::dereference_iterator_helper<Iterator>()(itr);
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_DEREFERENCE_ITERATOR_HPP_INCLUDED
-

Deleted: sandbox/tree_node/boost/tree_node/factory.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/factory.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,39 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_FACTORY_HPP_INCLUDED
-#define BOOST_TREE_NODE_FACTORY_HPP_INCLUDED
-
-//[reference__factory
-namespace boost { namespace tree_node {
-
- template <typename Node>
- struct factory
- {
- static typename Node::pointer create();
-
- static typename Node::pointer
- create(typename Node::traits::data_type const& data);
- };
-
- //<-
- template <typename Node>
- typename Node::pointer factory<Node>::create()
- {
- return typename Node::pointer(new Node());
- }
-
- template <typename Node>
- typename Node::pointer
- factory<Node>::create(typename Node::traits::data_type const& data)
- {
- return typename Node::pointer(new Node(data));
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_FACTORY_HPP_INCLUDED
-

Added: sandbox/tree_node/boost/tree_node/in_order_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/in_order_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,345 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_IN_ORDER_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_IN_ORDER_ITERATOR_HPP_INCLUDED
+
+#include <iterator>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+
+//[reference__in_order_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class in_order_iterator
+ : public ::boost::iterator_adaptor<
+ in_order_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::bidirectional_traversal_tag
+ >
+ {
+ //<-
+ typedef ::boost::iterator_adaptor<
+ in_order_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::bidirectional_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ Node* _root_parent_ptr;
+ traversal_state _state;
+ //->
+
+ public:
+ in_order_iterator();
+
+ explicit in_order_iterator(Node& node, bool start_left = true);
+
+ template <typename N>
+ in_order_iterator(
+ in_order_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ void decrement();
+
+ template <typename N1, typename N2>
+ friend bool
+ operator==(
+ in_order_iterator<N1> const& lhs
+ , in_order_iterator<N2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename Node>
+ in_order_iterator<Node>::in_order_iterator()
+ : super_t(), _root_parent_ptr(), _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ in_order_iterator<Node>::in_order_iterator(Node& node, bool start_left)
+ : super_t(&node)
+ , _root_parent_ptr(node.get_parent_ptr())
+ , _state(in_order_traversal)
+ {
+ if (start_left)
+ {
+ while (this->base()->get_left_child_ptr())
+ {
+ this->base_reference() = this->base()->get_left_child_ptr();
+ }
+ }
+ else
+ {
+ while (this->base()->get_right_child_ptr())
+ {
+ this->base_reference() = this->base()->get_right_child_ptr();
+ }
+ }
+ }
+
+ template <typename Node>
+ template <typename N>
+ in_order_iterator<Node>::in_order_iterator(
+ in_order_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+ ) : super_t(other.base())
+ , _root_parent_ptr(other._root_parent_ptr)
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline in_order_iterator<Node>::operator traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ void in_order_iterator<Node>::increment()
+ {
+ Node* node_ptr = this->base()->get_right_child_ptr();
+
+ if (node_ptr)
+ {
+ while (node_ptr->get_left_child_ptr())
+ {
+ node_ptr = node_ptr->get_left_child_ptr();
+ }
+
+ this->base_reference() = node_ptr;
+ return;
+ }
+
+ node_ptr = this->base();
+
+ for (
+ Node* next_ptr = node_ptr->get_parent_ptr();
+ next_ptr != _root_parent_ptr;
+ next_ptr = next_ptr->get_parent_ptr()
+ )
+ {
+ if (node_ptr == next_ptr->get_left_child_ptr())
+ {
+ this->base_reference() = next_ptr;
+ return;
+ }
+
+ node_ptr = next_ptr;
+ }
+
+ this->base_reference() = _root_parent_ptr = 0;
+ _state = no_traversal;
+ }
+
+ template <typename Node>
+ void in_order_iterator<Node>::decrement()
+ {
+ Node* node_ptr = this->base()->get_left_child_ptr();
+
+ if (node_ptr)
+ {
+ while (node_ptr->get_right_child_ptr())
+ {
+ node_ptr = node_ptr->get_right_child_ptr();
+ }
+
+ this->base_reference() = node_ptr;
+ return;
+ }
+
+ node_ptr = this->base();
+
+ for (
+ Node* next_ptr = node_ptr->get_parent_ptr();
+ next_ptr != _root_parent_ptr;
+ next_ptr = next_ptr->get_parent_ptr()
+ )
+ {
+ if (node_ptr == next_ptr->get_right_child_ptr())
+ {
+ this->base_reference() = next_ptr;
+ return;
+ }
+
+ node_ptr = next_ptr;
+ }
+
+ this->base_reference() = _root_parent_ptr = 0;
+ _state = no_traversal;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__in_order_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename N1, typename N2>
+ bool
+ operator==(
+ in_order_iterator<N1> const& lhs
+ , in_order_iterator<N2> const& rhs
+ );
+
+ //<-
+ template <typename N1, typename N2>
+ inline bool
+ operator==(
+ in_order_iterator<N1> const& lhs
+ , in_order_iterator<N2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (lhs.base() == rhs.base()) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__in_order_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename N1, typename N2>
+ bool
+ operator!=(
+ in_order_iterator<N1> const& lhs
+ , in_order_iterator<N2> const& rhs
+ );
+
+ //<-
+ template <typename N1, typename N2>
+ inline bool
+ operator!=(
+ in_order_iterator<N1> const& lhs
+ , in_order_iterator<N2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_in_order_forward_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ in_order_iterator<Node> make_in_order_forward_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline in_order_iterator<Node>
+ make_in_order_forward_iterator(Node& node)
+ {
+ return in_order_iterator<Node>(node, true);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_in_order_reverse_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ in_order_iterator<Node> make_in_order_reverse_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline in_order_iterator<Node>
+ make_in_order_reverse_iterator(Node& node)
+ {
+ return in_order_iterator<Node>(node, false);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__in_order_iterate_forward
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename UnaryFunction>
+ void in_order_iterate_forward(Node& node, UnaryFunction function);
+
+ //<-
+ template <typename Node, typename UnaryFunction>
+ void in_order_iterate_forward(Node& node, UnaryFunction function)
+ {
+ for (in_order_iterator<Node> itr(node, true); itr; ++itr)
+ {
+ function(*itr);
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__in_order_iterate_reverse
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename UnaryFunction>
+ void in_order_iterate_reverse(Node& node, UnaryFunction function);
+
+ //<-
+ template <typename Node, typename UnaryFunction>
+ void in_order_iterate_reverse(Node& node, UnaryFunction function)
+ {
+ for (in_order_iterator<Node> itr(node, false); itr; --itr)
+ {
+ function(*itr);
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_IN_ORDER_ITERATOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/nary_node.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/nary_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,655 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_NARY_NODE_HPP_INCLUDED
+#define BOOST_TREE_NODE_NARY_NODE_HPP_INCLUDED
+
+#include <utility>
+#include <boost/mpl/bool.hpp>
+#include <boost/move/move.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/utility/container_gen.hpp>
+#include <boost/utility/has_stable_iters_selector.hpp>
+#include <boost/utility/is_associative_selector.hpp>
+#include <boost/utility/is_unordered_selector.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/depth_first_desc_iterator.hpp>
+#include <boost/tree_node/breadth_first_iterator.hpp>
+#include <boost/tree_node/algorithm/equal.hpp>
+#include <boost/tree_node/algorithm/lexicographical_compare.hpp>
+
+//[reference__nary_node_base
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector>
+ class nary_node_base : public tree_node_base<Derived>
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(nary_node_base);
+ typedef typename ::boost::container_gen<Selector,Derived>::type
+ children;
+ //->
+
+ public:
+ struct traits
+ {
+ typedef T data_type;
+ };
+
+ typedef typename tree_node_base<Derived>::pointer
+ pointer;
+ typedef typename tree_node_base<Derived>::const_pointer
+ const_pointer;
+ typedef // implementation_defined
+ //<-
+ typename children::iterator
+ //->
+ iterator;
+ typedef // implementation_defined
+ //<-
+ typename children::const_iterator
+ //->
+ const_iterator;
+
+ //<-
+ private:
+ children _children;
+ pointer _parent;
+ typename traits::data_type _data;
+
+ public:
+ //->
+ nary_node_base();
+
+ explicit nary_node_base(typename traits::data_type const& data);
+
+ nary_node_base(nary_node_base const& copy);
+
+//<-
+#if 0
+//->
+ nary_node_base(nary_node_base&& source);
+
+ nary_node_base& operator=(nary_node_base const& copy);
+
+ nary_node_base& operator=(nary_node_base&& source);
+//<-
+#endif
+
+ nary_node_base(BOOST_RV_REF(nary_node_base) source);
+
+ nary_node_base& operator=(BOOST_COPY_ASSIGN_REF(nary_node_base) copy);
+
+ nary_node_base& operator=(BOOST_RV_REF(nary_node_base) source);
+//->
+
+ pointer clone() const;
+
+ typename traits::data_type const& get_data() const;
+
+ typename traits::data_type& get_data();
+
+ const_pointer get_parent_ptr() const;
+
+ pointer get_parent_ptr();
+
+ iterator add_child(typename traits::data_type const& data);
+
+ iterator add_child();
+
+ iterator add_child_copy(Derived const& copy);
+
+ const_iterator begin() const;
+
+ iterator begin();
+
+ const_iterator end() const;
+
+ iterator end();
+
+ bool empty() const;
+
+ void clear();
+
+ //<-
+ private:
+ template <typename Arg>
+ iterator _add_child(Arg& arg);
+
+ template <typename Arg>
+ iterator _add_child(Arg& arg, ::boost::mpl::true_);
+
+ template <typename Arg>
+ iterator _add_child(Arg& arg, ::boost::mpl::false_);
+
+ template <typename Arg>
+ iterator _add_child_assoc(Arg& arg, ::boost::mpl::true_);
+
+ template <typename Arg>
+ iterator _add_child_assoc(Arg& arg, ::boost::mpl::false_);
+
+ iterator _add_child_def();
+
+ iterator _add_child_def(::boost::mpl::true_);
+
+ iterator _add_child_def(::boost::mpl::false_);
+
+ iterator _add_child_def_assoc(::boost::mpl::true_);
+
+ iterator _add_child_def_assoc(::boost::mpl::false_);
+ // We shouldn't need all of these, but we do.
+
+ void _initialize(iterator& to_child);
+
+ void _clone(nary_node_base const& copy);
+ //->
+ };
+
+ //<-
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::nary_node_base()
+ : _children(), _parent(), _data()
+ {
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::nary_node_base(
+ typename traits::data_type const& data
+ ) : _children(), _parent(), _data(data)
+ {
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::nary_node_base(
+ nary_node_base const& copy
+ ) : _children(), _parent(), _data(copy._data)
+ {
+ _clone(copy);
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::nary_node_base(
+ BOOST_RV_REF(nary_node_base) source
+ ) : _children(::boost::move(source._children))
+ , _parent()
+ , _data(::boost::move(source._data))
+ {
+ this->shallow_update_derived();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>&
+ nary_node_base<Derived,T,Selector>::operator=(
+ BOOST_COPY_ASSIGN_REF(nary_node_base) copy
+ )
+ {
+ if (this != &copy)
+ {
+ nary_node_base twin(copy);
+
+ _children = ::boost::move(twin._children);
+ _data = ::boost::move(twin._data);
+
+ for (iterator itr = begin(); itr != end(); ++itr)
+ {
+ itr->_parent = this->get_derived();
+ }
+
+ this->shallow_update_derived();
+ }
+
+ return *this;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>&
+ nary_node_base<Derived,T,Selector>::operator=(
+ BOOST_RV_REF(nary_node_base) source
+ )
+ {
+ if (this != &source)
+ {
+ _children = ::boost::move(source._children);
+ _data = ::boost::move(source._data);
+
+ for (iterator itr = begin(); itr != end(); ++itr)
+ {
+ itr->_parent = this->get_derived();
+ }
+
+ this->shallow_update_derived();
+ }
+
+ return *this;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<
+ Derived
+ , T
+ , Selector
+ >::traits::data_type const&
+ nary_node_base<Derived,T,Selector>::get_data() const
+ {
+ return _data;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::traits::data_type&
+ nary_node_base<Derived,T,Selector>::get_data()
+ {
+ return _data;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::const_pointer
+ nary_node_base<Derived,T,Selector>::get_parent_ptr() const
+ {
+ return _parent;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::pointer
+ nary_node_base<Derived,T,Selector>::get_parent_ptr()
+ {
+ return _parent;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::add_child(
+ typename traits::data_type const& data
+ )
+ {
+ iterator result(_add_child(data));
+ this->shallow_update_derived();
+ return result;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::add_child()
+ {
+ iterator result(_add_child_def());
+ this->shallow_update_derived();
+ return result;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::add_child_copy(Derived const& copy)
+ {
+ iterator result(_add_child(copy));
+ this->shallow_update_derived();
+ return result;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::const_iterator
+ nary_node_base<Derived,T,Selector>::begin() const
+ {
+ return _children.begin();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::begin()
+ {
+ return _children.begin();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::const_iterator
+ nary_node_base<Derived,T,Selector>::end() const
+ {
+ return _children.end();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::end()
+ {
+ return _children.end();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline bool nary_node_base<Derived,T,Selector>::empty() const
+ {
+ return _children.empty();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void nary_node_base<Derived,T,Selector>::clear()
+ {
+ _children.clear();
+ this->shallow_update_derived();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename Arg>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child(Arg& arg)
+ {
+ return _add_child(arg, ::boost::is_associative_selector<Selector>());
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename Arg>
+ typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child(
+ Arg& arg
+ , ::boost::mpl::true_
+ )
+ {
+ return _add_child_assoc(
+ arg
+ , ::boost::is_unordered_selector<Selector>()
+ );
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename Arg>
+ typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child(
+ Arg& arg
+ , ::boost::mpl::false_
+ )
+ {
+ iterator to_child = _children.emplace(_children.end(), arg);
+ _initialize(to_child);
+ return to_child;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename Arg>
+ typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child_assoc(
+ Arg& arg
+ , ::boost::mpl::true_
+ )
+ {
+ ::std::pair<iterator,bool> p = _children.emplace(arg);
+
+ if (p.second)
+ {
+ _initialize(p.first);
+ }
+
+ return p.first;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename Arg>
+ typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child_assoc(
+ Arg& arg
+ , ::boost::mpl::false_
+ )
+ {
+ iterator to_child = _children.emplace(arg);
+ _initialize(to_child);
+ return to_child;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child_def()
+ {
+ return _add_child_def(::boost::is_associative_selector<Selector>());
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child_def(
+ ::boost::mpl::true_
+ )
+ {
+ return _add_child_def_assoc(
+ ::boost::is_unordered_selector<Selector>()
+ );
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child_def(
+ ::boost::mpl::false_
+ )
+ {
+ iterator to_child = _children.emplace(_children.end());
+ _initialize(to_child);
+ return to_child;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child_def_assoc(
+ ::boost::mpl::true_
+ )
+ {
+ ::std::pair<iterator,bool> p = _children.emplace(
+ ::boost::move(typename traits::data_type())
+ );
+
+ if (p.second)
+ {
+ _initialize(p.first);
+ }
+
+ return p.first;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child_def_assoc(
+ ::boost::mpl::false_
+ )
+ {
+ iterator to_child = _children.emplace();
+ _initialize(to_child);
+ return to_child;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::_initialize(iterator& to_child)
+ {
+ to_child->_parent = this->get_derived();
+ to_child->set_position_derived(
+ to_child
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ void
+ nary_node_base<Derived,T,Selector>::_clone(
+ nary_node_base const& copy
+ )
+ {
+ pointer p = this->get_derived();
+
+ for (
+ depth_first_descendant_iterator<Derived const> copy_itr(
+ *copy.get_derived()
+ );
+ copy_itr;
+ ++copy_itr
+ )
+ {
+ switch (traversal_state(copy_itr))
+ {
+ case pre_order_traversal:
+ {
+ p = &*p->_add_child(copy_itr->get_data());
+ break;
+ }
+
+ case post_order_traversal:
+ {
+ p = p->_parent;
+ break;
+ }
+ }
+ }
+
+ this->deep_update_derived();
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__nary_node_base__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector>
+ bool
+ operator==(
+ nary_node_base<Derived,T,Selector> const& lhs
+ , nary_node_base<Derived,T,Selector> const& rhs
+ );
+
+ //<-
+ template <typename Derived, typename T, typename Selector>
+ bool
+ operator==(
+ nary_node_base<Derived,T,Selector> const& lhs
+ , nary_node_base<Derived,T,Selector> const& rhs
+ )
+ {
+ return ::boost::tree_node::equal(
+ breadth_first_iterator<Derived const>(*lhs.get_derived())
+ , breadth_first_iterator<Derived const>(*rhs.get_derived())
+ );
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__nary_node_base__operator_less_than
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector>
+ bool
+ operator<(
+ nary_node_base<Derived,T,Selector> const& lhs
+ , nary_node_base<Derived,T,Selector> const& rhs
+ );
+
+ //<-
+ template <typename Derived, typename T, typename Selector>
+ bool
+ operator<(
+ nary_node_base<Derived,T,Selector> const& lhs
+ , nary_node_base<Derived,T,Selector> const& rhs
+ )
+ {
+ return ::boost::tree_node::lexicographical_compare(
+ breadth_first_iterator<Derived const>(*lhs.get_derived())
+ , breadth_first_iterator<Derived const>(*rhs.get_derived())
+ );
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__nary_node
+namespace boost { namespace tree_node {
+
+ template <typename T, typename Selector = ::boost::dequeS>
+ class nary_node : public nary_node_base<nary_node<T,Selector>,T,Selector>
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(nary_node);
+ //->
+ typedef nary_node_base<nary_node,T,Selector> super_t;
+
+ public:
+ typedef typename super_t::traits traits;
+ typedef typename super_t::pointer pointer;
+ typedef typename super_t::const_pointer const_pointer;
+ typedef typename super_t::iterator iterator;
+ typedef typename super_t::const_iterator const_iterator;
+
+ nary_node();
+
+ explicit nary_node(typename traits::data_type const& data);
+
+//<-
+#if 0
+//->
+ nary_node(nary_node const& copy);
+
+ nary_node(nary_node&& source);
+
+ nary_node& operator=(nary_node const& copy);
+
+ nary_node& operator=(nary_node&& source);
+//<-
+#endif
+
+ nary_node(BOOST_RV_REF(nary_node) source);
+
+ nary_node& operator=(BOOST_COPY_ASSIGN_REF(nary_node) copy);
+
+ nary_node& operator=(BOOST_RV_REF(nary_node) source);
+//->
+ };
+
+ //<-
+ template <typename T, typename Selector>
+ nary_node<T,Selector>::nary_node() : super_t()
+ {
+ }
+
+ template <typename T, typename Selector>
+ nary_node<T,Selector>::nary_node(typename traits::data_type const& data)
+ : super_t(data)
+ {
+ }
+
+ template <typename T, typename Selector>
+ nary_node<T,Selector>::nary_node(BOOST_RV_REF(nary_node) source)
+ : super_t(::boost::move(static_cast<super_t&>(source)))
+ {
+ }
+
+ template <typename T, typename Selector>
+ inline nary_node<T,Selector>&
+ nary_node<T,Selector>::operator=(
+ BOOST_COPY_ASSIGN_REF(nary_node) copy
+ )
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ return *this;
+ }
+
+ template <typename T, typename Selector>
+ inline nary_node<T,Selector>&
+ nary_node<T,Selector>::operator=(BOOST_RV_REF(nary_node) source)
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ return *this;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__nary_node_gen
+namespace boost { namespace tree_node {
+
+ template <typename Selector = ::boost::dequeS>
+ struct nary_node_gen
+ {
+ template <typename Derived, typename T>
+ struct apply
+ {
+ typedef nary_node_base<Derived,T,Selector> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_NARY_NODE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/post_order_desc_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/post_order_desc_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,288 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_POST_ORDER_DESC_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_POST_ORDER_DESC_ITERATOR_HPP_INCLUDED
+
+#include <deque>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+
+//[reference__post_order_descendant_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class post_order_descendant_iterator
+ : public ::boost::iterator_adaptor<
+ post_order_descendant_iterator<Node>
+ //, typename Node::iterator or typename Node::const_iterator
+ //<-
+ , typename ::boost::detail::container_iterator<Node>::type
+ //->
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ {
+ //<-
+ typedef typename ::boost::detail::container_iterator<Node>::type
+ child_iterator;
+ typedef ::boost::iterator_adaptor<
+ post_order_descendant_iterator<Node>
+ , child_iterator
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ std::deque<child_iterator> _stack;
+ traversal_state _state;
+ //->
+
+ public:
+ post_order_descendant_iterator();
+
+ explicit post_order_descendant_iterator(Node& node);
+
+ template <typename N>
+ post_order_descendant_iterator(
+ post_order_descendant_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ template <typename Node1, typename Node2>
+ friend bool
+ operator==(
+ post_order_descendant_iterator<Node1> const& lhs
+ , post_order_descendant_iterator<Node2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename Node>
+ post_order_descendant_iterator<Node>::post_order_descendant_iterator()
+ : super_t(), _stack(), _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ post_order_descendant_iterator<Node>::post_order_descendant_iterator(
+ Node& node
+ ) : super_t(), _stack(), _state(post_order_traversal)
+ {
+ child_iterator itr = node.begin();
+ child_iterator itr_end = node.end();
+
+ if (itr != itr_end)
+ {
+ ::std::deque<child_iterator> pre_order_stack;
+
+ for (;;)
+ {
+ while (itr != itr_end)
+ {
+ pre_order_stack.push_back(itr);
+ ++itr;
+ }
+
+ _stack.push_back(pre_order_stack.back());
+ pre_order_stack.pop_back();
+
+ if (pre_order_stack.empty())
+ {
+ Node& n = dereference_iterator(
+ this->base_reference() = _stack.back()
+ );
+
+ itr = n.begin();
+ itr_end = n.end();
+
+ if (itr == itr_end)
+ {
+ _stack.pop_back();
+ break;
+ }
+ }
+ else
+ {
+ Node& n = dereference_iterator(_stack.back());
+
+ itr = n.begin();
+ itr_end = n.end();
+ }
+ }
+ }
+
+ if (_stack.empty())
+ {
+ _state = no_traversal;
+ }
+ }
+
+ template <typename Node>
+ template <typename N>
+ post_order_descendant_iterator<Node>::post_order_descendant_iterator(
+ post_order_descendant_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+ ) : super_t(other.base())
+ , _stack(other._stack.begin(), other._stack.end())
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline post_order_descendant_iterator<Node>::operator
+ traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ inline void post_order_descendant_iterator<Node>::increment()
+ {
+ if (_stack.empty())
+ {
+ _state = no_traversal;
+ }
+ else
+ {
+ this->base_reference() = _stack.back();
+ _stack.pop_back();
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__post_order_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator==(
+ post_order_descendant_iterator<Node1> const& lhs
+ , post_order_descendant_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator==(
+ post_order_descendant_iterator<Node1> const& lhs
+ , post_order_descendant_iterator<Node2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (lhs.base() == rhs.base()) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__post_order_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator!=(
+ post_order_descendant_iterator<Node1> const& lhs
+ , post_order_descendant_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator!=(
+ post_order_descendant_iterator<Node1> const& lhs
+ , post_order_descendant_iterator<Node2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_post_order_descendant_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ post_order_descendant_iterator<Node>
+ make_post_order_descendant_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline post_order_descendant_iterator<Node>
+ make_post_order_descendant_iterator(Node& node)
+ {
+ return post_order_descendant_iterator<Node>(node);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__post_order_iterate_descendants
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename UnaryFunction>
+ void post_order_iterate_descendants(Node& node, UnaryFunction function);
+
+ //<-
+ template <typename Node, typename UnaryFunction>
+ void post_order_iterate_descendants(Node& node, UnaryFunction function)
+ {
+ for (post_order_descendant_iterator<Node> itr(node); itr; ++itr)
+ {
+ function(*itr);
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_POST_ORDER_DESC_ITERATOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/post_order_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/post_order_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,279 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_POST_ORDER_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_POST_ORDER_ITERATOR_HPP_INCLUDED
+
+#include <deque>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+
+//[reference__post_order_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class post_order_iterator
+ : public ::boost::iterator_adaptor<
+ post_order_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ {
+ //<-
+ typedef ::boost::iterator_adaptor<
+ post_order_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ std::deque<Node*> _stack;
+ traversal_state _state;
+
+ public:
+ //->
+ post_order_iterator();
+
+ explicit post_order_iterator(Node& node);
+
+ template <typename N>
+ post_order_iterator(
+ post_order_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ template <typename Node1, typename Node2>
+ friend bool
+ operator==(
+ post_order_iterator<Node1> const& lhs
+ , post_order_iterator<Node2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename Node>
+ post_order_iterator<Node>::post_order_iterator()
+ : super_t(), _stack(), _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ post_order_iterator<Node>::post_order_iterator(Node& node)
+ : super_t(&node), _stack(), _state(post_order_traversal)
+ {
+ typedef typename ::boost::detail::container_iterator<Node>::type
+ child_iterator;
+
+ _stack.push_back(&node);
+
+ child_iterator itr = node.begin();
+ child_iterator itr_end = node.end();
+
+ if (itr != itr_end)
+ {
+ ::std::deque<child_iterator> pre_order_stack;
+
+ for (;;)
+ {
+ while (itr != itr_end)
+ {
+ pre_order_stack.push_back(itr);
+ ++itr;
+ }
+
+ _stack.push_back(
+ &dereference_iterator(pre_order_stack.back())
+ );
+ pre_order_stack.pop_back();
+
+ if (pre_order_stack.empty())
+ {
+ Node* node_ptr = this->base_reference() = _stack.back();
+
+ itr = node_ptr->begin();
+ itr_end = node_ptr->end();
+
+ if (itr == itr_end)
+ {
+ _stack.pop_back();
+ break;
+ }
+ }
+ else
+ {
+ Node* node_ptr = _stack.back();
+
+ itr = node_ptr->begin();
+ itr_end = node_ptr->end();
+ }
+ }
+ }
+ }
+
+ template <typename Node>
+ template <typename N>
+ post_order_iterator<Node>::post_order_iterator(
+ post_order_iterator<N> const& other
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+ ) : super_t(other.base())
+ , _stack(other._stack.begin(), other._stack.end())
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline post_order_iterator<Node>::operator traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ inline void post_order_iterator<Node>::increment()
+ {
+ if (_stack.empty())
+ {
+ _state = no_traversal;
+ }
+ else
+ {
+ this->base_reference() = _stack.back();
+ _stack.pop_back();
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__post_order_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator==(
+ post_order_iterator<Node1> const& lhs
+ , post_order_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator==(
+ post_order_iterator<Node1> const& lhs
+ , post_order_iterator<Node2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (lhs.base() == rhs.base()) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__post_order_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator!=(
+ post_order_iterator<Node1> const& lhs
+ , post_order_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator!=(
+ post_order_iterator<Node1> const& lhs
+ , post_order_iterator<Node2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_post_order_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ post_order_iterator<Node> make_post_order_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline post_order_iterator<Node> make_post_order_iterator(Node& node)
+ {
+ return post_order_iterator<Node>(node);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__post_order_iterate
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename UnaryFunction>
+ void post_order_iterate(Node& node, UnaryFunction function);
+
+ //<-
+ template <typename Node, typename UnaryFunction>
+ void post_order_iterate(Node& node, UnaryFunction function)
+ {
+ for (post_order_iterator<Node> itr(node); itr; ++itr)
+ {
+ function(*itr);
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_POST_ORDER_ITERATOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/pre_order_desc_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/pre_order_desc_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,300 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_PRE_ORDER_DESC_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_PRE_ORDER_DESC_ITERATOR_HPP_INCLUDED
+
+#include <deque>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+
+//[reference__pre_order_descendant_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class pre_order_descendant_iterator
+ : public ::boost::iterator_adaptor<
+ pre_order_descendant_iterator<Node>
+ //, typename Node::iterator or typename Node::const_iterator
+ //<-
+ , typename ::boost::detail::container_iterator<Node>::type
+ //->
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ {
+ //<-
+ typedef typename ::boost::detail::container_iterator<Node>::type
+ child_iterator;
+ typedef ::boost::iterator_adaptor<
+ pre_order_descendant_iterator<Node>
+ , child_iterator
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ ::std::deque<Node*> _node_stack;
+ ::std::deque<child_iterator> _itr_stack;
+ Node* _current_node;
+ traversal_state _state;
+ //->
+
+ public:
+ pre_order_descendant_iterator();
+
+ explicit pre_order_descendant_iterator(Node& node);
+
+ template <typename N>
+ pre_order_descendant_iterator(
+ pre_order_descendant_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ template <typename Node1, typename Node2>
+ friend bool
+ operator==(
+ pre_order_descendant_iterator<Node1> const& lhs
+ , pre_order_descendant_iterator<Node2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename Node>
+ pre_order_descendant_iterator<Node>::pre_order_descendant_iterator()
+ : super_t()
+ , _node_stack()
+ , _itr_stack()
+ , _current_node()
+ , _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ pre_order_descendant_iterator<Node>::pre_order_descendant_iterator(
+ Node& node
+ ) : super_t()
+ , _node_stack()
+ , _itr_stack()
+ , _current_node(&node)
+ , _state(pre_order_traversal)
+ {
+ _itr_stack.push_back(node.begin());
+ increment();
+ }
+
+ template <typename Node>
+ template <typename N>
+ pre_order_descendant_iterator<Node>::pre_order_descendant_iterator(
+ pre_order_descendant_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+//->
+ ) : super_t(other.base())
+ , _node_stack(other._node_stack.begin(), other._node_stack.end())
+ , _itr_stack(other._itr_stack.begin(), other._itr_stack.end())
+ , _current_node(other._current_node)
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline pre_order_descendant_iterator<Node>::operator
+ traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ void pre_order_descendant_iterator<Node>::increment()
+ {
+ if (_itr_stack.back() == _current_node->end())
+ {
+ bool is_post_order = true;
+
+ while (is_post_order)
+ {
+ _itr_stack.pop_back();
+
+ if (_node_stack.empty())
+ {
+ _state = no_traversal;
+ _itr_stack.clear();
+ is_post_order = false;
+ }
+ else
+ {
+ _current_node = _node_stack.back();
+ _node_stack.pop_back();
+
+ if (++this->base_reference() == _current_node->end())
+ {
+ child_iterator itr = _itr_stack.back();
+
+ _itr_stack.pop_back();
+
+ if (!_itr_stack.empty())
+ {
+ this->base_reference() = _itr_stack.back();
+ }
+
+ _itr_stack.push_back(itr);
+ }
+ else
+ {
+ _itr_stack.pop_back();
+ _node_stack.push_back(_current_node);
+ _itr_stack.push_back(this->base());
+ _current_node = &dereference_iterator(this->base());
+ _itr_stack.push_back(_current_node->begin());
+ is_post_order = false;
+ }
+ }
+ }
+ }
+ else
+ {
+ _node_stack.push_back(_current_node);
+ _current_node = &dereference_iterator(
+ this->base_reference() = _itr_stack.back()
+ );
+ _itr_stack.push_back(_current_node->begin());
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__pre_order_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator==(
+ pre_order_descendant_iterator<Node1> const& lhs
+ , pre_order_descendant_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator==(
+ pre_order_descendant_iterator<Node1> const& lhs
+ , pre_order_descendant_iterator<Node2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (*lhs == *rhs) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__pre_order_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator!=(
+ pre_order_descendant_iterator<Node1> const& lhs
+ , pre_order_descendant_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator!=(
+ pre_order_descendant_iterator<Node1> const& lhs
+ , pre_order_descendant_iterator<Node2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_pre_order_descendant_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ pre_order_descendant_iterator<Node>
+ make_pre_order_descendant_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline pre_order_descendant_iterator<Node>
+ make_pre_order_descendant_iterator(Node& node)
+ {
+ return pre_order_descendant_iterator<Node>(node);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__pre_order_iterate_descendants
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename UnaryFunction>
+ void pre_order_iterate_descendants(Node& node, UnaryFunction function);
+
+ //<-
+ template <typename Node, typename UnaryFunction>
+ void pre_order_iterate_descendants(Node& node, UnaryFunction function)
+ {
+ for (pre_order_descendant_iterator<Node> itr(node); itr; ++itr)
+ {
+ function(*itr);
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_PRE_ORDER_DESC_ITERATOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/pre_order_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/pre_order_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,294 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_PRE_ORDER_ITERATOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_PRE_ORDER_ITERATOR_HPP_INCLUDED
+
+#include <deque>
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SFINAE
+#include <boost/tr1/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
+#endif
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+
+//[reference__pre_order_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ class pre_order_iterator
+ : public ::boost::iterator_adaptor<
+ pre_order_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ {
+ //<-
+ typedef typename ::boost::detail::container_iterator<Node>::type
+ child_iterator;
+ typedef ::boost::iterator_adaptor<
+ pre_order_iterator<Node>
+ , Node*
+ , ::boost::use_default
+ , ::boost::forward_traversal_tag
+ >
+ super_t;
+
+#ifndef BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ ::std::deque<Node*> _node_stack;
+ ::std::deque<child_iterator> _itr_stack;
+ child_iterator _current_itr;
+ traversal_state _state;
+ //->
+
+ public:
+ pre_order_iterator();
+
+ explicit pre_order_iterator(Node& node);
+
+ template <typename N>
+ pre_order_iterator(
+ pre_order_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type = enabler()
+#endif
+//->
+ );
+
+ operator traversal_state() const;
+
+ //<-
+#if !BOOST_WORKAROUND(__GNUC__, == 2)
+ private:
+ friend class ::boost::iterator_core_access;
+#endif
+
+ void increment();
+
+ template <typename Node1, typename Node2>
+ friend bool
+ operator==(
+ pre_order_iterator<Node1> const& lhs
+ , pre_order_iterator<Node2> const& rhs
+ );
+ //->
+ };
+
+ //<-
+ template <typename Node>
+ pre_order_iterator<Node>::pre_order_iterator()
+ : super_t()
+ , _node_stack()
+ , _itr_stack()
+ , _current_itr()
+ , _state(no_traversal)
+ {
+ }
+
+ template <typename Node>
+ pre_order_iterator<Node>::pre_order_iterator(Node& node)
+ : super_t(&node)
+ , _node_stack()
+ , _itr_stack()
+ , _current_itr()
+ , _state(pre_order_traversal)
+ {
+ _itr_stack.push_back(node.begin());
+ }
+
+ template <typename Node>
+ template <typename N>
+ pre_order_iterator<Node>::pre_order_iterator(
+ pre_order_iterator<N> const& other
+//<-
+#ifndef BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ ::std::tr1::is_convertible<N,Node>
+ , enabler
+ >::type
+#endif
+//->
+ ) : super_t(other.base())
+ , _node_stack(other._node_stack.begin(), other._node_stack.end())
+ , _itr_stack(other._itr_stack.begin(), other._itr_stack.end())
+ , _current_itr(other._current_itr)
+ , _state(other._state)
+ {
+ }
+
+ template <typename Node>
+ inline pre_order_iterator<Node>::operator traversal_state() const
+ {
+ return _state;
+ }
+
+ template <typename Node>
+ void pre_order_iterator<Node>::increment()
+ {
+ if (_itr_stack.back() == this->base()->end())
+ {
+ bool is_post_order = true;
+
+ while (is_post_order)
+ {
+ _itr_stack.pop_back();
+
+ if (_node_stack.empty())
+ {
+ _state = no_traversal;
+ _itr_stack.clear();
+ is_post_order = false;
+ }
+ else
+ {
+ this->base_reference() = _node_stack.back();
+ _node_stack.pop_back();
+
+ if (++_current_itr == this->base()->end())
+ {
+ child_iterator itr = _itr_stack.back();
+
+ _itr_stack.pop_back();
+
+ if (!_itr_stack.empty())
+ {
+ _current_itr = _itr_stack.back();
+ }
+
+ _itr_stack.push_back(itr);
+ }
+ else
+ {
+ _itr_stack.pop_back();
+ _node_stack.push_back(this->base());
+ _itr_stack.push_back(_current_itr);
+ this->base_reference() = &dereference_iterator(
+ _current_itr
+ );
+ _itr_stack.push_back(this->base()->begin());
+ is_post_order = false;
+ }
+ }
+ }
+ }
+ else
+ {
+ _node_stack.push_back(this->base());
+ this->base_reference() = &dereference_iterator(
+ _current_itr = _itr_stack.back()
+ );
+ _itr_stack.push_back(this->base()->begin());
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__pre_order_iterator__operator_equals
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator==(
+ pre_order_iterator<Node1> const& lhs
+ , pre_order_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator==(
+ pre_order_iterator<Node1> const& lhs
+ , pre_order_iterator<Node2> const& rhs
+ )
+ {
+ if (lhs._state == rhs._state)
+ {
+ return lhs._state ? (*lhs == *rhs) : !rhs._state;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__pre_order_iterator__operator_not_equal
+namespace boost { namespace tree_node {
+
+ template <typename Node1, typename Node2>
+ bool
+ operator!=(
+ pre_order_iterator<Node1> const& lhs
+ , pre_order_iterator<Node2> const& rhs
+ );
+
+ //<-
+ template <typename Node1, typename Node2>
+ inline bool
+ operator!=(
+ pre_order_iterator<Node1> const& lhs
+ , pre_order_iterator<Node2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__make_pre_order_iterator
+namespace boost { namespace tree_node {
+
+ template <typename Node>
+ pre_order_iterator<Node> make_pre_order_iterator(Node& node);
+
+ //<-
+ template <typename Node>
+ inline pre_order_iterator<Node> make_pre_order_iterator(Node& node)
+ {
+ return pre_order_iterator<Node>(node);
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__pre_order_iterate
+namespace boost { namespace tree_node {
+
+ template <typename Node, typename UnaryFunction>
+ void pre_order_iterate(Node& node, UnaryFunction function);
+
+ //<-
+ template <typename Node, typename UnaryFunction>
+ void pre_order_iterate(Node& node, UnaryFunction function)
+ {
+ for (pre_order_iterator<Node> itr(node); itr; ++itr)
+ {
+ function(*itr);
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_PRE_ORDER_ITERATOR_HPP_INCLUDED
+

Deleted: sandbox/tree_node/boost/tree_node/raw_associative_node.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/raw_associative_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,598 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_RAW_ASSOCIATIVE_NODE_HPP_INCLUDED
-#define BOOST_TREE_NODE_RAW_ASSOCIATIVE_NODE_HPP_INCLUDED
-
-#include <utility>
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/apply_wrap.hpp>
-#include <boost/tr1/tuple.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-#include <boost/utility/associative_container_gen.hpp>
-#include <boost/tree_node/base.hpp>
-#include <boost/tree_node/depth_first_iterator.hpp>
-#include <boost/tree_node/factory.hpp>
-#include <boost/detail/function/add_const_to_2nd_pointee.hpp>
-
-//[reference__raw_associative_node_base
-namespace boost { namespace tree_node {
-
- template <
- typename Derived
- , typename Key
- , typename Data
- , typename AssociativeContainerSelector
- >
- class raw_associative_node_base : public tree_node_base<Derived>
- {
- public:
- struct traits
- {
- typedef Key key_type;
- typedef Data data_type;
- };
-
- typedef typename tree_node_base<Derived>::pointer
- pointer;
- typedef typename tree_node_base<Derived>::const_pointer
- const_pointer;
-
- //<-
- private:
- typedef typename ::boost::mpl::apply_wrap2<
- associative_container_gen<
- AssociativeContainerSelector
- >
- , typename traits::key_type
- , pointer
- >::type
- children;
-
- public:
- //->
- typedef // implementation_defined
- //<-
- typename children::iterator
- //->
- child_iterator;
- typedef // implementation_defined
- //<-
-#if 0
- ::boost::transform_iterator<
- ::boost::detail::add_const_to_2nd_pointee<
- Key
- , Derived
- >
- , typename children::const_iterator
- >
-#else
- typename children::const_iterator
-#endif
- //->
- const_child_iterator;
-
- //<-
- private:
- children _children;
- pointer _parent;
- typename traits::data_type _data;
-
- public:
- //->
- raw_associative_node_base();
-
- explicit raw_associative_node_base(
- typename traits::data_type const& data
- );
-
- raw_associative_node_base(raw_associative_node_base const& copy);
-
- raw_associative_node_base&
- operator=(raw_associative_node_base const& copy);
-
- virtual ~raw_associative_node_base();
-
- pointer clone() const;
-
- typename traits::data_type const& get_data() const;
-
- typename traits::data_type& get_data();
-
- const_pointer get_parent() const;
-
- pointer get_parent();
-
- pointer
- add_child(
- typename traits::key_type const& key
- , typename traits::data_type const& data
- );
-
- pointer add_child(typename traits::key_type const& key);
-
- pointer
- add_child_copy(
- typename traits::key_type const& key
- , const_pointer const& copy
- );
-
- const_child_iterator get_child_begin() const;
-
- child_iterator get_child_begin();
-
- const_child_iterator get_child_end() const;
-
- child_iterator get_child_end();
-
- const_child_iterator
- find_child(typename traits::key_type const& key) const;
-
- child_iterator find_child(typename traits::key_type const& key);
-
- ::std::pair<const_child_iterator,const_child_iterator>
- find_children(typename traits::key_type const& key) const;
-
- ::std::pair<child_iterator,child_iterator>
- find_children(typename traits::key_type const& key);
-
- ::std::size_t remove_children(typename traits::key_type const& key);
-
- void remove_all_children();
-
- //<-
- private:
- void _remove_all_children();
-
- void
- _add_child(
- typename traits::key_type const& key
- , pointer const& child
- );
- //->
- };
-
- //<-
- template <typename Derived, typename K, typename D, typename A>
- raw_associative_node_base<Derived,K,D,A>::raw_associative_node_base()
- : _children(), _parent(), _data()
- {
- }
-
- template <typename Derived, typename K, typename D, typename A>
- raw_associative_node_base<Derived,K,D,A>::raw_associative_node_base(
- typename traits::data_type const& data
- ) : _children(), _parent(), _data(data)
- {
- }
-
- template <typename Derived, typename K, typename D, typename A>
- raw_associative_node_base<Derived,K,D,A>::raw_associative_node_base(
- raw_associative_node_base const& copy
- ) : _children(), _parent(), _data(copy._data)
- {
- pointer p = this->get_derived();
-
- for (
- depth_first_iterator<const_pointer,::boost::mpl::true_> copy_itr(
- copy.get_derived()
- );
- copy_itr;
- ++copy_itr
- )
- {
- switch (traversal_state(copy_itr))
- {
- case pre_order_traversal:
- {
- pointer child(
- ::boost::tree_node::factory<Derived>::create(
- copy_itr->second->get_data()
- )
- );
-
- p->_add_child(copy_itr->first, child);
- p = child;
- break;
- }
-
- case post_order_traversal:
- {
- p = p->_parent;
- break;
- }
- }
- }
-
- this->deep_update_derived();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- raw_associative_node_base<Derived,K,D,A>&
- raw_associative_node_base<Derived,K,D,A>::operator=(
- raw_associative_node_base const& copy
- )
- {
- if (this != &copy)
- {
- raw_associative_node_base temp_copy(copy);
-
- _remove_all_children();
- _children = temp_copy._children;
- _data = temp_copy._data;
- temp_copy._children.clear();
-
- child_iterator itr_end = get_child_end();
-
- for (child_iterator itr = get_child_begin(); itr != itr_end; ++itr)
- {
- itr->second->_parent = this->get_derived();
- }
-
- this->shallow_update_derived();
- }
-
- return *this;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- raw_associative_node_base<Derived,K,D,A>::~raw_associative_node_base()
- {
- _remove_all_children();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- typename raw_associative_node_base<Derived,K,D,A>::pointer
- raw_associative_node_base<Derived,K,D,A>::clone() const
- {
- pointer result = ::boost::tree_node::factory<Derived>::create(_data);
- pointer p = result;
-
- for (
- depth_first_iterator<const_pointer,::boost::mpl::true_> copy_itr(
- this->get_derived()
- );
- copy_itr;
- ++copy_itr
- )
- {
- switch (traversal_state(copy_itr))
- {
- case pre_order_traversal:
- {
- pointer child(
- ::boost::tree_node::factory<Derived>::create(
- copy_itr->second->get_data()
- )
- );
-
- p->_add_child(copy_itr->first, child);
- p = child;
- break;
- }
-
- case post_order_traversal:
- {
- p = p->_parent;
- break;
- }
- }
- }
-
- result->deep_update_derived();
- return result;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<
- Derived
- , K
- , D
- , A
- >::traits::data_type const&
- raw_associative_node_base<Derived,K,D,A>::get_data() const
- {
- return _data;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<
- Derived
- , K
- , D
- , A
- >::traits::data_type&
- raw_associative_node_base<Derived,K,D,A>::get_data()
- {
- return _data;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<Derived,K,D,A>::const_pointer
- raw_associative_node_base<Derived,K,D,A>::get_parent() const
- {
- return _parent;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<Derived,K,D,A>::pointer
- raw_associative_node_base<Derived,K,D,A>::get_parent()
- {
- return _parent;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- typename raw_associative_node_base<Derived,K,D,A>::pointer
- raw_associative_node_base<Derived,K,D,A>::add_child(
- typename traits::key_type const& key
- , typename traits::data_type const& data
- )
- {
- pointer child(::boost::tree_node::factory<Derived>::create(data));
-
- _add_child(key, child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- typename raw_associative_node_base<Derived,K,D,A>::pointer
- raw_associative_node_base<Derived,K,D,A>::add_child(
- typename traits::key_type const& key
- )
- {
- pointer child(::boost::tree_node::factory<Derived>::create());
-
- _add_child(key, child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- typename raw_associative_node_base<Derived,K,D,A>::pointer
- raw_associative_node_base<Derived,K,D,A>::add_child_copy(
- typename traits::key_type const& key
- , const_pointer const& copy
- )
- {
- pointer child(copy->clone());
-
- _add_child(key, child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- raw_associative_node_base<Derived,K,D,A>::get_child_begin() const
- {
- return const_child_iterator(_children.begin());
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<Derived,K,D,A>::child_iterator
- raw_associative_node_base<Derived,K,D,A>::get_child_begin()
- {
- return _children.begin();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- raw_associative_node_base<Derived,K,D,A>::get_child_end() const
- {
- return const_child_iterator(_children.end());
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<Derived,K,D,A>::child_iterator
- raw_associative_node_base<Derived,K,D,A>::get_child_end()
- {
- return _children.end();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- raw_associative_node_base<Derived,K,D,A>::find_child(
- typename traits::key_type const& key
- ) const
- {
- return const_child_iterator(_children.find(key));
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename raw_associative_node_base<Derived,K,D,A>::child_iterator
- raw_associative_node_base<Derived,K,D,A>::find_child(
- typename traits::key_type const& key
- )
- {
- return _children.find(key);
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline ::std::pair<
- typename raw_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- , typename raw_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- >
- raw_associative_node_base<Derived,K,D,A>::find_children(
- typename traits::key_type const& key
- ) const
- {
- ::std::pair<
- typename children::const_iterator
- , typename children::const_iterator
- > p(_children.equal_range(key));
-
- return ::std::pair<const_child_iterator,const_child_iterator>(
- const_child_iterator(p.first)
- , const_child_iterator(p.second)
- );
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline ::std::pair<
- typename raw_associative_node_base<Derived,K,D,A>::child_iterator
- , typename raw_associative_node_base<Derived,K,D,A>::child_iterator
- >
- raw_associative_node_base<Derived,K,D,A>::find_children(
- typename traits::key_type const& key
- )
- {
- return _children.equal_range(key);
- }
-
- template <typename Derived, typename K, typename D, typename A>
- ::std::size_t
- raw_associative_node_base<Derived,K,D,A>::remove_children(
- typename traits::key_type const& key
- )
- {
- child_iterator itr, itr_end;
-
- for (
- ::std::tr1::tie(itr, itr_end) = _children.equal_range(key);
- itr != itr_end;
- ++itr
- )
- {
- delete itr->second;
- }
-
- this->shallow_update_derived();
- return _children.erase(key);
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline void raw_associative_node_base<Derived,K,D,A>::remove_all_children()
- {
- _remove_all_children();
- this->shallow_update_derived();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- void raw_associative_node_base<Derived,K,D,A>::_remove_all_children()
- {
- child_iterator itr_end = get_child_end();
-
- for (child_iterator itr = get_child_begin(); itr != itr_end; ++itr)
- {
- delete itr->second;
- }
-
- _children.clear();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- void
- raw_associative_node_base<Derived,K,D,A>::_add_child(
- typename traits::key_type const& key
- , pointer const& child
- )
- {
- child->_parent = this->get_derived();
- _children.insert(typename children::value_type(key, child));
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__raw_associative_node
-namespace boost { namespace tree_node {
-
- template <
- typename Key
- , typename Data
- , typename AssociativeContainerSelector = ::boost::mapS
- >
- class raw_associative_node
- : public raw_associative_node_base<
- raw_associative_node<Key,Data,AssociativeContainerSelector>
- , Key
- , Data
- , AssociativeContainerSelector
- >
- {
- typedef raw_associative_node_base<
- raw_associative_node
- , Key
- , Data
- , AssociativeContainerSelector
- >
- super_t;
-
- public:
- typedef typename super_t::traits
- traits;
- typedef typename super_t::pointer
- pointer;
- typedef typename super_t::const_pointer
- const_pointer;
- typedef typename super_t::child_iterator
- child_iterator;
- typedef typename super_t::const_child_iterator
- const_child_iterator;
-
- raw_associative_node();
-
- explicit raw_associative_node(typename traits::data_type const& data);
- };
-
- //<-
- template <typename K, typename D, typename A>
- raw_associative_node<K,D,A>::raw_associative_node() : super_t()
- {
- }
-
- template <typename K, typename D, typename A>
- raw_associative_node<K,D,A>::raw_associative_node(
- typename traits::data_type const& data
- ) : super_t(data)
- {
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__raw_associative_node_gen
-namespace boost { namespace tree_node {
-
- template <typename Selector = ::boost::mapS>
- struct raw_associative_node_gen
- {
- template <typename Derived, typename Key, typename Data>
- struct apply
- {
- typedef raw_associative_node_base<Derived,Key,Data,Selector> type;
- };
- };
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_RAW_ASSOCIATIVE_NODE_HPP_INCLUDED
-

Deleted: sandbox/tree_node/boost/tree_node/raw_binary_node.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/raw_binary_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,684 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_RAW_BINARY_NODE_HPP_INCLUDED
-#define BOOST_TREE_NODE_RAW_BINARY_NODE_HPP_INCLUDED
-
-#include <iterator>
-#include <utility>
-#include <boost/config.hpp>
-#include <boost/mpl/bool.hpp>
-#ifndef BOOST_NO_SFINAE
-#include <boost/tr1/type_traits.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/utility/enable_if.hpp>
-#endif
-#include <boost/tree_node/base.hpp>
-#include <boost/tree_node/depth_first_iterator.hpp>
-#include <boost/tree_node/factory.hpp>
-
-//[reference__raw_binary_node_base
-namespace boost { namespace tree_node {
- //<-
- namespace _detail {
-
- template <typename NodePointer>
- class raw_binary_child_iterator
- {
-#ifndef BOOST_NO_SFINAE
- struct enabler
- {
- };
-#endif
-
- NodePointer _child;
-
- public:
- typedef NodePointer value_type;
- typedef value_type const& reference;
- typedef value_type const* pointer;
- typedef ::std::ptrdiff_t difference_type;
- typedef ::std::forward_iterator_tag iterator_category;
-
- explicit raw_binary_child_iterator(NodePointer const& p);
-
- raw_binary_child_iterator();
-
- template <typename NP>
- raw_binary_child_iterator(
- raw_binary_child_iterator<NP> const& other
-#ifndef BOOST_NO_SFINAE
- , typename ::boost::enable_if<
- ::std::tr1::is_convertible<NP,NodePointer>
- , enabler
- >::type = enabler()
-#endif
- );
-
- reference operator*() const;
-
- pointer operator->() const;
-
- raw_binary_child_iterator& operator++();
-
- raw_binary_child_iterator operator++(int);
-
- template <typename NP1, typename NP2>
- friend bool
- operator==(
- raw_binary_child_iterator<NP1> const& lhs
- , raw_binary_child_iterator<NP2> const& rhs
- );
- };
-
- template <typename NodePointer>
- raw_binary_child_iterator<NodePointer>::raw_binary_child_iterator(
- NodePointer const& p
- ) : _child(
- p->get_left_child() ? p->get_left_child() : p->get_right_child()
- )
- {
- }
-
- template <typename NodePointer>
- raw_binary_child_iterator<NodePointer>::raw_binary_child_iterator()
- : _child(0)
- {
- }
-
- template <typename NodePointer>
- template <typename NP>
- raw_binary_child_iterator<NodePointer>::raw_binary_child_iterator(
- raw_binary_child_iterator<NP> const& other
-#ifndef BOOST_NO_SFINAE
- , typename ::boost::enable_if<
- ::std::tr1::is_convertible<NP,NodePointer>
- , enabler
- >::type
-#endif
- ) : _child(*other)
- {
- }
-
- template <typename NodePointer>
- inline typename raw_binary_child_iterator<NodePointer>::reference
- raw_binary_child_iterator<NodePointer>::operator*() const
- {
- return _child;
- }
-
- template <typename NodePointer>
- inline typename raw_binary_child_iterator<NodePointer>::pointer
- raw_binary_child_iterator<NodePointer>::operator->() const
- {
- return &_child;
- }
-
- template <typename NodePointer>
- inline raw_binary_child_iterator<NodePointer>&
- raw_binary_child_iterator<NodePointer>::operator++()
- {
- NodePointer sibling = _child->get_parent()->get_right_child();
- _child = (_child == sibling) ? 0 : sibling;
- return *this;
- }
-
- template <typename NodePointer>
- raw_binary_child_iterator<NodePointer>
- raw_binary_child_iterator<NodePointer>::operator++(int)
- {
- raw_binary_child_iterator<NodePointer> itr(*this);
- ++(*this);
- return itr;
- }
-
- template <typename NP1, typename NP2>
- inline bool
- operator==(
- raw_binary_child_iterator<NP1> const& lhs
- , raw_binary_child_iterator<NP2> const& rhs
- )
- {
- return lhs._child == rhs._child;
- }
-
- template <typename NP1, typename NP2>
- inline bool
- operator!=(
- raw_binary_child_iterator<NP1> const& lhs
- , raw_binary_child_iterator<NP2> const& rhs
- )
- {
- return !(lhs == rhs);
- }
- } // namespace _detail
- //->
-
- template <typename Derived, typename T>
- class raw_binary_node_base : public tree_node_base<Derived>
- {
- public:
- struct traits
- {
- typedef T data_type;
- };
-
- typedef typename tree_node_base<Derived>::pointer
- pointer;
- typedef typename tree_node_base<Derived>::const_pointer
- const_pointer;
- typedef // implementation_defined
- //<-
- _detail::raw_binary_child_iterator<pointer>
- //->
- child_iterator;
- typedef // implementation_defined
- //<-
- _detail::raw_binary_child_iterator<const_pointer>
- //->
- const_child_iterator;
-
- //<-
- private:
- pointer _left_child;
- pointer _right_child;
- pointer _parent;
- typename traits::data_type _data;
-
- public:
- //->
- raw_binary_node_base();
-
- explicit raw_binary_node_base(typename traits::data_type const& data);
-
- raw_binary_node_base(raw_binary_node_base const& copy);
-
- raw_binary_node_base& operator=(raw_binary_node_base const& copy);
-
- virtual ~raw_binary_node_base();
-
- pointer clone() const;
-
- typename traits::data_type const& get_data() const;
-
- typename traits::data_type& get_data();
-
- const_pointer get_parent() const;
-
- pointer get_parent();
-
- pointer add_left_child(typename traits::data_type const& data);
-
- pointer add_left_child();
-
- pointer add_left_child_copy(const_pointer const& copy);
-
- pointer add_right_child(typename traits::data_type const& data);
-
- pointer add_right_child();
-
- pointer add_right_child_copy(const_pointer const& copy);
-
- const_pointer get_left_child() const;
-
- pointer get_left_child();
-
- const_pointer get_right_child() const;
-
- pointer get_right_child();
-
- const_child_iterator get_child_begin() const;
-
- child_iterator get_child_begin();
-
- const_child_iterator get_child_end() const;
-
- child_iterator get_child_end();
-
- pointer rotate_left();
-
- pointer rotate_right();
-
- void remove_left_child();
-
- void remove_right_child();
-
- void remove_all_children();
- };
-
- //<-
- template <typename Derived, typename T>
- raw_binary_node_base<Derived,T>::raw_binary_node_base()
- : _left_child(), _right_child(), _parent(), _data()
- {
- }
-
- template <typename Derived, typename T>
- raw_binary_node_base<Derived,T>::raw_binary_node_base(
- typename traits::data_type const& data
- ) : _left_child(), _right_child(), _parent(), _data(data)
- {
- }
-
- template <typename Derived, typename T>
- raw_binary_node_base<Derived,T>::raw_binary_node_base(
- raw_binary_node_base const& copy
- ) : _left_child(), _right_child(), _parent(), _data(copy._data)
- {
- pointer p = this->get_derived();
-
- for (
- depth_first_iterator<const_pointer,::boost::mpl::true_> copy_itr(
- copy.get_derived()
- );
- copy_itr;
- ++copy_itr
- )
- {
- switch (traversal_state(copy_itr))
- {
- case pre_order_traversal:
- {
- const_pointer c_p = *copy_itr;
-
- if (c_p->_parent->_left_child == c_p)
- {
- p->_left_child = ::boost::tree_node::factory<
- Derived
- >::create(c_p->get_data());
- p->_left_child->_parent = p;
- p = p->_left_child;
- }
- else // if (c_p->_parent->_right_child == c_p)
- {
- p->_right_child = ::boost::tree_node::factory<
- Derived
- >::create(c_p->get_data());
- p->_right_child->_parent = p;
- p = p->_right_child;
- }
-
- break;
- }
-
- case post_order_traversal:
- {
- p = p->_parent;
- break;
- }
- }
- }
-
- this->deep_update_derived();
- }
-
- template <typename Derived, typename T>
- raw_binary_node_base<Derived,T>&
- raw_binary_node_base<Derived,T>::operator=(
- raw_binary_node_base const& copy
- )
- {
- if (this != &copy)
- {
- raw_binary_node_base temp_copy(copy);
-
- delete _left_child;
- delete _right_child;
- _left_child = temp_copy._left_child;
- _right_child = temp_copy._right_child;
- _data = temp_copy._data;
- temp_copy._left_child = temp_copy._right_child = 0;
- _left_child->_parent = _right_child->_parent = this->get_derived();
- this->shallow_update_derived();
- }
-
- return *this;
- }
-
- template <typename Derived, typename T>
- raw_binary_node_base<Derived,T>::~raw_binary_node_base()
- {
- delete _left_child;
- delete _right_child;
- }
-
- template <typename Derived, typename T>
- typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::clone() const
- {
- pointer result = ::boost::tree_node::factory<Derived>::create(_data);
- pointer p = result;
-
- for (
- depth_first_iterator<const_pointer,::boost::mpl::true_> copy_itr(
- this->get_derived()
- );
- copy_itr;
- ++copy_itr
- )
- {
- switch (traversal_state(copy_itr))
- {
- case pre_order_traversal:
- {
- const_pointer c_p = *copy_itr;
-
- if (c_p->_parent->_left_child == c_p)
- {
- p->_left_child = ::boost::tree_node::factory<
- Derived
- >::create(c_p->get_data());
- p->_left_child->_parent = p;
- p = p->_left_child;
- }
- else // if (c_p->_parent->_right_child == c_p)
- {
- p->_right_child = ::boost::tree_node::factory<
- Derived
- >::create(c_p->get_data());
- p->_right_child->_parent = p;
- p = p->_right_child;
- }
-
- break;
- }
-
- case post_order_traversal:
- {
- p = p->_parent;
- break;
- }
- }
- }
-
- result->deep_update_derived();
- return result;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::traits::data_type const&
- raw_binary_node_base<Derived,T>::get_data() const
- {
- return _data;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::traits::data_type&
- raw_binary_node_base<Derived,T>::get_data()
- {
- return _data;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::const_pointer
- raw_binary_node_base<Derived,T>::get_parent() const
- {
- return _parent;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::get_parent()
- {
- return _parent;
- }
-
- template <typename Derived, typename T>
- typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::add_left_child(
- typename traits::data_type const& data
- )
- {
- _left_child = ::boost::tree_node::factory<Derived>::create(data);
- _left_child->_parent = this->get_derived();
- this->shallow_update_derived();
- return _left_child;
- }
-
- template <typename Derived, typename T>
- typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::add_left_child()
- {
- _left_child = ::boost::tree_node::factory<Derived>::create();
- _left_child->_parent = this->get_derived();
- this->shallow_update_derived();
- return _left_child;
- }
-
- template <typename Derived, typename T>
- typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::add_left_child_copy(
- const_pointer const& copy
- )
- {
- _left_child = copy->clone();
- _left_child->_parent = this->get_derived();
- this->shallow_update_derived();
- return _left_child;
- }
-
- template <typename Derived, typename T>
- typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::add_right_child(
- typename traits::data_type const& data
- )
- {
- _right_child = ::boost::tree_node::factory<Derived>::create(data);
- _right_child->_parent = this->get_derived();
- this->shallow_update_derived();
- return _right_child;
- }
-
- template <typename Derived, typename T>
- typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::add_right_child()
- {
- _right_child = ::boost::tree_node::factory<Derived>::create();
- _right_child->_parent = this->get_derived();
- this->shallow_update_derived();
- return _right_child;
- }
-
- template <typename Derived, typename T>
- typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::add_right_child_copy(
- const_pointer const& copy
- )
- {
- _right_child = copy->clone();
- _right_child->_parent = this->get_derived();
- this->shallow_update_derived();
- return _right_child;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::const_pointer
- raw_binary_node_base<Derived,T>::get_left_child() const
- {
- return _left_child;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::get_left_child()
- {
- return _left_child;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::const_pointer
- raw_binary_node_base<Derived,T>::get_right_child() const
- {
- return _right_child;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::get_right_child()
- {
- return _right_child;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::const_child_iterator
- raw_binary_node_base<Derived,T>::get_child_begin() const
- {
- return const_child_iterator(this->get_derived());
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::child_iterator
- raw_binary_node_base<Derived,T>::get_child_begin()
- {
- return child_iterator(this->get_derived());
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::const_child_iterator
- raw_binary_node_base<Derived,T>::get_child_end() const
- {
- return const_child_iterator();
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::child_iterator
- raw_binary_node_base<Derived,T>::get_child_end()
- {
- return child_iterator();
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::rotate_left()
- {
- pointer pivot = _right_child;
-
- pivot->_parent = _parent;
- _right_child = pivot->_left_child;
- _right_child->_parent = pivot->_left_child = this->get_derived();
-
- if (_parent)
- {
- if (_parent->_left_child == this->get_derived())
- {
- _parent->_left_child = pivot;
- }
- else // if (_parent->_right_child == this->get_derived())
- {
- _parent->_right_child = pivot;
- }
- }
-
- _parent = pivot;
- this->shallow_update_derived();
- return pivot;
- }
-
- template <typename Derived, typename T>
- inline typename raw_binary_node_base<Derived,T>::pointer
- raw_binary_node_base<Derived,T>::rotate_right()
- {
- pointer pivot = _left_child;
-
- pivot->_parent = _parent;
- _left_child = pivot->_right_child;
- _left_child->_parent = pivot->_right_child = this->get_derived();
-
- if (_parent)
- {
- if (_parent->_right_child == this->get_derived())
- {
- _parent->_right_child = pivot;
- }
- else // if (_parent->_left_child == this->get_derived())
- {
- _parent->_left_child = pivot;
- }
- }
-
- _parent = pivot;
- this->shallow_update_derived();
- return pivot;
- }
-
- template <typename Derived, typename T>
- void raw_binary_node_base<Derived,T>::remove_left_child()
- {
- delete _left_child;
- _left_child = 0;
- this->shallow_update_derived();
- }
-
- template <typename Derived, typename T>
- void raw_binary_node_base<Derived,T>::remove_right_child()
- {
- delete _right_child;
- _right_child = 0;
- this->shallow_update_derived();
- }
-
- template <typename Derived, typename T>
- void raw_binary_node_base<Derived,T>::remove_all_children()
- {
- delete _left_child;
- delete _right_child;
- _left_child = _right_child = 0;
- this->shallow_update_derived();
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__raw_binary_node
-namespace boost { namespace tree_node {
-
- template <typename T>
- class raw_binary_node : public raw_binary_node_base<raw_binary_node<T>,T>
- {
- typedef raw_binary_node_base<raw_binary_node<T>,T> super_t;
-
- public:
- typedef typename super_t::traits traits;
- typedef typename super_t::pointer pointer;
- typedef typename super_t::const_pointer const_pointer;
- typedef typename super_t::child_iterator child_iterator;
- typedef typename super_t::const_child_iterator const_child_iterator;
-
- raw_binary_node();
-
- explicit raw_binary_node(typename traits::data_type const& data);
- };
-
- //<-
- template <typename T>
- raw_binary_node<T>::raw_binary_node() : super_t()
- {
- }
-
- template <typename T>
- raw_binary_node<T>::raw_binary_node(typename traits::data_type const& data)
- : super_t(data)
- {
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__raw_binary_node_gen
-namespace boost { namespace tree_node {
-
- struct raw_binary_node_gen
- {
- template <typename Derived, typename T>
- struct apply
- {
- typedef raw_binary_node_base<Derived,T> type;
- };
- };
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_RAW_BINARY_NODE_HPP_INCLUDED
-

Deleted: sandbox/tree_node/boost/tree_node/raw_node.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/raw_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,414 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_RAW_NODE_HPP_INCLUDED
-#define BOOST_TREE_NODE_RAW_NODE_HPP_INCLUDED
-
-#include <utility>
-#include <boost/mpl/bool.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-#include <boost/utility/container_gen.hpp>
-#include <boost/tree_node/base.hpp>
-#include <boost/tree_node/depth_first_iterator.hpp>
-#include <boost/tree_node/factory.hpp>
-#include <boost/detail/function/add_const_to_pointee.hpp>
-
-//[reference__raw_node_base
-namespace boost { namespace tree_node {
-
- template <typename Derived, typename T, typename Selector>
- class raw_node_base : public tree_node_base<Derived>
- {
- public:
- struct traits
- {
- typedef T data_type;
- };
-
- typedef typename tree_node_base<Derived>::pointer
- pointer;
- typedef typename tree_node_base<Derived>::const_pointer
- const_pointer;
-
- //<-
- private:
- typedef typename ::boost::container_gen<Selector,pointer>::type
- children;
-
- public:
- //->
- typedef // implementation_defined
- //<-
- typename children::iterator
- //->
- child_iterator;
- typedef // implementation_defined
- //<-
-#if 0
-// TODO:
-// Fix crash that occurs on depth-first iteration
-// when this code is used.
- ::boost::transform_iterator<
- ::boost::detail::add_const_to_pointee<Derived>
- , typename children::const_iterator
- >
-#else
- typename children::const_iterator
-#endif
- //->
- const_child_iterator;
-
- //<-
- private:
- children _children;
- pointer _parent;
- typename traits::data_type _data;
-
- public:
- //->
- raw_node_base();
-
- explicit raw_node_base(typename traits::data_type const& data);
-
- raw_node_base(raw_node_base const& copy);
-
- raw_node_base& operator=(raw_node_base const& copy);
-
- virtual ~raw_node_base();
-
- pointer clone() const;
-
- typename traits::data_type const& get_data() const;
-
- typename traits::data_type& get_data();
-
- const_pointer get_parent() const;
-
- pointer get_parent();
-
- pointer add_child(typename traits::data_type const& data);
-
- pointer add_child();
-
- pointer add_child_copy(const_pointer const& copy);
-
- const_child_iterator get_child_begin() const;
-
- child_iterator get_child_begin();
-
- const_child_iterator get_child_end() const;
-
- child_iterator get_child_end();
-
- void remove_all_children();
-
- //<-
- private:
- void _remove_all_children();
-
- void _add_child(pointer const& child);
- //->
- };
-
- //<-
- template <typename Derived, typename T, typename Selector>
- raw_node_base<Derived,T,Selector>::raw_node_base()
- : _children(), _parent(), _data()
- {
- }
-
- template <typename Derived, typename T, typename Selector>
- raw_node_base<Derived,T,Selector>::raw_node_base(
- typename traits::data_type const& data
- ) : _children(), _parent(), _data(data)
- {
- }
-
- template <typename Derived, typename T, typename Selector>
- raw_node_base<Derived,T,Selector>::raw_node_base(raw_node_base const& copy)
- : _children(), _parent(), _data(copy._data)
- {
- pointer p = this->get_derived();
-
- for (
- depth_first_iterator<const_pointer,::boost::mpl::true_> copy_itr(
- copy.get_derived()
- );
- copy_itr;
- ++copy_itr
- )
- {
- switch (traversal_state(copy_itr))
- {
- case pre_order_traversal:
- {
- pointer child = ::boost::tree_node::factory<
- Derived
- >::create((*copy_itr)->get_data());
-
- p->_add_child(child);
- p = child;
- break;
- }
-
- case post_order_traversal:
- {
- p = p->_parent;
- break;
- }
- }
- }
-
- this->deep_update_derived();
- }
-
- template <typename Derived, typename T, typename Selector>
- raw_node_base<Derived,T,Selector>&
- raw_node_base<Derived,T,Selector>::operator=(raw_node_base const& copy)
- {
- if (this != &copy)
- {
- raw_node_base temp_copy(copy);
-
- _remove_all_children();
- _children = temp_copy._children;
- _data = temp_copy._data;
- temp_copy._children.clear();
-
- child_iterator itr_end = get_child_end();
-
- for (child_iterator itr = get_child_begin(); itr != itr_end; ++itr)
- {
- (*itr)->_parent = this->get_derived();
- }
-
- this->shallow_update_derived();
- }
-
- return *this;
- }
-
- template <typename Derived, typename T, typename Selector>
- raw_node_base<Derived,T,Selector>::~raw_node_base()
- {
- _remove_all_children();
- }
-
- template <typename Derived, typename T, typename Selector>
- typename raw_node_base<Derived,T,Selector>::pointer
- raw_node_base<Derived,T,Selector>::clone() const
- {
- pointer result = ::boost::tree_node::factory<Derived>::create(_data);
- pointer p = result;
-
- for (
- depth_first_iterator<const_pointer,::boost::mpl::true_> copy_itr(
- this->get_derived()
- );
- copy_itr;
- ++copy_itr
- )
- {
- switch (traversal_state(copy_itr))
- {
- case pre_order_traversal:
- {
- pointer child = ::boost::tree_node::factory<
- Derived
- >::create((*copy_itr)->get_data());
-
- p->_add_child(child);
- p = child;
- break;
- }
-
- case post_order_traversal:
- {
- p = p->_parent;
- break;
- }
- }
- }
-
- result->deep_update_derived();
- return result;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::traits::data_type const&
- raw_node_base<Derived,T,Selector>::get_data() const
- {
- return _data;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::traits::data_type&
- raw_node_base<Derived,T,Selector>::get_data()
- {
- return _data;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::const_pointer
- raw_node_base<Derived,T,Selector>::get_parent() const
- {
- return _parent;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::pointer
- raw_node_base<Derived,T,Selector>::get_parent()
- {
- return _parent;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::pointer
- raw_node_base<Derived,T,Selector>::add_child(
- typename traits::data_type const& data
- )
- {
- pointer child = ::boost::tree_node::factory<Derived>::create(data);
-
- _add_child(child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::pointer
- raw_node_base<Derived,T,Selector>::add_child()
- {
- pointer child = ::boost::tree_node::factory<Derived>::create();
-
- _add_child(child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::pointer
- raw_node_base<Derived,T,Selector>::add_child_copy(
- const_pointer const& copy
- )
- {
- pointer child = copy->clone();
-
- _add_child(child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::const_child_iterator
- raw_node_base<Derived,T,Selector>::get_child_begin() const
- {
- return const_child_iterator(_children.begin());
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::child_iterator
- raw_node_base<Derived,T,Selector>::get_child_begin()
- {
- return _children.begin();
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::const_child_iterator
- raw_node_base<Derived,T,Selector>::get_child_end() const
- {
- return const_child_iterator(_children.end());
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename raw_node_base<Derived,T,Selector>::child_iterator
- raw_node_base<Derived,T,Selector>::get_child_end()
- {
- return _children.end();
- }
-
- template <typename Derived, typename T, typename Selector>
- inline void raw_node_base<Derived,T,Selector>::remove_all_children()
- {
- _remove_all_children();
- this->shallow_update_derived();
- }
-
- template <typename Derived, typename T, typename Selector>
- void raw_node_base<Derived,T,Selector>::_remove_all_children()
- {
- child_iterator itr_end = get_child_end();
-
- for (child_iterator itr = get_child_begin(); itr != itr_end; ++itr)
- {
- delete *itr;
- }
-
- _children.clear();
- }
-
- template <typename Derived, typename T, typename Selector>
- inline void
- raw_node_base<Derived,T,Selector>::_add_child(pointer const& child)
- {
- child->_parent = this->get_derived();
- _children.insert(_children.end(), child);
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__raw_node
-namespace boost { namespace tree_node {
-
- template <typename T, typename Selector = ::boost::dequeS>
- class raw_node : public raw_node_base<raw_node<T,Selector>,T,Selector>
- {
- typedef raw_node_base<raw_node,T,Selector> super_t;
-
- public:
- typedef typename super_t::traits traits;
- typedef typename super_t::pointer pointer;
- typedef typename super_t::const_pointer const_pointer;
- typedef typename super_t::child_iterator child_iterator;
- typedef typename super_t::const_child_iterator const_child_iterator;
-
- raw_node();
-
- explicit raw_node(typename traits::data_type const& data);
- };
-
- //<-
- template <typename T, typename Selector>
- raw_node<T,Selector>::raw_node() : super_t()
- {
- }
-
- template <typename T, typename Selector>
- raw_node<T,Selector>::raw_node(typename traits::data_type const& data)
- : super_t(data)
- {
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__raw_node_gen
-namespace boost { namespace tree_node {
-
- template <typename Selector = ::boost::dequeS>
- struct raw_node_gen
- {
- template <typename Derived, typename T>
- struct apply
- {
- typedef raw_node_base<Derived,T,Selector> type;
- };
- };
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_RAW_NODE_HPP_INCLUDED
-

Deleted: sandbox/tree_node/boost/tree_node/shared_base.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/shared_base.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,72 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_SHARED_BASE_HPP_INCLUDED
-#define BOOST_TREE_NODE_SHARED_BASE_HPP_INCLUDED
-
-#include <boost/detail/base_pointee_shared.hpp>
-
-//[reference__shared_tree_node_base
-namespace boost { namespace tree_node {
-
- template <typename Derived>
- struct shared_tree_node_base
- //<-
- : public ::boost::detail::base_pointee_shared<Derived>
- //->
- {
- typedef // implementation_defined
- //<-
- typename ::boost::detail::base_pointee_shared<
- Derived
- >::pointer
- //->
- pointer;
- typedef // implementation_defined
- //<-
- typename ::boost::detail::base_pointee_shared<
- Derived
- >::const_pointer
- //->
- const_pointer;
-
- protected:
- void shallow_update_impl();
-
- void deep_update_impl();
-
- void shallow_update_derived();
-
- void deep_update_derived();
- };
-
- //<-
- template <typename Derived>
- inline void shared_tree_node_base<Derived>::shallow_update_impl()
- {
- }
-
- template <typename Derived>
- inline void shared_tree_node_base<Derived>::deep_update_impl()
- {
- }
-
- template <typename Derived>
- inline void shared_tree_node_base<Derived>::shallow_update_derived()
- {
- this->get_derived()->shallow_update_impl();
- }
-
- template <typename Derived>
- inline void shared_tree_node_base<Derived>::deep_update_derived()
- {
- this->get_derived()->deep_update_impl();
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_SHARED_BASE_HPP_INCLUDED
-

Deleted: sandbox/tree_node/boost/tree_node/simple_associative_node.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/simple_associative_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,546 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_SIMPLE_ASSOCIATIVE_NODE_HPP_INCLUDED
-#define BOOST_TREE_NODE_SIMPLE_ASSOCIATIVE_NODE_HPP_INCLUDED
-
-#include <utility>
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/apply_wrap.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/tr1/memory.hpp>
-#include <boost/tr1/tuple.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-#include <boost/utility/associative_container_gen.hpp>
-#include <boost/tree_node/shared_base.hpp>
-#include <boost/tree_node/depth_first_iterator.hpp>
-#include <boost/tree_node/factory.hpp>
-#include <boost/detail/function/add_const_to_2nd_sh_ptee.hpp>
-
-//[reference__simple_associative_node_base
-namespace boost { namespace tree_node {
-
- template <
- typename Derived
- , typename Key
- , typename Data
- , typename AssociativeContainerSelector
- >
- class simple_associative_node_base
- : public shared_tree_node_base<Derived>
- , private noncopyable
- {
- public:
- struct traits
- {
- typedef Key key_type;
- typedef Data data_type;
- };
-
- typedef typename shared_tree_node_base<Derived>::pointer
- pointer;
- typedef typename shared_tree_node_base<Derived>::const_pointer
- const_pointer;
-
- //<-
- private:
- typedef typename ::boost::mpl::apply_wrap2<
- associative_container_gen<
- AssociativeContainerSelector
- >
- , typename traits::key_type
- , pointer
- >::type
- children;
-
- public:
- //->
- typedef // implementation_defined
- //<-
- typename children::iterator
- //->
- child_iterator;
- typedef // implementation_defined
- //<-
-#if 0
- ::boost::transform_iterator<
- ::boost::detail::add_const_to_2nd_shared_pointee<
- Key
- , Derived
- >
- , typename children::const_iterator
- >
-#else
- typename children::const_iterator
-#endif
- //->
- const_child_iterator;
-
- //<-
- private:
- children _children;
- ::std::tr1::weak_ptr<Derived> _parent;
- typename traits::data_type _data;
- //->
-
- protected:
- simple_associative_node_base();
-
- explicit simple_associative_node_base(
- typename traits::data_type const& data
- );
-
- public:
- ~simple_associative_node_base();
-
- pointer clone() const;
-
- typename traits::data_type const& get_data() const;
-
- typename traits::data_type& get_data();
-
- const_pointer get_parent() const;
-
- pointer get_parent();
-
- pointer
- add_child(
- typename traits::key_type const& key
- , typename traits::data_type const& data
- );
-
- pointer add_child(typename traits::key_type const& key);
-
- pointer
- add_child_copy(
- typename traits::key_type const& key
- , const_pointer const& copy
- );
-
- const_child_iterator get_child_begin() const;
-
- child_iterator get_child_begin();
-
- const_child_iterator get_child_end() const;
-
- child_iterator get_child_end();
-
- const_child_iterator
- find_child(typename traits::key_type const& key) const;
-
- child_iterator find_child(typename traits::key_type const& key);
-
- ::std::pair<const_child_iterator,const_child_iterator>
- find_children(typename traits::key_type const& key) const;
-
- ::std::pair<child_iterator,child_iterator>
- find_children(typename traits::key_type const& key);
-
- ::std::size_t remove_children(typename traits::key_type const& key);
-
- void remove_all_children();
-
- //<-
- private:
- void _remove_all_children();
-
- void
- _add_child(
- typename traits::key_type const& key
- , pointer const& child
- );
- //->
- };
-
- //<-
- template <typename Derived, typename K, typename D, typename A>
- simple_associative_node_base<Derived,K,D,A>::simple_associative_node_base()
- : _children(), _parent(), _data()
- {
- }
-
- template <typename Derived, typename K, typename D, typename A>
- simple_associative_node_base<Derived,K,D,A>::simple_associative_node_base(
- typename traits::data_type const& d
- ) : _children(), _parent(), _data(d)
- {
- }
-
- template <typename Derived, typename K, typename D, typename A>
- simple_associative_node_base<
- Derived
- , K
- , D
- , A
- >::~simple_associative_node_base()
- {
- _remove_all_children();
- _parent.reset();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- typename simple_associative_node_base<Derived,K,D,A>::pointer
- simple_associative_node_base<Derived,K,D,A>::clone() const
- {
- pointer result(::boost::tree_node::factory<Derived>::create(_data));
- pointer p(result);
-
- for (
- depth_first_iterator<const_pointer,::boost::mpl::true_> copy_itr(
- this->get_derived()
- );
- copy_itr;
- ++copy_itr
- )
- {
- switch (traversal_state(copy_itr))
- {
- case pre_order_traversal:
- {
- pointer child(
- ::boost::tree_node::factory<Derived>::create(
- copy_itr->second->get_data()
- )
- );
-
- p->_add_child(copy_itr->first, child);
- p = child;
- break;
- }
-
- case post_order_traversal:
- {
- p = p->get_parent();
- break;
- }
- }
- }
-
- result->deep_update_derived();
- return result;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<
- Derived
- , K
- , D
- , A
- >::traits::data_type const&
- simple_associative_node_base<Derived,K,D,A>::get_data() const
- {
- return _data;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<
- Derived
- , K
- , D
- , A
- >::traits::data_type&
- simple_associative_node_base<Derived,K,D,A>::get_data()
- {
- return _data;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<Derived,K,D,A>::const_pointer
- simple_associative_node_base<Derived,K,D,A>::get_parent() const
- {
- return const_pointer(_parent.lock());
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<Derived,K,D,A>::pointer
- simple_associative_node_base<Derived,K,D,A>::get_parent()
- {
- return pointer(_parent.lock());
- }
-
- template <typename Derived, typename K, typename D, typename A>
- typename simple_associative_node_base<Derived,K,D,A>::pointer
- simple_associative_node_base<Derived,K,D,A>::add_child(
- typename traits::key_type const& key
- , typename traits::data_type const& data
- )
- {
- pointer child(::boost::tree_node::factory<Derived>::create(data));
-
- _add_child(key, child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- typename simple_associative_node_base<Derived,K,D,A>::pointer
- simple_associative_node_base<Derived,K,D,A>::add_child(
- typename traits::key_type const& key
- )
- {
- pointer child(::boost::tree_node::factory<Derived>::create());
-
- _add_child(key, child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- typename simple_associative_node_base<Derived,K,D,A>::pointer
- simple_associative_node_base<Derived,K,D,A>::add_child_copy(
- typename traits::key_type const& key
- , const_pointer const& copy
- )
- {
- pointer child(copy->clone());
-
- _add_child(key, child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- simple_associative_node_base<Derived,K,D,A>::get_child_begin() const
- {
- return const_child_iterator(_children.begin());
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<Derived,K,D,A>::child_iterator
- simple_associative_node_base<Derived,K,D,A>::get_child_begin()
- {
- return _children.begin();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- simple_associative_node_base<Derived,K,D,A>::get_child_end() const
- {
- return const_child_iterator(_children.end());
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<Derived,K,D,A>::child_iterator
- simple_associative_node_base<Derived,K,D,A>::get_child_end()
- {
- return _children.end();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- simple_associative_node_base<Derived,K,D,A>::find_child(
- typename traits::key_type const& key
- ) const
- {
- return const_child_iterator(_children.find(key));
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline typename simple_associative_node_base<Derived,K,D,A>::child_iterator
- simple_associative_node_base<Derived,K,D,A>::find_child(
- typename traits::key_type const& key
- )
- {
- return _children.find(key);
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline ::std::pair<
- typename simple_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- , typename simple_associative_node_base<
- Derived
- , K
- , D
- , A
- >::const_child_iterator
- >
- simple_associative_node_base<Derived,K,D,A>::find_children(
- typename traits::key_type const& key
- ) const
- {
- ::std::pair<
- typename children::const_iterator
- , typename children::const_iterator
- > p(_children.equal_range(key));
-
- return ::std::pair<const_child_iterator,const_child_iterator>(
- const_child_iterator(p.first)
- , const_child_iterator(p.second)
- );
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline ::std::pair<
- typename simple_associative_node_base<Derived,K,D,A>::child_iterator
- , typename simple_associative_node_base<Derived,K,D,A>::child_iterator
- >
- simple_associative_node_base<Derived,K,D,A>::find_children(
- typename traits::key_type const& key
- )
- {
- return _children.equal_range(key);
- }
-
- template <typename Derived, typename K, typename D, typename A>
- ::std::size_t
- simple_associative_node_base<Derived,K,D,A>::remove_children(
- typename traits::key_type const& key
- )
- {
- child_iterator itr, itr_end;
-
- for (
- ::std::tr1::tie(itr, itr_end) = _children.equal_range(key);
- itr != itr_end;
- ++itr
- )
- {
- itr->second->remove_all_children();
- itr->second->_parent.reset();
- }
-
- this->shallow_update_derived();
- return _children.erase(key);
- }
-
- template <typename Derived, typename K, typename D, typename A>
- inline void
- simple_associative_node_base<Derived,K,D,A>::remove_all_children()
- {
- _remove_all_children();
- this->shallow_update_derived();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- void simple_associative_node_base<Derived,K,D,A>::_remove_all_children()
- {
- child_iterator itr_end = get_child_end();
-
- for (child_iterator itr = get_child_begin(); itr != itr_end; ++itr)
- {
- itr->second->remove_all_children();
- itr->second->_parent.reset();
- }
-
- _children.clear();
- }
-
- template <typename Derived, typename K, typename D, typename A>
- void
- simple_associative_node_base<Derived,K,D,A>::_add_child(
- typename traits::key_type const& key
- , pointer const& child
- )
- {
- child->_parent = this->get_derived();
- _children.insert(typename children::value_type(key, child));
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__simple_associative_node
-namespace boost { namespace tree_node {
-
- template <
- typename Key
- , typename Data
- , typename AssociativeContainerSelector = ::boost::mapS
- >
- class simple_associative_node
- : public simple_associative_node_base<
- simple_associative_node<Key,Data,AssociativeContainerSelector>
- , Key
- , Data
- , AssociativeContainerSelector
- >
- {
- typedef simple_associative_node_base<
- simple_associative_node
- , Key
- , Data
- , AssociativeContainerSelector
- >
- super_t;
-
- public:
- typedef typename super_t::traits
- traits;
- typedef typename super_t::pointer
- pointer;
- typedef typename super_t::const_pointer
- const_pointer;
- typedef typename super_t::child_iterator
- child_iterator;
- typedef typename super_t::const_child_iterator
- const_child_iterator;
-
- //<-
- private:
- simple_associative_node();
-
- explicit simple_associative_node(
- typename traits::data_type const& data
- );
-
- friend struct ::boost::tree_node::factory<simple_associative_node>;
- //->
- };
-
- //<-
- template <typename K, typename D, typename A>
- simple_associative_node<K,D,A>::simple_associative_node() : super_t()
- {
- }
-
- template <typename K, typename D, typename A>
- simple_associative_node<K,D,A>::simple_associative_node(
- typename traits::data_type const& data
- ) : super_t(data)
- {
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__simple_associative_node_gen
-namespace boost { namespace tree_node {
-
- template <typename Selector = ::boost::mapS>
- struct simple_associative_node_gen
- {
- template <typename Derived, typename Key, typename Data>
- struct apply
- {
- typedef simple_associative_node_base<Derived,Key,Data,Selector>
- type;
- };
- };
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_SIMPLE_ASSOCIATIVE_NODE_HPP_INCLUDED
-

Deleted: sandbox/tree_node/boost/tree_node/simple_node.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/simple_node.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,367 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_SIMPLE_NODE_HPP_INCLUDED
-#define BOOST_TREE_NODE_SIMPLE_NODE_HPP_INCLUDED
-
-#include <utility>
-#include <boost/mpl/bool.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/tr1/memory.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-#include <boost/utility/container_gen.hpp>
-#include <boost/tree_node/shared_base.hpp>
-#include <boost/tree_node/depth_first_iterator.hpp>
-#include <boost/tree_node/factory.hpp>
-#include <boost/detail/function/add_const_to_sh_ptee.hpp>
-
-//[reference__simple_node_base
-namespace boost { namespace tree_node {
-
- template <typename Derived, typename T, typename Selector>
- class simple_node_base
- : public shared_tree_node_base<Derived>
- , private noncopyable
- {
- public:
- struct traits
- {
- typedef T data_type;
- };
-
- typedef typename shared_tree_node_base<Derived>::pointer
- pointer;
- typedef typename shared_tree_node_base<Derived>::const_pointer
- const_pointer;
-
- //<-
- private:
- typedef typename ::boost::container_gen<Selector,pointer>::type
- children;
-
- public:
- //->
- typedef // implementation_defined
- //<-
- typename children::iterator
- //->
- child_iterator;
- typedef // implementation_defined
- //<-
-#if 0
-// TODO:
-// Fix compiler error that occurs when this code is used
-// by the with_depth adaptor.
- ::boost::transform_iterator<
- ::boost::detail::add_const_to_shared_pointee<Derived>
- , typename children::const_iterator
- >
-#else
- typename children::const_iterator
-#endif
- //->
- const_child_iterator;
-
- //<-
- private:
- children _children;
- ::std::tr1::weak_ptr<Derived> _parent;
- typename traits::data_type _data;
- //->
-
- protected:
- simple_node_base();
-
- explicit simple_node_base(typename traits::data_type const& data);
-
- public:
- ~simple_node_base();
-
- pointer clone() const;
-
- typename traits::data_type const& get_data() const;
-
- typename traits::data_type& get_data();
-
- const_pointer get_parent() const;
-
- pointer get_parent();
-
- pointer add_child(typename traits::data_type const& data);
-
- pointer add_child();
-
- pointer add_child_copy(const_pointer const& copy);
-
- const_child_iterator get_child_begin() const;
-
- child_iterator get_child_begin();
-
- const_child_iterator get_child_end() const;
-
- child_iterator get_child_end();
-
- void remove_all_children();
-
- //<-
- private:
- void _remove_all_children();
-
- void _add_child(pointer const& child);
- //->
- };
-
- //<-
- template <typename Derived, typename T, typename Selector>
- simple_node_base<Derived,T,Selector>::simple_node_base()
- : _children(), _parent(), _data()
- {
- }
-
- template <typename Derived, typename T, typename Selector>
- simple_node_base<Derived,T,Selector>::simple_node_base(
- typename traits::data_type const& data
- ) : _children(), _parent(), _data(data)
- {
- }
-
- template <typename Derived, typename T, typename Selector>
- simple_node_base<Derived,T,Selector>::~simple_node_base()
- {
- _remove_all_children();
- _parent.reset();
- }
-
- template <typename Derived, typename T, typename Selector>
- typename simple_node_base<Derived,T,Selector>::pointer
- simple_node_base<Derived,T,Selector>::clone() const
- {
- pointer result(::boost::tree_node::factory<Derived>::create(_data));
- pointer p(result);
-
- for (
- depth_first_iterator<const_pointer,::boost::mpl::true_> copy_itr(
- this->get_derived()
- );
- copy_itr;
- ++copy_itr
- )
- {
- switch (traversal_state(copy_itr))
- {
- case pre_order_traversal:
- {
- pointer child(
- ::boost::tree_node::factory<Derived>::create(
- (*copy_itr)->get_data()
- )
- );
-
- p->_add_child(child);
- p = child;
- break;
- }
-
- case post_order_traversal:
- {
- p = p->get_parent();
- break;
- }
- }
- }
-
- result->deep_update_derived();
- return result;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<
- Derived
- , T
- , Selector
- >::traits::data_type const&
- simple_node_base<Derived,T,Selector>::get_data() const
- {
- return _data;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::traits::data_type&
- simple_node_base<Derived,T,Selector>::get_data()
- {
- return _data;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::const_pointer
- simple_node_base<Derived,T,Selector>::get_parent() const
- {
- return const_pointer(_parent.lock());
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::pointer
- simple_node_base<Derived,T,Selector>::get_parent()
- {
- return pointer(_parent.lock());
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::pointer
- simple_node_base<Derived,T,Selector>::add_child(
- typename traits::data_type const& data
- )
- {
- pointer child(::boost::tree_node::factory<Derived>::create(data));
-
- _add_child(child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::pointer
- simple_node_base<Derived,T,Selector>::add_child()
- {
- pointer child(::boost::tree_node::factory<Derived>::create());
-
- _add_child(child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::pointer
- simple_node_base<Derived,T,Selector>::add_child_copy(
- const_pointer const& copy
- )
- {
- pointer child(copy->clone());
-
- _add_child(child);
- this->shallow_update_derived();
- return child;
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::const_child_iterator
- simple_node_base<Derived,T,Selector>::get_child_begin() const
- {
- return const_child_iterator(_children.begin());
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::child_iterator
- simple_node_base<Derived,T,Selector>::get_child_begin()
- {
- return _children.begin();
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::const_child_iterator
- simple_node_base<Derived,T,Selector>::get_child_end() const
- {
- return const_child_iterator(_children.end());
- }
-
- template <typename Derived, typename T, typename Selector>
- inline typename simple_node_base<Derived,T,Selector>::child_iterator
- simple_node_base<Derived,T,Selector>::get_child_end()
- {
- return _children.end();
- }
-
- template <typename Derived, typename T, typename Selector>
- inline void simple_node_base<Derived,T,Selector>::remove_all_children()
- {
- _remove_all_children();
- this->shallow_update_derived();
- }
-
- template <typename Derived, typename T, typename Selector>
- void simple_node_base<Derived,T,Selector>::_remove_all_children()
- {
- child_iterator itr_end = get_child_end();
-
- for (child_iterator itr = get_child_begin(); itr != itr_end; ++itr)
- {
- (*itr)->remove_all_children();
- (*itr)->_parent.reset();
- }
-
- _children.clear();
- }
-
- template <typename Derived, typename T, typename Selector>
- inline void
- simple_node_base<Derived,T,Selector>::_add_child(pointer const& child)
- {
- child->_parent = this->get_derived();
- _children.insert(_children.end(), child);
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__simple_node
-namespace boost { namespace tree_node {
-
- template <typename T, typename Selector = ::boost::dequeS>
- class simple_node
- : public simple_node_base<simple_node<T>,T,Selector>
- {
- typedef simple_node_base<simple_node,T,Selector> super_t;
-
- public:
- typedef typename super_t::traits traits;
- typedef typename super_t::pointer pointer;
- typedef typename super_t::const_pointer const_pointer;
- typedef typename super_t::child_iterator child_iterator;
- typedef typename super_t::const_child_iterator const_child_iterator;
-
- //<-
- private:
- simple_node();
-
- explicit simple_node(typename traits::data_type const& data);
-
- friend struct ::boost::tree_node::factory<simple_node>;
- //->
- };
-
- //<-
- template <typename T, typename Selector>
- simple_node<T,Selector>::simple_node() : super_t()
- {
- }
-
- template <typename T, typename Selector>
- simple_node<T,Selector>::simple_node(
- typename traits::data_type const& data
- ) : super_t(data)
- {
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__simple_node_gen
-namespace boost { namespace tree_node {
-
- template <typename Selector = ::boost::dequeS>
- struct simple_node_gen
- {
- template <typename Derived, typename T>
- struct apply
- {
- typedef simple_node_base<Derived,T,Selector> type;
- };
- };
-//]
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_SIMPLE_NODE_HPP_INCLUDED
-

Added: sandbox/tree_node/boost/tree_node/traversal_state.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/traversal_state.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,24 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_TRAVERSAL_STATE_HPP_INCLUDED
+#define BOOST_TREE_NODE_TRAVERSAL_STATE_HPP_INCLUDED
+
+//[reference__traversal_state
+namespace boost { namespace tree_node {
+
+ enum traversal_state
+ {
+ no_traversal
+ , pre_order_traversal
+ , post_order_traversal
+ , breadth_first_traversal
+ , in_order_traversal
+ };
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_TRAVERSAL_STATE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/typeof.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/typeof.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,56 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_TYPEOF_HPP_INCLUDED
+#define BOOST_TREE_NODE_TYPEOF_HPP_INCLUDED
+
+#include <boost/typeof/typeof.hpp>
+#include <boost/tree_node.hpp>
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TYPE(boost::tree_node::traversal_state)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::breadth_first_iterator, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::tree_node::breadth_first_descendant_iterator
+ , 1
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::pre_order_iterator, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::tree_node::pre_order_descendant_iterator
+ , 1
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::post_order_iterator, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::tree_node::post_order_descendant_iterator
+ , 1
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::in_order_iterator, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::depth_first_iterator, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ boost::tree_node::depth_first_descendant_iterator
+ , 1
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::tree_node_base, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::binary_node_base, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::binary_node, 1)
+BOOST_TYPEOF_REGISTER_TYPE(boost::tree_node::binary_node_gen)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::nary_node_base, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::nary_node, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::nary_node_gen, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::associative_node_base, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::associative_node, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::associative_node_gen, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_depth_base, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_depth, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_depth_gen, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_position_base, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_position, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_position_gen, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_red_black_flag_base, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_red_black_flag, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::tree_node::with_red_black_flag_gen, 1)
+
+#endif // BOOST_TREE_NODE_TYPEOF_HPP_INCLUDED
+

Deleted: sandbox/tree_node/boost/tree_node/with_child_range_access.hpp
==============================================================================
--- sandbox/tree_node/boost/tree_node/with_child_range_access.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,239 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef BOOST_TREE_NODE_WITH_CHILD_RANGE_ACCESS_HPP_INCLUDED
-#define BOOST_TREE_NODE_WITH_CHILD_RANGE_ACCESS_HPP_INCLUDED
-
-#include <utility>
-#include <boost/tr1/type_traits.hpp>
-#include <boost/mpl/apply_wrap.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/tree_node/factory.hpp>
-
-//[reference__with_child_range_access_base
-namespace boost { namespace tree_node {
-
- template <
- typename Derived
- , typename BaseGenerator
- , typename T1
- , typename T2
- >
- class with_child_range_access_base
- : public ::boost::mpl::eval_if<
- ::std::tr1::is_void<T2>
- , ::boost::mpl::apply_wrap2<BaseGenerator,Derived,T1>
- , ::boost::mpl::apply_wrap3<BaseGenerator,Derived,T1,T2>
- >::type
- {
- typedef typename ::boost::mpl::eval_if<
- ::std::tr1::is_void<T2>
- , ::boost::mpl::apply_wrap2<BaseGenerator,Derived,T1>
- , ::boost::mpl::apply_wrap3<BaseGenerator,Derived,T1,T2>
- >::type
- super_t;
-
- public:
- typedef typename super_t::traits traits;
- typedef typename super_t::pointer pointer;
- typedef typename super_t::const_pointer const_pointer;
- typedef typename super_t::child_iterator child_iterator;
- typedef typename super_t::const_child_iterator const_child_iterator;
-
- protected:
- with_child_range_access_base();
-
- explicit with_child_range_access_base(
- typename traits::data_type const& data
- );
-
- public:
- std::pair<const_child_iterator,const_child_iterator>
- get_children() const;
-
- std::pair<child_iterator,child_iterator>
- get_children();
- };
-
- //<-
- template <
- typename Derived
- , typename BaseGenerator
- , typename T1
- , typename T2
- >
- with_child_range_access_base<
- Derived
- , BaseGenerator
- , T1
- , T2
- >::with_child_range_access_base() : super_t()
- {
- }
-
- template <
- typename Derived
- , typename BaseGenerator
- , typename T1
- , typename T2
- >
- with_child_range_access_base<
- Derived
- , BaseGenerator
- , T1
- , T2
- >::with_child_range_access_base(typename traits::data_type const& data)
- : super_t(data)
- {
- }
-
- template <
- typename Derived
- , typename BaseGenerator
- , typename T1
- , typename T2
- >
- inline ::std::pair<
- typename with_child_range_access_base<
- Derived
- , BaseGenerator
- , T1
- , T2
- >::const_child_iterator
- , typename with_child_range_access_base<
- Derived
- , BaseGenerator
- , T1
- , T2
- >::const_child_iterator
- >
- with_child_range_access_base<
- Derived
- , BaseGenerator
- , T1
- , T2
- >::get_children() const
- {
- return ::std::pair<const_child_iterator,const_child_iterator>(
- this->get_child_begin()
- , this->get_child_end()
- );
- }
-
- template <
- typename Derived
- , typename BaseGenerator
- , typename T1
- , typename T2
- >
- inline ::std::pair<
- typename with_child_range_access_base<
- Derived
- , BaseGenerator
- , T1
- , T2
- >::child_iterator
- , typename with_child_range_access_base<
- Derived
- , BaseGenerator
- , T1
- , T2
- >::child_iterator
- >
- with_child_range_access_base<
- Derived
- , BaseGenerator
- , T1
- , T2
- >::get_children()
- {
- return ::std::pair<child_iterator,child_iterator>(
- this->get_child_begin()
- , this->get_child_end()
- );
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__with_child_range_access
-namespace boost { namespace tree_node {
-
- template <typename BaseGenerator, typename T1, typename T2 = void>
- class with_child_range_access
- : public with_child_range_access_base<
- with_child_range_access<BaseGenerator,T1,T2>
- , BaseGenerator
- , T1
- , T2
- >
- {
- typedef with_child_range_access_base<
- with_child_range_access
- , BaseGenerator
- , T1
- , T2
- >
- super_t;
-
- public:
- typedef typename super_t::traits
- traits;
- typedef typename super_t::pointer
- pointer;
- typedef typename super_t::const_pointer
- const_pointer;
- typedef typename super_t::child_iterator
- child_iterator;
- typedef typename super_t::const_child_iterator
- const_child_iterator;
-
- //<-
- private:
- with_child_range_access();
-
- explicit with_child_range_access(
- typename traits::data_type const& data
- );
-
- friend struct ::boost::tree_node::factory<with_child_range_access>;
- //->
- };
-
- //<-
- template <typename BaseGenerator, typename T1, typename T2>
- with_child_range_access<BaseGenerator,T1,T2>::with_child_range_access()
- : super_t()
- {
- }
-
- template <typename BaseGenerator, typename T1, typename T2>
- with_child_range_access<BaseGenerator,T1,T2>::with_child_range_access(
- typename traits::data_type const& data
- ) : super_t(data)
- {
- }
- //->
-}} // namespace boost::tree_node
-//]
-
-//[reference__with_child_range_access_gen
-namespace boost { namespace tree_node {
-
- template <typename BaseGenerator>
- struct with_child_range_access_gen
- {
- template <typename Derived, typename T1, typename T2 = void>
- struct apply
- {
- typedef with_child_range_access_base<Derived,BaseGenerator,T1,T2>
- type;
- };
- };
-}} // namespace boost::tree_node
-//]
-
-#endif // BOOST_TREE_NODE_WITH_CHILD_RANGE_ACCESS_HPP_INCLUDED
-

Added: sandbox/tree_node/boost/tree_node/with_depth.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_depth.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,441 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_WITH_DEPTH_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_DEPTH_HPP_INCLUDED
+
+#include <boost/cstdint.hpp>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/move/move.hpp>
+#include <boost/tree_node/post_order_iterator.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+
+//[reference__with_depth_base
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ class with_depth_base
+ : public ::boost::mpl::eval_if<
+ ::std::tr1::is_void<T2>
+ , ::boost::mpl::apply_wrap2<BaseGenerator,Derived,T1>
+ , ::boost::mpl::apply_wrap3<BaseGenerator,Derived,T1,T2>
+ >::type
+ {
+ friend struct tree_node_base<Derived>;
+
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(with_depth_base);
+ //->
+ typedef typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<T2>
+ , ::boost::mpl::apply_wrap2<BaseGenerator,Derived,T1>
+ , ::boost::mpl::apply_wrap3<BaseGenerator,Derived,T1,T2>
+ >::type
+ super_t;
+
+ public:
+ typedef typename super_t::traits
+ traits;
+ typedef typename super_t::pointer
+ pointer;
+ typedef typename super_t::const_pointer
+ const_pointer;
+ typedef typename super_t::iterator
+ iterator;
+ typedef typename super_t::const_iterator
+ const_iterator;
+
+ //<-
+ private:
+ ::std::size_t _depth;
+
+ public:
+ //->
+ with_depth_base();
+
+ explicit with_depth_base(typename traits::data_type const& data);
+
+//<-
+#if 0
+//->
+ with_depth_base(with_depth_base const& copy);
+
+ with_depth_base(with_depth_base&& source);
+
+ with_depth_base& operator=(with_depth_base const& copy);
+
+ with_depth_base& operator=(with_depth_base&& source);
+//<-
+#endif
+
+ with_depth_base(BOOST_RV_REF(with_depth_base) source);
+
+ with_depth_base&
+ operator=(BOOST_COPY_ASSIGN_REF(with_depth_base) copy);
+
+ with_depth_base& operator=(BOOST_RV_REF(with_depth_base) source);
+//->
+
+ ::std::size_t get_depth() const;
+
+ //<-
+ protected:
+ void shallow_update_impl();
+
+ void deep_update_impl();
+
+ private:
+ void _update_less_depth();
+
+ void _update_greater_depth();
+ //->
+ };
+
+ //<-
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_depth_base<Derived,BaseGenerator,T1,T2>::with_depth_base()
+ : super_t(), _depth(0)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_depth_base<Derived,BaseGenerator,T1,T2>::with_depth_base(
+ typename traits::data_type const& data
+ ) : super_t(data), _depth(0)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_depth_base<Derived,BaseGenerator,T1,T2>::with_depth_base(
+ BOOST_RV_REF(with_depth_base) source
+ ) : super_t(::boost::move(static_cast<super_t&>(source)))
+ , _depth(source._depth)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline with_depth_base<Derived,BaseGenerator,T1,T2>&
+ with_depth_base<Derived,BaseGenerator,T1,T2>::operator=(
+ BOOST_COPY_ASSIGN_REF(with_depth_base) copy
+ )
+ {
+ if (this != &copy)
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ _depth = copy._depth;
+ }
+
+ return *this;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline with_depth_base<Derived,BaseGenerator,T1,T2>&
+ with_depth_base<Derived,BaseGenerator,T1,T2>::operator=(
+ BOOST_RV_REF(with_depth_base) source
+ )
+ {
+ if (this != &source)
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ _depth = source._depth;
+ }
+
+ return *this;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline ::std::size_t
+ with_depth_base<Derived,BaseGenerator,T1,T2>::get_depth() const
+ {
+ return _depth;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void with_depth_base<Derived,BaseGenerator,T1,T2>::shallow_update_impl()
+ {
+ super_t::shallow_update_impl();
+
+ ::std::size_t new_depth = 0, depth_plus_1;
+ const_iterator c_end(this->end());
+
+ for (const_iterator c_itr(this->begin()); c_itr != c_end; ++c_itr)
+ {
+ depth_plus_1 = dereference_iterator(c_itr).get_depth() + 1;
+
+ if (new_depth < depth_plus_1)
+ {
+ new_depth = depth_plus_1;
+ }
+ }
+
+ if (new_depth < _depth)
+ {
+ _depth = new_depth;
+ _update_less_depth();
+ }
+ else if (_depth < new_depth)
+ {
+ _depth = new_depth;
+ _update_greater_depth();
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void with_depth_base<Derived,BaseGenerator,T1,T2>::deep_update_impl()
+ {
+ super_t::deep_update_impl();
+
+ ::std::size_t const old_depth = _depth;
+ ::std::size_t new_depth, depth_plus_1;
+ const_iterator c_itr, c_end;
+
+ for (
+ post_order_iterator<Derived> itr(*this->get_derived());
+ itr;
+ ++itr
+ )
+ {
+ new_depth = 0;
+ c_end = itr->end();
+
+ for (c_itr = itr->begin(); c_itr != c_end; ++c_itr)
+ {
+ depth_plus_1 = dereference_iterator(c_itr).get_depth() + 1;
+
+ if (new_depth < depth_plus_1)
+ {
+ new_depth = depth_plus_1;
+ }
+ }
+
+ itr->_depth = new_depth;
+ }
+
+ if (_depth < old_depth)
+ {
+ _update_less_depth();
+ }
+ else if (old_depth < _depth)
+ {
+ _update_greater_depth();
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void with_depth_base<Derived,BaseGenerator,T1,T2>::_update_less_depth()
+ {
+ pointer p = this->get_derived();
+ ::std::size_t new_depth, depth_plus_1;
+ const_iterator c_itr, c_end;
+
+ while (p = p->get_parent_ptr())
+ {
+ new_depth = 0;
+ c_end = p->end();
+
+ for (c_itr = p->begin(); c_itr != c_end; ++c_itr)
+ {
+ depth_plus_1 = dereference_iterator(c_itr).get_depth() + 1;
+
+ if (new_depth < depth_plus_1)
+ {
+ new_depth = depth_plus_1;
+ }
+ }
+
+ if (p->get_depth() == new_depth)
+ {
+ return;
+ }
+ else
+ {
+ // This is no longer the deepest branch.
+ p->_depth = new_depth;
+ }
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void with_depth_base<Derived,BaseGenerator,T1,T2>::_update_greater_depth()
+ {
+ ::std::size_t this_depth = _depth;
+ pointer p = this->get_derived();
+
+ while ((p = p->get_parent_ptr()) && (p->_depth < ++this_depth))
+ {
+ // This is the new deepest branch.
+ p->_depth = this_depth;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_depth
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename T1, typename T2 = void>
+ class with_depth
+ : public with_depth_base<
+ with_depth<BaseGenerator,T1,T2>
+ , BaseGenerator
+ , T1
+ , T2
+ >
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(with_depth);
+ //->
+ typedef with_depth_base<with_depth,BaseGenerator,T1,T2> super_t;
+
+ public:
+ typedef typename super_t::traits traits;
+ typedef typename super_t::pointer pointer;
+ typedef typename super_t::const_pointer const_pointer;
+ typedef typename super_t::iterator iterator;
+ typedef typename super_t::const_iterator const_iterator;
+
+ with_depth();
+
+ explicit with_depth(typename traits::data_type const& data);
+
+//<-
+#if 0
+//->
+ with_depth(with_depth const& copy);
+
+ with_depth(with_depth&& source);
+
+ with_depth& operator=(with_depth const& copy);
+
+ with_depth& operator=(with_depth&& source);
+//<-
+#endif
+
+ with_depth(BOOST_RV_REF(with_depth) source);
+
+ with_depth& operator=(BOOST_COPY_ASSIGN_REF(with_depth) copy);
+
+ with_depth& operator=(BOOST_RV_REF(with_depth) source);
+//->
+ };
+
+ //<-
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_depth<BaseGenerator,T1,T2>::with_depth() : super_t()
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_depth<BaseGenerator,T1,T2>::with_depth(
+ typename traits::data_type const& data
+ ) : super_t(data)
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_depth<BaseGenerator,T1,T2>::with_depth(
+ BOOST_RV_REF(with_depth) source
+ ) : super_t(::boost::move(static_cast<super_t&>(source)))
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ inline with_depth<BaseGenerator,T1,T2>&
+ with_depth<BaseGenerator,T1,T2>::operator=(
+ BOOST_COPY_ASSIGN_REF(with_depth) copy
+ )
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ return *this;
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ inline with_depth<BaseGenerator,T1,T2>&
+ with_depth<BaseGenerator,T1,T2>::operator=(
+ BOOST_RV_REF(with_depth) source
+ )
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ return *this;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_depth_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator>
+ struct with_depth_gen
+ {
+ template <typename Derived, typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_depth_base<Derived,BaseGenerator,T1,T2> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_WITH_DEPTH_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_position.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_position.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,359 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_WITH_POSITION_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_POSITION_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/move/move.hpp>
+#include <boost/tree_node/algorithm/dereference_iterator.hpp>
+
+//[reference__with_position_base
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ class with_position_base
+ : public ::boost::mpl::eval_if<
+ ::std::tr1::is_void<T2>
+ , ::boost::mpl::apply_wrap2<BaseGenerator,Derived,T1>
+ , ::boost::mpl::apply_wrap3<BaseGenerator,Derived,T1,T2>
+ >::type
+ {
+ friend struct tree_node_base<Derived>;
+
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(with_position_base);
+ //->
+ typedef typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<T2>
+ , ::boost::mpl::apply_wrap2<BaseGenerator,Derived,T1>
+ , ::boost::mpl::apply_wrap3<BaseGenerator,Derived,T1,T2>
+ >::type
+ super_t;
+
+ public:
+ typedef typename super_t::traits traits;
+ typedef typename super_t::pointer pointer;
+ typedef typename super_t::const_pointer const_pointer;
+ typedef typename super_t::iterator iterator;
+ typedef typename super_t::const_iterator const_iterator;
+
+ //<-
+ private:
+ iterator _position;
+
+ public:
+ //->
+ with_position_base();
+
+ explicit with_position_base(typename traits::data_type const& data);
+
+//<-
+#if 0
+//->
+ with_position_base(with_position_base const& copy);
+
+ with_position_base(with_position_base&& source);
+
+ with_position_base& operator=(with_position_base const& copy);
+
+ with_position_base& operator=(with_position_base&& source);
+//<-
+#endif
+
+ with_position_base(BOOST_RV_REF(with_position_base) source);
+
+ with_position_base&
+ operator=(BOOST_COPY_ASSIGN_REF(with_position_base) copy);
+
+ with_position_base&
+ operator=(BOOST_RV_REF(with_position_base) source);
+//->
+
+ const_iterator get_position() const;
+
+ iterator get_position();
+
+ //<-
+ protected:
+ void set_position_impl(iterator position, ::boost::mpl::true_);
+
+ void set_position_impl(iterator position, ::boost::mpl::false_);
+ //->
+ };
+
+ //<-
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_position_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_position_base() : super_t(), _position()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_position_base<Derived,BaseGenerator,T1,T2>::with_position_base(
+ typename traits::data_type const& data
+ ) : super_t(data), _position()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_position_base<Derived,BaseGenerator,T1,T2>::with_position_base(
+ BOOST_RV_REF(with_position_base) source
+ )
+ : super_t(::boost::move(static_cast<super_t&>(source)))
+ , _position(source._position)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline with_position_base<Derived,BaseGenerator,T1,T2>&
+ with_position_base<Derived,BaseGenerator,T1,T2>::operator=(
+ BOOST_COPY_ASSIGN_REF(with_position_base) copy
+ )
+ {
+ if (this != &copy)
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ _position = copy._position;
+ }
+
+ return *this;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline with_position_base<Derived,BaseGenerator,T1,T2>&
+ with_position_base<Derived,BaseGenerator,T1,T2>::operator=(
+ BOOST_RV_REF(with_position_base) source
+ )
+ {
+ if (this != &source)
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ _position = source._position;
+ }
+
+ return *this;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline typename with_position_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::const_iterator
+ with_position_base<Derived,BaseGenerator,T1,T2>::get_position() const
+ {
+ return _position;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline typename with_position_base<Derived,BaseGenerator,T1,T2>::iterator
+ with_position_base<Derived,BaseGenerator,T1,T2>::get_position()
+ {
+ return _position;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_position_base<Derived,BaseGenerator,T1, T2>::set_position_impl(
+ iterator position
+ , ::boost::mpl::true_ t
+ )
+ {
+ super_t::set_position_impl(position, t);
+ _position = position;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void
+ with_position_base<Derived,BaseGenerator,T1, T2>::set_position_impl(
+ iterator position
+ , ::boost::mpl::false_ f
+ )
+ {
+ super_t::set_position_impl(position, f);
+
+ iterator c_end = this->get_parent_ptr()->end();
+
+ for (
+ position = this->get_parent_ptr()->begin();
+ position != c_end;
+ ++position
+ )
+ {
+ dereference_iterator(position)._position = position;
+ }
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_position
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename T1, typename T2 = void>
+ class with_position
+ : public with_position_base<
+ with_position<BaseGenerator,T1,T2>
+ , BaseGenerator
+ , T1
+ , T2
+ >
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(with_position);
+ //->
+ typedef with_position_base<with_position,BaseGenerator,T1,T2> super_t;
+
+ public:
+ typedef typename super_t::traits traits;
+ typedef typename super_t::pointer pointer;
+ typedef typename super_t::const_pointer const_pointer;
+ typedef typename super_t::iterator iterator;
+ typedef typename super_t::const_iterator const_iterator;
+
+ with_position();
+
+ explicit with_position(typename traits::data_type const& data);
+
+//<-
+#if 0
+//->
+ with_position(with_position const& copy);
+
+ with_position(with_position&& source);
+
+ with_position& operator=(with_position const& copy);
+
+ with_position& operator=(with_position&& source);
+//<-
+#endif
+
+ with_position(BOOST_RV_REF(with_position) source);
+
+ with_position& operator=(BOOST_COPY_ASSIGN_REF(with_position) copy);
+
+ with_position& operator=(BOOST_RV_REF(with_position) source);
+//->
+ };
+
+ //<-
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_position<BaseGenerator,T1,T2>::with_position() : super_t()
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_position<BaseGenerator,T1,T2>::with_position(
+ typename traits::data_type const& data
+ ) : super_t(data)
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_position<BaseGenerator,T1,T2>::with_position(
+ BOOST_RV_REF(with_position) source
+ ) : super_t(::boost::move(static_cast<super_t&>(source)))
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ inline with_position<BaseGenerator,T1,T2>&
+ with_position<BaseGenerator,T1,T2>::operator=(
+ BOOST_COPY_ASSIGN_REF(with_position) copy
+ )
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ return *this;
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ inline with_position<BaseGenerator,T1,T2>&
+ with_position<BaseGenerator,T1,T2>::operator=(
+ BOOST_RV_REF(with_position) source
+ )
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ return *this;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_position_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator>
+ struct with_position_gen
+ {
+ template <typename Derived, typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_position_base<Derived,BaseGenerator,T1,T2> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_WITH_POSITION_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_red_black_flag.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_red_black_flag.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,351 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/move/move.hpp>
+
+//[reference__with_red_black_flag_base
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ class with_red_black_flag_base
+ : public ::boost::mpl::eval_if<
+ ::std::tr1::is_void<T2>
+ , ::boost::mpl::apply_wrap2<BaseGenerator,Derived,T1>
+ , ::boost::mpl::apply_wrap3<BaseGenerator,Derived,T1,T2>
+ >::type
+ {
+ //<-
+ BOOST_COPYABLE_AND_MOVABLE(with_red_black_flag_base);
+ //->
+ typedef typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<T2>
+ , ::boost::mpl::apply_wrap2<BaseGenerator,Derived,T1>
+ , ::boost::mpl::apply_wrap3<BaseGenerator,Derived,T1,T2>
+ >::type
+ super_t;
+
+ public:
+ typedef typename super_t::traits
+ traits;
+ typedef typename super_t::pointer
+ pointer;
+ typedef typename super_t::const_pointer
+ const_pointer;
+ typedef typename super_t::iterator
+ iterator;
+ typedef typename super_t::const_iterator
+ const_iterator;
+
+ //<-
+ private:
+ bool _is_red;
+
+ public:
+ //->
+ with_red_black_flag_base();
+
+ explicit with_red_black_flag_base(
+ typename traits::data_type const& data
+ );
+
+//<-
+#if 0
+//->
+ with_red_black_flag_base(with_red_black_flag_base const& copy);
+
+ with_red_black_flag_base(with_red_black_flag_base&& source);
+
+ with_red_black_flag_base&
+ operator=(with_red_black_flag_base const& copy);
+
+ with_red_black_flag_base&
+ operator=(with_red_black_flag_base&& source);
+//<-
+#endif
+
+ with_red_black_flag_base(
+ BOOST_RV_REF(with_red_black_flag_base) source
+ );
+
+ with_red_black_flag_base&
+ operator=(BOOST_COPY_ASSIGN_REF(with_red_black_flag_base) copy);
+
+ with_red_black_flag_base&
+ operator=(BOOST_RV_REF(with_red_black_flag_base) source);
+//->
+
+ bool is_red() const;
+
+ bool is_black() const;
+
+ void set_red_flag(bool flag);
+ };
+
+ //<-
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_red_black_flag_base() : super_t(), _is_red(false)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_red_black_flag_base(typename traits::data_type const& data)
+ : super_t(data), _is_red(false)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_red_black_flag_base(BOOST_RV_REF(with_red_black_flag_base) source)
+ : super_t(::boost::move(static_cast<super_t&>(source)))
+ , _is_red(source._is_red)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline with_red_black_flag_base<Derived,BaseGenerator,T1,T2>&
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>::operator=(
+ BOOST_COPY_ASSIGN_REF(with_red_black_flag_base) copy
+ )
+ {
+ if (this != &copy)
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ _is_red = copy._is_red;
+ }
+
+ return *this;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline with_red_black_flag_base<Derived,BaseGenerator,T1,T2>&
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>::operator=(
+ BOOST_RV_REF(with_red_black_flag_base) source
+ )
+ {
+ if (this != &source)
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ _is_red = source._is_red;
+ }
+
+ return *this;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline bool
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>::is_red() const
+ {
+ return _is_red;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline bool
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::is_black() const
+ {
+ return !_is_red;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>::set_red_flag(
+ bool flag
+ )
+ {
+ _is_red = flag;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_red_black_flag
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename T1, typename T2 = void>
+ class with_red_black_flag
+ : public with_red_black_flag_base<
+ with_red_black_flag<BaseGenerator,T1,T2>
+ , BaseGenerator
+ , T1
+ , T2
+ >
+ {
+ typedef with_red_black_flag_base<
+ with_red_black_flag
+ , BaseGenerator
+ , T1
+ , T2
+ >
+ super_t;
+
+ public:
+ typedef typename super_t::traits
+ traits;
+ typedef typename super_t::pointer
+ pointer;
+ typedef typename super_t::const_pointer
+ const_pointer;
+ typedef typename super_t::iterator
+ iterator;
+ typedef typename super_t::const_iterator
+ const_iterator;
+
+ with_red_black_flag();
+
+ explicit with_red_black_flag(typename traits::data_type const& data);
+
+//<-
+#if 0
+//->
+ with_red_black_flag(with_red_black_flag const& copy);
+
+ with_red_black_flag(with_red_black_flag&& source);
+
+ with_red_black_flag& operator=(with_red_black_flag const& copy);
+
+ with_red_black_flag& operator=(with_red_black_flag&& source);
+//<-
+#endif
+
+ with_red_black_flag(BOOST_RV_REF(with_red_black_flag) source);
+
+ with_red_black_flag&
+ operator=(BOOST_COPY_ASSIGN_REF(with_red_black_flag) copy);
+
+ with_red_black_flag&
+ operator=(BOOST_RV_REF(with_red_black_flag) source);
+//->
+ };
+
+ //<-
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_red_black_flag<BaseGenerator,T1,T2>::with_red_black_flag() : super_t()
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_red_black_flag<BaseGenerator,T1,T2>::with_red_black_flag(
+ typename traits::data_type const& data
+ ) : super_t(data)
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ with_red_black_flag<BaseGenerator,T1,T2>::with_red_black_flag(
+ BOOST_RV_REF(with_red_black_flag) source
+ ) : super_t(::boost::move(static_cast<super_t&>(source)))
+ {
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ inline with_red_black_flag<BaseGenerator,T1,T2>&
+ with_red_black_flag<BaseGenerator,T1,T2>::operator=(
+ BOOST_COPY_ASSIGN_REF(with_red_black_flag) copy
+ )
+ {
+ super_t::operator=(static_cast<super_t const&>(copy));
+ return *this;
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ inline with_red_black_flag<BaseGenerator,T1,T2>&
+ with_red_black_flag<BaseGenerator,T1,T2>::operator=(
+ BOOST_RV_REF(with_red_black_flag) source
+ )
+ {
+ super_t::operator=(::boost::move(static_cast<super_t&>(source)));
+ return *this;
+ }
+ //->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_red_black_flag_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator>
+ struct with_red_black_flag_gen
+ {
+ template <typename Derived, typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_red_black_flag_base<Derived,BaseGenerator,T1,T2>
+ type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_HPP_INCLUDED
+

Added: sandbox/tree_node/libs/tree_node/example/associative_node.cpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/associative_node.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,250 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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 <iostream>
+#include <boost/assert.hpp>
+#include <boost/tr1/tuple.hpp>
+#include <boost/tree_node/typeof.hpp>
+#include "default_unconstruct_type.hpp"
+#include "show_functions.hpp"
+#include "showcase_desc_iterators.hpp"
+
+typedef boost::tree_node::associative_node<
+ char const*
+ , default_unconstructible_example_type
+ , boost::multimapS
+ >
+ DNode;
+typedef boost::tree_node::with_depth<
+ boost::tree_node::with_position_gen<
+ boost::tree_node::associative_node_gen<
+ boost::hash_multimapS
+ >
+ >
+ , char const*
+ , char*
+ >
+ ANode;
+
+int main()
+{
+ char const* names[] = {"able", "baker", "charlie", "dog", "easy", "fox"};
+ DNode d_root(create_instance(5));
+ ANode a_root;
+
+ BOOST_ASSERT(
+ !d_root.get_parent_ptr()
+ && "Parent member uninitialized."
+ );
+ BOOST_ASSERT(
+ !a_root.get_data()
+ && "Data member not default-constructed."
+ );
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_breadth_first_iterator(d_root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ std::size_t const count = itr->get_data().number;
+
+ if (1 < count)
+ {
+ for (std::size_t i = 0; i < count; ++i)
+ {
+ for (std::size_t j = 0; j + i < count; ++j)
+ {
+ DNode::iterator child_itr(
+ itr->add_child(names[j], create_instance(i))
+ );
+ DNode const& const_child(child_itr->second);
+
+ BOOST_ASSERT(
+ (child_itr->second.get_parent_ptr() == &*itr)
+ && "Ctor not linking child to parent."
+ );
+ BOOST_ASSERT(
+ (
+ child_itr->second.get_parent_ptr()
+ == const_child.get_parent_ptr()
+ )
+ && "Why are these pointers different?"
+ );
+ }
+ }
+ }
+ }
+
+ {
+ boost::tree_node::depth_first_iterate(d_root, show_number_tree());
+ std::cout << std::endl;
+ }
+
+ std::cout << "After d_root tree construction," << std::endl;
+ showcase_descendant_iterators(
+ d_root
+ , show_key_and_number<char const*,DNode>
+ , show_key_and_number_tree()
+ );
+
+ {
+ DNode::iterator d_child_itr = d_root.find_child(
+ names[2]
+ )->second.add_child_copy(names[5], d_root);
+
+ std::cout << "After add_child_copy call," << std::endl;
+ showcase_descendant_iterators(
+ d_root
+ , show_key_and_number<char const*,DNode>
+ , show_key_and_number_tree()
+ );
+
+ d_root = d_child_itr->second;
+ std::cout << "After assignment to descendant," << std::endl;
+ showcase_descendant_iterators(
+ d_root
+ , show_key_and_number<char const*,DNode>
+ , show_key_and_number_tree()
+ );
+ }
+
+ d_root.find_child(names[4])->second = d_root;
+ std::cout << "After assignment to ancestor," << std::endl;
+ showcase_descendant_iterators(
+ d_root
+ , show_key_and_number<char const*,DNode>
+ , show_key_and_number_tree()
+ );
+
+ {
+ char* root_data = new char[2];
+
+ root_data[0] = '5';
+ root_data[1] = '\0';
+ a_root.get_data() = root_data;
+ }
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_breadth_first_iterator(a_root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ char digit = itr->get_data()[0];
+
+ if ('1' < digit)
+ {
+ char numchar = digit;
+
+ while (numchar != '0')
+ {
+ --numchar;
+
+ for (char j = 0; numchar + j < digit; ++j)
+ {
+ ANode::iterator child_itr(itr->add_child(names[j]));
+ char*& data = child_itr->second.get_data();
+
+ BOOST_ASSERT(
+ !data
+ && "Data member not default-constructed."
+ );
+ data = new char[2];
+ data[0] = numchar;
+ data[1] = '\0';
+ BOOST_ASSERT(
+ (child_itr->second.get_parent_ptr() == &*itr)
+ && "Ctor not linking child to parent."
+ );
+ BOOST_ASSERT(
+ (child_itr->second.get_position() == child_itr)
+ && "Position iterator incorrect."
+ );
+ }
+ }
+ }
+ }
+
+ std::cout << "After a_root tree construction," << std::endl;
+ showcase_descendant_iterators(
+ a_root
+ , show_key_and_data<char const*,ANode>
+ , show_key_and_data_tree()
+ );
+
+ {
+ ANode::iterator a_child_itr(
+ a_root.find_child(names[2])->second.add_child(names[5])
+ );
+ ANode& a_child(a_child_itr->second);
+
+ a_child.get_data() = new char[2];
+ a_child.get_data()[0] = '7';
+ a_child.get_data()[1] = '\0';
+ BOOST_ASSERT(
+ (a_child.get_position() == a_child_itr)
+ && "Position iterator incorrect."
+ );
+ std::cout << "After a_child construction," << std::endl;
+ showcase_descendant_iterators(
+ a_root
+ , show_key_and_data<char const*,ANode>
+ , show_key_and_data_tree()
+ );
+ }
+
+ {
+ ANode& to_be_pruned = a_root.begin()->second;
+ ANode::iterator c_itr, c_end;
+
+ for (
+ ::std::tr1::tie(c_itr, c_end) = to_be_pruned.find_children(
+ names[1]
+ );
+ c_itr != c_end;
+ ++c_itr
+ )
+ {
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_pre_order_iterator(c_itr->second)
+ );
+ itr;
+ ++itr
+ )
+ {
+ delete[] itr->get_data();
+ }
+ }
+
+ to_be_pruned.remove_children(names[1]);
+ std::cout << "After remove_children call," << std::endl;
+ showcase_descendant_iterators(
+ a_root
+ , show_key_and_data<char const*,ANode>
+ , show_key_and_data_tree()
+ );
+ }
+
+ for (
+ BOOST_AUTO(itr, boost::tree_node::make_post_order_iterator(a_root));
+ itr;
+ ++itr
+ )
+ {
+ delete[] itr->get_data();
+ }
+
+ return 0;
+}
+

Added: sandbox/tree_node/libs/tree_node/example/binary_node.cpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/binary_node.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,244 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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 <iostream>
+#include <boost/assert.hpp>
+#include <boost/tree_node/typeof.hpp>
+#include "default_unconstruct_type.hpp"
+#include "show_functions.hpp"
+#include "showcase_iterators.hpp"
+
+typedef boost::tree_node::binary_node<default_unconstructible_example_type>
+ DNode;
+typedef boost::tree_node::with_depth<
+ boost::tree_node::with_position_gen<
+ boost::tree_node::binary_node_gen
+ >
+ , char*
+ >
+ ANode;
+
+int main()
+{
+ DNode d_root(create_instance(5));
+ ANode a_root;
+
+ BOOST_ASSERT(
+ !d_root.get_parent_ptr()
+ && "Parent member uninitialized."
+ );
+ BOOST_ASSERT(
+ !a_root.get_data()
+ && "Data member not default-constructed."
+ );
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_breadth_first_iterator(d_root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ std::size_t const count = itr->get_data().number;
+
+ if (1 < count)
+ {
+ DNode::iterator child_itr(
+ itr->add_left_child(create_instance(count - 2))
+ );
+ DNode::const_pointer const_child(&*child_itr);
+
+ BOOST_ASSERT(
+ (child_itr->get_parent_ptr() == &*itr)
+ && "Ctor not linking child to parent."
+ );
+ BOOST_ASSERT(
+ (itr->get_left_child_ptr() == &*child_itr)
+ && "Ctor not linking parent to child."
+ );
+ BOOST_ASSERT(
+ (child_itr->get_parent_ptr() == const_child->get_parent_ptr())
+ && "Why are these pointers different?"
+ );
+
+ child_itr = itr->add_right_child(create_instance(count - 1));
+ const_child = &*child_itr;
+
+ BOOST_ASSERT(
+ (child_itr->get_parent_ptr() == &*itr)
+ && "Ctor not linking child to parent."
+ );
+ BOOST_ASSERT(
+ (itr->get_right_child_ptr() == &*child_itr)
+ && "Ctor not linking parent to child."
+ );
+ BOOST_ASSERT(
+ (child_itr->get_parent_ptr() == const_child->get_parent_ptr())
+ && "Why are these pointers different?"
+ );
+ }
+ }
+
+ std::cout << "After d_root tree construction," << std::endl;
+ showcase_in_order_iterator(d_root, show_number<DNode>);
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+
+ {
+ DNode::pointer p = d_root.get_left_child_ptr()->get_left_child_ptr();
+ DNode::iterator p_child_itr = p->add_left_child_copy(d_root);
+
+ std::cout << "After add_left_child_copy call," << std::endl;
+ showcase_in_order_iterator(d_root, show_number<DNode>);
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+
+ d_root = *p_child_itr;
+ std::cout << "After assignment to descendant," << std::endl;
+ showcase_in_order_iterator(d_root, show_number<DNode>);
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+ }
+
+ *(d_root.get_right_child_ptr()) = d_root;
+ std::cout << "After assignment to ancestor," << std::endl;
+ showcase_in_order_iterator(d_root, show_number<DNode>);
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+
+ d_root.get_right_child_ptr()->rotate_left();
+ std::cout << "After rotate_left call," << std::endl;
+ showcase_in_order_iterator(d_root, show_number<DNode>);
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+
+ {
+ char* root_data = new char[2];
+
+ root_data[0] = '5';
+ root_data[1] = '\0';
+ a_root.get_data() = root_data;
+ }
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_breadth_first_iterator(a_root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ char digit = itr->get_data()[0];
+
+ if ('1' < digit)
+ {
+ {
+ ANode::iterator child_itr(itr->add_left_child());
+ char*& data = child_itr->get_data();
+
+ BOOST_ASSERT(
+ !data
+ && "Data member not default-constructed."
+ );
+ data = new char[2];
+ data[0] = digit - 1;
+ data[1] = '\0';
+ BOOST_ASSERT(
+ (child_itr->get_parent_ptr() == &*itr)
+ && "Ctor not linking child to parent."
+ );
+ BOOST_ASSERT(
+ (itr->get_left_child_ptr() == &*child_itr)
+ && "Ctor not linking parent to child."
+ );
+ BOOST_ASSERT(
+ (child_itr->get_position() == child_itr)
+ && "Position iterator incorrect."
+ );
+ }
+
+ {
+ ANode::iterator child_itr(itr->add_right_child());
+ char*& data = child_itr->get_data();
+
+ BOOST_ASSERT(
+ !data
+ && "Data member not default-constructed."
+ );
+ data = new char[2];
+ data[0] = digit - 2;
+ data[1] = '\0';
+ BOOST_ASSERT(
+ (child_itr->get_parent_ptr() == &*itr)
+ && "Ctor not linking child to parent."
+ );
+ BOOST_ASSERT(
+ (itr->get_right_child_ptr() == &*child_itr)
+ && "Ctor not linking parent to child."
+ );
+ BOOST_ASSERT(
+ (child_itr->get_position() == child_itr)
+ && "Position iterator incorrect."
+ );
+ }
+ }
+ }
+
+ std::cout << "After a_root tree construction," << std::endl;
+ showcase_in_order_iterator(a_root, show_data<ANode>);
+ showcase_iterators(a_root, show_data<ANode>, show_data_tree());
+
+ {
+ ANode::pointer p(a_root.get_right_child_ptr()->get_right_child_ptr());
+ ANode::iterator p_child_itr(p->add_right_child());
+
+ p_child_itr->get_data() = new char[2];
+ p_child_itr->get_data()[0] = '7';
+ p_child_itr->get_data()[1] = '\0';
+ BOOST_ASSERT(
+ (p_child_itr->get_position() == p_child_itr)
+ && "Position iterator incorrect."
+ );
+ std::cout << "After add_right_child call," << std::endl;
+ showcase_in_order_iterator(a_root, show_data<ANode>);
+ showcase_iterators(a_root, show_data<ANode>, show_data_tree());
+ }
+
+ a_root.get_left_child_ptr()->rotate_right();
+ std::cout << "After rotate_right call," << std::endl;
+ showcase_in_order_iterator(a_root, show_data<ANode>);
+ showcase_iterators(a_root, show_data<ANode>, show_data_tree());
+
+ {
+ ANode::iterator leaf = a_root.begin();
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_pre_order_descendant_iterator(*leaf)
+ );
+ itr;
+ ++itr
+ )
+ {
+ delete[] itr->get_data();
+ }
+
+ leaf->clear();
+ std::cout << "After clear call," << std::endl;
+ showcase_in_order_iterator(a_root, show_data<ANode>);
+ showcase_iterators(a_root, show_data<ANode>, show_data_tree());
+ }
+
+ for (
+ BOOST_AUTO(itr, boost::tree_node::make_post_order_iterator(a_root));
+ itr;
+ ++itr
+ )
+ {
+ delete[] itr->get_data();
+ }
+
+ return 0;
+}
+

Added: sandbox/tree_node/libs/tree_node/example/default_unconstruct_type.cpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/default_unconstruct_type.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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 "default_unconstruct_type.hpp"
+
+//[example__default_unconstructible_type__definitions
+default_unconstructible_example_type::default_unconstructible_example_type()
+{
+}
+
+default_unconstructible_example_type create_instance(std::size_t n)
+{
+ default_unconstructible_example_type instance;
+ instance.number = n;
+ return instance;
+}
+
+bool
+ operator==(
+ default_unconstructible_example_type const& lhs
+ , default_unconstructible_example_type const& rhs
+ )
+{
+ return lhs.number == rhs.number;
+}
+
+bool
+ operator<(
+ default_unconstructible_example_type const& lhs
+ , default_unconstructible_example_type const& rhs
+ )
+{
+ return lhs.number < rhs.number;
+}
+//]
+

Added: sandbox/tree_node/libs/tree_node/example/default_unconstruct_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/default_unconstruct_type.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,43 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef LIBS_TREE_NODE_EXAMPLE_DEFAULT_UNCONSTRUCT_TYPE_HPP_INCLUDED
+#define LIBS_TREE_NODE_EXAMPLE_DEFAULT_UNCONSTRUCT_TYPE_HPP_INCLUDED
+
+#include <vector>
+
+//[example__default_unconstructible_type
+class default_unconstructible_example_type
+{
+ default_unconstructible_example_type();
+
+ friend default_unconstructible_example_type
+ create_instance(std::size_t n);
+
+ public:
+ std::size_t number;
+};
+//]
+
+//[example__default_unconstructible_type__operator_equal
+bool
+ operator==(
+ default_unconstructible_example_type const& lhs
+ , default_unconstructible_example_type const& rhs
+ );
+//]
+
+//[example__default_unconstructible_type__operator_less
+bool
+ operator<(
+ default_unconstructible_example_type const& lhs
+ , default_unconstructible_example_type const& rhs
+ );
+//]
+
+default_unconstructible_example_type create_instance(std::size_t n);
+
+#endif // LIBS_TREE_NODE_EXAMPLE_DEFAULT_UNCONSTRUCT_TYPE_HPP_INCLUDED
+

Deleted: sandbox/tree_node/libs/tree_node/example/default_unconstructible_type.cpp
==============================================================================
--- sandbox/tree_node/libs/tree_node/example/default_unconstructible_type.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,20 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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 "default_unconstructible_type.hpp"
-
-//[example__default_unconstructible_type__definitions
-default_unconstructible_example_type::default_unconstructible_example_type()
-{
-}
-
-default_unconstructible_example_type create_instance(std::size_t n)
-{
- default_unconstructible_example_type instance;
- instance.number = n;
- return instance;
-}
-//]
-

Deleted: sandbox/tree_node/libs/tree_node/example/default_unconstructible_type.hpp
==============================================================================
--- sandbox/tree_node/libs/tree_node/example/default_unconstructible_type.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,27 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef LIBS_TREE_NODE_EXAMPLE_DEFAULT_UNCONSTRUCTIBLE_TYPE_HPP_INCLUDED
-#define LIBS_TREE_NODE_EXAMPLE_DEFAULT_UNCONSTRUCTIBLE_TYPE_HPP_INCLUDED
-
-#include <vector>
-
-//[example__default_unconstructible_type
-class default_unconstructible_example_type
-{
- default_unconstructible_example_type();
-
- friend default_unconstructible_example_type
- create_instance(std::size_t n);
-
- public:
- std::size_t number;
-};
-//]
-
-default_unconstructible_example_type create_instance(std::size_t n);
-
-#endif // LIBS_TREE_NODE_EXAMPLE_DEFAULT_UNCONSTRUCTIBLE_TYPE_HPP_INCLUDED
-

Added: sandbox/tree_node/libs/tree_node/example/nary_node.cpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/nary_node.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,198 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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 <iostream>
+#include <iterator>
+#include <boost/assert.hpp>
+#include <boost/tree_node/typeof.hpp>
+#include "default_unconstruct_type.hpp"
+#include "show_functions.hpp"
+#include "showcase_iterators.hpp"
+
+typedef boost::tree_node::nary_node<default_unconstructible_example_type>
+ DNode;
+typedef boost::tree_node::with_depth<
+ boost::tree_node::with_position_gen<
+ boost::tree_node::nary_node_gen<boost::slistS>
+ >
+ , char*
+ >
+ ANode;
+
+int main()
+{
+ DNode d_root(create_instance(5));
+ ANode a_root;
+
+ BOOST_ASSERT(
+ !d_root.get_parent_ptr()
+ && "Parent member uninitialized."
+ );
+ BOOST_ASSERT(
+ !a_root.get_data()
+ && "Data member not default-constructed."
+ );
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_breadth_first_iterator(d_root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ std::size_t const count = itr->get_data().number;
+
+ if (1 < count)
+ {
+ for (std::size_t i = 0; i < count; ++i)
+ {
+ DNode::iterator child_itr(itr->add_child(create_instance(i)));
+ DNode::const_pointer const_child(&*child_itr);
+
+ BOOST_ASSERT(
+ (child_itr->get_parent_ptr() == &*itr)
+ && "Ctor not linking child to parent."
+ );
+ BOOST_ASSERT(
+ (&*child_itr == &*(itr->begin() + i))
+ && "Ctor not linking parent to child."
+ );
+ BOOST_ASSERT(
+ (
+ child_itr->get_parent_ptr()
+ == const_child->get_parent_ptr()
+ )
+ && "Why are these pointers different?"
+ );
+ }
+ }
+ }
+
+ std::cout << "After d_root tree construction," << std::endl;
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+
+ {
+ DNode::iterator d_child = (d_root.begin() + 2)->add_child_copy(d_root);
+
+ std::cout << "After add_child_copy call," << std::endl;
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+
+ d_root = *d_child;
+ std::cout << "After assignment to descendant," << std::endl;
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+ }
+
+ *(d_root.begin() + 4) = d_root;
+ std::cout << "After assignment to ancestor," << std::endl;
+ showcase_iterators(d_root, show_number<DNode>, show_number_tree());
+
+ {
+ char* root_data = new char[2];
+
+ root_data[0] = '5';
+ root_data[1] = '\0';
+ a_root.get_data() = root_data;
+ }
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_breadth_first_iterator(a_root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ char digit = itr->get_data()[0];
+
+ if ('1' < digit)
+ {
+ char numchar = digit;
+
+ while (numchar != '0')
+ {
+ ANode::iterator child_itr(itr->add_child());
+ char*& data = child_itr->get_data();
+
+ BOOST_ASSERT(
+ !data
+ && "Data member not default-constructed."
+ );
+ data = new char[2];
+ data[0] = --numchar;
+ data[1] = '\0';
+ BOOST_ASSERT(
+ (child_itr->get_parent_ptr() == &*itr)
+ && "Ctor not linking child to parent."
+ );
+ BOOST_ASSERT(
+ (child_itr->get_position() == child_itr)
+ && "Position iterator incorrect."
+ );
+
+ {
+ ANode::iterator c_itr = itr->begin();
+
+ std::advance(c_itr, digit - (numchar + 1));
+ BOOST_ASSERT(
+ (child_itr == c_itr)
+ && "Ctor not linking parent to child."
+ );
+ }
+ }
+ }
+ }
+
+ std::cout << "After a_root tree construction," << std::endl;
+ showcase_iterators(a_root, show_data<ANode>, show_data_tree());
+
+ {
+ ANode::iterator a_child_itr((++(++a_root.begin()))->add_child());
+
+ a_child_itr->get_data() = new char[2];
+ a_child_itr->get_data()[0] = '7';
+ a_child_itr->get_data()[1] = '\0';
+ BOOST_ASSERT(
+ (a_child_itr->get_position() == a_child_itr)
+ && "Position iterator incorrect."
+ );
+ std::cout << "After add_child no-argument call," << std::endl;
+ showcase_iterators(a_root, show_data<ANode>, show_data_tree());
+ }
+
+ {
+ ANode::iterator leaf = a_root.begin();
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_pre_order_descendant_iterator(*leaf)
+ );
+ itr;
+ ++itr
+ )
+ {
+ delete[] itr->get_data();
+ }
+
+ leaf->clear();
+ std::cout << "After clear call," << std::endl;
+ showcase_iterators(a_root, show_data<ANode>, show_data_tree());
+ }
+
+ for (
+ BOOST_AUTO(itr, boost::tree_node::make_post_order_iterator(a_root));
+ itr;
+ ++itr
+ )
+ {
+ delete[] itr->get_data();
+ }
+
+ return 0;
+}
+

Deleted: sandbox/tree_node/libs/tree_node/example/raw_associative_node.cpp
==============================================================================
--- sandbox/tree_node/libs/tree_node/example/raw_associative_node.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,238 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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 <iostream>
-#include <boost/assert.hpp>
-#include <boost/tr1/tuple.hpp>
-#include <boost/tree_node/typeof.hpp>
-#include "default_unconstructible_type.hpp"
-#include "show_functions.hpp"
-#include "showcase_descendant_iterators.hpp"
-
-typedef boost::tree_node::raw_associative_node<
- char const*
- , default_unconstructible_example_type
- , boost::multimapS
- >
- DNode;
-typedef boost::tree_node::with_depth<
- boost::tree_node::raw_associative_node_gen<boost::hash_multimapS>
- >
- , char const*
- , char*
- >
- ANode;
-typedef boost::tree_node::factory<ANode>
- ANodeFactory;
-
-int main()
-{
- char const* names[] = {"able", "baker", "charlie", "dog", "easy", "fox"};
- DNode d_root(create_instance(5));
- ANode::pointer a_root(ANodeFactory::create());
-
- BOOST_ASSERT(
- !d_root.get_parent()
- && "Parent member uninitialized."
- );
- BOOST_ASSERT(
- !a_root->get_data()
- && "Data member not default-constructed."
- );
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_breadth_first_iterator(&d_root)
- );
- itr;
- ++itr
- )
- {
- std::size_t const count = (*itr)->get_data().number;
-
- if (1 < count)
- {
- for (std::size_t i = 0; i < count; ++i)
- {
- for (std::size_t j = 0; j + i < count; ++j)
- {
- DNode::pointer child(
- (*itr)->add_child(names[j], create_instance(i))
- );
- DNode::const_pointer const_child(child);
-
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- BOOST_ASSERT(
- (child->get_parent() == const_child->get_parent())
- && "Why are these pointers different?"
- );
- }
- }
- }
- }
-
- {
- boost::tree_node::depth_first_iterate(&d_root, show_number_tree());
- std::cout << std::endl;
- }
-
- std::cout << "After d_root tree construction," << std::endl;
- showcase_descendant_iterators(
- DNode::const_pointer(&d_root)
- , show_key_and_number<char const*,DNode::const_pointer>
- , show_key_and_number_tree()
- );
-
- {
- DNode::pointer d_child = d_root.find_child(
- names[2]
- )->second->add_child_copy(names[5], &d_root);
-
- std::cout << "After add_child_copy call," << std::endl;
- showcase_descendant_iterators(
- DNode::const_pointer(&d_root)
- , show_key_and_number<char const*,DNode::const_pointer>
- , show_key_and_number_tree()
- );
-
- d_root = *d_child;
- std::cout << "After assignment to descendant," << std::endl;
- showcase_descendant_iterators(
- DNode::const_pointer(&d_root)
- , show_key_and_number<char const*,DNode::const_pointer>
- , show_key_and_number_tree()
- );
- }
-
- *(d_root.find_child(names[4])->second) = d_root;
- std::cout << "After assignment to ancestor," << std::endl;
- showcase_descendant_iterators(
- DNode::const_pointer(&d_root)
- , show_key_and_number<char const*,DNode::const_pointer>
- , show_key_and_number_tree()
- );
-
- {
- char* root_data = new char[2];
-
- root_data[0] = '5';
- root_data[1] = '\0';
- a_root->get_data() = root_data;
- }
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_breadth_first_iterator(a_root)
- );
- itr;
- ++itr
- )
- {
- char digit = (*itr)->get_data()[0];
-
- if ('1' < digit)
- {
- char numchar = digit;
-
- while (numchar != '0')
- {
- --numchar;
-
- for (char j = 0; numchar + j < digit; ++j)
- {
- ANode::pointer child((*itr)->add_child(names[j]));
- char*& data = child->get_data();
-
- BOOST_ASSERT(
- !data
- && "Data member not default-constructed."
- );
- data = new char[2];
- data[0] = numchar;
- data[1] = '\0';
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- }
- }
- }
- }
-
- std::cout << "After a_root tree construction," << std::endl;
- showcase_descendant_iterators(
- ANode::const_pointer(a_root)
- , show_key_and_data<char const*,ANode::const_pointer>
- , show_key_and_data_tree()
- );
-
- {
- ANode::pointer a_child(
- a_root->find_child(names[2])->second->add_child(names[5])
- );
-
- a_child->get_data() = new char[2];
- a_child->get_data()[0] = '7';
- a_child->get_data()[1] = '\0';
- std::cout << "After a_child construction," << std::endl;
- showcase_descendant_iterators(
- ANode::const_pointer(a_root)
- , show_key_and_data<char const*,ANode::const_pointer>
- , show_key_and_data_tree()
- );
- }
-
- {
- ANode::pointer to_be_pruned = a_root->get_child_begin()->second;
- ANode::child_iterator c_itr, c_end;
-
- for (
- std::tr1::tie(c_itr, c_end) = to_be_pruned->find_children(
- names[1]
- );
- c_itr != c_end;
- ++c_itr
- )
- {
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_pre_order_iterator(c_itr->second)
- );
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
- }
-
- to_be_pruned->remove_children(names[1]);
- std::cout << "After remove_children call," << std::endl;
- showcase_descendant_iterators(
- ANode::const_pointer(a_root)
- , show_key_and_data<char const*,ANode::const_pointer>
- , show_key_and_data_tree()
- );
- }
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_post_order_iterator(a_root));
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
-
- delete a_root;
- return 0;
-}
-

Deleted: sandbox/tree_node/libs/tree_node/example/raw_binary_node.cpp
==============================================================================
--- sandbox/tree_node/libs/tree_node/example/raw_binary_node.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,280 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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 <iostream>
-#include <boost/assert.hpp>
-#include <boost/tree_node/typeof.hpp>
-#include "default_unconstructible_type.hpp"
-#include "show_functions.hpp"
-#include "showcase_iterators.hpp"
-
-typedef boost::tree_node::raw_binary_node<default_unconstructible_example_type>
- DNode;
-typedef boost::tree_node::with_depth<
- boost::tree_node::raw_binary_node_gen
- , char*
- >
- ANode;
-typedef boost::tree_node::factory<ANode>
- ANodeFactory;
-
-int main()
-{
- DNode d_root(create_instance(5));
- ANode::pointer a_root(ANodeFactory::create());
-
- BOOST_ASSERT(
- !d_root.get_parent()
- && "Parent member uninitialized."
- );
- BOOST_ASSERT(
- !a_root->get_data()
- && "Data member not default-constructed."
- );
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_breadth_first_iterator(&d_root)
- );
- itr;
- ++itr
- )
- {
- std::size_t const count = (*itr)->get_data().number;
-
- if (1 < count)
- {
- DNode::pointer child(
- (*itr)->add_left_child(create_instance(count - 2))
- );
- DNode::const_pointer const_child(child);
-
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- BOOST_ASSERT(
- (child->get_parent() == const_child->get_parent())
- && "Why are these pointers different?"
- );
-
- child = (*itr)->add_right_child(create_instance(count - 1));
- const_child = child;
-
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- BOOST_ASSERT(
- (child->get_parent() == const_child->get_parent())
- && "Why are these pointers different?"
- );
- }
- }
-
- std::cout << "After d_root tree construction," << std::endl;
- showcase_in_order_iterator(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- );
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- {
- DNode::pointer p = d_root.get_left_child()->get_left_child();
- DNode::pointer p_child = p->add_left_child_copy(&d_root);
-
- std::cout << "After add_left_child_copy call," << std::endl;
- showcase_in_order_iterator(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- );
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- d_root = *p_child;
- std::cout << "After assignment to descendant," << std::endl;
- showcase_in_order_iterator(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- );
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
- }
-
- *(d_root.get_right_child()) = d_root;
- std::cout << "After assignment to ancestor," << std::endl;
- showcase_in_order_iterator(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- );
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- d_root.get_right_child()->rotate_left();
- std::cout << "After rotate_left call," << std::endl;
- showcase_in_order_iterator(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- );
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- {
- char* root_data = new char[2];
-
- root_data[0] = '5';
- root_data[1] = '\0';
- a_root->get_data() = root_data;
- }
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_breadth_first_iterator(a_root)
- );
- itr;
- ++itr
- )
- {
- char digit = (*itr)->get_data()[0];
-
- if ('1' < digit)
- {
- {
- ANode::pointer child((*itr)->add_left_child());
- char*& data = child->get_data();
-
- BOOST_ASSERT(
- !data
- && "Data member not default-constructed."
- );
- data = new char[2];
- data[0] = digit - 1;
- data[1] = '\0';
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- }
-
- {
- ANode::pointer child((*itr)->add_right_child());
- char*& data = child->get_data();
-
- BOOST_ASSERT(
- !data
- && "Data member not default-constructed."
- );
- data = new char[2];
- data[0] = digit - 2;
- data[1] = '\0';
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- }
- }
- }
-
- std::cout << "After a_root tree construction," << std::endl;
- showcase_in_order_iterator(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- );
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
-
- {
- ANode::pointer p = a_root->get_right_child()->get_right_child();
- ANode::pointer p_child = p->add_right_child();
-
- p_child->get_data() = new char[2];
- p_child->get_data()[0] = '7';
- p_child->get_data()[1] = '\0';
- std::cout << "After add_right_child call," << std::endl;
- showcase_in_order_iterator(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- );
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
- }
-
- a_root->get_left_child()->rotate_right();
- std::cout << "After rotate_right call," << std::endl;
- showcase_in_order_iterator(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- );
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
-
- {
- ANode::pointer leaf = *a_root->get_child_begin();
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_pre_order_descendant_iterator(leaf)
- );
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
-
- leaf->remove_all_children();
- std::cout << "After remove_all_children call," << std::endl;
- showcase_in_order_iterator(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- );
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
- }
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_post_order_iterator(a_root));
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
-
- delete a_root;
- return 0;
-}
-

Deleted: sandbox/tree_node/libs/tree_node/example/raw_node.cpp
==============================================================================
--- sandbox/tree_node/libs/tree_node/example/raw_node.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,216 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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 <iostream>
-#include <boost/assert.hpp>
-#include <boost/tree_node/typeof.hpp>
-#include "default_unconstructible_type.hpp"
-#include "show_functions.hpp"
-#include "showcase_iterators.hpp"
-
-typedef boost::tree_node::raw_node<default_unconstructible_example_type>
- DNode;
-typedef boost::tree_node::with_depth<
- boost::tree_node::raw_node_gen<>
- , char*
- >
- ANode;
-typedef boost::tree_node::factory<ANode>
- ANodeFactory;
-
-int main()
-{
- DNode d_root(create_instance(5));
- ANode::pointer a_root(ANodeFactory::create());
-
- BOOST_ASSERT(
- !d_root.get_parent()
- && "Parent member uninitialized."
- );
- BOOST_ASSERT(
- !a_root->get_data()
- && "Data member not default-constructed."
- );
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_breadth_first_iterator(&d_root)
- );
- itr;
- ++itr
- )
- {
- std::size_t const count = (*itr)->get_data().number;
-
- if (1 < count)
- {
- for (std::size_t i = 0; i < count; ++i)
- {
- DNode::pointer child((*itr)->add_child(create_instance(i)));
- DNode::const_pointer const_child(child);
-
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- BOOST_ASSERT(
- (child == *((*itr)->get_child_begin() + i))
- && "Ctor not linking parent to child."
- );
- BOOST_ASSERT(
- (child->get_parent() == const_child->get_parent())
- && "Why are these pointers different?"
- );
- }
- }
- }
-
- std::cout << "After d_root tree construction," << std::endl;
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- {
- DNode::pointer d_child = (
- *(d_root.get_child_begin() + 2)
- )->add_child_copy(&d_root);
-
- std::cout << "After add_child_copy call," << std::endl;
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- d_root = *d_child;
- std::cout << "After assignment to descendant," << std::endl;
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
- }
-
- *(*(d_root.get_child_begin() + 4)) = d_root;
- std::cout << "After assignment to ancestor," << std::endl;
- showcase_iterators(
- DNode::const_pointer(&d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- {
- char* root_data = new char[2];
-
- root_data[0] = '5';
- root_data[1] = '\0';
- a_root->get_data() = root_data;
- }
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_breadth_first_iterator(a_root)
- );
- itr;
- ++itr
- )
- {
- char digit = (*itr)->get_data()[0];
-
- if ('1' < digit)
- {
- char numchar = digit;
-
- while (numchar != '0')
- {
- ANode::pointer child((*itr)->add_child());
- char*& data = child->get_data();
-
- BOOST_ASSERT(
- !data
- && "Data member not default-constructed."
- );
- data = new char[2];
- data[0] = --numchar;
- data[1] = '\0';
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- BOOST_ASSERT(
- (
- child
- == *((*itr)->get_child_begin() + (digit - (numchar + 1)))
- )
- && "Ctor not linking parent to child."
- );
- }
- }
- }
-
- std::cout << "After a_root tree construction," << std::endl;
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
-
- {
- ANode::pointer a_child(
- (*(a_root->get_child_begin() + 2))->add_child()
- );
-
- a_child->get_data() = new char[2];
- a_child->get_data()[0] = '7';
- a_child->get_data()[1] = '\0';
- std::cout << "After a_child construction," << std::endl;
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
- }
-
- {
- ANode::pointer leaf = *a_root->get_child_begin();
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_pre_order_descendant_iterator(leaf)
- );
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
-
- leaf->remove_all_children();
- std::cout << "After remove_all_children call," << std::endl;
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
- }
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_post_order_iterator(a_root));
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
-
- delete a_root;
- return 0;
-}
-

Added: sandbox/tree_node/libs/tree_node/example/show_functions.cpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/show_functions.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,60 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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 "show_functions.hpp"
+
+//[example__show_tabs
+void
+ show_tabs(
+ boost::tree_node::traversal_state state
+ , unsigned int& ply_limit
+ )
+{
+ switch (state)
+ {
+ case boost::tree_node::pre_order_traversal:
+ {
+ ++ply_limit;
+
+ for (unsigned int ply = 0; ply < ply_limit; ++ply)
+ {
+ std::cout << " ";
+ }
+
+ std::cout << "Pre-order: ";
+ break;
+ }
+
+ case boost::tree_node::post_order_traversal:
+ {
+ for (unsigned int ply = 0; ply < ply_limit; ++ply)
+ {
+ std::cout << " ";
+ }
+
+ std::cout << "Post-order: ";
+ --ply_limit;
+ break;
+ }
+ }
+}
+//]
+
+show_number_tree::show_number_tree() : ply_limit(1)
+{
+}
+
+show_key_and_number_tree::show_key_and_number_tree() : ply_limit(1)
+{
+}
+
+show_data_tree::show_data_tree() : ply_limit(1)
+{
+}
+
+show_key_and_data_tree::show_key_and_data_tree() : ply_limit(1)
+{
+}
+

Added: sandbox/tree_node/libs/tree_node/example/show_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/show_functions.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,140 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef LIBS_TREE_NODE_EXAMPLE_SHOW_FUNCTIONS_HPP_INCLUDED
+#define LIBS_TREE_NODE_EXAMPLE_SHOW_FUNCTIONS_HPP_INCLUDED
+
+#include <iostream>
+#include <boost/tree_node/traversal_state.hpp>
+
+void
+ show_tabs(
+ boost::tree_node::traversal_state state
+ , unsigned int& ply_limit
+ );
+
+//[example__show_number
+template <typename Node>
+void show_number(Node const& node)
+{
+ std::cout << ' ' << node.get_data().number;
+}
+//]
+
+//[example__show_number_tree
+class show_number_tree
+{
+ unsigned int ply_limit;
+
+ public:
+ show_number_tree();
+
+ template <typename Node>
+ void
+ operator()(
+ Node const& node
+ , boost::tree_node::traversal_state state
+ )
+ {
+ show_tabs(state, ply_limit);
+ std::cout << node.get_data().number << std::endl;
+ }
+};
+//]
+
+//[example__show_key_and_number
+template <typename Key, typename Node>
+void show_key_and_number(Key const& key, Node const& node)
+{
+ std::cout << " [" << key << ", " << node.get_data().number << ']';
+}
+//]
+
+//[example__show_key_and_number_tree
+class show_key_and_number_tree
+{
+ unsigned int ply_limit;
+
+ public:
+ show_key_and_number_tree();
+
+ template <typename Iterator>
+ void
+ operator()(
+ Iterator const& itr
+ , boost::tree_node::traversal_state state
+ )
+ {
+ show_tabs(state, ply_limit);
+ show_key_and_number(itr->first, itr->second);
+ std::cout << std::endl;
+ }
+};
+//]
+
+//[example__show_data
+template <typename Node>
+void show_data(Node const& node)
+{
+ std::cout << ' ' << node.get_data();
+}
+//]
+
+//[example__show_data_tree
+class show_data_tree
+{
+ unsigned int ply_limit;
+
+ public:
+ show_data_tree();
+
+ template <typename Node>
+ void
+ operator()(
+ Node const& node
+ , boost::tree_node::traversal_state state
+ )
+ {
+ show_tabs(state, ply_limit);
+ std::cout << node.get_data();
+ std::cout << " (Depth = " << node.get_depth() << ')';
+ std::cout << std::endl;
+ }
+};
+//]
+
+//[example__show_key_and_data
+template <typename Key, typename Node>
+void show_key_and_data(Key const& key, Node const& node)
+{
+ std::cout << " [" << key << ", " << node.get_data() << ']';
+}
+//]
+
+//[example__show_key_and_data_tree
+class show_key_and_data_tree
+{
+ unsigned int ply_limit;
+
+ public:
+ show_key_and_data_tree();
+
+ template <typename Iterator>
+ void
+ operator()(
+ Iterator const& itr
+ , boost::tree_node::traversal_state state
+ )
+ {
+ show_tabs(state, ply_limit);
+ show_key_and_data(itr->first, itr->second);
+ std::cout << " (Depth = " << itr->second.get_depth() << ')';
+ std::cout << std::endl;
+ }
+};
+//]
+
+#endif // LIBS_TREE_NODE_EXAMPLE_SHOW_FUNCTIONS_HPP_INCLUDED
+

Added: sandbox/tree_node/libs/tree_node/example/showcase_desc_iterators.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/showcase_desc_iterators.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,82 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef LIBS_TREE_NODE_EXAMPLE_SHOWCASE_DESC_ITERATORS_HPP_INCLUDED
+#define LIBS_TREE_NODE_EXAMPLE_SHOWCASE_DESC_ITERATORS_HPP_INCLUDED
+
+#include <iostream>
+#include <boost/tree_node/typeof.hpp>
+
+//[example__showcase_descendant_iterators
+template <typename Node, typename Function1, typename Function2>
+void
+ showcase_descendant_iterators(
+ Node const& root
+ , Function1 show1
+ , Function2 show2
+ )
+{
+ std::cout << " Breadth-first traversal:";
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_breadth_first_descendant_iterator(root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ show1(itr->first, itr->second);
+ }
+
+ std::cout << std::endl << " Pre-order traversal:";
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_pre_order_descendant_iterator(root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ show1(itr->first, itr->second);
+ }
+
+ std::cout << std::endl << " Post-order traversal:";
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_post_order_descendant_iterator(root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ show1(itr->first, itr->second);
+ }
+
+ std::cout << std::endl << " Depth-first traversal:" << std::endl;
+
+ for (
+ BOOST_AUTO(
+ itr
+ , boost::tree_node::make_depth_first_descendant_iterator(root)
+ );
+ itr;
+ ++itr
+ )
+ {
+ show2(itr, boost::tree_node::traversal_state(itr));
+ }
+
+ std::cout << std::endl;
+}
+//]
+
+#endif // LIBS_TREE_NODE_EXAMPLE_SHOWCASE_DESC_ITERATORS_HPP_INCLUDED
+

Deleted: sandbox/tree_node/libs/tree_node/example/showcase_descendant_iterators.hpp
==============================================================================
--- sandbox/tree_node/libs/tree_node/example/showcase_descendant_iterators.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,82 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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)
-
-#ifndef LIBS_TREE_NODE_EXAMPLE_SHOWCASE_DESCENDANT_ITERATORS_HPP_INCLUDED
-#define LIBS_TREE_NODE_EXAMPLE_SHOWCASE_DESCENDANT_ITERATORS_HPP_INCLUDED
-
-#include <iostream>
-#include <boost/tree_node/typeof.hpp>
-
-//[example__showcase_descendant_iterators
-template <typename NodePointer, typename Function1, typename Function2>
-void
- showcase_descendant_iterators(
- NodePointer const& root
- , Function1 show1
- , Function2 show2
- )
-{
- std::cout << " Breadth-first traversal:";
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_breadth_first_descendant_iterator(root)
- );
- itr;
- ++itr
- )
- {
- show1(itr->first, itr->second);
- }
-
- std::cout << std::endl << " Pre-order traversal:";
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_pre_order_descendant_iterator(root)
- );
- itr;
- ++itr
- )
- {
- show1(itr->first, itr->second);
- }
-
- std::cout << std::endl << " Post-order traversal:";
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_post_order_descendant_iterator(root)
- );
- itr;
- ++itr
- )
- {
- show1(itr->first, itr->second);
- }
-
- std::cout << std::endl << " Depth-first traversal:" << std::endl;
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_depth_first_descendant_iterator(root)
- );
- itr;
- ++itr
- )
- {
- show2(itr, boost::tree_node::traversal_state(itr));
- }
-
- std::cout << std::endl;
-}
-//]
-
-#endif // LIBS_TREE_NODE_EXAMPLE_SHOWCASE_DESCENDANT_ITERATORS_HPP_INCLUDED
-

Added: sandbox/tree_node/libs/tree_node/example/showcase_iterators.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/showcase_iterators.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,58 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef LIBS_TREE_NODE_EXAMPLE_SHOWCASE_ITERATORS_HPP_INCLUDED
+#define LIBS_TREE_NODE_EXAMPLE_SHOWCASE_ITERATORS_HPP_INCLUDED
+
+#include <iostream>
+#include <boost/tree_node/breadth_first_iterator.hpp>
+#include <boost/tree_node/pre_order_iterator.hpp>
+#include <boost/tree_node/post_order_iterator.hpp>
+#include <boost/tree_node/depth_first_iterator.hpp>
+#include <boost/tree_node/in_order_iterator.hpp>
+
+//[example__showcase_iterators
+template <typename Node, typename Function1, typename Function2>
+void
+ showcase_iterators(
+ Node const& root
+ , Function1 show1
+ , Function2 show2
+ )
+{
+ std::cout << " Breadth-first: ";
+ boost::tree_node::breadth_first_iterate(root, show1);
+ std::cout << std::endl << " sans root: ";
+ boost::tree_node::breadth_first_iterate_descendants(root, show1);
+ std::cout << std::endl << " Pre-order: ";
+ boost::tree_node::pre_order_iterate(root, show1);
+ std::cout << std::endl << " sans root: ";
+ boost::tree_node::pre_order_iterate_descendants(root, show1);
+ std::cout << std::endl << " Post-order: ";
+ boost::tree_node::post_order_iterate(root, show1);
+ std::cout << std::endl << " sans root: ";
+ boost::tree_node::post_order_iterate_descendants(root, show1);
+ std::cout << std::endl << " Depth-first:" << std::endl;
+ boost::tree_node::depth_first_iterate(root, show2);
+ std::cout << std::endl << " sans root:" << std::endl;
+ boost::tree_node::depth_first_iterate_descendants(root, show2);
+ std::cout << std::endl;
+}
+//]
+
+//[example__showcase_in_order_iterator
+template <typename Node, typename Function>
+void showcase_in_order_iterator(Node const& node, Function show)
+{
+ std::cout << " In-order fwd: ";
+ boost::tree_node::in_order_iterate_forward(node, show);
+ std::cout << std::endl << " In-order bck: ";
+ boost::tree_node::in_order_iterate_reverse(node, show);
+ std::cout << std::endl;
+}
+//]
+
+#endif // LIBS_TREE_NODE_EXAMPLE_SHOWCASE_ITERATORS_HPP_INCLUDED
+

Deleted: sandbox/tree_node/libs/tree_node/example/simple_associative_node.cpp
==============================================================================
--- sandbox/tree_node/libs/tree_node/example/simple_associative_node.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,217 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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 <iostream>
-#include <boost/assert.hpp>
-#include <boost/tr1/tuple.hpp>
-#include <boost/tree_node/typeof.hpp>
-#include "default_unconstructible_type.hpp"
-#include "show_functions.hpp"
-#include "showcase_descendant_iterators.hpp"
-
-typedef boost::tree_node::simple_associative_node<
- char const*
- , default_unconstructible_example_type
- , boost::multimapS
- >
- DNode;
-typedef boost::tree_node::with_depth<
- boost::tree_node::simple_associative_node_gen<
- boost::hash_multimapS
- >
- , char const*
- , char*
- >
- ANode;
-typedef boost::tree_node::factory<DNode>
- DNodeFactory;
-typedef boost::tree_node::factory<ANode>
- ANodeFactory;
-
-int main()
-{
- char const* names[] = {"able", "baker", "charlie", "dog", "easy", "fox"};
- DNode::pointer d_root(DNodeFactory::create(create_instance(5)));
- ANode::pointer a_root(ANodeFactory::create());
-
- BOOST_ASSERT(
- !d_root->get_parent()
- && "Parent member uninitialized."
- );
- BOOST_ASSERT(
- !a_root->get_data()
- && "Data member not default-constructed."
- );
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_breadth_first_iterator(d_root));
- itr;
- ++itr
- )
- {
- std::size_t const count = (*itr)->get_data().number;
-
- if (1 < count)
- {
- for (std::size_t i = 0; i < count; ++i)
- {
- for (std::size_t j = 0; j + i < count; ++j)
- {
- DNode::pointer child(
- (*itr)->add_child(names[j], create_instance(i))
- );
- DNode::const_pointer const_child(child);
-
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- BOOST_ASSERT(
- (child->get_parent() == const_child->get_parent())
- && "Why are these pointers different?"
- );
- }
- }
- }
- }
-
- {
- boost::tree_node::depth_first_iterate(d_root, show_number_tree());
- std::cout << std::endl;
- }
-
- std::cout << "After d_root tree construction," << std::endl;
- showcase_descendant_iterators(
- DNode::const_pointer(d_root)
- , show_key_and_number<char const*,DNode::const_pointer>
- , show_key_and_number_tree()
- );
-
- {
- d_root->find_child(
- names[2]
- )->second->add_child_copy(names[5], d_root);
- std::cout << "After add_child_copy call," << std::endl;
- showcase_descendant_iterators(
- DNode::const_pointer(d_root)
- , show_key_and_number<char const*,DNode::const_pointer>
- , show_key_and_number_tree()
- );
- }
-
- {
- char* root_data = new char[2];
-
- root_data[0] = '5';
- root_data[1] = '\0';
- a_root->get_data() = root_data;
- }
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_breadth_first_iterator(a_root));
- itr;
- ++itr
- )
- {
- char digit = (*itr)->get_data()[0];
-
- if ('1' < digit)
- {
- char numchar = digit;
-
- while (numchar != '0')
- {
- --numchar;
-
- for (char j = 0; numchar + j < digit; ++j)
- {
- ANode::pointer child((*itr)->add_child(names[j]));
- char*& data = child->get_data();
-
- BOOST_ASSERT(
- !data
- && "Data member not default-constructed."
- );
- data = new char[2];
- data[0] = numchar;
- data[1] = '\0';
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- }
- }
- }
- }
-
- std::cout << "After a_root tree construction," << std::endl;
- showcase_descendant_iterators(
- ANode::const_pointer(a_root)
- , show_key_and_data<char const*,ANode::const_pointer>
- , show_key_and_data_tree()
- );
-
- {
- ANode::pointer a_child(
- a_root->find_child(names[2])->second->add_child(names[5])
- );
-
- a_child->get_data() = new char[2];
- a_child->get_data()[0] = '7';
- a_child->get_data()[1] = '\0';
- std::cout << "After a_child construction," << std::endl;
- showcase_descendant_iterators(
- ANode::const_pointer(a_root)
- , show_key_and_data<char const*,ANode::const_pointer>
- , show_key_and_data_tree()
- );
- }
-
- {
- ANode::pointer to_be_pruned = a_root->get_child_begin()->second;
- ANode::child_iterator c_itr, c_end;
-
- for (
- std::tr1::tie(c_itr, c_end) = to_be_pruned->find_children(
- names[1]
- );
- c_itr != c_end;
- ++c_itr
- )
- {
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_pre_order_iterator(c_itr->second)
- );
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
- }
-
- to_be_pruned->remove_children(names[1]);
- std::cout << "After remove_children call," << std::endl;
- showcase_descendant_iterators(
- ANode::const_pointer(a_root)
- , show_key_and_data<char const*,ANode::const_pointer>
- , show_key_and_data_tree()
- );
- }
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_post_order_iterator(a_root));
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
-
- return 0;
-}
-

Deleted: sandbox/tree_node/libs/tree_node/example/simple_node.cpp
==============================================================================
--- sandbox/tree_node/libs/tree_node/example/simple_node.cpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
+++ (empty file)
@@ -1,198 +0,0 @@
-// Copyright (C) 2011 Cromwell D. Enage
-// Distributed under 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 <iostream>
-#include <boost/assert.hpp>
-#include <boost/tree_node/typeof.hpp>
-#include "default_unconstructible_type.hpp"
-#include "show_functions.hpp"
-#include "showcase_iterators.hpp"
-
-typedef boost::tree_node::simple_node<default_unconstructible_example_type>
- DNode;
-typedef boost::tree_node::with_depth<
- boost::tree_node::simple_node_gen<>
- , char*
- >
- ANode;
-typedef boost::tree_node::factory<DNode>
- DNodeFactory;
-typedef boost::tree_node::factory<ANode>
- ANodeFactory;
-
-int main()
-{
- DNode::pointer d_root(DNodeFactory::create(create_instance(5)));
- ANode::pointer a_root(ANodeFactory::create());
-
- BOOST_ASSERT(
- !d_root->get_parent()
- && "Parent member uninitialized."
- );
- BOOST_ASSERT(
- !a_root->get_data()
- && "Data member not default-constructed."
- );
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_breadth_first_iterator(d_root));
- itr;
- ++itr
- )
- {
- std::size_t const count = (*itr)->get_data().number;
-
- if (1 < count)
- {
- for (std::size_t i = 0; i < count; ++i)
- {
- DNode::pointer child((*itr)->add_child(create_instance(i)));
- DNode::const_pointer const_child(child);
-
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- BOOST_ASSERT(
- (child == *((*itr)->get_child_begin() + i))
- && "Ctor not linking parent to child."
- );
- BOOST_ASSERT(
- (child->get_parent() == const_child->get_parent())
- && "Why are these pointers different?"
- );
- }
- }
- }
-
- std::cout << "After d_root tree construction," << std::endl;
- showcase_iterators(
- DNode::const_pointer(d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- {
- (*(d_root->get_child_begin() + 2))->add_child_copy(d_root);
- std::cout << "After add_child_copy call," << std::endl;
- showcase_iterators(
- DNode::const_pointer(d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
- }
-
- (*(d_root->get_child_begin() + 4))->remove_all_children();
- std::cout << "After remove_all_children call," << std::endl;
- showcase_iterators(
- DNode::const_pointer(d_root)
- , show_number<DNode::const_pointer>
- , show_number_tree()
- );
-
- char* root_data = new char[2];
-
- root_data[0] = '5';
- root_data[1] = '\0';
- a_root->get_data() = root_data;
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_breadth_first_iterator(a_root));
- itr;
- ++itr
- )
- {
- char digit = (*itr)->get_data()[0];
-
- if ('1' < digit)
- {
- char numchar = digit;
-
- while (numchar != '0')
- {
- ANode::pointer child((*itr)->add_child());
- char*& data = child->get_data();
-
- BOOST_ASSERT(
- !data
- && "Data member not default-constructed."
- );
- data = new char[2];
- data[0] = --numchar;
- data[1] = '\0';
- BOOST_ASSERT(
- (child->get_parent() == *itr)
- && "Ctor not linking child to parent."
- );
- BOOST_ASSERT(
- (
- child
- == *((*itr)->get_child_begin() + (digit - (numchar + 1)))
- )
- && "Ctor not linking parent to child."
- );
- }
- }
- }
-
- std::cout << "After a_root tree construction," << std::endl;
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
-
- {
- ANode::pointer a_child(
- (*(a_root->get_child_begin() + 2))->add_child()
- );
-
- a_child->get_data() = new char[2];
- a_child->get_data()[0] = '7';
- a_child->get_data()[1] = '\0';
- std::cout << "After a_child construction," << std::endl;
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
- }
-
- {
- ANode::pointer leaf = *a_root->get_child_begin();
-
- for (
- BOOST_AUTO(
- itr
- , boost::tree_node::make_pre_order_descendant_iterator(leaf)
- );
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
-
- leaf->remove_all_children();
- std::cout << "After remove_all_children call," << std::endl;
- showcase_iterators(
- ANode::const_pointer(a_root)
- , show_data<ANode::const_pointer>
- , show_data_tree()
- );
- }
-
- for (
- BOOST_AUTO(itr, boost::tree_node::make_post_order_iterator(a_root));
- itr;
- ++itr
- )
- {
- delete[] (*itr)->get_data();
- }
-
- return 0;
-}
-

Added: sandbox/utility-container_gen/boost/detail/metafunction/has_const_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/has_const_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_CONST_ITERATOR_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_CONST_ITERATOR_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_const_iterator metafunction will determine whether or not the
+ // specified type has a nested 'const_iterator' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_CONST_ITERATOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/has_const_pointer.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/has_const_pointer.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_CONST_POINTER_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_CONST_POINTER_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_const_pointer metafunction will determine whether or not the
+ // specified type has a nested 'const_pointer' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(const_pointer)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_CONST_POINTER_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/has_const_reference.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/has_const_reference.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_CONST_REFERENCE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_CONST_REFERENCE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_const_reference metafunction will determine whether or not the
+ // specified type has a nested 'const_reference' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(const_reference)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_CONST_REFERENCE_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/has_difference_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/has_difference_type.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_DIFFERENCE_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_DIFFERENCE_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_difference_type metafunction will determine whether or not the
+ // specified type has a nested 'difference_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(difference_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_DIFFERENCE_TYPE_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/has_pointer.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/has_pointer.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_POINTER_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_POINTER_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_pointer metafunction will determine whether or not the
+ // specified type has a nested 'pointer' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(pointer)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_POINTER_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/has_reference.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/has_reference.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_REFERENCE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_REFERENCE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_reference metafunction will determine whether or not the
+ // specified type has a nested 'reference' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(reference)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_REFERENCE_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/has_size_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/has_size_type.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_SIZE_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_SIZE_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_size_type metafunction will determine whether or not the
+ // specified type has a nested 'size_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(size_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_SIZE_TYPE_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/has_value_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/has_value_type.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,19 @@
+// Copyright (C) 2007-2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_HAS_VALUE_TYPE_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_HAS_VALUE_TYPE_HPP_INCLUDED
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost { namespace detail {
+
+ // The has_value_type metafunction will determine whether or not the
+ // specified type has a nested 'value_type' type definition.
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_HAS_VALUE_TYPE_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/is_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/is_container.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,53 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_IS_CONTAINER_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_IS_CONTAINER_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/detail/metafunction/has_value_type.hpp>
+#include <boost/detail/metafunction/has_difference_type.hpp>
+#include <boost/detail/metafunction/has_size_type.hpp>
+#include <boost/detail/metafunction/has_const_iterator.hpp>
+#include <boost/detail/metafunction/has_const_pointer.hpp>
+#include <boost/detail/metafunction/has_const_reference.hpp>
+#include <boost/detail/metafunction/is_input_iterator.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T>
+ struct is_container_impl
+ : is_input_iterator<typename T::const_iterator>
+ {
+ };
+
+ template <typename T>
+ struct is_container
+ : ::boost::mpl::if_<
+ ::boost::mpl::and_<
+ ::boost::mpl::and_<
+ typename has_value_type<T>::type
+ , typename has_difference_type<T>::type
+ , typename has_size_type<T>::type
+ >
+ , ::boost::mpl::and_<
+ typename has_const_iterator<T>::type
+ , typename has_const_pointer<T>::type
+ , typename has_const_reference<T>::type
+ >
+ >
+ , is_container_impl<T>
+ , ::boost::mpl::false_
+ >::type
+ {
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_container,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_IS_CONTAINER_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/detail/metafunction/is_input_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/detail/metafunction/is_input_iterator.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,55 @@
+// Copyright (C) 2011 Cromwell D. Enage
+// Distributed under 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)
+
+#ifndef BOOST_DETAIL_METAFUNCTION_IS_INPUT_ITERATOR_HPP_INCLUDED
+#define BOOST_DETAIL_METAFUNCTION_IS_INPUT_ITERATOR_HPP_INCLUDED
+
+#include <boost/type_traits/is_signed.hpp>
+#include <boost/type_traits/has_equal_to.hpp>
+#include <boost/type_traits/has_dereference.hpp>
+#include <boost/type_traits/has_pre_increment.hpp>
+#include <boost/type_traits/has_post_increment.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/detail/metafunction/has_value_type.hpp>
+#include <boost/detail/metafunction/has_difference_type.hpp>
+#include <boost/detail/metafunction/has_pointer.hpp>
+#include <boost/detail/metafunction/has_reference.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename T>
+ struct is_input_iterator_impl
+ : ::boost::is_signed<typename T::difference_type>
+ {
+ };
+
+ template <typename T>
+ struct is_input_iterator
+ : ::boost::mpl::if_<
+ ::boost::mpl::and_<
+ typename has_value_type<T>::type
+ , typename has_difference_type<T>::type
+ , typename has_pointer<T>::type
+ , typename has_reference<T>::type
+ >
+ , ::boost::mpl::and_<
+ ::boost::has_equal_to<T>
+ , ::boost::has_dereference<T>
+ , ::boost::has_pre_increment<T>
+ , ::boost::has_post_increment<T>
+ , is_input_iterator_impl<T>
+ >
+ , ::boost::mpl::false_
+ >::type
+ {
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_input_iterator,(T))
+ };
+}} // namespace boost::detail
+
+#endif // BOOST_DETAIL_METAFUNCTION_IS_INPUT_ITERATOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/associative_container_gen.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/associative_container_gen.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,445 @@
+//=======================================================================
+// Copyright (C) 2011 Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_ASSOCIATIVE_CONTAINER_GEN_HPP_INCLUDED
+#define BOOST_UTILITY_ASSOCIATIVE_CONTAINER_GEN_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/utility/container_selector.hpp>
+
+#include <boost/container/set.hpp>
+#include <boost/container/map.hpp>
+#include <boost/container/flat_set.hpp>
+#include <boost/container/flat_map.hpp>
+
+#include <boost/tr1/unordered_set.hpp>
+#include <boost/tr1/unordered_map.hpp>
+#include <boost/functional/hash.hpp>
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/detail/metafunction/is_container.hpp>
+#include <boost/detail/function/range_equal.hpp>
+#include <boost/detail/function/range_less.hpp>
+
+//[reference__associative_container_gen
+namespace boost {
+
+ template <typename Selector>
+ struct associative_container_gen
+ {
+//<-
+#if 0
+//->
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ // typedef ... type;
+ };
+//<-
+#endif
+//->
+ };
+
+ //<-
+ template <>
+ struct associative_container_gen<setS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::set<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::map<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::set<Key>
+ , ::boost::container::map<Key,Mapped>
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<mapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::set<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::map<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::set<Key>
+ , ::boost::container::map<Key,Mapped>
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<multisetS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::multiset<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::multimap<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::multiset<Key>
+ , ::boost::container::multimap<Key,Mapped>
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<multimapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::multiset<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::multimap<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::multiset<Key>
+ , ::boost::container::multimap<Key,Mapped>
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<hash_setS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::std::tr1::unordered_set<
+ Key
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::std::tr1::unordered_set<Key,::boost::hash<Key> >
+ , ::std::tr1::unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<hash_mapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::std::tr1::unordered_set<
+ Key
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::std::tr1::unordered_set<Key,::boost::hash<Key> >
+ , ::std::tr1::unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<hash_multisetS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::std::tr1::unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::std::tr1::unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ >
+ , ::std::tr1::unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<hash_multimapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::std::tr1::unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::std::tr1::unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ >
+ , ::std::tr1::unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<flat_setS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::flat_set<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_map<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::flat_set<Key>
+ , ::boost::container::flat_map<Key,Mapped>
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<flat_mapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::flat_set<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_map<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::flat_set<Key>
+ , ::boost::container::flat_map<Key,Mapped>
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<flat_multisetS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::flat_multiset<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_multimap<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::flat_multiset<Key>
+ , ::boost::container::flat_multimap<Key,Mapped>
+ >
+ >::type
+ type;
+ };
+ };
+
+ template <>
+ struct associative_container_gen<flat_multimapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::flat_multiset<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_multimap<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::container::flat_multiset<Key>
+ , ::boost::container::flat_multimap<Key,Mapped>
+ >
+ >::type
+ type;
+ };
+ };
+ //->
+} // namespace boost
+//]
+
+#endif // BOOST_UTILITY_ASSOCIATIVE_CONTAINER_GEN_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/container_gen.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/container_gen.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,292 @@
+//=======================================================================
+// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
+// Copyright 2010 Thomas Claveirole
+// Copyright 2011 Cromwell D. Enage
+// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Thomas Claveirole,
+// Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_CONTAINER_GEN_HPP_INCLUDED
+#define BOOST_UTILITY_CONTAINER_GEN_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/utility/container_selector.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#include <boost/container/vector.hpp>
+#include <boost/container/stable_vector.hpp>
+#include <boost/container/deque.hpp>
+#include <boost/container/list.hpp>
+#include <boost/container/slist.hpp>
+#include <boost/container/set.hpp>
+#include <boost/container/flat_set.hpp>
+
+#include <boost/tr1/unordered_set.hpp>
+#include <boost/functional/hash.hpp>
+
+#include <boost/mpl/if.hpp>
+#include <boost/detail/metafunction/is_container.hpp>
+#include <boost/detail/function/range_equal.hpp>
+#include <boost/detail/function/range_less.hpp>
+
+//[reference__container_gen__list_specialization
+namespace boost {
+
+ //<-
+ template <typename Selector, typename ValueType>
+ struct container_gen
+ {
+ };
+
+ template <typename ValueType>
+ struct container_gen<vecS,ValueType>
+ {
+ typedef ::boost::container::vector<ValueType> type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<stable_vecS,ValueType>
+ {
+ typedef ::boost::container::stable_vector<ValueType> type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<dequeS,ValueType>
+ {
+ typedef ::boost::container::deque<ValueType> type;
+ };
+ //->
+
+ template <typename ValueType>
+ struct container_gen<listS,ValueType>
+ {
+ typedef ::boost::container::list<ValueType> type;
+ };
+
+ //<-
+ template <typename ValueType>
+ struct container_gen<slistS,ValueType>
+ {
+ typedef ::boost::container::slist<ValueType> type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<setS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::container::set<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::set<ValueType>
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<mapS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::container::set<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::set<ValueType>
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<multisetS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::container::multiset<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::multiset<ValueType>
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<multimapS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::container::multiset<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::multiset<ValueType>
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<hash_setS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::std::tr1::unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<hash_mapS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::std::tr1::unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<hash_multisetS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::std::tr1::unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<hash_multimapS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::std::tr1::unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<flat_setS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::container::flat_set<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_set<ValueType>
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<flat_mapS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::container::flat_set<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_set<ValueType>
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<flat_multisetS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::container::flat_multiset<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_multiset<ValueType>
+ >::type
+ type;
+ };
+
+ template <typename ValueType>
+ struct container_gen<flat_multimapS,ValueType>
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::container::flat_multiset<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_multiset<ValueType>
+ >::type
+ type;
+ };
+ //->
+} // namespace boost
+//]
+
+#else // defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ //===========================================================================
+ // The main container_gen traits class uses partial specialization,
+ // so we also include a workaround.
+ //===========================================================================
+
+//[reference__container_gen
+namespace boost {
+
+ template <typename Selector, typename ValueType>
+ struct container_gen
+ {
+ //<-
+ typedef typename container_selector<Selector>::type
+ Select;
+ typedef typename Select::BOOST_NESTED_TEMPLATE bind_<ValueType>::type
+ type;
+ //->
+ // typedef .... type;
+ };
+} // namespace boost
+//]
+
+#endif // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#endif // BOOST_UTILITY_CONTAINER_GEN_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/container_selector.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/container_selector.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,424 @@
+//=======================================================================
+// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
+// Copyright 2010 Thomas Claveirole
+// Copyright 2011 Cromwell D. Enage
+// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Thomas Claveirole,
+// Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_CONTAINER_SELECTOR_HPP_INCLUDED
+#define BOOST_UTILITY_CONTAINER_SELECTOR_HPP_INCLUDED
+
+#include <boost/config.hpp>
+
+ //===========================================================================
+ // Selectors for the VertexList and EdgeList template parameters of
+ // adjacency_list, and the container_gen traits class which is used
+ // to map the selectors to the container type used to implement the
+ // graph.
+ //===========================================================================
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+//[reference__container_selectors
+namespace boost {
+
+ struct vecS { };
+ struct stable_vecS { };
+ struct dequeS { };
+ struct listS { };
+ struct slistS { };
+ struct setS { };
+ struct mapS { };
+ struct multisetS { };
+ struct multimapS { };
+ struct hash_setS { };
+ struct hash_mapS { };
+ struct hash_multisetS { };
+ struct hash_multimapS { };
+ struct flat_setS { };
+ struct flat_mapS { };
+ struct flat_multisetS { };
+ struct flat_multimapS { };
+} // namespace boost
+//]
+
+#else // defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#include <boost/container/vector.hpp>
+#include <boost/container/stable_vector.hpp>
+#include <boost/container/deque.hpp>
+#include <boost/container/list.hpp>
+#include <boost/container/slist.hpp>
+#include <boost/container/set.hpp>
+#include <boost/container/flat_set.hpp>
+
+#include <boost/tr1/unordered_set.hpp>
+#include <boost/functional/hash.hpp>
+
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/ptr_container/ptr_deque.hpp>
+#include <boost/ptr_container/ptr_list.hpp>
+#include <boost/ptr_container/ptr_set.hpp>
+#include <boost/ptr_container/ptr_unordered_set.hpp>
+
+#include <boost/mpl/if.hpp>
+#include <boost/detail/metafunction/is_container.hpp>
+#include <boost/detail/function/range_equal.hpp>
+#include <boost/detail/function/range_less.hpp>
+
+namespace boost {
+
+ struct vecS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef ::boost::container::vector<T> type;
+ typedef ::boost::ptr_vector<T> ptr_type;
+ };
+ };
+
+ struct stable_vecS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef ::boost::container::stable_vector<T> type;
+ };
+ };
+
+ struct dequeS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef ::boost::container::deque<T> type;
+ typedef ::boost::ptr_deque<T> ptr_type;
+ };
+ };
+
+ struct listS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef ::boost::container::list<T> type;
+ typedef ::boost::ptr_list<T> ptr_type;
+ };
+ };
+
+ struct slistS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef ::boost::container::slist<T> type;
+ };
+ };
+
+ struct setS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::container::set<T,::boost::detail::range_less>
+ , ::boost::container::set<T>
+ >::type
+ type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::ptr_set<T,::boost::detail::range_less>
+ , ::boost::ptr_set<T>
+ >::type
+ ptr_type;
+ };
+ };
+
+ struct mapS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::container::set<T,::boost::detail::range_less>
+ , ::boost::container::set<T>
+ >::type
+ type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::ptr_set<T,::boost::detail::range_less>
+ , ::boost::ptr_set<T>
+ >::type
+ ptr_type;
+ };
+ };
+
+ struct multisetS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::container::multiset<
+ T
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::multiset<T>
+ >::type
+ type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::ptr_multiset<T,::boost::detail::range_less>
+ , ::boost::ptr_multiset<T>
+ >::type
+ ptr_type;
+ };
+ };
+
+ struct multimapS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::container::multiset<
+ T
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::multiset<T>
+ >::type
+ type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::ptr_multiset<T,::boost::detail::range_less>
+ , ::boost::ptr_multiset<T>
+ >::type
+ ptr_type;
+ };
+ };
+
+ struct hash_setS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::std::tr1::unordered_set<
+ ValueType
+ , ::boost::hash<T>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_set<T,::boost::hash<T> >
+ >::type
+ type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::ptr_unordered_set<
+ T
+ , ::boost::hash<T>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_set<T,::boost::hash<T> >
+ >::type
+ ptr_type;
+ };
+ };
+
+ struct hash_mapS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::std::tr1::unordered_set<
+ T
+ , ::boost::hash<T>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_set<T,::boost::hash<T> >
+ >::type
+ type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::ptr_unordered_set<
+ T
+ , ::boost::hash<T>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_set<T,::boost::hash<T> >
+ >::type
+ ptr_type;
+ };
+ };
+
+ struct hash_multisetS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::std::tr1::unordered_multiset<
+ T
+ , ::boost::hash<T>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_multiset<T,::boost::hash<T> >
+ >::type
+ type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::ptr_unordered_multiset<
+ T
+ , ::boost::hash<T>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_multiset<T,::boost::hash<T> >
+ >::type
+ ptr_type;
+ };
+ };
+
+ struct hash_multimapS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::std::tr1::unordered_multiset<
+ T
+ , ::boost::hash<T>
+ , ::boost::detail::range_equal
+ >
+ , ::std::tr1::unordered_multiset<T,::boost::hash<T> >
+ >::type
+ type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::ptr_unordered_multiset<
+ T
+ , ::boost::hash<T>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_multiset<T,::boost::hash<T> >
+ >::type
+ ptr_type;
+ };
+ };
+
+ struct flat_setS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::container::flat_set<
+ T
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_set<T>
+ >::type
+ type;
+ };
+ };
+
+ struct flat_mapS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::container::flat_set<
+ T
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_set<T>
+ >::type
+ type;
+ };
+ };
+
+ struct flat_multisetS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::container::flat_multiset<
+ T
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_multiset<T>
+ >::type
+ type;
+ };
+ };
+
+ struct flat_multimapS
+ {
+ template <typename T>
+ struct bind_
+ {
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<T>
+ , ::boost::container::flat_multiset<
+ T
+ , ::boost::detail::range_less
+ >
+ , ::boost::container::flat_multiset<T>
+ >::type
+ type;
+ };
+ };
+
+ template <typename Selector>
+ struct container_selector
+ {
+ typedef vecS type;
+ };
+
+#define BOOST_CONTAINER_SELECTOR(NAME) \
+ template <> struct container_selector<NAME> { typedef NAME type; }
+
+ BOOST_CONTAINER_SELECTOR(vecS);
+ BOOST_CONTAINER_SELECTOR(stable_vecS);
+ BOOST_CONTAINER_SELECTOR(dequeS);
+ BOOST_CONTAINER_SELECTOR(listS);
+ BOOST_CONTAINER_SELECTOR(slistS);
+ BOOST_CONTAINER_SELECTOR(setS);
+ BOOST_CONTAINER_SELECTOR(mapS);
+ BOOST_CONTAINER_SELECTOR(multisetS);
+ BOOST_CONTAINER_SELECTOR(multimapS);
+ BOOST_CONTAINER_SELECTOR(hash_setS);
+ BOOST_CONTAINER_SELECTOR(hash_mapS);
+ BOOST_CONTAINER_SELECTOR(hash_multisetS);
+ BOOST_CONTAINER_SELECTOR(hash_multimapS);
+ BOOST_CONTAINER_SELECTOR(flat_setS);
+ BOOST_CONTAINER_SELECTOR(flat_mapS);
+ BOOST_CONTAINER_SELECTOR(flat_multisetS);
+ BOOST_CONTAINER_SELECTOR(flat_multimapS);
+
+#undef BOOST_CONTAINER_SELECTOR
+
+} // namespace boost
+
+#endif // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#endif // BOOST_UTILITY_CONTAINER_SELECTOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/has_stable_iters_selector.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/has_stable_iters_selector.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,68 @@
+//=======================================================================
+// Copyright (C) 2011 Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_HAS_STABLE_ITERS_SELECTOR_HPP_INCLUDED
+#define BOOST_UTILITY_HAS_STABLE_ITERS_SELECTOR_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/utility/container_selector.hpp>
+
+//[reference__has_stable_iterators_selector
+namespace boost {
+
+ template <typename Selector>
+ struct has_stable_iterators_selector : ::boost::mpl::true_
+ {
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(
+ 1
+ , is_unique_associative_selector
+ , (Selector)
+ )
+ //->
+ };
+
+ //<-
+ template <>
+ struct has_stable_iterators_selector<vecS> : ::boost::mpl::false_
+ {
+ };
+
+ template <>
+ struct has_stable_iterators_selector<dequeS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct has_stable_iterators_selector<flat_setS> : ::boost::mpl::false_
+ {
+ };
+
+ template <>
+ struct has_stable_iterators_selector<flat_mapS> : ::boost::mpl::false_
+ {
+ };
+
+ template <>
+ struct has_stable_iterators_selector<flat_multisetS>
+ : ::boost::mpl::false_
+ {
+ };
+
+ template <>
+ struct has_stable_iterators_selector<flat_multimapS>
+ : ::boost::mpl::false_
+ {
+ };
+ //->
+} // namespace boost
+//]
+
+#endif // BOOST_UTILITY_HAS_STABLE_ITERS_SELECTOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/is_associative_selector.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/is_associative_selector.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,39 @@
+//=======================================================================
+// Copyright (C) 2011 Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_IS_ASSOCIATIVE_SELECTOR_HPP_INCLUDED
+#define BOOST_UTILITY_IS_ASSOCIATIVE_SELECTOR_HPP_INCLUDED
+
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/utility/is_unique_assoc_selector.hpp>
+#include <boost/utility/is_multiple_assoc_selector.hpp>
+
+//[reference__is_associative_selector
+namespace boost {
+
+ template <typename Selector>
+ struct is_associative_selector
+ : ::boost::mpl::or_<
+ is_unique_associative_selector<Selector>
+ , is_multiple_associative_selector<Selector>
+ >
+ {
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(
+ 1
+ , is_associative_selector
+ , (Selector)
+ )
+ //->
+ };
+} // namespace boost
+//]
+
+#endif // BOOST_UTILITY_IS_ASSOCIATIVE_SELECTOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/is_multiple_assoc_selector.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/is_multiple_assoc_selector.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,70 @@
+//=======================================================================
+// Copyright (C) 2011 Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_IS_MULTIPLE_ASSOC_SELECTOR_HPP_INCLUDED
+#define BOOST_UTILITY_IS_MULTIPLE_ASSOC_SELECTOR_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/utility/container_selector.hpp>
+
+//[reference__is_multiple_associative_selector
+namespace boost {
+
+ template <typename Selector>
+ struct is_multiple_associative_selector : ::boost::mpl::false_
+ {
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(
+ 1
+ , is_multiple_associative_selector
+ , (Selector)
+ )
+ //->
+ };
+
+ //<-
+ template <>
+ struct is_multiple_associative_selector<multisetS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_multiple_associative_selector<multimapS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_multiple_associative_selector<hash_multisetS>
+ : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_multiple_associative_selector<hash_multimapS>
+ : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_multiple_associative_selector<flat_multisetS>
+ : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_multiple_associative_selector<flat_multimapS>
+ : ::boost::mpl::true_
+ {
+ };
+ //->
+} // namespace boost
+//]
+
+#endif // BOOST_UTILITY_IS_MULTIPLE_ASSOC_SELECTOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/is_random_access_selector.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/is_random_access_selector.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,71 @@
+//=======================================================================
+// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
+// Copyright 2010 Thomas Claveirole
+// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Thomas Claveirole
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_IS_RANDOM_ACCESS_SELECTOR_HPP_INCLUDED
+#define BOOST_UTILITY_IS_RANDOM_ACCESS_SELECTOR_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/utility/container_selector.hpp>
+
+//[reference__is_random_access_selector
+namespace boost {
+
+ template <typename Selector>
+ struct is_random_access_selector : ::boost::mpl::false_
+ {
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_random_access_selector,(Selector))
+ //->
+ };
+
+ //<-
+ template <>
+ struct is_random_access_selector<vecS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_random_access_selector<stable_vecS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_random_access_selector<dequeS> : ::boost::mpl::true_
+ {
+ };
+
+#if 0
+ template <>
+ struct is_random_access_selector<flat_setS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_random_access_selector<flat_mapS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_random_access_selector<flat_multisetS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_random_access_selector<flat_multimapS> : ::boost::mpl::true_
+ {
+ };
+#endif
+ //->
+} // namespace boost
+//]
+
+#endif // BOOST_UTILITY_IS_RANDOM_ACCESS_SELECTOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/is_unique_assoc_selector.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/is_unique_assoc_selector.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,66 @@
+//=======================================================================
+// Copyright (C) 2011 Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_IS_UNIQUE_ASSOC_SELECTOR_HPP_INCLUDED
+#define BOOST_UTILITY_IS_UNIQUE_ASSOC_SELECTOR_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/utility/container_selector.hpp>
+
+//[reference__is_unique_associative_selector
+namespace boost {
+
+ template <typename Selector>
+ struct is_unique_associative_selector : ::boost::mpl::false_
+ {
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(
+ 1
+ , is_unique_associative_selector
+ , (Selector)
+ )
+ //->
+ };
+
+ //<-
+ template <>
+ struct is_unique_associative_selector<setS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_unique_associative_selector<mapS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_unique_associative_selector<hash_setS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_unique_associative_selector<hash_mapS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_unique_associative_selector<flat_setS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_unique_associative_selector<flat_mapS> : ::boost::mpl::true_
+ {
+ };
+ //->
+} // namespace boost
+//]
+
+#endif // BOOST_UTILITY_IS_UNIQUE_ASSOC_SELECTOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/is_unordered_selector.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/is_unordered_selector.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,52 @@
+//=======================================================================
+// Copyright (C) 2011 Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_IS_UNORDERED_SELECTOR_HPP_INCLUDED
+#define BOOST_UTILITY_IS_UNORDERED_SELECTOR_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/utility/container_selector.hpp>
+
+//[reference__is_unordered_selector
+namespace boost {
+
+ template <typename Selector>
+ struct is_unordered_selector : ::boost::mpl::false_
+ {
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_unordered_selector,(Selector))
+ //->
+ };
+
+ //<-
+ template <>
+ struct is_unordered_selector<hash_setS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_unordered_selector<hash_mapS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_unordered_selector<hash_multisetS> : ::boost::mpl::true_
+ {
+ };
+
+ template <>
+ struct is_unordered_selector<hash_multimapS> : ::boost::mpl::true_
+ {
+ };
+ //->
+} // namespace boost
+//]
+
+#endif // BOOST_UTILITY_IS_UNORDERED_SELECTOR_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/ptr_assoc_container_gen.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/ptr_assoc_container_gen.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,415 @@
+//=======================================================================
+// Copyright (C) 2011 Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_PTR_ASSOC_CONTAINER_GEN_HPP_INCLUDED
+#define BOOST_UTILITY_PTR_ASSOC_CONTAINER_GEN_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/ptr_container/ptr_set.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
+#include <boost/ptr_container/ptr_unordered_set.hpp>
+#include <boost/ptr_container/ptr_unordered_map.hpp>
+#include <boost/utility/container_selector.hpp>
+
+#if !defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS && BOOST_VERSION >= 104800
+#define BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+#endif
+
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+#include <boost/mpl/eval_if.hpp>
+#include <boost/detail/metafunction/is_container.hpp>
+#include <boost/detail/function/range_equal.hpp>
+#include <boost/detail/function/range_less.hpp>
+#endif
+
+//[reference__ptr_associative_container_gen
+namespace boost {
+
+ template <typename Selector>
+ struct ptr_associative_container_gen
+ {
+//<-
+#if 0
+//->
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+ // typedef ... type;
+ };
+//<-
+#endif
+//->
+ };
+
+ //<-
+ template <>
+ struct ptr_associative_container_gen<setS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_set<Key,::boost::detail::range_less>
+ , ::boost::ptr_map<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_set<Key>
+ , ::boost::ptr_map<Key,Mapped>
+ >
+ >::type
+ type;
+#else
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_set<Key>
+ , ::boost::ptr_map<Key,Mapped>
+ >::type
+ type;
+#endif
+ };
+ };
+
+ template <>
+ struct ptr_associative_container_gen<mapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_set<Key,::boost::detail::range_less>
+ , ::boost::ptr_map<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_set<Key>
+ , ::boost::ptr_map<Key,Mapped>
+ >
+ >::type
+ type;
+#else
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_set<Key>
+ , ::boost::ptr_map<Key,Mapped>
+ >::type
+ type;
+#endif
+ };
+ };
+
+ template <>
+ struct ptr_associative_container_gen<multisetS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_multiset<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::ptr_multimap<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_multiset<Key>
+ , ::boost::ptr_multimap<Key,Mapped>
+ >
+ >::type
+ type;
+#else
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_multiset<Key>
+ , ::boost::ptr_multimap<Key,Mapped>
+ >::type
+ type;
+#endif
+ };
+ };
+
+ template <>
+ struct ptr_associative_container_gen<multimapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_multiset<
+ Key
+ , ::boost::detail::range_less
+ >
+ , ::boost::ptr_multimap<
+ Key
+ , Mapped
+ , ::boost::detail::range_less
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_multiset<Key>
+ , ::boost::ptr_multimap<Key,Mapped>
+ >
+ >::type
+ type;
+#else
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_multiset<Key>
+ , ::boost::ptr_multimap<Key,Mapped>
+ >::type
+ type;
+#endif
+ };
+ };
+
+ template <>
+ struct ptr_associative_container_gen<hash_setS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_set<
+ Key
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_set<Key,::boost::hash<Key> >
+ , ::boost::ptr_unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >
+ >::type
+ type;
+#else
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_set<Key,::boost::hash<Key> >
+ , ::boost::ptr_unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >::type
+ type;
+#endif
+ };
+ };
+
+ template <>
+ struct ptr_associative_container_gen<hash_mapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_set<
+ Key
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_set<Key,::boost::hash<Key> >
+ , ::boost::ptr_unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >
+ >::type
+ type;
+#else
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_set<Key,::boost::hash<Key> >
+ , ::boost::ptr_unordered_map<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >::type
+ type;
+#endif
+ };
+ };
+
+ template <>
+ struct ptr_associative_container_gen<hash_multisetS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ >
+ , ::boost::ptr_unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >
+ >::type
+ type;
+#else
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ >
+ , ::boost::ptr_unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >::type
+ type;
+#endif
+ };
+ };
+
+ template <>
+ struct ptr_associative_container_gen<hash_multimapS>
+ {
+ template <typename Key, typename Mapped = void>
+ struct apply
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::eval_if<
+ ::boost::detail::is_container<Key>
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ , ::boost::detail::range_equal
+ >
+ >
+ , ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ >
+ , ::boost::ptr_unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >
+ >::type
+ type;
+#else
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_same<Mapped,void>
+ , ::boost::ptr_unordered_multiset<
+ Key
+ , ::boost::hash<Key>
+ >
+ , ::boost::ptr_unordered_multimap<
+ Key
+ , Mapped
+ , ::boost::hash<Key>
+ >
+ >::type
+ type;
+#endif
+ };
+ };
+ //->
+} // namespace boost
+//]
+
+#endif // BOOST_UTILITY_PTR_ASSOC_CONTAINER_GEN_HPP_INCLUDED
+

Added: sandbox/utility-container_gen/boost/utility/ptr_container_gen.hpp
==============================================================================
--- (empty file)
+++ sandbox/utility-container_gen/boost/utility/ptr_container_gen.hpp 2011-12-27 15:11:11 EST (Tue, 27 Dec 2011)
@@ -0,0 +1,272 @@
+//=======================================================================
+// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
+// Copyright 2010 Thomas Claveirole
+// Copyright 2011 Cromwell D. Enage
+// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Thomas Claveirole,
+// Cromwell D. Enage
+//
+// Distributed under 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)
+//=======================================================================
+
+#ifndef BOOST_UTILITY_PTR_CONTAINER_GEN_HPP_INCLUDED
+#define BOOST_UTILITY_PTR_CONTAINER_GEN_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/utility/container_selector.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#include <boost/functional/hash.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/ptr_container/ptr_deque.hpp>
+#include <boost/ptr_container/ptr_list.hpp>
+#include <boost/ptr_container/ptr_set.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
+#include <boost/ptr_container/ptr_unordered_set.hpp>
+#include <boost/ptr_container/ptr_unordered_map.hpp>
+
+#if !defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS && BOOST_VERSION >= 104800
+#define BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+#endif
+
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+#include <boost/mpl/if.hpp>
+#include <boost/detail/metafunction/is_container.hpp>
+#include <boost/detail/function/range_equal.hpp>
+#include <boost/detail/function/range_less.hpp>
+#endif
+
+//[reference__ptr_container_gen__list_specialization
+namespace boost {
+
+ //<-
+ template <typename Selector, typename ValueType>
+ struct ptr_container_gen
+ {
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<vecS,ValueType>
+ {
+ typedef ::boost::ptr_vector<ValueType> type;
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<dequeS,ValueType>
+ {
+ typedef ::boost::ptr_deque<ValueType> type;
+ };
+ //->
+
+ template <typename ValueType>
+ struct ptr_container_gen<listS,ValueType>
+ {
+ typedef ::boost::ptr_list<ValueType> type;
+ };
+
+ //<-
+ template <typename ValueType>
+ struct ptr_container_gen<setS,ValueType>
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::ptr_set<ValueType,::boost::detail::range_less>
+ , ::boost::ptr_set<ValueType>
+ >::type
+ type;
+#else
+ typedef ::boost::ptr_set<ValueType> type;
+#endif
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<mapS,ValueType>
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::ptr_set<ValueType,::boost::detail::range_less>
+ , ::boost::ptr_set<ValueType>
+ >::type
+ type;
+#else
+ typedef ::boost::ptr_set<ValueType> type;
+#endif
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<multisetS,ValueType>
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::ptr_multiset<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::ptr_multiset<ValueType>
+ >::type
+ type;
+#else
+ typedef ::boost::ptr_multiset<ValueType> type;
+#endif
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<multimapS,ValueType>
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::ptr_multiset<
+ ValueType
+ , ::boost::detail::range_less
+ >
+ , ::boost::ptr_multiset<ValueType>
+ >::type
+ type;
+#else
+ typedef ::boost::ptr_multiset<ValueType> type;
+#endif
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<hash_setS,ValueType>
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::ptr_unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ >::type
+ type;
+#else
+ typedef ::boost::ptr_unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ type;
+#endif
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<hash_mapS,ValueType>
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::ptr_unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ >::type
+ type;
+#else
+ typedef ::boost::ptr_unordered_set<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ type;
+#endif
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<hash_multisetS,ValueType>
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::ptr_unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ >::type
+ type;
+#else
+ typedef ::boost::ptr_unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ type;
+#endif
+ };
+
+ template <typename ValueType>
+ struct ptr_container_gen<hash_multimapS,ValueType>
+ {
+#if defined BOOST_CONTAINER_GEN_USES_OP_TYPE_TRAITS
+ typedef typename ::boost::mpl::if_<
+ ::boost::detail::is_container<ValueType>
+ , ::boost::ptr_unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ , ::boost::detail::range_equal
+ >
+ , ::boost::ptr_unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ >::type
+ type;
+#else
+ typedef ::boost::ptr_unordered_multiset<
+ ValueType
+ , ::boost::hash<ValueType>
+ >
+ type;
+#endif
+ };
+ //->
+} // namespace boost
+//]
+
+#else // defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ //===========================================================================
+ // The main ptr_container_gen traits class uses partial specialization,
+ // so we also include a workaround.
+ //===========================================================================
+
+//[reference__ptr_container_gen
+namespace boost {
+
+ template <typename Selector, typename ValueType>
+ struct ptr_container_gen
+ {
+ //<-
+ typedef typename container_selector<Selector>::type
+ Select;
+ typedef typename Select::BOOST_NESTED_TEMPLATE bind_<
+ ValueType
+ >::ptr_type
+ type;
+ //->
+ // typedef .... type;
+ };
+} // namespace boost
+//]
+
+#endif // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#endif // BOOST_UTILITY_PTR_CONTAINER_GEN_HPP_INCLUDED
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk