Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83794 - in sandbox: container_gen/boost/container_gen tree_node/boost/tree_node tree_node/boost/tree_node/balancer tree_node/boost/tree_node/container tree_node/boost/typeof/boost/tree_node/balancer tree_node/boost/typeof/boost/tree_node/container tree_node/libs/tree_node/doc tree_node/libs/tree_node/example tree_node/libs/tree_node/test
From: sponage_at_[hidden]
Date: 2013-04-07 12:06:51


Author: expaler
Date: 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
New Revision: 83794
URL: http://svn.boost.org/trac/boost/changeset/83794

Log:
Boost.ContainerGen: updated insert_range_function_gen and splice_function_gen metafunctions; Boost.TreeNode: improved copy ctor implementations, added splicing functionality to nary_node data structure, temporarily removed documentation for later update.
Added:
   sandbox/container_gen/boost/container_gen/insert_range_function_gen.hpp (contents, props changed)
   sandbox/container_gen/boost/container_gen/splice_function_gen.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/associative_node.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/associative_node_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/balancer/adelson_velskii_landis.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/balancer/null.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/balancer/red_black.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/binary_node_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/container/binode.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/container/binode_associative.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/container/binode_associative_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/container/binode_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/nary_node.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/nary_node_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/preprocessor.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/traversal_state.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_accumulation.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_accumulation_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_count.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_count_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_height.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_height_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_position.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_position_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_red_black_flag.hpp (contents, props changed)
   sandbox/tree_node/boost/tree_node/with_red_black_flag_fwd.hpp (contents, props changed)
   sandbox/tree_node/boost/typeof/boost/tree_node/balancer/adelson_velskii_landis.hpp (contents, props changed)
   sandbox/tree_node/boost/typeof/boost/tree_node/balancer/null.hpp (contents, props changed)
   sandbox/tree_node/boost/typeof/boost/tree_node/balancer/red_black.hpp (contents, props changed)
   sandbox/tree_node/boost/typeof/boost/tree_node/container/binode.hpp (contents, props changed)
   sandbox/tree_node/boost/typeof/boost/tree_node/container/binode_associative.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/assoc_iterator_functions.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/iterator_functions.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/match_predicate.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/nary_node.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/output_functions.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/output_preamble.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/output_preamble.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/output_tabs.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/output_tabs.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/example/type_definitions.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/associative_node.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/avl_tree.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/binary_node.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/binode_container.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/binode_map.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/binode_set.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/container_functions.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/iterator_functions.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/nary_node.cpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/red_black_tree.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/sequence.hpp (contents, props changed)
   sandbox/tree_node/libs/tree_node/test/type_definitions.hpp (contents, props changed)
Removed:
   sandbox/tree_node/libs/tree_node/doc/

Added: sandbox/container_gen/boost/container_gen/insert_range_function_gen.hpp
==============================================================================
--- (empty file)
+++ sandbox/container_gen/boost/container_gen/insert_range_function_gen.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,879 @@
+//=======================================================================
+// Copyright (C) 2013 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_CONTAINER_GEN_INSERT_RANGE_FUNCTION_GEN_HPP_INCLUDED
+#define BOOST_CONTAINER_GEN_INSERT_RANGE_FUNCTION_GEN_HPP_INCLUDED
+
+#include <deque>
+#include <utility>
+#include <algorithm>
+#include <boost/mpl/bool.hpp>
+#include <boost/range.hpp>
+#include <boost/assert.hpp>
+
+namespace boost { namespace detail {
+
+ template <typename F, typename C>
+ class insert_range_function_proxy
+ {
+ C& _container;
+
+ public:
+ explicit insert_range_function_proxy(C& c);
+
+ template <typename Itr>
+ insert_range_function_proxy&
+ operator()(typename C::iterator pos, Itr itr, Itr itr_end);
+
+ template <typename InputRange>
+ insert_range_function_proxy&
+ operator()(typename C::iterator pos, InputRange const& r);
+ };
+
+ template <typename F, typename C>
+ insert_range_function_proxy<F,C>::insert_range_function_proxy(C& c)
+ : _container(c)
+ {
+ }
+
+ template <typename F, typename C>
+ template <typename Itr>
+ inline insert_range_function_proxy<F,C>&
+ insert_range_function_proxy<F,C>::operator()(
+ typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ F::evaluate(this->_container, pos, itr, itr_end);
+ return *this;
+ }
+
+ template <typename F, typename C>
+ template <typename InputRange>
+ inline insert_range_function_proxy<F,C>&
+ insert_range_function_proxy<F,C>::operator()(
+ typename C::iterator pos
+ , InputRange const& r
+ )
+ {
+ F::evaluate(this->_container, pos, ::boost::begin(r), ::boost::end(r));
+ return *this;
+ }
+
+ struct fis_insert_range_function
+ {
+ template <typename C>
+ insert_range_function_proxy<fis_insert_range_function,C>
+ operator[](C& _container) const;
+
+ template <typename C, typename InputRange>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const;
+
+ template <typename C, typename Itr>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const;
+
+ template <typename C, typename Itr>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ );
+ };
+
+ template <typename C>
+ inline insert_range_function_proxy<fis_insert_range_function,C>
+ fis_insert_range_function::operator[](C& _container) const
+ {
+ return insert_range_function_proxy<fis_insert_range_function,C>(
+ _container
+ );
+ }
+
+ template <typename C, typename InputRange>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ fis_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const
+ {
+ return this->operator()(
+ _container
+ , pos
+ , ::boost::begin(r)
+ , ::boost::end(r)
+ );
+ }
+
+ template <typename C, typename Itr>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ fis_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const
+ {
+ typename C::iterator result_begin = _container.previous(pos);
+ fis_insert_range_function::evaluate(_container, pos, itr, itr_end);
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ ++result_begin
+ , pos
+ );
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ fis_insert_range_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ _container.insert(pos, itr, itr_end);
+ }
+
+ struct ras_insert_range_function
+ {
+ template <typename C>
+ insert_range_function_proxy<ras_insert_range_function,C>
+ operator[](C& _container) const;
+
+ template <typename C, typename InputRange>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const;
+
+ template <typename C, typename Itr>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const;
+
+ template <typename C, typename Itr>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ );
+ };
+
+ template <typename C>
+ inline insert_range_function_proxy<ras_insert_range_function,C>
+ ras_insert_range_function::operator[](C& _container) const
+ {
+ return insert_range_function_proxy<ras_insert_range_function,C>(
+ _container
+ );
+ }
+
+ template <typename C, typename InputRange>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ ras_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const
+ {
+ return this->operator()(
+ _container
+ , pos
+ , ::boost::begin(r)
+ , ::boost::end(r)
+ );
+ }
+
+ template <typename C, typename Itr>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ ras_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const
+ {
+ typename C::size_type const begin_index = (
+ ::std::distance(_container.begin(), pos)
+ );
+ ras_insert_range_function::evaluate(_container, pos, itr, itr_end);
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ _container.begin() + begin_index
+ , _container.begin() + begin_index + ::std::distance(itr, itr_end)
+ );
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ ras_insert_range_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ _container.insert(pos, itr, itr_end);
+ }
+
+ struct bis_insert_range_function
+ {
+ template <typename C>
+ insert_range_function_proxy<bis_insert_range_function,C>
+ operator[](C& _container) const;
+
+ template <typename C, typename InputRange>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const;
+
+ template <typename C, typename Itr>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const;
+
+ template <typename C, typename Itr>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ );
+ };
+
+ template <typename C>
+ inline insert_range_function_proxy<bis_insert_range_function,C>
+ bis_insert_range_function::operator[](C& _container) const
+ {
+ return insert_range_function_proxy<bis_insert_range_function,C>(
+ _container
+ );
+ }
+
+ template <typename C, typename InputRange>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ bis_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const
+ {
+ return this->operator()(
+ _container
+ , pos
+ , ::boost::begin(r)
+ , ::boost::end(r)
+ );
+ }
+
+ template <typename C, typename Itr>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ bis_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const
+ {
+ if (_container.empty())
+ {
+ BOOST_ASSERT(pos == _container.end());
+ bis_insert_range_function::evaluate(_container, pos, itr, itr_end);
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ _container.begin()
+ , _container.end()
+ );
+ }
+ else
+ {
+ typename C::iterator start = pos;
+ --start;
+ bis_insert_range_function::evaluate(_container, pos, itr, itr_end);
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ ++start
+ , pos
+ );
+ }
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ bis_insert_range_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ _container.insert(pos, itr, itr_end);
+ }
+
+ struct uac_insert_range_function
+ {
+ template <typename C>
+ insert_range_function_proxy<uac_insert_range_function,C>
+ operator[](C& _container) const;
+
+ template <typename C, typename InputRange>
+ ::std::deque<typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const;
+
+ template <typename C, typename Itr>
+ ::std::deque<typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const;
+
+ template <typename C, typename Itr>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ );
+ };
+
+ template <typename C>
+ inline insert_range_function_proxy<uac_insert_range_function,C>
+ uac_insert_range_function::operator[](C& _container) const
+ {
+ return insert_range_function_proxy<uac_insert_range_function,C>(
+ _container
+ );
+ }
+
+ template <typename C, typename InputRange>
+ inline ::std::deque<typename C::iterator>
+ uac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const
+ {
+ return this->operator()(
+ _container
+ , pos
+ , ::boost::begin(r)
+ , ::boost::end(r)
+ );
+ }
+
+ template <typename C, typename Itr>
+ ::std::deque<typename C::iterator>
+ uac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const
+ {
+ ::std::deque<typename C::iterator> result;
+
+ for (
+ ::std::pair<typename C::iterator,bool> insert_result;
+ itr != itr_end;
+ ++itr
+ )
+ {
+ insert_result = _container.insert(*itr);
+
+ if (insert_result.second)
+ {
+ result.push_back(insert_result.first);
+ }
+ }
+
+ return result;
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ uac_insert_range_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ _container.insert(itr, itr_end);
+ }
+
+ struct mac_insert_range_function
+ {
+ template <typename C>
+ insert_range_function_proxy<mac_insert_range_function,C>
+ operator[](C& _container) const;
+
+ template <typename C, typename InputRange>
+ ::std::deque<typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const;
+
+ template <typename C, typename Itr>
+ ::std::deque<typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const;
+
+ template <typename C, typename Itr>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ );
+ };
+
+ template <typename C>
+ inline insert_range_function_proxy<mac_insert_range_function,C>
+ mac_insert_range_function::operator[](C& _container) const
+ {
+ return insert_range_function_proxy<mac_insert_range_function,C>(
+ _container
+ );
+ }
+
+ template <typename C, typename InputRange>
+ inline ::std::deque<typename C::iterator>
+ mac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const
+ {
+ return this->operator()(
+ _container
+ , pos
+ , ::boost::begin(r)
+ , ::boost::end(r)
+ );
+ }
+
+ template <typename C, typename Itr>
+ ::std::deque<typename C::iterator>
+ mac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const
+ {
+ ::std::deque<typename C::iterator> result;
+
+ for (; itr != itr_end; ++itr)
+ {
+ result.push_back(_container.insert(*itr));
+ }
+
+ return result;
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ mac_insert_range_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ _container.insert(itr, itr_end);
+ }
+
+ struct ptr_uac_insert_range_function
+ {
+ template <typename C>
+ insert_range_function_proxy<ptr_uac_insert_range_function,C>
+ operator[](C& _container) const;
+
+ template <typename C, typename InputRange>
+ ::std::deque<typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const;
+
+ template <typename C, typename Itr>
+ ::std::deque<typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const;
+
+ template <typename C, typename Itr>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ );
+ };
+
+ template <typename C>
+ inline insert_range_function_proxy<ptr_uac_insert_range_function,C>
+ ptr_uac_insert_range_function::operator[](C& _container) const
+ {
+ return insert_range_function_proxy<ptr_uac_insert_range_function,C>(
+ _container
+ );
+ }
+
+ template <typename C, typename InputRange>
+ inline ::std::deque<typename C::iterator>
+ ptr_uac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const
+ {
+ return this->operator()(
+ _container
+ , pos
+ , ::boost::begin(r)
+ , ::boost::end(r)
+ );
+ }
+
+ template <typename C, typename Itr>
+ ::std::deque<typename C::iterator>
+ ptr_uac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const
+ {
+ ::std::deque<typename C::iterator> result;
+
+ for (
+ ::std::pair<typename C::iterator,bool> insert_result;
+ itr != itr_end;
+ ++itr
+ )
+ {
+ insert_result = _container.insert(new typename C::key_type(*itr));
+
+ if (insert_result.second)
+ {
+ result.push_back(insert_result.first);
+ }
+ }
+
+ return result;
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ ptr_uac_insert_range_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ _container.insert(itr, itr_end);
+ }
+
+ struct ptr_mac_insert_range_function
+ {
+ template <typename C>
+ insert_range_function_proxy<ptr_mac_insert_range_function,C>
+ operator[](C& _container) const;
+
+ template <typename C, typename InputRange>
+ ::std::deque<typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const;
+
+ template <typename C, typename Itr>
+ ::std::deque<typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const;
+
+ template <typename C, typename Itr>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ );
+ };
+
+ template <typename C>
+ inline insert_range_function_proxy<ptr_mac_insert_range_function,C>
+ ptr_mac_insert_range_function::operator[](C& _container) const
+ {
+ return insert_range_function_proxy<ptr_mac_insert_range_function,C>(
+ _container
+ );
+ }
+
+ template <typename C, typename InputRange>
+ inline ::std::deque<typename C::iterator>
+ ptr_mac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const
+ {
+ return this->operator()(
+ _container
+ , pos
+ , ::boost::begin(r)
+ , ::boost::end(r)
+ );
+ }
+
+ template <typename C, typename Itr>
+ ::std::deque<typename C::iterator>
+ ptr_mac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const
+ {
+ ::std::deque<typename C::iterator> result;
+
+ for (; itr != itr_end; ++itr)
+ {
+ result.push_back(
+ _container.insert(new typename C::key_type(*itr))
+ );
+ }
+
+ return result;
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ ptr_mac_insert_range_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ _container.insert(itr, itr_end);
+ }
+
+ struct uns_ac_insert_range_function
+ {
+ template <typename C>
+ insert_range_function_proxy<uns_ac_insert_range_function,C>
+ operator[](C& _container) const;
+
+ template <typename C, typename InputRange>
+ void
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const;
+
+ template <typename C, typename Itr>
+ void
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const;
+
+ template <typename C, typename Itr>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ );
+ };
+
+ template <typename C>
+ inline insert_range_function_proxy<uns_ac_insert_range_function,C>
+ uns_ac_insert_range_function::operator[](C& _container) const
+ {
+ return insert_range_function_proxy<uns_ac_insert_range_function,C>(
+ _container
+ );
+ }
+
+ template <typename C, typename InputRange>
+ inline void
+ uns_ac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , InputRange const& r
+ ) const
+ {
+ this->operator()(_container, pos, ::boost::begin(r), ::boost::end(r));
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ uns_ac_insert_range_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ ) const
+ {
+ uns_ac_insert_range_function::evaluate(_container, pos, itr, itr_end);
+ }
+
+ template <typename C, typename Itr>
+ inline void
+ uns_ac_insert_range_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , Itr itr
+ , Itr itr_end
+ )
+ {
+ _container.insert(itr, itr_end);
+ }
+}} // namespace boost::detail
+
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/container_gen/has_stable_iters_selector.hpp>
+#include <boost/container_gen/is_associative_selector.hpp>
+#include <boost/container_gen/is_unique_assoc_selector.hpp>
+#include <boost/container_gen/is_multiple_assoc_selector.hpp>
+#include <boost/container_gen/is_ptr_selector.hpp>
+#include <boost/container_gen/is_random_access_selector.hpp>
+
+//[reference__insert_range_function_gen
+namespace boost {
+
+ template <typename Selector>
+ struct insert_range_function_gen
+ //<-
+ : ::boost::mpl::eval_if<
+ is_associative_selector<Selector>
+ , ::boost::mpl::eval_if<
+ has_stable_iterators_selector<Selector>
+ , ::boost::mpl::eval_if<
+ is_ptr_selector<Selector>
+ , ::boost::mpl::if_<
+ is_unique_associative_selector<Selector>
+ , detail::ptr_uac_insert_range_function
+ , detail::ptr_mac_insert_range_function
+ >
+ , ::boost::mpl::if_<
+ is_multiple_associative_selector<Selector>
+ , detail::mac_insert_range_function
+ , detail::uac_insert_range_function
+ >
+ >
+ , ::boost::mpl::identity<detail::uns_ac_insert_range_function>
+ >
+ , ::boost::mpl::if_<
+ is_random_access_selector<Selector>
+ , detail::ras_insert_range_function
+ , detail::bis_insert_range_function
+ >
+ >
+ //->
+ {
+ // typedef ... type;
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1, insert_range_function_gen, (Selector))
+ //->
+ };
+} // namespace boost
+//]
+
+#include <boost/config.hpp>
+#include <boost/container_gen/selectors.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+namespace boost {
+
+ template <typename AllocatorSelector>
+ struct insert_range_function_gen<slist_selector<AllocatorSelector> >
+ {
+ typedef detail::fis_insert_range_function type;
+ };
+} // namespace boost
+
+#elif !defined BOOST_NO_SLIST
+
+namespace boost {
+
+ template <>
+ struct insert_range_function_gen<slist_selector_base>
+ {
+ typedef detail::fis_insert_range_function type;
+ };
+} // namespace boost
+
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION, BOOST_NO_SLIST
+
+#endif // BOOST_CONTAINER_GEN_INSERT_RANGE_FUNCTION_GEN_HPP_INCLUDED
+

Added: sandbox/container_gen/boost/container_gen/splice_function_gen.hpp
==============================================================================
--- (empty file)
+++ sandbox/container_gen/boost/container_gen/splice_function_gen.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,849 @@
+//=======================================================================
+// Copyright (C) 2013 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_CONTAINER_GEN_SPLICE_FUNCTION_GEN_HPP_INCLUDED
+#define BOOST_CONTAINER_GEN_SPLICE_FUNCTION_GEN_HPP_INCLUDED
+
+#include <deque>
+#include <utility>
+#include <boost/config.hpp>
+#include <algorithm>
+#include <boost/mpl/bool.hpp>
+#include <boost/range.hpp>
+#include <boost/assert.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/move/move.hpp>
+#endif
+
+namespace boost { namespace detail {
+
+ template <typename F, typename C>
+ class splice_function_proxy
+ {
+ C& _container;
+
+ public:
+ explicit splice_function_proxy(C& c);
+
+ splice_function_proxy&
+ operator()(
+ typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ );
+
+ splice_function_proxy&
+ operator()(
+ typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ );
+ };
+
+ template <typename F, typename C>
+ splice_function_proxy<F,C>::splice_function_proxy(C& c)
+ : _container(c)
+ {
+ }
+
+ template <typename F, typename C>
+ inline splice_function_proxy<F,C>&
+ splice_function_proxy<F,C>::operator()(
+ typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ )
+ {
+ F::evaluate(this->_container, pos, c, itr);
+ return *this;
+ }
+
+ template <typename F, typename C>
+ inline splice_function_proxy<F,C>&
+ splice_function_proxy<F,C>::operator()(
+ typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ )
+ {
+ F::evaluate(this->_container, pos, c, itr, itr_end);
+ return *this;
+ }
+
+ struct fis_splice_function
+ {
+ template <typename C>
+ splice_function_proxy<fis_splice_function,C>
+ operator[](C& _container) const;
+
+ template <typename C>
+ typename C::iterator
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const;
+
+ template <typename C>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const;
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ );
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ );
+ };
+
+ template <typename C>
+ inline splice_function_proxy<fis_splice_function,C>
+ fis_splice_function::operator[](C& _container) const
+ {
+ return splice_function_proxy<fis_splice_function,C>(_container);
+ }
+
+ template <typename C>
+ inline typename C::iterator
+ fis_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const
+ {
+ typename C::iterator result_begin = _container.previous(pos);
+ fis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ );
+ return ++result_begin;
+ }
+
+ template <typename C>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ fis_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const
+ {
+ typename C::iterator result_begin = _container.previous(pos);
+ fis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ , itr_end
+ );
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ ++result_begin
+ , pos
+ );
+ }
+
+ template <typename C>
+ inline void
+ fis_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ _container.insert(pos, *itr);
+#else
+ _container.insert(pos, ::boost::move(*itr));
+#endif
+ c.erase(itr);
+ }
+
+ template <typename C>
+ inline void
+ fis_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ _container.insert(pos, itr, itr_end);
+#else
+ _container.insert(
+ pos
+ , ::boost::move_iterator<typename C::iterator>(itr)
+ , ::boost::move_iterator<typename C::iterator>(itr_end)
+ );
+#endif
+ c.erase(itr, itr_end);
+ }
+
+ struct ras_splice_function
+ {
+ template <typename C>
+ splice_function_proxy<ras_splice_function,C>
+ operator[](C& _container) const;
+
+ template <typename C>
+ typename C::iterator
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const;
+
+ template <typename C>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const;
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ );
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ );
+ };
+
+ template <typename C>
+ inline splice_function_proxy<ras_splice_function,C>
+ ras_splice_function::operator[](C& _container) const
+ {
+ return splice_function_proxy<ras_splice_function,C>(_container);
+ }
+
+ template <typename C>
+ inline typename C::iterator
+ ras_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename C::iterator result = _container.insert(pos, *itr);
+#else
+ typename C::iterator result = _container.insert(
+ pos
+ , ::boost::move(*itr)
+ );
+#endif
+ c.erase(itr);
+ return result;
+ }
+
+ template <typename C>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ ras_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const
+ {
+ typename C::size_type const range_size = (
+ ::std::distance(itr, itr_end)
+ );
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename C::iterator result_itr = _container.insert(pos, itr, itr_end);
+#else
+ typename C::iterator result_itr = _container.insert(
+ pos
+ , ::boost::move_iterator<typename C::iterator>(itr)
+ , ::boost::move_iterator<typename C::iterator>(itr_end)
+ );
+#endif
+ c.erase(itr, itr_end);
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ result_itr
+ , result_itr + range_size
+ );
+ }
+
+ template <typename C>
+ inline void
+ ras_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ _container.insert(pos, *itr);
+#else
+ _container.insert(pos, ::boost::move(*itr));
+#endif
+ c.erase(itr);
+ }
+
+ template <typename C>
+ inline void
+ ras_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ _container.insert(pos, itr, itr_end);
+#else
+ _container.insert(
+ pos
+ , ::boost::move_iterator<typename C::iterator>(itr)
+ , ::boost::move_iterator<typename C::iterator>(itr_end)
+ );
+#endif
+ c.erase(itr, itr_end);
+ }
+
+ struct ptr_ras_splice_function
+ {
+ template <typename C>
+ splice_function_proxy<ptr_ras_splice_function,C>
+ operator[](C& _container) const;
+
+ template <typename C>
+ typename C::iterator
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const;
+
+ template <typename C>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const;
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ );
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ );
+ };
+
+ template <typename C>
+ inline splice_function_proxy<ptr_ras_splice_function,C>
+ ptr_ras_splice_function::operator[](C& _container) const
+ {
+ return splice_function_proxy<ptr_ras_splice_function,C>(_container);
+ }
+
+ template <typename C>
+ inline typename C::iterator
+ ptr_ras_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const
+ {
+ typename C::size_type const index = (
+ ::std::distance(_container.begin(), pos)
+ );
+ ptr_ras_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ );
+ return _container.begin() + index;
+ }
+
+ template <typename C>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ ptr_ras_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const
+ {
+ typename C::size_type const begin_index = (
+ ::std::distance(_container.begin(), pos)
+ );
+ typename C::size_type const end_index = (
+ begin_index + ::std::distance(itr, itr_end)
+ );
+ ptr_ras_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ , itr_end
+ );
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ _container.begin() + begin_index
+ , _container.begin() + end_index
+ );
+ }
+
+ template <typename C>
+ inline void
+ ptr_ras_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ )
+ {
+ _container.transfer(pos, itr, itr + 1, c);
+ }
+
+ template <typename C>
+ inline void
+ ptr_ras_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ )
+ {
+ _container.transfer(pos, itr, itr_end, c);
+ }
+
+ struct bis_splice_function
+ {
+ template <typename C>
+ splice_function_proxy<bis_splice_function,C>
+ operator[](C& _container) const;
+
+ template <typename C>
+ typename C::iterator
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const;
+
+ template <typename C>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const;
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ );
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ );
+ };
+
+ template <typename C>
+ inline splice_function_proxy<bis_splice_function,C>
+ bis_splice_function::operator[](C& _container) const
+ {
+ return splice_function_proxy<bis_splice_function,C>(_container);
+ }
+
+ template <typename C>
+ inline typename C::iterator
+ bis_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const
+ {
+ if (_container.empty())
+ {
+ BOOST_ASSERT(pos == _container.end());
+ bis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ );
+ return _container.begin();
+ }
+ else
+ {
+ typename C::iterator start = pos;
+ --start;
+ bis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ );
+ return ++start;
+ }
+ }
+
+ template <typename C>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ bis_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const
+ {
+ if (_container.empty())
+ {
+ BOOST_ASSERT(pos == _container.end());
+ bis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ , itr_end
+ );
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ _container.begin()
+ , _container.end()
+ );
+ }
+ else
+ {
+ typename C::iterator start = pos;
+ --start;
+ bis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ , itr_end
+ );
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ ++start
+ , pos
+ );
+ }
+ }
+
+ template <typename C>
+ inline void
+ bis_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ _container.insert(pos, *itr);
+#else
+ _container.insert(pos, ::boost::move(*itr));
+#endif
+ c.erase(itr);
+ }
+
+ template <typename C>
+ inline void
+ bis_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ _container.insert(pos, itr, itr_end);
+#else
+ _container.insert(
+ pos
+ , ::boost::move_iterator<typename C::iterator>(itr)
+ , ::boost::move_iterator<typename C::iterator>(itr_end)
+ );
+#endif
+ c.erase(itr, itr_end);
+ }
+
+ struct ptr_bis_splice_function
+ {
+ template <typename C>
+ splice_function_proxy<ptr_bis_splice_function,C>
+ operator[](C& _container) const;
+
+ template <typename C>
+ typename C::iterator
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const;
+
+ template <typename C>
+ ::std::pair<typename C::iterator,typename C::iterator>
+ operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const;
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ );
+
+ template <typename C>
+ static void
+ evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ );
+ };
+
+ template <typename C>
+ inline splice_function_proxy<ptr_bis_splice_function,C>
+ ptr_bis_splice_function::operator[](C& _container) const
+ {
+ return splice_function_proxy<ptr_bis_splice_function,C>(_container);
+ }
+
+ template <typename C>
+ inline typename C::iterator
+ ptr_bis_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ ) const
+ {
+ if (_container.empty())
+ {
+ BOOST_ASSERT(pos == _container.end());
+ ptr_bis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ );
+ return _container.begin();
+ }
+ else
+ {
+ typename C::iterator start = pos;
+ --start;
+ ptr_bis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ );
+ return ++start;
+ }
+ }
+
+ template <typename C>
+ inline ::std::pair<typename C::iterator,typename C::iterator>
+ ptr_bis_splice_function::operator()(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ ) const
+ {
+ if (_container.empty())
+ {
+ BOOST_ASSERT(pos == _container.end());
+ ptr_bis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ , itr_end
+ );
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ _container.begin()
+ , _container.end()
+ );
+ }
+ else
+ {
+ typename C::iterator start = pos;
+ --start;
+ ptr_bis_splice_function::evaluate(
+ _container
+ , pos
+ , c
+ , itr
+ , itr_end
+ );
+ return ::std::pair<typename C::iterator,typename C::iterator>(
+ ++start
+ , pos
+ );
+ }
+ }
+
+ template <typename C>
+ inline void
+ ptr_bis_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ )
+ {
+ _container.transfer(pos, itr, c);
+ }
+
+ template <typename C>
+ inline void
+ ptr_bis_splice_function::evaluate(
+ C& _container
+ , typename C::iterator pos
+ , C& c
+ , typename C::iterator itr
+ , typename C::iterator itr_end
+ )
+ {
+ _container.transfer(pos, itr, itr_end, c);
+ }
+}} // namespace boost::detail
+
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/container_gen/is_ptr_selector.hpp>
+#include <boost/container_gen/is_random_access_selector.hpp>
+#include <boost/container_gen/is_reversible_selector.hpp>
+
+//[reference__splice_function_gen
+namespace boost {
+
+ template <typename Selector>
+ struct splice_function_gen
+ //<-
+ : ::boost::mpl::eval_if<
+ is_ptr_selector<Selector>
+ , ::boost::mpl::if_<
+ is_random_access_selector<Selector>
+ , detail::ptr_ras_splice_function
+ , detail::ptr_bis_splice_function
+ >
+ , ::boost::mpl::eval_if<
+ is_random_access_selector<Selector>
+ , ::boost::mpl::identity<detail::ras_splice_function>
+ , ::boost::mpl::if_<
+ is_reversible_selector<Selector>
+ , detail::bis_splice_function
+ , detail::fis_splice_function
+ >
+ >
+ >
+ //->
+ {
+ // typedef ... type;
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1, splice_function_gen, (Selector))
+ //->
+ };
+
+} // namespace boost
+//]
+
+#endif // BOOST_CONTAINER_GEN_SPLICE_FUNCTION_GEN_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/associative_node.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/associative_node.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,2025 @@
+// Copyright (C) 2011-2013 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/assert.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/utility/get_iterator_value_second.hpp>
+#include <boost/container_gen/container_gen.hpp>
+#include <boost/container_gen/emplace_assoc_function_gen.hpp>
+#include <boost/container_gen/is_associative_selector.hpp>
+#include <boost/container_gen/is_recursive_selector.hpp>
+#include <boost/container_gen/is_ptr_selector.hpp>
+#include <boost/container_gen/has_stable_iters_selector.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/associative_node_fwd.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/get_keys.hpp>
+#include <boost/tree_node/iterator/dereference.hpp>
+#include <boost/tree_node/iterator/post_order_descendant.hpp>
+#include <boost/tree_node/iterator/depth_first_descendant.hpp>
+#include <boost/tree_node/iterator/depth_first.hpp>
+#include <boost/detail/metafunction/container_reverse_iterator.hpp>
+#include <boost/detail/metafunction/is_random_access_iterator.hpp>
+#include <boost/assert.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/move/move.hpp>
+//#include <deque>
+//#include <boost/container/container_fwd.hpp>
+//#include <boost/container_gen/is_unique_assoc_selector.hpp>
+#endif
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/enum_trailing.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/_detail/config_begin.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/type_traits/is_pod.hpp>
+
+namespace boost {
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ struct is_POD<
+ ::boost::tree_node::associative_node_base<Derived,Key,Data,Selector>
+ > : ::boost::false_type
+ {
+ };
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ struct is_pod<
+ ::boost::tree_node::associative_node_base<Derived,Key,Data,Selector>
+ > : ::boost::false_type
+ {
+ };
+} // namespace boost
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/transform_view.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/iterator/key_of.hpp>
+#include <boost/fusion/support/is_sequence.hpp>
+#include <boost/fusion/support/category_of.hpp>
+
+namespace boost { namespace tree_node { namespace result_of {
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename FusionKey
+ >
+ struct has_key_impl<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ > : ::boost::mpl::eval_if<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::has_key<Data,FusionKey>
+ , ::std::tr1::is_same<FusionKey,data_key>
+ >::type
+ {
+ };
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ struct get_keys_impl<
+ associative_node_base<Derived,Key,Data,Selector>
+ > : ::boost::mpl::eval_if<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::transform_view<
+ Data
+ , ::boost::fusion::result_of::key_of< ::boost::mpl::_>
+ >
+ , ::boost::mpl::vector1<data_key>
+ >
+ {
+ };
+}}} // namespace boost::tree_node::result_of
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ class associative_node_base
+ : public
+ //[reference__associative_node_base__bases
+ tree_node_base<Derived>
+ //]
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , public data_key
+#endif
+ , private ::boost::noncopyable
+ {
+ BOOST_MPL_ASSERT((::boost::is_associative_selector<Selector>));
+ BOOST_MPL_ASSERT((::boost::is_recursive_selector<Selector>));
+
+ //[reference__associative_node_base__children
+ typedef typename ::boost::container_gen<Selector,Key,Derived>::type
+ children;
+ //]
+
+ public:
+ //[reference__associative_node_base__super_t
+ typedef tree_node_base<Derived> super_t;
+ //]
+
+ //[reference__associative_node_base__pointer
+ typedef typename super_t::pointer pointer;
+ //]
+
+ //[reference__associative_node_base__const_pointer
+ typedef typename super_t::const_pointer const_pointer;
+ //]
+
+ //[reference__associative_node_base__iterator
+ typedef typename children::iterator iterator;
+ //]
+
+ //[reference__associative_node_base__const_iterator
+ typedef typename children::const_iterator const_iterator;
+ //]
+
+ typedef typename ::boost::detail::metafunction
+ ::container_reverse_iterator<children>::type
+ reverse_iterator;
+ typedef typename ::boost::detail::metafunction
+ ::container_reverse_iterator<children const>::type
+ const_reverse_iterator;
+
+ //[reference__associative_node_base__size_type
+ typedef typename children::size_type size_type;
+ //]
+
+ //[reference__associative_node_base__traits
+ struct traits
+ {
+ typedef Key
+ key_type;
+ typedef Data
+ data_type;
+ typedef typename ::boost::mpl::if_<
+ ::boost::is_ptr_selector<Selector>
+ , ::boost::iterator_range<iterator>
+ , ::std::pair<iterator,iterator>
+ >::type
+ iterator_range;
+ typedef typename ::boost::mpl::if_<
+ ::boost::is_ptr_selector<Selector>
+ , ::boost::iterator_range<const_iterator>
+ , ::std::pair<const_iterator,const_iterator>
+ >::type
+ const_iterator_range;
+ typedef typename children::allocator_type
+ allocator;
+ typedef allocator const&
+ allocator_reference;
+ };
+ //]
+
+ private:
+ struct _clone_transform_function
+ {
+ typedef ::std::pair<
+ typename traits::key_type const&
+ , typename traits::data_type const&
+ >
+ result_type;
+
+ template <typename Pair>
+ result_type operator()(Pair const& p) const;
+ };
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ struct _move_transform_function
+ {
+ typedef ::std::pair<
+ typename traits::key_type const&
+ , BOOST_RV_REF(typename traits::data_type)
+ >
+ result_type;
+
+ template <typename Pair>
+ result_type operator()(Pair& p) const;
+ };
+#endif
+
+ children _children;
+ typename traits::data_type _data;
+ pointer _parent;
+
+ protected:
+ //[reference__associative_node_base__derived_copy_ctor
+ associative_node_base(Derived const& copy);
+ //]
+
+ //[reference__associative_node_base__derived_copy_ctor_w_allocator
+ associative_node_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ );
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ associative_node_base(BOOST_RV_REF(Derived) source);
+
+ associative_node_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ );
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__associative_node_base__emplacement_ctor
+ template <typename ...Args>
+ explicit associative_node_base(Args&& ...args);
+ //]
+
+ //[reference__associative_node_base__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit associative_node_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_FWD_DECL
+ , associative_node_base
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_FWD_DECL
+ , associative_node_base
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ ~associative_node_base();
+
+ //[reference__associative_node_base__clone_descendants
+ void clone_descendants(Derived const& copy);
+ //]
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__associative_node_base__copy_assign
+ void copy_assign(Derived const& copy);
+ //]
+#else
+ void move_descendants(BOOST_RV_REF(Derived) source);
+
+ void copy_assign(BOOST_COPY_ASSIGN_REF(Derived) copy);
+
+ void move_assign(BOOST_RV_REF(Derived) source);
+#endif
+
+ //[reference__associative_node_base__on_post_assign
+ void on_post_assign();
+ //]
+
+ public:
+ //[reference__associative_node_base__data_key_value_operator__const
+ typename traits::data_type const& operator[](data_key const&) const;
+ //]
+
+ //[reference__associative_node_base__data_key_value_operator
+ typename traits::data_type& operator[](data_key const&);
+ //]
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ //[reference__associative_node_base__key_value_operator__const
+ template <typename FusionKey>
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data const,FusionKey>
+ >::type
+ operator[](FusionKey const&) const;
+ //]
+
+ //[reference__associative_node_base__key_value_operator
+ template <typename FusionKey>
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data,FusionKey>
+ >::type
+ operator[](FusionKey const&);
+ //]
+#endif
+
+ //[reference__associative_node_base__get_parent_ptr__const
+ const_pointer get_parent_ptr() const;
+ //]
+
+ //[reference__associative_node_base__get_parent_ptr
+ pointer get_parent_ptr();
+ //]
+
+ //[reference__associative_node_base__cbegin
+ const_iterator cbegin() const;
+ const_iterator begin() const;
+ //]
+
+ //[reference__associative_node_base__begin
+ iterator begin();
+ //]
+
+ //[reference__associative_node_base__cend
+ const_iterator cend() const;
+ const_iterator end() const;
+ //]
+
+ //[reference__associative_node_base__end
+ iterator end();
+ //]
+
+ //[reference__associative_node_base__crbegin
+ const_reverse_iterator crbegin() const;
+ const_reverse_iterator rbegin() const;
+ //]
+
+ //[reference__associative_node_base__rbegin
+ reverse_iterator rbegin();
+ //]
+
+ //[reference__associative_node_base__crend
+ const_reverse_iterator crend() const;
+ const_reverse_iterator rend() const;
+ //]
+
+ //[reference__associative_node_base__rend
+ reverse_iterator rend();
+ //]
+
+ //[reference__associative_node_base__size
+ size_type size() const;
+ //]
+
+ //[reference__associative_node_base__empty
+ bool empty() const;
+ //]
+
+ //[reference__associative_node_base__clear
+ void clear();
+ //]
+
+ //[reference__associative_node_base__insert
+ iterator
+ insert(
+ typename traits::key_type const& key
+ , Derived const& child
+ );
+ //]
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__associative_node_base__emplace
+ template <typename ...Args>
+ iterator emplace(typename traits::key_type const& key, Args&& ...args);
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ iterator \
+ emplace( \
+ typename traits::key_type const& key \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ //[reference__associative_node_base__find__const
+ const_iterator find(typename traits::key_type const& key) const;
+ //]
+
+ //[reference__associative_node_base__find
+ iterator find(typename traits::key_type const& key);
+ //]
+
+ //[reference__associative_node_base__equal_range__const
+ typename traits::const_iterator_range
+ equal_range(typename traits::key_type const& key) const;
+ //]
+
+ //[reference__associative_node_base__equal_range
+ typename traits::iterator_range
+ equal_range(typename traits::key_type const& key);
+ //]
+
+ //[reference__associative_node_base__erase
+ size_type erase(typename traits::key_type const& key);
+ //]
+
+ private:
+ void _clone_descendants(Derived const& copy);
+
+ void _clone_descendants(Derived const& copy, ::boost::mpl::true_);
+
+ void _clone_descendants(Derived const& copy, ::boost::mpl::false_);
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ void _move_descendants(Derived& source);
+
+ void _move_descendants(Derived& source, ::boost::mpl::true_);
+
+ void _move_descendants(Derived& source, ::boost::mpl::false_);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ void _on_post_insert(iterator itr, ::boost::mpl::true_);
+
+ void _on_post_insert(iterator itr, ::boost::mpl::false_);
+
+ void _link_children_to_parent();
+
+ void _on_post_modify_value(data_key const& key);
+
+ template <typename D, typename K, typename T, typename S, typename V>
+ friend void
+ put(
+ associative_node_base<D,K,T,S>& node
+ , data_key const& key
+ , V const& value
+ );
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename FusionKey>
+ void _on_post_modify_value(FusionKey const& key);
+
+ template <
+ typename D
+ , typename K
+ , typename T
+ , typename S
+ , typename FusionKey
+ , typename V
+ >
+ friend void
+ put(
+ associative_node_base<D,K,T,S>& node
+ , FusionKey const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<associative_node_base<D,K,T,S>,FusionKey>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type
+ );
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+ };
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ template <typename Pair>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_clone_transform_function::result_type
+ associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_clone_transform_function::operator()(Pair const& p) const
+ {
+ return result_type(
+ p.first
+ , get(::boost::get_iterator_value_second(p), data_key())
+ );
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ template <typename Pair>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_move_transform_function::result_type
+ associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_move_transform_function::operator()(Pair& p) const
+ {
+ return ::std::make_pair(
+ p.first
+ , ::boost::move(get(::boost::get_iterator_value_second(p), data_key()))
+ );
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ associative_node_base<Derived,Key,Data,Selector>::associative_node_base(
+ Derived const& copy
+ ) : _children(), _data(copy._data), _parent()
+ {
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ associative_node_base<Derived,Key,Data,Selector>::associative_node_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ ) : _children(allocator), _data(copy._data), _parent()
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ associative_node_base<Derived,Key,Data,Selector>::associative_node_base(
+ BOOST_RV_REF(Derived) source
+ ) : _children(), _data(::boost::move(source._data)), _parent()
+ {
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ associative_node_base<Derived,Key,Data,Selector>::associative_node_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ ) : _children(allocator), _data(::boost::move(source._data)), _parent()
+ {
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ template <typename ...Args>
+ associative_node_base<Derived,Key,Data,Selector>::associative_node_base(
+ Args&& ...args
+ ) : _children(), _data(::boost::forward<Args>(args)...), _parent()
+ {
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ template <typename ...Args>
+ associative_node_base<Derived,Key,Data,Selector>::associative_node_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : _children(allocator), _data(::boost::forward<Args>(args)...), _parent()
+ {
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename Key \
+ , typename Data \
+ , typename Selector \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ associative_node_base<Derived,Key,Data,Selector>::associative_node_base( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) : _children() \
+ , _data( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ , _parent() \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO
+
+#define BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename Key \
+ , typename Data \
+ , typename Selector \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ associative_node_base<Derived,Key,Data,Selector>::associative_node_base( \
+ ::boost::container::allocator_arg_t \
+ , typename traits::allocator_reference allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) : _children(allocator) \
+ , _data( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ , _parent() \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ associative_node_base<Derived,Key,Data,Selector>::~associative_node_base()
+ {
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<Derived,Key,Data,Selector>::clone_descendants(
+ Derived const& copy
+ )
+ {
+ this->_clone_descendants(copy);
+ }
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ void
+ associative_node_base<Derived,Key,Data,Selector>::copy_assign(
+ Derived const& copy
+ )
+ {
+ Derived twin(copy._data);
+
+ twin._clone_descendants(copy);
+ this->_children.clear();
+ this->_data = twin._data;
+ this->clone_metadata(copy);
+ this->_clone_descendants(twin);
+ }
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<Derived,Key,Data,Selector>::move_descendants(
+ BOOST_RV_REF(Derived) source
+ )
+ {
+ this->_move_descendants(static_cast<Derived&>(source));
+ source._children.clear();
+ source.on_post_clear();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ void
+ associative_node_base<Derived,Key,Data,Selector>::copy_assign(
+ BOOST_COPY_ASSIGN_REF(Derived) copy
+ )
+ {
+ Derived twin(copy._data);
+
+ twin._clone_descendants(static_cast<Derived const&>(copy));
+ this->_children.clear();
+ this->_data = ::boost::move(twin._data);
+ this->_move_descendants(twin);
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<Derived,Key,Data,Selector>::move_assign(
+ BOOST_RV_REF(Derived) source
+ )
+ {
+ this->_children.clear();
+ this->_data = ::boost::move(source._data);
+ this->_move_descendants(static_cast<Derived&>(source));
+ source._children.clear();
+ source.on_post_clear();
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::on_post_assign()
+ {
+ if (this->_parent)
+ {
+ this->_parent->on_post_propagate_value(data_key());
+ }
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type const&
+ associative_node_base<Derived,Key,Data,Selector>::operator[](
+ data_key const&
+ ) const
+ {
+ return this->_data;
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type&
+ associative_node_base<Derived,Key,Data,Selector>::operator[](
+ data_key const&
+ )
+ {
+ return this->_data;
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ template <typename FusionKey>
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data const,FusionKey>
+ >::type
+ associative_node_base<Derived,Key,Data,Selector>::operator[](
+ FusionKey const&
+ ) const
+ {
+ return ::boost::fusion::at_key<FusionKey>(this->_data);
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ template <typename FusionKey>
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data,FusionKey>
+ >::type
+ associative_node_base<Derived,Key,Data,Selector>::operator[](
+ FusionKey const&
+ )
+ {
+ return ::boost::fusion::at_key<FusionKey>(this->_data);
+ }
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_pointer
+ associative_node_base<Derived,Key,Data,Selector>::get_parent_ptr() const
+ {
+ return this->_parent;
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<Derived,Key,Data,Selector>::pointer
+ associative_node_base<Derived,Key,Data,Selector>::get_parent_ptr()
+ {
+ return this->_parent;
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_iterator
+ associative_node_base<Derived,Key,Data,Selector>::cbegin() const
+ {
+ return this->_children.cbegin();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_iterator
+ associative_node_base<Derived,Key,Data,Selector>::begin() const
+ {
+ return this->_children.begin();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<Derived,Key,Data,Selector>::iterator
+ associative_node_base<Derived,Key,Data,Selector>::begin()
+ {
+ return this->_children.begin();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_iterator
+ associative_node_base<Derived,Key,Data,Selector>::cend() const
+ {
+ return this->_children.cend();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_iterator
+ associative_node_base<Derived,Key,Data,Selector>::end() const
+ {
+ return this->_children.end();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<Derived,Key,Data,Selector>::iterator
+ associative_node_base<Derived,Key,Data,Selector>::end()
+ {
+ return this->_children.end();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_reverse_iterator
+ associative_node_base<Derived,Key,Data,Selector>::crbegin() const
+ {
+ return this->_children.crbegin();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_reverse_iterator
+ associative_node_base<Derived,Key,Data,Selector>::rbegin() const
+ {
+ return this->_children.rbegin();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::reverse_iterator
+ associative_node_base<Derived,Key,Data,Selector>::rbegin()
+ {
+ return this->_children.rbegin();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_reverse_iterator
+ associative_node_base<Derived,Key,Data,Selector>::crend() const
+ {
+ return this->_children.crend();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_reverse_iterator
+ associative_node_base<Derived,Key,Data,Selector>::rend() const
+ {
+ return this->_children.rend();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::reverse_iterator
+ associative_node_base<Derived,Key,Data,Selector>::rend()
+ {
+ return this->_children.rend();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<Derived,Key,Data,Selector>::size_type
+ associative_node_base<Derived,Key,Data,Selector>::size() const
+ {
+ return this->_children.size();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline bool associative_node_base<Derived,Key,Data,Selector>::empty() const
+ {
+ return this->_children.empty();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void associative_node_base<Derived,Key,Data,Selector>::clear()
+ {
+ this->_children.clear();
+ this->on_post_clear();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<Derived,Key,Data,Selector>::iterator
+ associative_node_base<Derived,Key,Data,Selector>::insert(
+ typename traits::key_type const& key
+ , Derived const& child
+ )
+ {
+ Derived twin(child._data);
+
+ twin._clone_descendants(child);
+
+ typename ::boost::emplace_associative_function_gen<Selector>::type
+ emplacer;
+ ::std::pair<iterator,bool> p = emplacer(
+ this->_children
+ , key
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , twin._data
+#else
+ , ::boost::move(twin._data)
+#endif
+ );
+
+ if (p.second)
+ {
+ this->_on_post_insert(
+ p.first
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ dereference_iterator(p.first)._clone_descendants(twin);
+#else
+ dereference_iterator(p.first)._move_descendants(twin);
+#endif
+ dereference_iterator(p.first).on_post_inserted(
+ p.first
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ }
+
+ BOOST_ASSERT(
+ dereference_iterator(p.first)._parent == this->get_derived()
+ );
+ return p.first;
+ }
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ template <typename ...Args>
+ typename associative_node_base<Derived,Key,Data,Selector>::iterator
+ associative_node_base<Derived,Key,Data,Selector>::emplace(
+ typename traits::key_type const& key
+ , Args&& ...args
+ )
+ {
+ typename ::boost::emplace_associative_function_gen<Selector>::type
+ emplacer;
+ ::std::pair<iterator,bool> p = emplacer(
+ this->_children
+ , key
+ , ::boost::forward<Args>(args)...
+ );
+
+ if (p.second)
+ {
+ this->_on_post_insert(
+ p.first
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ dereference_iterator(p.first).on_post_inserted(
+ p.first
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ }
+
+ BOOST_ASSERT(
+ dereference_iterator(p.first)._parent == this->get_derived()
+ );
+ return p.first;
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename Key \
+ , typename Data \
+ , typename Selector \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename associative_node_base<Derived,Key,Data,Selector>::iterator \
+ associative_node_base<Derived,Key,Data,Selector>::emplace( \
+ typename traits::key_type const& key \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename ::boost::emplace_associative_function_gen<Selector>::type \
+ emplacer; \
+ ::std::pair<iterator,bool> p = emplacer( \
+ this->_children \
+ , key \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ if (p.second) \
+ { \
+ this->_on_post_insert( \
+ p.first \
+ , ::boost::has_stable_iterators_selector<Selector>() \
+ ); \
+ dereference_iterator(p.first).on_post_inserted( \
+ p.first \
+ , ::boost::has_stable_iterators_selector<Selector>() \
+ ); \
+ } \
+ BOOST_ASSERT( \
+ dereference_iterator(p.first)._parent == this->get_derived() \
+ ); \
+ return p.first; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_ASSOCIATIVE_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::const_iterator
+ associative_node_base<Derived,Key,Data,Selector>::find(
+ typename traits::key_type const& key
+ ) const
+ {
+ return this->_children.find(key);
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<Derived,Key,Data,Selector>::iterator
+ associative_node_base<Derived,Key,Data,Selector>::find(
+ typename traits::key_type const& key
+ )
+ {
+ return this->_children.find(key);
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::const_iterator_range
+ associative_node_base<Derived,Key,Data,Selector>::equal_range(
+ typename traits::key_type const& key
+ ) const
+ {
+ return this->_children.equal_range(key);
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::iterator_range
+ associative_node_base<Derived,Key,Data,Selector>::equal_range(
+ typename traits::key_type const& key
+ )
+ {
+ return this->_children.equal_range(key);
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ typename associative_node_base<Derived,Key,Data,Selector>::size_type
+ associative_node_base<Derived,Key,Data,Selector>::erase(
+ typename traits::key_type const& key
+ )
+ {
+ size_type result = this->_children.erase(key);
+ this->on_post_erase();
+ return result;
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<Derived,Key,Data,Selector>::_clone_descendants(
+ Derived const& copy
+ )
+ {
+ this->_clone_descendants(
+ copy
+ , ::boost::detail::metafunction::is_random_access_iterator<
+ iterator
+ >()
+ );
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ void
+ associative_node_base<Derived,Key,Data,Selector>::_clone_descendants(
+ Derived const& copy
+ , ::boost::mpl::true_
+ )
+ {
+#if 1
+ this->_children = copy._children;
+ this->_link_children_to_parent();
+ this->clone_metadata(copy);
+ this->on_post_copy_or_move();
+#else
+ ::std::deque<iterator> itrs;
+ pointer p = this->get_derived();
+
+ for (depth_first_iterator<Derived const> itr(copy); itr; ++itr)
+ {
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ p->clone_metadata(dereference_iterator(itr));
+ p->_children.clear();
+
+ if (!dereference_iterator(itr).empty())
+ {
+ p->_children.insert(
+ ::boost::make_transform_iterator(
+ dereference_iterator(itr)._children.begin()
+ , _clone_transform_function()
+ )
+ , ::boost::make_transform_iterator(
+ dereference_iterator(itr)._children.end()
+ , _clone_transform_function()
+ )
+ );
+ p->_link_children_to_parent();
+ itrs.push_back(p->_children.begin());
+ p = &dereference_iterator(itrs.back());
+ BOOST_ASSERT(!!p->get_parent_ptr());
+ }
+
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ p->on_post_copy_or_move();
+
+ if (!itrs.empty())
+ {
+ BOOST_ASSERT(!!p->get_parent_ptr());
+
+ if (++itrs.back() == p->_parent->_children.end())
+ {
+ p = p->get_parent_ptr();
+ itrs.pop_back();
+ }
+ else
+ {
+ p = &dereference_iterator(itrs.back());
+ BOOST_ASSERT(!!p->get_parent_ptr());
+ }
+ }
+
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "itr not at-the-end");
+#endif
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ void
+ associative_node_base<Derived,Key,Data,Selector>::_clone_descendants(
+ Derived const& copy
+ , ::boost::mpl::false_ f
+ )
+ {
+ typename ::boost::emplace_associative_function_gen<Selector>::type
+ emplacer;
+ iterator child_itr;
+ pointer p = this->get_derived();
+
+ p->clone_metadata(copy);
+ p->_children.clear();
+
+ for (
+ depth_first_descendant_iterator<Derived const> itr(copy);
+ itr;
+ ++itr
+ )
+ {
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ child_itr = emplacer(
+ p->_children
+ , itr->first
+ , dereference_iterator(itr)._data
+ ).first;
+ p->_on_post_insert(child_itr, f);
+ p = &dereference_iterator(child_itr);
+ p->clone_metadata(dereference_iterator(itr));
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ p->on_post_copy_or_move();
+ p = p->get_parent_ptr();
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "itr not at-the-end");
+ p->on_post_copy_or_move();
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<Derived,Key,Data,Selector>::_move_descendants(
+ Derived& source
+ )
+ {
+ this->_move_descendants(
+ source
+ , ::boost::detail::metafunction::is_random_access_iterator<
+ iterator
+ >()
+ );
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ void
+ associative_node_base<Derived,Key,Data,Selector>::_move_descendants(
+ Derived& source
+ , ::boost::mpl::true_
+ )
+ {
+#if 1
+ this->_children.clear();
+ this->_children = ::boost::move(source._children);
+ this->_link_children_to_parent();
+ this->move_metadata(::boost::move(source));
+ this->on_post_copy_or_move();
+#else
+ ::std::deque<iterator> itrs;
+ pointer p = this->get_derived();
+
+ for (depth_first_iterator<Derived> itr(source); itr; ++itr)
+ {
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ p->clone_metadata(dereference_iterator(itr));
+ p->_children.clear();
+
+ if (!dereference_iterator(itr).empty())
+ {
+ p->_children.insert(
+ /*typename ::boost::mpl::if_<
+ ::boost::is_unique_associative_selector<
+ Selector
+ >
+ , ::boost::container::ordered_unique_range_t
+ , ::boost::container::ordered_range_t
+ >::type()
+ , */::boost::make_transform_iterator(
+ dereference_iterator(itr)._children.begin()
+ , _move_transform_function()
+ )
+ , ::boost::make_transform_iterator(
+ dereference_iterator(itr)._children.end()
+ , _move_transform_function()
+ )
+ );
+ p->_link_children_to_parent();
+ itrs.push_back(p->_children.begin());
+ p = &dereference_iterator(itrs.back());
+ BOOST_ASSERT(!!p->get_parent_ptr());
+ }
+
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ p->on_post_copy_or_move();
+
+ if (!itrs.empty())
+ {
+ BOOST_ASSERT(!!p->get_parent_ptr());
+
+ if (++itrs.back() == p->_parent->_children.end())
+ {
+ p = p->get_parent_ptr();
+ itrs.pop_back();
+ }
+ else
+ {
+ p = &dereference_iterator(itrs.back());
+ BOOST_ASSERT(!!p->get_parent_ptr());
+ }
+ }
+
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "itr not at-the-end");
+#endif
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ void
+ associative_node_base<Derived,Key,Data,Selector>::_move_descendants(
+ Derived& source
+ , ::boost::mpl::false_
+ )
+ {
+ typename ::boost::emplace_associative_function_gen<Selector>::type
+ emplacer;
+ iterator child_itr;
+ pointer p = this->get_derived();
+
+ p->move_metadata(::boost::move(source));
+ p->_children.clear();
+
+ for (depth_first_descendant_iterator<Derived> itr(source); itr; ++itr)
+ {
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ child_itr = emplacer(
+ p->_children
+ , itr->first
+ , ::boost::move(dereference_iterator(itr)._data)
+ ).first;
+ p->_on_post_insert(
+ child_itr
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ p = &dereference_iterator(child_itr);
+ p->move_metadata(
+ ::boost::move(dereference_iterator(itr))
+ );
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ dereference_iterator(itr)._children.clear();
+ p->on_post_copy_or_move();
+ p = p->get_parent_ptr();
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "itr not at-the-end");
+ p->on_post_copy_or_move();
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_on_post_insert(iterator itr, ::boost::mpl::true_)
+ {
+ dereference_iterator(itr)._parent = this->get_derived();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_on_post_insert(iterator itr, ::boost::mpl::false_)
+ {
+ this->_link_children_to_parent();
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ void
+ associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_link_children_to_parent()
+ {
+ iterator itr = this->begin();
+
+ for (iterator itr_end = this->end(); itr != itr_end; ++itr)
+ {
+ dereference_iterator(itr)._parent = this->get_derived();
+ }
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline void
+ associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_on_post_modify_value(data_key const& key)
+ {
+ this->on_post_propagate_value(key);
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ template <typename FusionKey>
+ inline void
+ associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::_on_post_modify_value(FusionKey const& key)
+ {
+ this->on_post_propagate_value(key);
+ }
+#endif
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type const&
+ get(
+ associative_node_base<Derived,Key,Data,Selector> const& node
+ , data_key const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ inline typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type&
+ get(
+ associative_node_base<Derived,Key,Data,Selector>& node
+ , data_key const& key
+ )
+ {
+ return node[key];
+ }
+
+#if !defined BOOST_NO_SFINAE
+ template <
+ typename DataKey
+ , typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<DataKey,data_key>
+ , typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type const&
+ >::type
+ get(associative_node_base<Derived,Key,Data,Selector> const& node)
+ {
+ return node[data_key()];
+ }
+
+ template <
+ typename DataKey
+ , typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<DataKey,data_key>
+ , typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type&
+ >::type
+ get(associative_node_base<Derived,Key,Data,Selector>& node)
+ {
+ return node[data_key()];
+ }
+#endif // BOOST_NO_SFINAE
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename V
+ >
+ inline void
+ put(
+ associative_node_base<Derived,Key,Data,Selector>& node
+ , data_key const& key
+ , V const& value
+ )
+ {
+ node[key] = value;
+ node._on_post_modify_value(key);
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename FusionKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data const,FusionKey>
+ >::type
+ get(
+ associative_node_base<Derived,Key,Data,Selector> const& node
+ , FusionKey const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename FusionKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data,FusionKey>
+ >::type
+ get(
+ associative_node_base<Derived,Key,Data,Selector>& node
+ , FusionKey const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data const,FusionKey>
+ >::type
+ get(associative_node_base<Derived,Key,Data,Selector> const& node)
+ {
+ return node[FusionKey()];
+ }
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data,FusionKey>
+ >::type
+ get(associative_node_base<Derived,Key,Data,Selector>& node)
+ {
+ return node[FusionKey()];
+ }
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename FusionKey
+ , typename V
+ >
+ inline void
+ put(
+ associative_node_base<Derived,Key,Data,Selector>& node
+ , FusionKey const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type
+ )
+ {
+ node[key] = value;
+ node._on_post_modify_value(key);
+ }
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+}} // namespace boost::tree_node
+
+//[reference__associative_node_base_gen
+namespace boost { namespace tree_node {
+
+ template <typename Selector = ::boost::ptr_mapS>
+ struct associative_node_base_gen
+ {
+ template <typename Derived, typename Key, typename Data>
+ struct apply
+ {
+ typedef associative_node_base<Derived,Key,Data,Selector> type;
+ };
+ };
+
+ typedef associative_node_base_gen<> associative_node_base_default_gen;
+}} // namespace boost::tree_node
+//]
+
+namespace boost { namespace tree_node {
+
+ template <typename Key, typename Data, typename Selector>
+ struct associative_node
+ : public
+ //[reference__associative_node__bases
+ associative_node_base<
+ associative_node<Key,Data,Selector>
+ , Key
+ , Data
+ , Selector
+ >
+ //]
+ {
+ //[reference__associative_node__super_t
+ typedef associative_node_base<
+ associative_node
+ , Key
+ , Data
+ , Selector
+ >
+ super_t;
+ //]
+
+ //[reference__associative_node__traits
+ typedef typename super_t::traits
+ traits;
+ //]
+
+ //[reference__associative_node__pointer
+ typedef typename super_t::pointer
+ pointer;
+ //]
+
+ //[reference__associative_node__const_pointer
+ typedef typename super_t::const_pointer
+ const_pointer;
+ //]
+
+ //[reference__associative_node__iterator
+ typedef typename super_t::iterator
+ iterator;
+ //]
+
+ //[reference__associative_node__const_iterator
+ typedef typename super_t::const_iterator
+ const_iterator;
+ //]
+
+ //[reference__associative_node__reverse_iterator
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ //]
+
+ //[reference__associative_node__const_reverse_iterator
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ //]
+
+ //[reference__associative_node__size_type
+ typedef typename super_t::size_type
+ size_type;
+ //]
+
+ BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(associative_node, super_t)
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__associative_node__emplacement_ctor
+ template <typename ...Args>
+ explicit associative_node(Args&& ...args);
+ //]
+
+ //[reference__associative_node__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit associative_node(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF
+ , (associative_node, super_t)
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF
+ , (associative_node, super_t)
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+ };
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Key, typename Data, typename Selector>
+ template <typename ...Args>
+ inline associative_node<Key,Data,Selector>::associative_node(
+ Args&& ...args
+ ) : super_t(::boost::forward<Args>(args)...)
+ {
+ }
+
+ template <typename Key, typename Data, typename Selector>
+ template <typename ...Args>
+ inline associative_node<Key,Data,Selector>::associative_node(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ {
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+}} // namespace boost::tree_node
+
+//[reference__associative_node_gen
+namespace boost { namespace tree_node {
+
+ template <typename Selector = ::boost::ptr_mapS>
+ struct associative_node_gen
+ {
+ template <typename Key, typename Data>
+ struct apply
+ {
+ typedef associative_node<Key,Data,Selector> type;
+ };
+ };
+
+ typedef associative_node_gen<> associative_node_default_gen;
+}} // namespace boost::tree_node
+//]
+
+#include <boost/tree_node/_detail/config_end.hpp>
+
+#endif // BOOST_TREE_NODE_ASSOCIATIVE_NODE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/associative_node_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/associative_node_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,293 @@
+// Copyright (C) 2013 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_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_ASSOCIATIVE_NODE_FWD_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/container_gen/selectors.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/key/data.hpp>
+
+#if !defined BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/tr1/type_traits.hpp>
+#endif
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/fusion/sequence/intrinsic/has_key.hpp>
+#include <boost/fusion/support/is_sequence.hpp>
+#include <boost/fusion/support/category_of.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#endif
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ class associative_node_base;
+
+ template <
+ typename Key
+ , typename Data
+ , typename Selector = ::boost::ptr_mapS
+ >
+ struct associative_node;
+}} // namespace boost::tree_node
+
+//[reference__associative_node_base__at_data_key__const
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type const&
+ get(
+ associative_node_base<Derived,Key,Data,Selector> const& node
+ , data_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename DataKey
+ , typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<DataKey,data_key>
+ , typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type const&
+ >::type
+ get(associative_node_base<Derived,Key,Data,Selector> const& node);
+//<-
+#endif // BOOST_NO_SFINAE
+//->
+}} // namespace boost::tree_node
+//]
+
+//[reference__associative_node_base__at_data_key
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename Key, typename Data, typename Selector>
+ typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type&
+ get(
+ associative_node_base<Derived,Key,Data,Selector>& node
+ , data_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename DataKey
+ , typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<DataKey,data_key>
+ , typename associative_node_base<
+ Derived
+ , Key
+ , Data
+ , Selector
+ >::traits::data_type&
+ >::type
+ get(associative_node_base<Derived,Key,Data,Selector>& node);
+//<-
+#endif // BOOST_NO_SFINAE
+//->
+}} // namespace boost::tree_node
+//]
+
+//[reference__associative_node_base__put_data
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename V
+ >
+ void
+ put(
+ associative_node_base<Derived,Key,Data,Selector>& node
+ , data_key const& key
+ , V const& value
+ );
+}} // namespace boost::tree_node
+//]
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+//[reference__associative_node_base__at_key__const
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename FusionKey
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data const,FusionKey>
+ >::type
+ get(
+ associative_node_base<Derived,Key,Data,Selector> const& node
+ , FusionKey const& key
+ );
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data const,FusionKey>
+ >::type
+ get(associative_node_base<Derived,Key,Data,Selector> const& node);
+}} // namespace boost::tree_node
+//]
+
+//[reference__associative_node_base__at_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename FusionKey
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data,FusionKey>
+ >::type
+ get(
+ associative_node_base<Derived,Key,Data,Selector>& node
+ , FusionKey const& key
+ );
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<Data,FusionKey>
+ >::type
+ get(associative_node_base<Derived,Key,Data,Selector>& node);
+}} // namespace boost::tree_node
+//]
+
+//[reference__associative_node_base__put
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename Key
+ , typename Data
+ , typename Selector
+ , typename FusionKey
+ , typename V
+ >
+ void
+ put(
+ associative_node_base<Derived,Key,Data,Selector>& node
+ , FusionKey const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<Data>::type
+ , ::boost::fusion::traits::is_associative<Data>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ associative_node_base<Derived,Key,Data,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type = ::boost::mpl::true_()
+ );
+}} // namespace boost::tree_node
+//]
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+#endif // BOOST_TREE_NODE_ASSOCIATIVE_NODE_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/balancer/adelson_velskii_landis.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/balancer/adelson_velskii_landis.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,183 @@
+// Copyright (C) 2013 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_BALANCER_ADELSON_VELSKII_LANDIS_HPP_INCLUDED
+#define BOOST_TREE_NODE_BALANCER_ADELSON_VELSKII_LANDIS_HPP_INCLUDED
+
+#include <boost/tree_node/key/height.hpp>
+
+//[reference__adelson_velskii_landis_balancer
+namespace boost { namespace tree_node {
+
+ struct adelson_velskii_landis_balancer
+ {
+ template <typename NodePointer>
+ static NodePointer post_insert(NodePointer node_ptr);
+
+ template <typename Node>
+ static bool choose_predecessor(Node const& node);
+
+ template <typename Node>
+ static bool pre_erase(Node const& node);
+
+ template <typename NodePointer>
+ static NodePointer post_erase_left(NodePointer node_ptr);
+
+ template <typename NodePointer>
+ static NodePointer post_erase_right(NodePointer node_ptr);
+
+ //<-
+ private:
+ template <typename NodePointer>
+ static NodePointer _balance(NodePointer node_ptr);
+ //->
+ };
+
+ //<-
+ template <typename NodePointer>
+ inline NodePointer
+ adelson_velskii_landis_balancer::post_insert(NodePointer node_ptr)
+ {
+ return adelson_velskii_landis_balancer::_balance(node_ptr);
+ }
+
+ template <typename Node>
+ inline bool adelson_velskii_landis_balancer::choose_predecessor(Node const& node)
+ {
+ return get(*node.get_right_child_ptr(), height_key()) < get(
+ *node.get_left_child_ptr()
+ , height_key()
+ );
+ }
+
+ template <typename Node>
+ inline bool adelson_velskii_landis_balancer::pre_erase(Node const& node)
+ {
+ return true;
+ }
+
+ template <typename NodePointer>
+ inline NodePointer
+ adelson_velskii_landis_balancer::post_erase_left(NodePointer node_ptr)
+ {
+ return adelson_velskii_landis_balancer::_balance(node_ptr);
+ }
+
+ template <typename NodePointer>
+ inline NodePointer
+ adelson_velskii_landis_balancer::post_erase_right(NodePointer node_ptr)
+ {
+ return adelson_velskii_landis_balancer::_balance(node_ptr);
+ }
+
+ template <typename NodePointer>
+ NodePointer adelson_velskii_landis_balancer::_balance(NodePointer node_ptr)
+ {
+ NodePointer grandparent_ptr;
+
+ for (
+ NodePointer parent_ptr;
+ (parent_ptr = node_ptr->get_parent_ptr()) && (
+ grandparent_ptr = parent_ptr->get_parent_ptr()
+ );
+ node_ptr = parent_ptr
+ )
+ {
+ if (
+ !grandparent_ptr->get_left_child_ptr() || (
+ grandparent_ptr->get_right_child_ptr() && (
+ 1 + get(
+ *grandparent_ptr->get_left_child_ptr()
+ , height_key()
+ ) < get(
+ *grandparent_ptr->get_right_child_ptr()
+ , height_key()
+ )
+ )
+ )
+ )
+ {
+ parent_ptr = grandparent_ptr->get_right_child_ptr();
+
+ if (
+ !parent_ptr->get_right_child_ptr() || (
+ parent_ptr->get_left_child_ptr() && (
+ get(
+ *parent_ptr->get_right_child_ptr()
+ , height_key()
+ ) < get(
+ *parent_ptr->get_left_child_ptr()
+ , height_key()
+ )
+ )
+ )
+ )
+ {
+ parent_ptr = parent_ptr->rotate_right();
+ }
+
+ grandparent_ptr = grandparent_ptr->rotate_left();
+
+ if (!grandparent_ptr->get_parent_ptr())
+ {
+ return grandparent_ptr;
+ }
+ }
+ else if (
+ !grandparent_ptr->get_right_child_ptr() || (
+ grandparent_ptr->get_left_child_ptr() && (
+ 1 + get(
+ *grandparent_ptr->get_right_child_ptr()
+ , height_key()
+ ) < get(
+ *grandparent_ptr->get_left_child_ptr()
+ , height_key()
+ )
+ )
+ )
+ )
+ {
+ parent_ptr = grandparent_ptr->get_left_child_ptr();
+
+ if (
+ !parent_ptr->get_left_child_ptr() || (
+ parent_ptr->get_right_child_ptr() && (
+ get(
+ *parent_ptr->get_left_child_ptr()
+ , height_key()
+ ) < get(
+ *parent_ptr->get_right_child_ptr()
+ , height_key()
+ )
+ )
+ )
+ )
+ {
+ parent_ptr = parent_ptr->rotate_left();
+ }
+
+ grandparent_ptr = grandparent_ptr->rotate_right();
+
+ if (!grandparent_ptr->get_parent_ptr())
+ {
+ return grandparent_ptr;
+ }
+ }
+ }
+
+ return node_ptr;
+ }
+ //->
+
+ namespace balancer {
+
+ typedef ::boost::tree_node::adelson_velskii_landis_balancer
+ adelson_velskii_landis;
+ } // namespace balancer
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_BALANCER_ADELSON_VELSKII_LANDIS_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/balancer/null.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/balancer/null.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,70 @@
+// Copyright (C) 2013 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_BALANCER_NULL_HPP_INCLUDED
+#define BOOST_TREE_NODE_BALANCER_NULL_HPP_INCLUDED
+
+//[reference__null_balancer
+namespace boost { namespace tree_node {
+
+ struct null_balancer
+ {
+ template <typename NodePointer>
+ static NodePointer post_insert(NodePointer node_ptr);
+
+ template <typename Node>
+ static bool choose_predecessor(Node const& node);
+
+ template <typename Node>
+ static bool pre_erase(Node const& node);
+
+ template <typename NodePointer>
+ static NodePointer post_erase_left(NodePointer node_ptr);
+
+ template <typename NodePointer>
+ static NodePointer post_erase_right(NodePointer node_ptr);
+ };
+
+ //<-
+ template <typename NodePointer>
+ inline NodePointer null_balancer::post_insert(NodePointer node_ptr)
+ {
+ return node_ptr;
+ }
+
+ template <typename Node>
+ inline bool null_balancer::choose_predecessor(Node const& node)
+ {
+ return true;
+ }
+
+ template <typename Node>
+ inline bool null_balancer::pre_erase(Node const& node)
+ {
+ return true;
+ }
+
+ template <typename NodePointer>
+ inline NodePointer null_balancer::post_erase_left(NodePointer node_ptr)
+ {
+ return node_ptr;
+ }
+
+ template <typename NodePointer>
+ inline NodePointer null_balancer::post_erase_right(NodePointer node_ptr)
+ {
+ return node_ptr;
+ }
+ //->
+
+ namespace balancer {
+
+ typedef ::boost::tree_node::null_balancer null;
+ } // namespace balancer
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_BALANCER_NULL_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/balancer/red_black.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/balancer/red_black.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,421 @@
+// Copyright (C) 2013 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_BALANCER_RED_BLACK_HPP_INCLUDED
+#define BOOST_TREE_NODE_BALANCER_RED_BLACK_HPP_INCLUDED
+
+#include <boost/utility/value_init.hpp>
+#include <boost/tree_node/key/red_black_flag.hpp>
+#include <boost/assert.hpp>
+
+//[reference__red_black_balancer
+namespace boost { namespace tree_node {
+
+ struct red_black_balancer
+ {
+ template <typename NodePointer>
+ static NodePointer post_insert(NodePointer node_ptr);
+
+ template <typename Node>
+ static bool choose_predecessor(Node const& node);
+
+ template <typename Node>
+ static bool pre_erase(Node const& node);
+
+ template <typename NodePointer>
+ static NodePointer post_erase_left(NodePointer node_ptr);
+
+ template <typename NodePointer>
+ static NodePointer post_erase_right(NodePointer node_ptr);
+
+ //<-
+ private:
+ template <typename NodePointer>
+ static NodePointer _balance(NodePointer node_ptr);
+ //->
+ };
+
+ //<-
+ template <typename NodePointer>
+ NodePointer red_black_balancer::post_insert(NodePointer node_ptr)
+ {
+ NodePointer parent_ptr;
+ NodePointer grandparent_ptr;
+ NodePointer uncle_ptr;
+
+ put(*node_ptr, red_flag_key(), true);
+
+ while ((parent_ptr = node_ptr->get_parent_ptr()))
+ {
+ if (get(*parent_ptr, black_flag_key()))
+ {
+ return node_ptr;
+ }
+
+ grandparent_ptr = parent_ptr->get_parent_ptr();
+
+ if (parent_ptr == grandparent_ptr->get_left_child_ptr())
+ {
+ if (
+ (
+ uncle_ptr = grandparent_ptr->get_right_child_ptr()
+ ) && get(*uncle_ptr, red_flag_key())
+ )
+ {
+ put(*parent_ptr, black_flag_key(), true);
+ put(*uncle_ptr, black_flag_key(), true);
+ put(*grandparent_ptr, red_flag_key(), true);
+ node_ptr = grandparent_ptr;
+ continue;
+ }
+ }
+ else // if (parent_ptr == grandparent_ptr->get_right_child_ptr())
+ {
+ if (
+ (
+ uncle_ptr = grandparent_ptr->get_left_child_ptr()
+ ) && get(*uncle_ptr, red_flag_key())
+ )
+ {
+ put(*parent_ptr, black_flag_key(), true);
+ put(*uncle_ptr, black_flag_key(), true);
+ put(*grandparent_ptr, red_flag_key(), true);
+ node_ptr = grandparent_ptr;
+ continue;
+ }
+ }
+
+ if (
+ (node_ptr == parent_ptr->get_right_child_ptr()) && (
+ parent_ptr == grandparent_ptr->get_left_child_ptr()
+ )
+ )
+ {
+ parent_ptr = parent_ptr->rotate_left();
+ node_ptr = node_ptr->get_left_child_ptr();
+ }
+ else if (
+ (node_ptr == parent_ptr->get_left_child_ptr()) && (
+ parent_ptr == grandparent_ptr->get_right_child_ptr()
+ )
+ )
+ {
+ parent_ptr = parent_ptr->rotate_right();
+ node_ptr = node_ptr->get_right_child_ptr();
+ }
+
+ grandparent_ptr = parent_ptr->get_parent_ptr();
+ put(*parent_ptr, black_flag_key(), true);
+ put(*grandparent_ptr, red_flag_key(), true);
+
+ return (node_ptr == parent_ptr->get_left_child_ptr()) ? (
+ grandparent_ptr->rotate_right()
+ ) : grandparent_ptr->rotate_left();
+ }
+
+ put(*node_ptr, black_flag_key(), true);
+ return node_ptr;
+ }
+
+ template <typename Node>
+ inline bool red_black_balancer::choose_predecessor(Node const& node)
+ {
+ typename Node::const_pointer succ_ptr = node.get_right_child_ptr();
+
+ while (succ_ptr->get_left_child_ptr())
+ {
+ succ_ptr = succ_ptr->get_left_child_ptr();
+ }
+
+ return get(*succ_ptr, black_flag_key()) && succ_ptr->empty();
+ }
+
+ template <typename Node>
+ inline bool red_black_balancer::pre_erase(Node const& node)
+ {
+ return get(node, black_flag_key());
+ }
+
+ template <typename NodePointer>
+ NodePointer red_black_balancer::post_erase_left(NodePointer node_ptr)
+ {
+ NodePointer result_ptr = ::boost::initialized_value;
+ NodePointer child_ptr = node_ptr->get_right_child_ptr();
+
+ if (get(*child_ptr, red_flag_key()))
+ {
+std::cout << "Right Sib 5.1" << std::endl;
+ put(*node_ptr, red_flag_key(), true);
+ put(*child_ptr, black_flag_key(), true);
+ result_ptr = node_ptr->rotate_left();
+ child_ptr = node_ptr->get_right_child_ptr();
+ }
+
+ NodePointer grandchild_ptr = child_ptr->get_right_child_ptr();
+
+ if (grandchild_ptr)
+ {
+ BOOST_ASSERT(get(*grandchild_ptr, red_flag_key()));
+std::cout << "Right Sib 5.3.2" << std::endl;
+ put(*grandchild_ptr, black_flag_key(), true);
+ put(
+ *child_ptr
+ , red_flag_key()
+ , get(*node_ptr, red_flag_key())
+ );
+ put(*node_ptr, black_flag_key(), true);
+
+ if (result_ptr)
+ {
+ node_ptr->rotate_left();
+ }
+ else
+ {
+ result_ptr = node_ptr->rotate_left();
+ }
+
+ return result_ptr;
+ }
+
+ if ((grandchild_ptr = child_ptr->get_left_child_ptr()))
+ {
+ BOOST_ASSERT(get(*grandchild_ptr, red_flag_key()));
+std::cout << "Right Sib 5.3.1" << std::endl;
+ put(
+ *(child_ptr = child_ptr->rotate_right())
+ , red_flag_key()
+ , get(*node_ptr, red_flag_key())
+ );
+ put(*node_ptr, black_flag_key(), true);
+
+ if (result_ptr)
+ {
+ node_ptr->rotate_left();
+ }
+ else
+ {
+ result_ptr = node_ptr->rotate_left();
+ }
+
+ return result_ptr;
+ }
+
+std::cout << "Right Sib 5.2" << std::endl;
+ put(*child_ptr, red_flag_key(), true);
+
+ if (result_ptr)
+ {
+ BOOST_ASSERT(get(*node_ptr, red_flag_key()));
+ put(*node_ptr, black_flag_key(), true);
+ return result_ptr;
+ }
+ else if (get(*node_ptr, red_flag_key()))
+ {
+ put(*node_ptr, black_flag_key(), true);
+ return node_ptr;
+ }
+ else
+ {
+ return red_black_balancer::_balance(node_ptr);
+ }
+ }
+
+ template <typename NodePointer>
+ NodePointer red_black_balancer::post_erase_right(NodePointer node_ptr)
+ {
+ NodePointer result_ptr = ::boost::initialized_value;
+ NodePointer child_ptr = node_ptr->get_left_child_ptr();
+
+ if (get(*child_ptr, red_flag_key()))
+ {
+std::cout << "Left Sib 5.1" << std::endl;
+ put(*node_ptr, red_flag_key(), true);
+ put(*child_ptr, black_flag_key(), true);
+ result_ptr = node_ptr->rotate_right();
+ child_ptr = node_ptr->get_left_child_ptr();
+ }
+
+ NodePointer grandchild_ptr = child_ptr->get_left_child_ptr();
+
+ if (grandchild_ptr)
+ {
+ BOOST_ASSERT(get(*grandchild_ptr, red_flag_key()));
+std::cout << "Left Sib 5.3.2" << std::endl;
+ put(*grandchild_ptr, black_flag_key(), true);
+ put(
+ *child_ptr
+ , red_flag_key()
+ , get(*node_ptr, red_flag_key())
+ );
+ put(*node_ptr, black_flag_key(), true);
+
+ if (result_ptr)
+ {
+ node_ptr->rotate_right();
+ }
+ else
+ {
+ result_ptr = node_ptr->rotate_right();
+ }
+
+ return result_ptr;
+ }
+
+ if ((grandchild_ptr = child_ptr->get_right_child_ptr()))
+ {
+ BOOST_ASSERT(get(*grandchild_ptr, red_flag_key()));
+std::cout << "Left Sib 5.3.1" << std::endl;
+ put(
+ *(child_ptr = child_ptr->rotate_left())
+ , red_flag_key()
+ , get(*node_ptr, red_flag_key())
+ );
+ put(*node_ptr, black_flag_key(), true);
+
+ if (result_ptr)
+ {
+ node_ptr->rotate_right();
+ }
+ else
+ {
+ result_ptr = node_ptr->rotate_right();
+ }
+
+ return result_ptr;
+ }
+
+std::cout << "Left Sib 5.2" << std::endl;
+ put(*child_ptr, red_flag_key(), true);
+
+ if (result_ptr)
+ {
+ BOOST_ASSERT(get(*node_ptr, red_flag_key()));
+ put(*node_ptr, black_flag_key(), true);
+ return result_ptr;
+ }
+ else if (get(*node_ptr, red_flag_key()))
+ {
+ put(*node_ptr, black_flag_key(), true);
+ return node_ptr;
+ }
+ else
+ {
+ return red_black_balancer::_balance(node_ptr);
+ }
+ }
+
+ template <typename NodePointer>
+ NodePointer red_black_balancer::_balance(NodePointer node_ptr)
+ {
+ NodePointer parent_ptr;
+ NodePointer sibling_ptr;
+ NodePointer nephew_ptr;
+
+ for (
+ bool is_left;
+ (parent_ptr = node_ptr->get_parent_ptr());
+ node_ptr = parent_ptr
+ )
+ {
+ sibling_ptr = (
+ is_left = (node_ptr == parent_ptr->get_left_child_ptr())
+ ) ? parent_ptr->get_right_child_ptr() : (
+ parent_ptr->get_left_child_ptr()
+ );
+
+ if (get(*sibling_ptr, red_flag_key()))
+ {
+std::cout << "5.1" << std::endl;
+ put(*parent_ptr, red_flag_key(), true);
+ put(*sibling_ptr, black_flag_key(), true);
+
+ if (is_left)
+ {
+ parent_ptr->rotate_left();
+ sibling_ptr = parent_ptr->get_right_child_ptr();
+ }
+ else
+ {
+ parent_ptr->rotate_right();
+ sibling_ptr = parent_ptr->get_left_child_ptr();
+ }
+
+ put(*sibling_ptr, red_flag_key(), true);
+ put(*parent_ptr, black_flag_key(), true);
+ return parent_ptr->get_parent_ptr();
+ }
+
+ nephew_ptr = is_left ? sibling_ptr->get_right_child_ptr() : (
+ sibling_ptr->get_left_child_ptr()
+ );
+
+ if (nephew_ptr)
+ {
+ if (get(*nephew_ptr, red_flag_key()))
+ {
+std::cout << "5.3.2" << std::endl;
+ put(*nephew_ptr, black_flag_key(), true);
+ put(
+ *sibling_ptr
+ , red_flag_key()
+ , get(*parent_ptr, red_flag_key())
+ );
+ put(*parent_ptr, black_flag_key(), true);
+ return is_left ? parent_ptr->rotate_left() : (
+ parent_ptr->rotate_right()
+ );
+ }
+ }
+
+ if (
+ (
+ nephew_ptr = is_left ? (
+ sibling_ptr->get_left_child_ptr()
+ ) : sibling_ptr->get_right_child_ptr()
+ )
+ )
+ {
+ if (get(*nephew_ptr, red_flag_key()))
+ {
+std::cout << "5.3.1" << std::endl;
+ put(
+ *(
+ sibling_ptr = is_left ? (
+ sibling_ptr->rotate_right()
+ ) : sibling_ptr->rotate_left()
+ )
+ , red_flag_key()
+ , get(*parent_ptr, red_flag_key())
+ );
+ put(*parent_ptr, black_flag_key(), true);
+ return is_left ? parent_ptr->rotate_left() : (
+ parent_ptr->rotate_right()
+ );
+ }
+ }
+
+std::cout << "5.2" << std::endl;
+ put(*sibling_ptr, red_flag_key(), true);
+
+ if (get(*parent_ptr, red_flag_key()))
+ {
+ put(*parent_ptr, black_flag_key(), true);
+ return parent_ptr;
+ }
+ }
+
+ return node_ptr;
+ }
+ //->
+
+ namespace balancer {
+
+ typedef ::boost::tree_node::red_black_balancer red_black;
+ } // namespace balancer
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_BALANCER_RED_BLACK_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/base.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/base.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,407 @@
+// Copyright (C) 2011-2013 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/config.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/detail/base_pointee.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/move/move.hpp>
+#endif
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived>
+ struct tree_node_base
+ : public ::boost::detail::base_pointee<Derived>
+ {
+ typedef typename ::boost::detail::base_pointee<Derived>::pointer
+ pointer;
+ typedef typename ::boost::detail::base_pointee<Derived>::const_pointer
+ const_pointer;
+ typedef void
+ super_t;
+
+ protected:
+ ~tree_node_base();
+
+ //[reference__tree_node_base__clone_metadata_impl
+ void clone_metadata_impl(Derived const& copy);
+ //]
+
+ //[reference__tree_node_base__clone_metadata
+ void clone_metadata(Derived const& copy);
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#if defined BOOST_NO_RVALUE_REFERENCES
+ void move_metadata_impl(::boost::rv<Derived>& source);
+
+ void move_metadata(::boost::rv<Derived>& source);
+#else // !defined BOOST_NO_RVALUE_REFERENCES
+ //[reference__tree_node_base__move_metadata_impl
+ void move_metadata_impl(Derived&& source);
+ //]
+
+ //[reference__tree_node_base__move_metadata
+ void move_metadata(Derived&& source);
+ //]
+#endif // BOOST_NO_RVALUE_REFERENCES
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ //[reference__tree_node_base__on_post_emplacement_construct
+ void on_post_emplacement_construct();
+ //]
+
+ //[reference__tree_node_base__on_post_copy_or_move_impl
+ void on_post_copy_or_move_impl();
+ //]
+
+ //[reference__tree_node_base__on_post_copy_or_move
+ void on_post_copy_or_move();
+ //]
+
+ //[reference__tree_node_base__on_post_modify_value_impl
+ template <typename Key>
+ void on_post_modify_value_impl(Key const& key);
+ //]
+
+ //[reference__tree_node_base__on_post_modify_value
+ template <typename Key>
+ void on_post_modify_value(Key const& key);
+ //]
+
+ //[reference__tree_node_base__on_post_propagate_value_impl
+ template <typename Key>
+ void on_post_propagate_value_impl(Key const& key);
+ //]
+
+ //[reference__tree_node_base__on_post_propagate_value
+ template <typename Key>
+ void on_post_propagate_value(Key const& key);
+ //]
+
+ //[reference__tree_node_base__on_post_propagate_value_once_impl
+ template <typename Key>
+ void on_post_propagate_value_once_impl(Key const& key);
+ //]
+
+ //[reference__tree_node_base__on_post_propagate_value_once
+ template <typename Key>
+ void on_post_propagate_value_once(Key const& key);
+ //]
+
+ //[reference__tree_node_base__on_post_inserted_impl__true
+ template <typename Iterator>
+ void on_post_inserted_impl(Iterator position, ::boost::mpl::true_);
+ //]
+
+ //[reference__tree_node_base__on_post_inserted_impl__false
+ template <typename Iterator>
+ void on_post_inserted_impl(Iterator position, ::boost::mpl::false_);
+ //]
+
+ //[reference__tree_node_base__on_post_inserted
+ template <typename Iterator, typename BooleanIntegralConstant>
+ void
+ on_post_inserted(
+ Iterator position
+ , BooleanIntegralConstant invalidates_sibling_positions
+ );
+ //]
+
+ //[reference__tree_node_base__on_post_insert_impl__true
+ template <typename Iterator>
+ void
+ on_post_insert_impl(
+ Iterator itr
+ , Iterator itr_end
+ , ::boost::mpl::true_
+ );
+ //]
+
+ //[reference__tree_node_base__on_post_insert_impl__false
+ template <typename Iterator>
+ void
+ on_post_insert_impl(
+ Iterator itr
+ , Iterator itr_end
+ , ::boost::mpl::false_
+ );
+ //]
+
+ //[reference__tree_node_base__on_post_insert
+ template <typename Iterator, typename BooleanIntegralConstant>
+ void
+ on_post_insert(
+ Iterator itr
+ , Iterator itr_end
+ , BooleanIntegralConstant invalidates_children_positions
+ );
+ //]
+
+ //[reference__tree_node_base__on_post_erase_impl
+ void on_post_erase_impl();
+ //]
+
+ //[reference__tree_node_base__on_post_erase
+ void on_post_erase();
+ //]
+
+ //[reference__tree_node_base__on_post_clear_impl
+ void on_post_clear_impl();
+ //]
+
+ //[reference__tree_node_base__on_post_clear
+ void on_post_clear();
+ //]
+
+ //[reference__tree_node_base__on_post_rotate_left_impl
+ void on_post_rotate_left_impl();
+ //]
+
+ //[reference__tree_node_base__on_post_rotate_left
+ void on_post_rotate_left();
+ //]
+
+ //[reference__tree_node_base__on_post_rotate_right_impl
+ void on_post_rotate_right_impl();
+ //]
+
+ //[reference__tree_node_base__on_post_rotate_right
+ void on_post_rotate_right();
+ //]
+ };
+
+ template <typename Derived>
+ tree_node_base<Derived>::~tree_node_base()
+ {
+ }
+
+ template <typename Derived>
+ inline void
+ tree_node_base<Derived>::clone_metadata_impl(Derived const& copy)
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::clone_metadata(Derived const& copy)
+ {
+ this->get_derived()->clone_metadata_impl(copy);
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#if defined BOOST_NO_RVALUE_REFERENCES
+ template <typename Derived>
+ inline void
+ tree_node_base<Derived>::move_metadata_impl(
+ ::boost::rv<Derived>& source
+ )
+ {
+ }
+
+ template <typename Derived>
+ inline void
+ tree_node_base<Derived>::move_metadata(::boost::rv<Derived>& source)
+ {
+ this->get_derived()->move_metadata_impl(source);
+ }
+#else // !defined BOOST_NO_RVALUE_REFERENCES
+ template <typename Derived>
+ inline void tree_node_base<Derived>::move_metadata_impl(Derived&& source)
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::move_metadata(Derived&& source)
+ {
+ this->get_derived()->move_metadata_impl(
+ static_cast<Derived&&>(source)
+ );
+ }
+#endif // BOOST_NO_RVALUE_REFERENCES
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_emplacement_construct()
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_copy_or_move_impl()
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_copy_or_move()
+ {
+ this->get_derived()->on_post_copy_or_move_impl();
+ }
+
+ template <typename Derived>
+ template <typename Key>
+ inline void tree_node_base<Derived>::on_post_modify_value_impl(Key const&)
+ {
+ }
+
+ template <typename Derived>
+ template <typename Key>
+ inline void tree_node_base<Derived>::on_post_modify_value(Key const& key)
+ {
+ this->get_derived()->on_post_modify_value_impl(key);
+ }
+
+ template <typename Derived>
+ template <typename Key>
+ inline void
+ tree_node_base<Derived>::on_post_propagate_value_impl(Key const&)
+ {
+ }
+
+ template <typename Derived>
+ template <typename Key>
+ inline void
+ tree_node_base<Derived>::on_post_propagate_value(Key const& key)
+ {
+ this->get_derived()->on_post_propagate_value_impl(key);
+ }
+
+ template <typename Derived>
+ template <typename Key>
+ inline void
+ tree_node_base<Derived>::on_post_propagate_value_once_impl(Key const&)
+ {
+ }
+
+ template <typename Derived>
+ template <typename Key>
+ inline void
+ tree_node_base<Derived>::on_post_propagate_value_once(Key const& key)
+ {
+ this->get_derived()->on_post_propagate_value_once_impl(key);
+ }
+
+ template <typename Derived>
+ template <typename Iterator>
+ inline void
+ tree_node_base<Derived>::on_post_inserted_impl(
+ Iterator position
+ , ::boost::mpl::true_
+ )
+ {
+ }
+
+ template <typename Derived>
+ template <typename Iterator>
+ inline void
+ tree_node_base<Derived>::on_post_inserted_impl(
+ Iterator position
+ , ::boost::mpl::false_
+ )
+ {
+ }
+
+ template <typename Derived>
+ template <typename Iterator, typename BooleanIntegralConstant>
+ inline void
+ tree_node_base<Derived>::on_post_inserted(
+ Iterator position
+ , BooleanIntegralConstant invalidates_sibling_positions
+ )
+ {
+ this->get_derived()->on_post_inserted_impl(
+ position
+ , invalidates_sibling_positions
+ );
+ }
+
+ template <typename Derived>
+ template <typename Iterator>
+ inline void
+ tree_node_base<Derived>::on_post_insert_impl(
+ Iterator itr
+ , Iterator itr_end
+ , ::boost::mpl::true_
+ )
+ {
+ }
+
+ template <typename Derived>
+ template <typename Iterator>
+ inline void
+ tree_node_base<Derived>::on_post_insert_impl(
+ Iterator itr
+ , Iterator itr_end
+ , ::boost::mpl::false_
+ )
+ {
+ }
+
+ template <typename Derived>
+ template <typename Iterator, typename BooleanIntegralConstant>
+ inline void
+ tree_node_base<Derived>::on_post_insert(
+ Iterator itr
+ , Iterator itr_end
+ , BooleanIntegralConstant invalidates_children_positions
+ )
+ {
+ this->get_derived()->on_post_insert_impl(
+ itr
+ , itr_end
+ , invalidates_children_positions
+ );
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_erase_impl()
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_erase()
+ {
+ this->get_derived()->on_post_erase_impl();
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_clear_impl()
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_clear()
+ {
+ this->get_derived()->on_post_clear_impl();
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_rotate_left_impl()
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_rotate_left()
+ {
+ this->get_derived()->on_post_rotate_left_impl();
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_rotate_right_impl()
+ {
+ }
+
+ template <typename Derived>
+ inline void tree_node_base<Derived>::on_post_rotate_right()
+ {
+ this->get_derived()->on_post_rotate_right_impl();
+ }
+}} // 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 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,2979 @@
+// Copyright (C) 2011-2013 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/tr1/type_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/container/scoped_allocator_fwd.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/binary_node_fwd.hpp>
+#include <boost/tree_node/traits/binary_node_fwd.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/get_keys.hpp>
+#include <boost/tree_node/iterator/depth_first_descendant.hpp>
+#include <boost/utility/value_init.hpp>
+#include <boost/assert.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/move/move.hpp>
+#include <boost/container/allocator_traits.hpp>
+#endif
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/_detail/config_begin.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/type_traits/is_pod.hpp>
+
+namespace boost {
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ struct is_POD<
+ ::boost::tree_node::binary_node_base<Derived,T,Size,Allocator>
+ > : ::boost::false_type
+ {
+ };
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ struct is_pod<
+ ::boost::tree_node::binary_node_base<Derived,T,Size,Allocator>
+ > : ::boost::false_type
+ {
+ };
+} // namespace boost
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/transform_view.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/iterator/key_of.hpp>
+#include <boost/fusion/support/is_sequence.hpp>
+#include <boost/fusion/support/category_of.hpp>
+
+namespace boost { namespace tree_node { namespace result_of {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename FusionKey
+ >
+ struct has_key_impl<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ > : ::boost::mpl::eval_if<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::has_key<T,FusionKey>
+ , ::std::tr1::is_same<FusionKey,data_key>
+ >::type
+ {
+ };
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ struct get_keys_impl<binary_node_base<Derived,T,Size,Allocator> >
+ : ::boost::mpl::eval_if<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::transform_view<
+ T
+ , ::boost::fusion::result_of::key_of< ::boost::mpl::_>
+ >
+ , ::boost::mpl::vector1<data_key>
+ >
+ {
+ };
+}}} // namespace boost::tree_node::result_of
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+namespace boost { namespace tree_node { namespace _detail {
+
+ template <typename Node, typename IsReverse>
+ class binary_child_iterator
+ {
+#if !defined BOOST_NO_SFINAE
+ struct enabler
+ {
+ };
+#endif
+
+ public:
+ typedef ::std::random_access_iterator_tag iterator_category;
+ typedef Node value_type;
+ typedef ::std::ptrdiff_t difference_type;
+ typedef value_type* pointer;
+ typedef value_type& reference;
+
+ private:
+ class proxy
+ {
+ binary_child_iterator _itr;
+
+ public:
+ proxy(pointer const& p, difference_type n);
+
+ operator binary_child_iterator&();
+ };
+
+ public: // Should be private, but conversion ctor won't work.
+ pointer _current;
+ pointer _parent;
+
+ public:
+ binary_child_iterator();
+
+ explicit binary_child_iterator(pointer const& p);
+
+ binary_child_iterator(pointer const& p, bool p_is_child);
+
+ template <typename N, typename I>
+ binary_child_iterator(
+ binary_child_iterator<N,I> const& other
+#if !defined BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ ::std::tr1::is_convertible<N,Node>
+ , ::boost::mpl::equal_to<I,IsReverse>
+ , ::boost::mpl::false_
+ >::type
+ , enabler
+ >::type = enabler()
+#endif
+ );
+
+ reference operator*() const;
+
+ pointer operator->() const;
+
+ proxy operator[](difference_type n) const;
+
+ binary_child_iterator& operator++();
+
+ binary_child_iterator operator++(int);
+
+ binary_child_iterator& operator--();
+
+ binary_child_iterator operator--(int);
+
+ binary_child_iterator& operator+=(difference_type n);
+
+ binary_child_iterator operator+(difference_type n) const;
+
+ binary_child_iterator& operator-=(difference_type n);
+
+ binary_child_iterator operator-(difference_type n) const;
+
+ private:
+ void _iterate(pointer const& sibling);
+
+ void _advance(difference_type n);
+
+ template <typename N1, typename I1, typename N2, typename I2>
+ friend
+#if defined BOOST_NO_SFINAE
+ bool
+#else
+ typename ::boost::enable_if< ::boost::mpl::equal_to<I1,I2>,bool>::type
+#endif
+ operator==(
+ binary_child_iterator<N1,I1> const& lhs
+ , binary_child_iterator<N2,I2> const& rhs
+ );
+
+ template <typename N1, typename I1, typename N2, typename I2>
+ friend
+#if defined BOOST_NO_SFINAE
+ bool
+#else
+ typename ::boost::enable_if< ::boost::mpl::equal_to<I1,I2>,bool>::type
+#endif
+ operator<(
+ binary_child_iterator<N1,I1> const& lhs
+ , binary_child_iterator<N2,I2> const& rhs
+ );
+
+ template <typename N1, typename I1, typename N2, typename I2>
+ friend ::std::ptrdiff_t
+ operator-(
+ binary_child_iterator<N1,I1> const& lhs
+ , binary_child_iterator<N2,I2> const& rhs
+ );
+ };
+
+ template <typename Node, typename IsReverse>
+ binary_child_iterator<Node,IsReverse>::proxy::proxy(
+ pointer const& p
+ , difference_type n
+ ) : _itr(p, true)
+ {
+ this->_itr._advance(n);
+ }
+
+ template <typename Node, typename IsReverse>
+ inline binary_child_iterator<
+ Node
+ , IsReverse
+ >::proxy::operator binary_child_iterator&()
+ {
+ return this->_itr;
+ }
+
+ template <typename Node, typename IsReverse>
+ binary_child_iterator<Node,IsReverse>::binary_child_iterator()
+ : _current(::boost::initialized_value)
+ , _parent(::boost::initialized_value)
+ {
+ }
+
+ template <typename Node, typename IsReverse>
+ binary_child_iterator<Node,IsReverse>::binary_child_iterator(
+ pointer const& p
+ , bool p_is_child
+ ) : _current(
+ p_is_child ? p : IsReverse::value ? (
+ p->get_right_child_ptr()
+ ? p->get_right_child_ptr()
+ : p->get_left_child_ptr()
+ ) : (
+ p->get_left_child_ptr()
+ ? p->get_left_child_ptr()
+ : p->get_right_child_ptr()
+ )
+ )
+ , _parent(p_is_child ? p->get_parent_ptr() : p)
+ {
+ }
+
+ template <typename Node, typename IsReverse>
+ binary_child_iterator<Node,IsReverse>::binary_child_iterator(
+ pointer const& p
+ ) : _current(::boost::initialized_value), _parent(p)
+ {
+ }
+
+ template <typename Node, typename IsReverse>
+ template <typename N, typename I>
+ binary_child_iterator<Node,IsReverse>::binary_child_iterator(
+ binary_child_iterator<N,I> const& other
+#if !defined BOOST_NO_SFINAE
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ ::std::tr1::is_convertible<N,Node>
+ , ::boost::mpl::equal_to<I,IsReverse>
+ , ::boost::mpl::false_
+ >::type
+ , enabler
+ >::type
+#endif
+ ) : _current(other._current), _parent(other._parent)
+ {
+ }
+
+ template <typename Node, typename IsReverse>
+ inline typename binary_child_iterator<Node,IsReverse>::reference
+ binary_child_iterator<Node,IsReverse>::operator*() const
+ {
+ return *this->_current;
+ }
+
+ template <typename Node, typename IsReverse>
+ inline typename binary_child_iterator<Node,IsReverse>::pointer
+ binary_child_iterator<Node,IsReverse>::operator->() const
+ {
+ return this->_current;
+ }
+
+ template <typename Node, typename IsReverse>
+ inline typename binary_child_iterator<Node,IsReverse>::proxy
+ binary_child_iterator<Node,IsReverse>::operator[](
+ difference_type n
+ ) const
+ {
+ return proxy(this->_current, n);
+ }
+
+ template <typename Node, typename IsReverse>
+ inline binary_child_iterator<Node,IsReverse>&
+ binary_child_iterator<Node,IsReverse>::operator++()
+ {
+ this->_iterate(
+ IsReverse::value
+ ? this->_parent->get_left_child_ptr()
+ : this->_parent->get_right_child_ptr()
+ );
+ return *this;
+ }
+
+ template <typename Node, typename IsReverse>
+ binary_child_iterator<Node,IsReverse>
+ binary_child_iterator<Node,IsReverse>::operator++(int)
+ {
+ binary_child_iterator itr(*this);
+ ++(*this);
+ return itr;
+ }
+
+ template <typename Node, typename IsReverse>
+ inline binary_child_iterator<Node,IsReverse>&
+ binary_child_iterator<Node,IsReverse>::operator--()
+ {
+ if (this->_current)
+ {
+ this->_iterate(
+ IsReverse::value
+ ? this->_parent->get_right_child_ptr()
+ : this->_parent->get_left_child_ptr()
+ );
+ }
+ else if (IsReverse::value)
+ {
+ this->_current = this->_parent->get_left_child_ptr();
+
+ if (!this->_current)
+ {
+ this->_current = this->_parent->get_right_child_ptr();
+ }
+ }
+ else
+ {
+ this->_current = this->_parent->get_right_child_ptr();
+
+ if (!this->_current)
+ {
+ this->_current = this->_parent->get_left_child_ptr();
+ }
+ }
+
+ BOOST_ASSERT_MSG(this->_current, "Result not dereferenceable.");
+ return *this;
+ }
+
+ template <typename Node, typename IsReverse>
+ binary_child_iterator<Node,IsReverse>
+ binary_child_iterator<Node,IsReverse>::operator--(int)
+ {
+ binary_child_iterator itr(*this);
+ --(*this);
+ return itr;
+ }
+
+ template <typename Node, typename IsReverse>
+ inline binary_child_iterator<Node,IsReverse>&
+ binary_child_iterator<Node,IsReverse>::operator+=(difference_type n)
+ {
+ this->_advance(n);
+ return *this;
+ }
+
+ template <typename Node, typename IsReverse>
+ binary_child_iterator<Node,IsReverse>
+ binary_child_iterator<Node,IsReverse>::operator+(
+ difference_type n
+ ) const
+ {
+ binary_child_iterator itr(*this);
+ itr += n;
+ return itr;
+ }
+
+ template <typename Node, typename IsReverse>
+ inline binary_child_iterator<Node,IsReverse>&
+ binary_child_iterator<Node,IsReverse>::operator-=(difference_type n)
+ {
+ this->_advance(-n);
+ return *this;
+ }
+
+ template <typename Node, typename IsReverse>
+ binary_child_iterator<Node,IsReverse>
+ binary_child_iterator<Node,IsReverse>::operator-(
+ difference_type n
+ ) const
+ {
+ binary_child_iterator itr(*this);
+ itr -= n;
+ return itr;
+ }
+
+ template <typename Node, typename IsReverse>
+ inline void
+ binary_child_iterator<Node,IsReverse>::_iterate(pointer const& sibling)
+ {
+ this->_current = (
+ this->_current == sibling
+ ) ? ::boost::initialized_value : sibling;
+ }
+
+ template <typename Node, typename IsReverse>
+ inline void
+ binary_child_iterator<Node,IsReverse>::_advance(difference_type n)
+ {
+ switch (n)
+ {
+ case -2:
+ {
+ BOOST_ASSERT_MSG(
+ (
+ IsReverse::value
+ ? (
+ (
+ this->_current == (
+ this->_parent->get_left_child_ptr()
+ )
+ ) && this->_parent->get_right_child_ptr()
+ )
+ : (
+ (
+ this->_current == (
+ this->_parent->get_right_child_ptr()
+ )
+ ) && this->_parent->get_left_child_ptr()
+ )
+ )
+ , "n must be greater than -2."
+ );
+
+ this->_current = ::boost::initialized_value;
+ break;
+ }
+
+ case -1:
+ {
+ --(*this);
+ break;
+ }
+
+ case 0:
+ {
+ break;
+ }
+
+ case 1:
+ {
+ ++(*this);
+ break;
+ }
+
+ case 2:
+ {
+ BOOST_ASSERT_MSG(
+ (
+ IsReverse::value
+ ? (
+ (
+ this->_current == (
+ this->_parent->get_right_child_ptr()
+ )
+ ) && this->_parent->get_left_child_ptr()
+ )
+ : (
+ (
+ this->_current == (
+ this->_parent->get_left_child_ptr()
+ )
+ ) && this->_parent->get_right_child_ptr()
+ )
+ )
+ , "n must be less than 2."
+ );
+
+ this->_current = ::boost::initialized_value;
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(false, "|n| must be less than 3.");
+ }
+ }
+ }
+
+ template <typename Node1, typename IsR1, typename Node2, typename IsR2>
+ inline
+#if defined BOOST_NO_SFINAE
+ bool
+#else
+ typename ::boost::enable_if< ::boost::mpl::equal_to<IsR1,IsR2>,bool>::type
+#endif
+ operator==(
+ binary_child_iterator<Node1,IsR1> const& lhs
+ , binary_child_iterator<Node2,IsR2> const& rhs
+ )
+ {
+ return lhs._current == rhs._current;
+ }
+
+ template <typename Node1, typename IsR1, typename Node2, typename IsR2>
+ inline
+#if defined BOOST_NO_SFINAE
+ bool
+#else
+ typename ::boost::enable_if< ::boost::mpl::equal_to<IsR1,IsR2>,bool>::type
+#endif
+ operator!=(
+ binary_child_iterator<Node1,IsR1> const& lhs
+ , binary_child_iterator<Node2,IsR2> const& rhs
+ )
+ {
+ return !(lhs == rhs);
+ }
+
+ template <typename Node1, typename IsR1, typename Node2, typename IsR2>
+ inline
+#if defined BOOST_NO_SFINAE
+ bool
+#else
+ typename ::boost::enable_if< ::boost::mpl::equal_to<IsR1,IsR2>,bool>::type
+#endif
+ operator<(
+ binary_child_iterator<Node1,IsR1> const& lhs
+ , binary_child_iterator<Node2,IsR2> const& rhs
+ )
+ {
+ BOOST_ASSERT_MSG(lhs._parent, "lhs is unreachable.");
+ BOOST_ASSERT_MSG(rhs._parent, "rhs is unreachable.");
+ BOOST_ASSERT_MSG(
+ rhs._parent == lhs._parent
+ , "Neither iterator is reachable from one other."
+ );
+
+ if (lhs._current)
+ {
+ if (rhs._current)
+ {
+ return rhs._current == lhs._parent->get_right_child_ptr();
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ template <typename Node1, typename IsR1, typename Node2, typename IsR2>
+ inline
+#if defined BOOST_NO_SFINAE
+ bool
+#else
+ typename ::boost::enable_if< ::boost::mpl::equal_to<IsR1,IsR2>,bool>::type
+#endif
+ operator>(
+ binary_child_iterator<Node1,IsR1> const& lhs
+ , binary_child_iterator<Node2,IsR2> const& rhs
+ )
+ {
+ return rhs < lhs;
+ }
+
+ template <typename Node1, typename IsR1, typename Node2, typename IsR2>
+ inline
+#if defined BOOST_NO_SFINAE
+ bool
+#else
+ typename ::boost::enable_if< ::boost::mpl::equal_to<IsR1,IsR2>,bool>::type
+#endif
+ operator<=(
+ binary_child_iterator<Node1,IsR1> const& lhs
+ , binary_child_iterator<Node2,IsR2> const& rhs
+ )
+ {
+ return !(rhs < lhs);
+ }
+
+ template <typename Node1, typename IsR1, typename Node2, typename IsR2>
+ inline
+#if defined BOOST_NO_SFINAE
+ bool
+#else
+ typename ::boost::enable_if< ::boost::mpl::equal_to<IsR1,IsR2>,bool>::type
+#endif
+ operator>=(
+ binary_child_iterator<Node1,IsR1> const& lhs
+ , binary_child_iterator<Node2,IsR2> const& rhs
+ )
+ {
+ return !(lhs < rhs);
+ }
+
+ template <typename Node, typename IsReverse>
+ inline binary_child_iterator<Node,IsReverse>
+ operator+(
+ typename binary_child_iterator<Node,IsReverse>::difference_type n
+ , binary_child_iterator<Node,IsReverse> const& itr
+ )
+ {
+ return itr + n;
+ }
+
+ template <typename Node1, typename IsR1, typename Node2, typename IsR2>
+ inline ::std::ptrdiff_t
+ operator-(
+ binary_child_iterator<Node1,IsR1> const& lhs
+ , binary_child_iterator<Node2,IsR2> const& rhs
+ )
+ {
+ BOOST_ASSERT_MSG(lhs._parent, "lhs is unreachable.");
+ BOOST_ASSERT_MSG(rhs._parent, "rhs is unreachable.");
+ BOOST_ASSERT_MSG(
+ rhs._parent == lhs._parent
+ , "Neither iterator is reachable from one other."
+ );
+
+ if (lhs._current == rhs._current)
+ {
+ return 0;
+ }
+ else if (lhs._current)
+ {
+ if (rhs._current)
+ {
+ return (
+ rhs._current == lhs._parent->get_left_child_ptr()
+ ) ? 1 : -1;
+ }
+ else
+ {
+ return (
+ lhs._parent->get_left_child_ptr() && (
+ lhs._parent->get_right_child_ptr()
+ )
+ ) ? 2 : 1;
+ }
+ }
+ else
+ {
+ return (
+ rhs._parent->get_left_child_ptr() && (
+ rhs._parent->get_right_child_ptr()
+ )
+ ) ? -2 : -1;
+ }
+ }
+}}} // namespace boost::tree_node::_detail
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ class binary_node_base
+ : public
+ //[reference__binary_node_base__bases
+ tree_node_base<Derived>
+ //]
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , public data_key
+#endif
+ , private ::boost::noncopyable
+ {
+ template <typename D>
+ friend struct binary_node_traits;
+
+ typedef binary_node_base<Derived,T,Size,Allocator> self;
+
+ public:
+ //[reference__binary_node_base__super_t
+ typedef tree_node_base<Derived> super_t;
+ //]
+
+ //[reference__binary_node_base__traits
+ struct traits
+ {
+ typedef T
+ data_type;
+ typedef typename ::std::tr1::remove_reference<Allocator>::type
+ allocator;
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_reference<Allocator>
+ , Allocator
+ , typename ::std::tr1::add_reference<
+ typename ::std::tr1::add_const<Allocator>::type
+ >::type
+ >::type
+ allocator_reference;
+ };
+ //]
+
+ //[reference__binary_node_base__pointer
+ typedef typename super_t::pointer pointer;
+ //]
+
+ //[reference__binary_node_base__const_pointer
+ typedef typename super_t::const_pointer const_pointer;
+ //]
+
+ typedef _detail::binary_child_iterator<Derived,::boost::mpl::false_>
+ iterator;
+ typedef _detail::binary_child_iterator<
+ Derived const
+ , ::boost::mpl::false_
+ >
+ const_iterator;
+ typedef _detail::binary_child_iterator<Derived,::boost::mpl::true_>
+ reverse_iterator;
+ typedef _detail::binary_child_iterator<
+ Derived const
+ , ::boost::mpl::true_
+ >
+ const_reverse_iterator;
+
+ //[reference__binary_node_base__size_type
+ typedef Size size_type;
+ //]
+
+ private:
+ typename traits::data_type _data;
+ Allocator _allocator;
+ pointer _left_child;
+ pointer _right_child;
+ pointer _parent;
+
+ protected:
+ //[reference__binary_node_base__derived_copy_ctor
+ binary_node_base(Derived const& copy);
+ //]
+
+ //[reference__binary_node_base__derived_copy_ctor_w_allocator
+ binary_node_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ );
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binary_node_base(BOOST_RV_REF(Derived) source);
+
+ binary_node_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ );
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__binary_node_base__emplacement_ctor
+ template <typename ...Args>
+ explicit binary_node_base(Args&& ...args);
+ //]
+
+ //[reference__binary_node_base__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit binary_node_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_FWD_DECL
+ , binary_node_base
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_FWD_DECL
+ , binary_node_base
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ ~binary_node_base();
+
+ //[reference__binary_node_base__clone_descendants
+ void clone_descendants(Derived const& copy);
+ //]
+
+ //[reference__binary_node_base__copy_assign
+ void copy_assign(Derived const& copy);
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ void move_descendants(BOOST_RV_REF(Derived) source);
+
+ void move_assign(BOOST_RV_REF(Derived) source);
+#endif
+
+ //[reference__binary_node_base__on_post_assign
+ void on_post_assign();
+ //]
+
+ public:
+ //[reference__binary_node_base__key_value_operator__const
+ typename traits::data_type const& operator[](data_key const&) const;
+
+//<-
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+//->
+ template <typename FusionKey>
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ operator[](FusionKey const&) const;
+//<-
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+//->
+ //]
+
+ //[reference__binary_node_base__key_value_operator
+ typename traits::data_type& operator[](data_key const&);
+
+//<-
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+//->
+ template <typename FusionKey>
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ operator[](FusionKey const&);
+//<-
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+//->
+ //]
+
+ //[reference__binary_node_base__get_parent_ptr__const
+ const_pointer get_parent_ptr() const;
+ //]
+
+ //[reference__binary_node_base__get_parent_ptr
+ pointer get_parent_ptr();
+ //]
+
+ //[reference__binary_node_base__get_left_child_ptr__const
+ const_pointer get_left_child_ptr() const;
+ //]
+
+ //[reference__binary_node_base__get_left_child_ptr
+ pointer get_left_child_ptr();
+ //]
+
+ //[reference__binary_node_base__get_right_child_ptr__const
+ const_pointer get_right_child_ptr() const;
+ //]
+
+ //[reference__binary_node_base__get_right_child_ptr
+ pointer get_right_child_ptr();
+ //]
+
+ //[reference__binary_node_base__cbegin
+ const_iterator cbegin() const;
+ const_iterator begin() const;
+ //]
+
+ //[reference__binary_node_base__begin
+ iterator begin();
+ //]
+
+ //[reference__binary_node_base__cend
+ const_iterator cend() const;
+ const_iterator end() const;
+ //]
+
+ //[reference__binary_node_base__end
+ iterator end();
+ //]
+
+ //[reference__binary_node_base__crbegin
+ const_reverse_iterator crbegin() const;
+ const_reverse_iterator rbegin() const;
+ //]
+
+ //[reference__binary_node_base__rbegin
+ reverse_iterator rbegin();
+ //]
+
+ //[reference__binary_node_base__crend
+ const_reverse_iterator crend() const;
+ const_reverse_iterator rend() const;
+ //]
+
+ //[reference__binary_node_base__rend
+ reverse_iterator rend();
+ //]
+
+ //[reference__binary_node_base__size
+ size_type size() const;
+ //]
+
+ //[reference__binary_node_base__empty
+ bool empty() const;
+ //]
+
+ //[reference__binary_node_base__clear
+ void clear();
+ //]
+
+ //[reference__binary_node_base__insert_left
+ iterator insert_left(Derived const& child);
+ //]
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__binary_node_base__emplace_left
+ template <typename ...Args>
+ iterator emplace_left(Args&& ...args);
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_BINARY_NODE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ iterator \
+ emplace_left( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_BINARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_BINARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ //[reference__binary_node_base__insert_right
+ iterator insert_right(Derived const& child);
+ //]
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__binary_node_base__emplace_right
+ template <typename ...Args>
+ iterator emplace_right(Args&& ...args);
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_BINARY_NODE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ iterator \
+ emplace_right( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_BINARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_BINARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ //[reference__binary_node_base__rotate_left
+ pointer rotate_left();
+ //]
+
+ //[reference__binary_node_base__rotate_right
+ pointer rotate_right();
+ //]
+
+ //[reference__binary_node_base__erase_left
+ bool erase_left();
+ //]
+
+ //[reference__binary_node_base__erase_right
+ bool erase_right();
+ //]
+
+ private:
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ static typename traits::allocator_reference
+ _construct_from(
+ typename traits::allocator_reference allocator
+ , ::std::tr1::true_type
+ );
+
+ static Allocator
+ _construct_from(
+ typename traits::allocator_reference allocator
+ , ::std::tr1::false_type
+ );
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ static bool
+ _clone_data(
+ pointer& p
+ , const_pointer const& c_p
+ , Allocator& allocator
+ );
+
+ static bool
+ _move(pointer& dest_p, pointer& src_p, Allocator& allocator);
+
+ static void _destroy(pointer const& p, Allocator& allocator);
+
+ static bool _erase(pointer& p, Allocator& allocator);
+
+ static iterator _on_post_inserted(pointer const& child);
+
+ void _clone_descendants(Derived const& copy);
+
+ void _move_descendants(Derived& source);
+
+ void _on_post_modify_value(data_key const& key);
+
+ void _set_parent_ptr(pointer p);
+
+ void _set_left_child_ptr(pointer p);
+
+ void _set_right_child_ptr(pointer p);
+
+ template <typename D, typename T0, typename S, typename A, typename V>
+ friend void
+ put(binary_node_base<D,T0,S,A>&, data_key const&, V const&);
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename FusionKey>
+ void _on_post_modify_value(FusionKey const& key);
+
+ template <
+ typename D
+ , typename T0
+ , typename S
+ , typename A
+ , typename FK
+ , typename V
+ >
+ friend void
+ put(
+ binary_node_base<D,T0,S,A>& node
+ , FK const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T0>::type
+ , ::boost::fusion::traits::is_associative<T0>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<binary_node_base<D,T0,S,A>,FK>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type
+ );
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+ };
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ binary_node_base<Derived,T,Size,Allocator>::binary_node_base(
+ Derived const& copy
+ ) : _data(copy._data)
+ , _allocator(
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ copy._allocator
+#else
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::select_on_container_copy_construction(copy._allocator)
+#endif
+ )
+ , _left_child(::boost::initialized_value)
+ , _right_child(::boost::initialized_value)
+ , _parent(::boost::initialized_value)
+ {
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ binary_node_base<Derived,T,Size,Allocator>::binary_node_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ ) : _data(copy._data)
+ , _allocator(
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ allocator
+#else
+ this->_construct_from(
+ allocator
+ , typename ::std::tr1::is_reference<Allocator>::type()
+ )
+#endif
+ )
+ , _left_child(::boost::initialized_value)
+ , _right_child(::boost::initialized_value)
+ , _parent(::boost::initialized_value)
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ binary_node_base<Derived,T,Size,Allocator>::binary_node_base(
+ BOOST_RV_REF(Derived) source
+ ) : _data(::boost::move(source._data))
+ , _allocator(::boost::move(source._allocator))
+ , _left_child(source._left_child)
+ , _right_child(source._right_child)
+ , _parent(::boost::initialized_value)
+ {
+ source._left_child = source._right_child = ::boost::initialized_value;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ binary_node_base<Derived,T,Size,Allocator>::binary_node_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ ) : _data(::boost::move(source._data))
+ , _allocator(
+ this->_construct_from(
+ allocator
+ , typename ::std::tr1::is_reference<Allocator>::type()
+ )
+ )
+ , _left_child(source._left_child)
+ , _right_child(source._right_child)
+ , _parent(::boost::initialized_value)
+ {
+ source._left_child = source._right_child = ::boost::initialized_value;
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ template <typename ...Args>
+ binary_node_base<Derived,T,Size,Allocator>::binary_node_base(
+ Args&& ...args
+ ) : _data(::boost::forward<Args>(args)...)
+ , _allocator()
+ , _left_child(::boost::initialized_value)
+ , _right_child(::boost::initialized_value)
+ , _parent(::boost::initialized_value)
+ {
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ template <typename ...Args>
+ binary_node_base<Derived,T,Size,Allocator>::binary_node_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : _data(::boost::forward<Args>(args)...)
+ , _allocator(
+ this->_construct_from(
+ allocator
+ , typename ::std::tr1::is_reference<Allocator>::type()
+ )
+ )
+ , _left_child(::boost::initialized_value)
+ , _right_child(::boost::initialized_value)
+ , _parent(::boost::initialized_value)
+ {
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_BINARY_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename T \
+ , typename Size \
+ , typename Allocator \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ binary_node_base<Derived,T,Size,Allocator>::binary_node_base( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) : _data( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ , _allocator() \
+ , _left_child(::boost::initialized_value) \
+ , _right_child(::boost::initialized_value) \
+ , _parent(::boost::initialized_value) \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_BINARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_BINARY_NODE_MACRO
+
+#define BOOST_TREE_NODE_BINARY_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename T \
+ , typename Size \
+ , typename Allocator \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ binary_node_base<Derived,T,Size,Allocator>::binary_node_base( \
+ ::boost::container::allocator_arg_t \
+ , typename traits::allocator_reference allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) : _data( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ , _allocator( \
+ this->_construct_from( \
+ allocator \
+ , typename ::std::tr1::is_reference<Allocator>::type() \
+ ) \
+ ) \
+ , _left_child(::boost::initialized_value) \
+ , _right_child(::boost::initialized_value) \
+ , _parent(::boost::initialized_value) \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_BINARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_BINARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ binary_node_base<Derived,T,Size,Allocator>::~binary_node_base()
+ {
+ if (this->_left_child)
+ {
+ self::_destroy(this->_left_child, this->_allocator);
+ }
+
+ if (this->_right_child)
+ {
+ self::_destroy(this->_right_child, this->_allocator);
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::clone_descendants(
+ Derived const& copy
+ )
+ {
+ this->_clone_descendants(copy);
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ void
+ binary_node_base<Derived,T,Size,Allocator>::copy_assign(
+ Derived const& copy
+ )
+ {
+ Derived twin(copy._data);
+
+ twin._clone_descendants(copy);
+ this->_data = twin._data;
+ this->_move_descendants(twin);
+ this->clone_metadata(copy);
+ }
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::move_descendants(
+ BOOST_RV_REF(Derived) source
+ )
+ {
+ if (this->_left_child)
+ {
+ this->_left_child->_parent = this->get_derived();
+ }
+
+ if (this->_right_child)
+ {
+ this->_right_child->_parent = this->get_derived();
+ }
+
+ source.on_post_clear();
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::move_assign(
+ BOOST_RV_REF(Derived) source
+ )
+ {
+ this->_data = ::boost::move(source._data);
+ this->_move_descendants(static_cast<Derived&>(source));
+#if defined BOOST_NO_RVALUE_REFERENCES
+ this->move_metadata(source);
+#else
+ this->move_metadata(static_cast<Derived&&>(source));
+#endif
+ source.on_post_clear();
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::on_post_assign()
+ {
+ if (this->_parent)
+ {
+ this->_parent->on_post_propagate_value(data_key());
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::traits::data_type const&
+ binary_node_base<Derived,T,Size,Allocator>::operator[](
+ data_key const&
+ ) const
+ {
+ return this->_data;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::traits::data_type&
+ binary_node_base<Derived,T,Size,Allocator>::operator[](data_key const&)
+ {
+ return this->_data;
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ template <typename FusionKey>
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ binary_node_base<Derived,T,Size,Allocator>::operator[](
+ FusionKey const&
+ ) const
+ {
+ return ::boost::fusion::at_key<FusionKey>(this->_data);
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ template <typename FusionKey>
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ binary_node_base<Derived,T,Size,Allocator>::operator[](
+ FusionKey const&
+ )
+ {
+ return ::boost::fusion::at_key<FusionKey>(this->_data);
+ }
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::const_pointer
+ binary_node_base<Derived,T,Size,Allocator>::get_parent_ptr() const
+ {
+ return this->_parent;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::pointer
+ binary_node_base<Derived,T,Size,Allocator>::get_parent_ptr()
+ {
+ return this->_parent;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ typename binary_node_base<Derived,T,Size,Allocator>::iterator
+ binary_node_base<Derived,T,Size,Allocator>::insert_left(
+ Derived const& child
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ pointer p(this->_allocator.allocate(1));
+ this->_allocator.construct(p, child._data);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ pointer p(
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::allocate(this->_allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::construct(this->_allocator, p, child._data);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ p->_clone_descendants(child);
+ p->clone_metadata(child);
+
+ pointer c = p->_left_child;
+
+ if (c)
+ {
+ while (c->_left_child)
+ {
+ c = c->_left_child;
+ }
+
+ this->_left_child->_parent = c;
+ self::_on_post_inserted(c->_left_child = this->_left_child);
+ this->_left_child = ::boost::initialized_value;
+ this->on_post_erase();
+ }
+
+ p->_parent = this->get_derived();
+ return self::_on_post_inserted(this->_left_child = p);
+ }
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ template <typename ...Args>
+ typename binary_node_base<Derived,T,Size,Allocator>::iterator
+ binary_node_base<Derived,T,Size,Allocator>::emplace_left(
+ Args&& ...args
+ )
+ {
+ if (this->_left_child)
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ pointer p(this->_allocator.allocate(1));
+ this->_allocator.construct(p, ::boost::forward<Args>(args)...);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ pointer p(
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::allocate(this->_allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::construct(this->_allocator, p, ::boost::forward<Args>(args)...);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ this->_left_child->_parent = p;
+ self::_on_post_inserted(p->_left_child = this->_left_child);
+ this->_left_child = ::boost::initialized_value;
+ this->on_post_erase();
+ p->_parent = this->get_derived();
+ return self::_on_post_inserted(this->_left_child = p);
+ }
+ else
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ this->_allocator.construct(
+ this->_left_child = this->_allocator.allocate(1)
+ , ::boost::forward<Args>(args)...
+ );
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::construct(
+ this->_allocator
+ , this->_left_child = ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::allocate(this->_allocator, 1)
+ , ::boost::forward<Args>(args)...
+ );
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ this->_left_child->_parent = this->get_derived();
+ return self::_on_post_inserted(this->_left_child);
+ }
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_BINARY_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename T \
+ , typename Size \
+ , typename Allocator \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binary_node_base<Derived,T,Size,Allocator>::iterator \
+ binary_node_base<Derived,T,Size,Allocator>::emplace_left( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (this->_left_child) \
+ { \
+ pointer p(this->_allocator.allocate(1)); \
+ this->_allocator.construct( \
+ p \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ this->_left_child->_parent = p; \
+ self::_on_post_inserted(p->_left_child = this->_left_child); \
+ this->_left_child = ::boost::initialized_value; \
+ this->on_post_erase(); \
+ p->_parent = this->get_derived(); \
+ return self::_on_post_inserted(this->_left_child = p); \
+ } \
+ else \
+ { \
+ this->_allocator.construct( \
+ this->_left_child = this->_allocator.allocate(1) \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ this->_left_child->_parent = this->get_derived(); \
+ return self::_on_post_inserted(this->_left_child); \
+ } \
+ } \
+//!
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_BINARY_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename T \
+ , typename Size \
+ , typename Allocator \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binary_node_base<Derived,T,Size,Allocator>::iterator \
+ binary_node_base<Derived,T,Size,Allocator>::emplace_left( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (this->_left_child) \
+ { \
+ pointer p( \
+ ::boost::container::allocator_traits< \
+ typename traits::allocator \
+ >::allocate(this->_allocator, 1) \
+ ); \
+ ::boost::container::allocator_traits< \
+ typename traits::allocator \
+ >::construct( \
+ this->_allocator \
+ , p \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ this->_left_child->_parent = p; \
+ self::_on_post_inserted(p->_left_child = this->_left_child); \
+ this->_left_child = ::boost::initialized_value; \
+ this->on_post_erase(); \
+ p->_parent = this->get_derived(); \
+ return self::_on_post_inserted(this->_left_child = p); \
+ } \
+ else \
+ { \
+ ::boost::container::allocator_traits< \
+ typename traits::allocator \
+ >::construct( \
+ this->_allocator \
+ , this->_left_child = ::boost::container::allocator_traits< \
+ typename traits::allocator \
+ >::allocate(this->_allocator, 1) \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ this->_left_child->_parent = this->get_derived(); \
+ return self::_on_post_inserted(this->_left_child); \
+ } \
+ } \
+//!
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_BINARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_BINARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ typename binary_node_base<Derived,T,Size,Allocator>::iterator
+ binary_node_base<Derived,T,Size,Allocator>::insert_right(
+ Derived const& child
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ pointer p(this->_allocator.allocate(1));
+ this->_allocator.construct(p, child._data);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ pointer p(
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::allocate(this->_allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::construct(this->_allocator, p, child._data);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ p->_clone_descendants(child);
+ p->clone_metadata(child);
+
+ pointer c = p->_right_child;
+
+ if (c)
+ {
+ while (c->_right_child)
+ {
+ c = c->_right_child;
+ }
+
+ this->_right_child->_parent = c;
+ self::_on_post_inserted(c->_right_child = this->_right_child);
+ this->_right_child = ::boost::initialized_value;
+ this->on_post_erase();
+ }
+
+ p->_parent = this->get_derived();
+ return self::_on_post_inserted(this->_right_child = p);
+ }
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ template <typename ...Args>
+ typename binary_node_base<Derived,T,Size,Allocator>::iterator
+ binary_node_base<Derived,T,Size,Allocator>::emplace_right(
+ Args&& ...args
+ )
+ {
+ if (this->_right_child)
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ pointer p(this->_allocator.allocate(1));
+ this->_allocator.construct(p, ::boost::forward<Args>(args)...);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ pointer p(
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::allocate(this->_allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::construct(this->_allocator, p, ::boost::forward<Args>(args)...);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ this->_right_child->_parent = p;
+ self::_on_post_inserted(p->_right_child = this->_right_child);
+ this->_right_child = ::boost::initialized_value;
+ this->on_post_erase();
+ p->_parent = this->get_derived();
+ return self::_on_post_inserted(this->_right_child = p);
+ }
+ else
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ this->_allocator.construct(
+ this->_right_child = this->_allocator.allocate(1)
+ , ::boost::forward<Args>(args)...
+ );
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::construct(
+ this->_allocator
+ , this->_right_child = ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::allocate(this->_allocator, 1)
+ , ::boost::forward<Args>(args)...
+ );
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ this->_right_child->_parent = this->get_derived();
+ return self::_on_post_inserted(this->_right_child);
+ }
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_BINARY_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename T \
+ , typename Size \
+ , typename Allocator \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binary_node_base<Derived,T,Size,Allocator>::iterator \
+ binary_node_base<Derived,T,Size,Allocator>::emplace_right( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (this->_right_child) \
+ { \
+ pointer p(this->_allocator.allocate(1)); \
+ this->_allocator.construct( \
+ p \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ this->_right_child->_parent = p; \
+ self::_on_post_inserted(p->_right_child = this->_right_child); \
+ this->_right_child = ::boost::initialized_value; \
+ this->on_post_erase(); \
+ p->_parent = this->get_derived(); \
+ return self::_on_post_inserted(this->_right_child = p); \
+ } \
+ else \
+ { \
+ this->_allocator.construct( \
+ this->_right_child = this->_allocator.allocate(1) \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ this->_right_child->_parent = this->get_derived(); \
+ return self::_on_post_inserted(this->_right_child); \
+ } \
+ } \
+//!
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_BINARY_NODE_MACRO(z, n, _) \
+ template < \
+ typename Derived \
+ , typename T \
+ , typename Size \
+ , typename Allocator \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binary_node_base<Derived,T,Size,Allocator>::iterator \
+ binary_node_base<Derived,T,Size,Allocator>::emplace_right( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (this->_right_child) \
+ { \
+ pointer p( \
+ ::boost::container::allocator_traits< \
+ typename traits::allocator \
+ >::allocate(this->_allocator, 1) \
+ ); \
+ ::boost::container::allocator_traits< \
+ typename traits::allocator \
+ >::construct( \
+ this->_allocator \
+ , p \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ this->_right_child->_parent = p; \
+ self::_on_post_inserted(p->_right_child = this->_right_child); \
+ this->_right_child = ::boost::initialized_value; \
+ this->on_post_erase(); \
+ p->_parent = this->get_derived(); \
+ return self::_on_post_inserted(this->_right_child = p); \
+ } \
+ else \
+ { \
+ ::boost::container::allocator_traits< \
+ typename traits::allocator \
+ >::construct( \
+ this->_allocator \
+ , this->_right_child = ::boost::container::allocator_traits< \
+ typename traits::allocator \
+ >::allocate(this->_allocator, 1) \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ this->_right_child->_parent = this->get_derived(); \
+ return self::_on_post_inserted(this->_right_child); \
+ } \
+ } \
+//!
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_BINARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_BINARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::const_pointer
+ binary_node_base<Derived,T,Size,Allocator>::get_left_child_ptr() const
+ {
+ return this->_left_child;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::pointer
+ binary_node_base<Derived,T,Size,Allocator>::get_left_child_ptr()
+ {
+ return this->_left_child;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::const_pointer
+ binary_node_base<Derived,T,Size,Allocator>::get_right_child_ptr() const
+ {
+ return this->_right_child;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::pointer
+ binary_node_base<Derived,T,Size,Allocator>::get_right_child_ptr()
+ {
+ return this->_right_child;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::const_iterator
+ binary_node_base<Derived,T,Size,Allocator>::cbegin() const
+ {
+ return const_iterator(this->get_derived(), false);
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::const_iterator
+ binary_node_base<Derived,T,Size,Allocator>::begin() const
+ {
+ return const_iterator(this->get_derived(), false);
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::iterator
+ binary_node_base<Derived,T,Size,Allocator>::begin()
+ {
+ return iterator(this->get_derived(), false);
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::const_iterator
+ binary_node_base<Derived,T,Size,Allocator>::cend() const
+ {
+ return const_iterator(this->get_derived());
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::const_iterator
+ binary_node_base<Derived,T,Size,Allocator>::end() const
+ {
+ return const_iterator(this->get_derived());
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::iterator
+ binary_node_base<Derived,T,Size,Allocator>::end()
+ {
+ return iterator(this->get_derived());
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::const_reverse_iterator
+ binary_node_base<Derived,T,Size,Allocator>::crbegin() const
+ {
+ return const_reverse_iterator(this->get_derived(), false);
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::const_reverse_iterator
+ binary_node_base<Derived,T,Size,Allocator>::rbegin() const
+ {
+ return const_reverse_iterator(this->get_derived(), false);
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::reverse_iterator
+ binary_node_base<Derived,T,Size,Allocator>::rbegin()
+ {
+ return reverse_iterator(this->get_derived(), false);
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::const_reverse_iterator
+ binary_node_base<Derived,T,Size,Allocator>::crend() const
+ {
+ return const_reverse_iterator(this->get_derived());
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::const_reverse_iterator
+ binary_node_base<Derived,T,Size,Allocator>::rend() const
+ {
+ return const_reverse_iterator(this->get_derived());
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::reverse_iterator
+ binary_node_base<Derived,T,Size,Allocator>::rend()
+ {
+ return reverse_iterator(this->get_derived());
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::size_type
+ binary_node_base<Derived,T,Size,Allocator>::size() const
+ {
+ return (
+ this->_left_child
+ ? (this->_right_child ? 2 : 1)
+ : (this->_right_child ? 1 : 0)
+ );
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline bool binary_node_base<Derived,T,Size,Allocator>::empty() const
+ {
+ return !this->_left_child && !this->_right_child;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void binary_node_base<Derived,T,Size,Allocator>::clear()
+ {
+ if (this->_left_child)
+ {
+ self::_destroy(this->_left_child, this->_allocator);
+ }
+
+ if (this->_right_child)
+ {
+ self::_destroy(this->_right_child, this->_allocator);
+ }
+
+ this->_left_child = this->_right_child = ::boost::initialized_value;
+ this->on_post_clear();
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::pointer
+ binary_node_base<Derived,T,Size,Allocator>::rotate_left()
+ {
+ pointer pivot = this->_right_child;
+
+ pivot->_parent = this->_parent;
+
+ if ((this->_right_child = pivot->_left_child))
+ {
+ this->_right_child->_parent = this->get_derived();
+ }
+
+ pivot->_left_child = this->get_derived();
+
+ if (this->_parent)
+ {
+ if (this->_parent->_left_child == this->get_derived())
+ {
+ this->_parent->_left_child = pivot;
+ }
+ else // if (this->_parent->_right_child == this->get_derived())
+ {
+ this->_parent->_right_child = pivot;
+ }
+ }
+
+ this->_parent = pivot;
+ this->on_post_rotate_left();
+ return pivot;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::pointer
+ binary_node_base<Derived,T,Size,Allocator>::rotate_right()
+ {
+ pointer pivot = this->_left_child;
+
+ pivot->_parent = this->_parent;
+
+ if ((this->_left_child = pivot->_right_child))
+ {
+ this->_left_child->_parent = this->get_derived();
+ }
+
+ pivot->_right_child = this->get_derived();
+
+ if (this->_parent)
+ {
+ if (this->_parent->_right_child == this->get_derived())
+ {
+ this->_parent->_right_child = pivot;
+ }
+ else // if (this->_parent->_left_child == this->get_derived())
+ {
+ this->_parent->_left_child = pivot;
+ }
+ }
+
+ this->_parent = pivot;
+ this->on_post_rotate_right();
+ return pivot;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline bool binary_node_base<Derived,T,Size,Allocator>::erase_left()
+ {
+ if (self::_erase(this->_left_child, this->_allocator))
+ {
+ this->on_post_erase();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline bool binary_node_base<Derived,T,Size,Allocator>::erase_right()
+ {
+ if (self::_erase(this->_right_child, this->_allocator))
+ {
+ this->on_post_erase();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::traits::allocator_reference
+ binary_node_base<Derived,T,Size,Allocator>::_construct_from(
+ typename traits::allocator_reference allocator
+ , ::std::tr1::true_type
+ )
+ {
+ return allocator;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline Allocator
+ binary_node_base<Derived,T,Size,Allocator>::_construct_from(
+ typename traits::allocator_reference allocator
+ , ::std::tr1::false_type
+ )
+ {
+ return ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::select_on_container_copy_construction(allocator);
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ bool
+ binary_node_base<Derived,T,Size,Allocator>::_clone_data(
+ pointer& p
+ , const_pointer const& c_p
+ , Allocator& allocator
+ )
+ {
+ if (c_p)
+ {
+ if (p)
+ {
+ p->_data = c_p->_data;
+ }
+ else
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ allocator.construct(p = allocator.allocate(1), c_p->_data);
+#else
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::construct(
+ allocator
+ , p = ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::allocate(allocator, 1)
+ , c_p->_data
+ );
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ }
+
+ return true;
+ }
+ else
+ {
+ if (p)
+ {
+ self::_destroy(p, allocator);
+ p = ::boost::initialized_value;
+ }
+
+ return false;
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline bool
+ binary_node_base<Derived,T,Size,Allocator>::_move(
+ pointer& dest_p
+ , pointer& src_p
+ , Allocator& allocator
+ )
+ {
+ if (dest_p)
+ {
+ self::_destroy(dest_p, allocator);
+ }
+
+ if ((dest_p = src_p))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::_destroy(
+ pointer const& p
+ , Allocator& allocator
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ allocator.destroy(p);
+ allocator.deallocate(p, 1);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::destroy(allocator, p);
+ ::boost::container::allocator_traits<
+ typename traits::allocator
+ >::deallocate(allocator, p, 1);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline bool
+ binary_node_base<Derived,T,Size,Allocator>::_erase(
+ pointer& p
+ , Allocator& allocator
+ )
+ {
+ if (p)
+ {
+ self::_destroy(p, allocator);
+ p = ::boost::initialized_value;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<Derived,T,Size,Allocator>::iterator
+ binary_node_base<Derived,T,Size,Allocator>::_on_post_inserted(
+ pointer const& child
+ )
+ {
+ iterator result(child, true);
+ result->on_post_inserted(result, ::boost::mpl::true_());
+ return result;
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ void
+ binary_node_base<Derived,T,Size,Allocator>::_clone_descendants(
+ Derived const& copy
+ )
+ {
+ bool must_traverse_left_child = true;
+
+ if (
+ self::_clone_data(
+ this->_left_child
+ , copy._left_child
+ , this->_allocator
+ )
+ )
+ {
+ this->_left_child->_parent = this->get_derived();
+ }
+ else
+ {
+ must_traverse_left_child = false;
+ }
+
+ if (
+ self::_clone_data(
+ this->_right_child
+ , copy._right_child
+ , this->_allocator
+ )
+ )
+ {
+ this->_right_child->_parent = this->get_derived();
+ }
+
+ pointer p = this->get_derived();
+
+ for (
+ depth_first_descendant_iterator<Derived const> itr(copy);
+ itr;
+ ++itr
+ )
+ {
+ BOOST_ASSERT_MSG(p, "Premature past-the-end target.");
+
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ if (must_traverse_left_child)
+ {
+ p = p->_left_child;
+ }
+ else
+ {
+ BOOST_ASSERT_MSG(
+ p->_right_child
+ , "itr is at wrong traversal_state"
+ );
+ p = p->_right_child;
+ }
+
+ if (
+ (
+ must_traverse_left_child = self::_clone_data(
+ p->_left_child
+ , itr->_left_child
+ , p->_allocator
+ )
+ )
+ )
+ {
+ p->_left_child->_parent = p;
+ }
+
+ if (
+ self::_clone_data(
+ p->_right_child
+ , itr->_right_child
+ , p->_allocator
+ )
+ )
+ {
+ p->_right_child->_parent = p;
+ }
+
+ p->clone_metadata(*itr);
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ p->on_post_copy_or_move();
+ p = p->get_parent_ptr();
+ must_traverse_left_child = false;
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "p not at-the-end");
+ p->on_post_copy_or_move();
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::_move_descendants(
+ Derived& source
+ )
+ {
+ if (
+ self::_move(
+ this->_left_child
+ , source._left_child
+ , source._allocator
+ )
+ )
+ {
+ this->_left_child->_parent = this->get_derived();
+ source._left_child = ::boost::initialized_value;
+ }
+
+ if (
+ self::_move(
+ this->_right_child
+ , source._right_child
+ , source._allocator
+ )
+ )
+ {
+ this->_right_child->_parent = this->get_derived();
+ source._right_child = ::boost::initialized_value;
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::_on_post_modify_value(
+ data_key const& key
+ )
+ {
+ this->on_post_propagate_value(key);
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ template <typename FusionKey>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::_on_post_modify_value(
+ FusionKey const& key
+ )
+ {
+ this->on_post_propagate_value(key);
+ }
+#endif
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::_set_parent_ptr(pointer p)
+ {
+ if (this->_parent)
+ {
+ if (this->get_derived() == this->_parent->_left_child)
+ {
+ this->_parent->_left_child = ::boost::initialized_value;
+ }
+ else // if (this->get_derived() == this->_parent->_right_child)
+ {
+ this->_parent->_right_child = ::boost::initialized_value;
+ }
+
+ this->_parent->on_post_erase();
+ }
+
+ if ((this->_parent = p))
+ {
+ this->on_post_inserted(
+ iterator(this->get_derived(), true)
+ , ::boost::mpl::true_()
+ );
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::_set_left_child_ptr(
+ pointer p
+ )
+ {
+ if (this->_left_child)
+ {
+ this->_left_child = ::boost::initialized_value;
+ this->on_post_erase();
+ }
+
+ if ((this->_left_child = p))
+ {
+ p->_parent = this->get_derived();
+ p->on_post_inserted(iterator(p, true), ::boost::mpl::true_());
+ }
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline void
+ binary_node_base<Derived,T,Size,Allocator>::_set_right_child_ptr(
+ pointer p
+ )
+ {
+ if (this->_right_child)
+ {
+ this->_right_child = ::boost::initialized_value;
+ this->on_post_erase();
+ }
+
+ if ((this->_right_child = p))
+ {
+ p->_parent = this->get_derived();
+ p->on_post_inserted(iterator(p, true), ::boost::mpl::true_());
+ }
+ }
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::traits::data_type const&
+ get(
+ binary_node_base<Derived,T,Size,Allocator> const& node
+ , data_key const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ inline typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::traits::data_type&
+ get(
+ binary_node_base<Derived,T,Size,Allocator>& node
+ , data_key const& key
+ )
+ {
+ return node[key];
+ }
+
+#if !defined BOOST_NO_SFINAE
+ template <
+ typename Key
+ , typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,data_key>
+ , typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::traits::data_type const&
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator> const& node)
+ {
+ return node[data_key()];
+ }
+
+ template <
+ typename Key
+ , typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,data_key>
+ , typename binary_node_base<Derived,T,Size,Allocator>::traits::data_type&
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator>& node)
+ {
+ return node[data_key()];
+ }
+#endif // BOOST_NO_SFINAE
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename V
+ >
+ inline void
+ put(
+ binary_node_base<Derived,T,Size,Allocator>& node
+ , data_key const& key
+ , V const& value
+ )
+ {
+ node[key] = value;
+ node._on_post_modify_value(key);
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename FusionKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ get(
+ binary_node_base<Derived,T,Size,Allocator> const& node
+ , FusionKey const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename FusionKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ get(
+ binary_node_base<Derived,T,Size,Allocator>& node
+ , FusionKey const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename FusionKey
+ , typename V
+ >
+ inline void
+ put(
+ binary_node_base<Derived,T,Size,Allocator>& node
+ , FusionKey const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type
+ )
+ {
+ node[key] = value;
+ node._on_post_modify_value(key);
+ }
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator> const& node)
+ {
+ return node[FusionKey()];
+ }
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator>& node)
+ {
+ return node[FusionKey()];
+ }
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+}} // namespace boost::tree_node
+
+//[reference__binary_node_base_gen
+namespace boost { namespace tree_node {
+
+ template <
+ typename Size = ::boost::uint32_t
+ , typename AllocatorSelector = ::boost::std_allocator_selector
+ >
+ struct binary_node_base_gen
+ {
+ template <typename Derived, typename T>
+ struct apply
+ {
+ typedef binary_node_base<
+ Derived
+ , T
+ , Size
+ , typename ::boost::mpl::apply_wrap1<
+ AllocatorSelector
+ , Derived
+ >::type
+ >
+ type;
+ };
+ };
+
+ typedef binary_node_base_gen<> binary_node_base_default_gen;
+}} // namespace boost::tree_node
+//]
+
+namespace boost { namespace tree_node {
+
+ template <typename T, typename Size, typename AllocatorSelector>
+ struct binary_node
+ : public
+ //[reference__binary_node__bases
+ binary_node_base<
+ binary_node<T,Size,AllocatorSelector>
+ , T
+ , Size
+ , typename ::boost::mpl::apply_wrap1<
+ AllocatorSelector
+ , binary_node<T,Size,AllocatorSelector>
+ >::type
+ >
+ //]
+ {
+ //[reference__binary_node__super_t
+ typedef binary_node_base<
+ binary_node
+ , T
+ , Size
+ , typename ::boost::mpl::apply_wrap1<
+ AllocatorSelector
+ , binary_node
+ >::type
+ >
+ super_t;
+ //]
+
+ //[reference__binary_node__traits
+ typedef typename super_t::traits
+ traits;
+ //]
+
+ //[reference__binary_node__pointer
+ typedef typename super_t::pointer
+ pointer;
+ //]
+
+ //[reference__binary_node__const_pointer
+ typedef typename super_t::const_pointer
+ const_pointer;
+ //]
+
+ //[reference__binary_node__iterator
+ typedef typename super_t::iterator
+ iterator;
+ //]
+
+ //[reference__binary_node__const_iterator
+ typedef typename super_t::const_iterator
+ const_iterator;
+ //]
+
+ //[reference__binary_node__reverse_iterator
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ //]
+
+ //[reference__binary_node__const_reverse_iterator
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ //]
+
+ //[reference__binary_node__size_type
+ typedef typename super_t::size_type
+ size_type;
+ //]
+
+ BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(binary_node, super_t)
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__binary_node__emplacement_ctor
+ template <typename ...Args>
+ explicit binary_node(Args&& ...args);
+ //]
+
+ //[reference__binary_node__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit binary_node(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF
+ , (binary_node, super_t)
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF
+ , (binary_node, super_t)
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+ };
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename T, typename Size, typename AllocatorSelector>
+ template <typename ...Args>
+ inline binary_node<T,Size,AllocatorSelector>::binary_node(Args&& ...args)
+ : super_t(::boost::forward<Args>(args)...)
+ {
+ }
+
+ template <typename T, typename Size, typename AllocatorSelector>
+ template <typename ...Args>
+ inline binary_node<T,Size,AllocatorSelector>::binary_node(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ {
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+}} // namespace boost::tree_node
+
+//[reference__binary_node_gen
+namespace boost { namespace tree_node {
+
+ template <
+ typename Size = ::boost::uint32_t
+ , typename AllocatorSelector = ::boost::std_allocator_selector
+ >
+ struct binary_node_gen
+ {
+ template <typename T>
+ struct apply
+ {
+ typedef binary_node<T,Size,AllocatorSelector> type;
+ };
+ };
+
+ typedef binary_node_gen<> binary_node_default_gen;
+}} // namespace boost::tree_node
+//]
+
+#include <boost/tree_node/_detail/config_end.hpp>
+
+#endif // BOOST_TREE_NODE_BINARY_NODE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/binary_node_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/binary_node_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,289 @@
+// Copyright (C) 2013 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_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_BINARY_NODE_FWD_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/container_gen/selectors.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/key/data.hpp>
+
+#if !defined BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/equal_to.hpp>
+#endif
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/support/is_sequence.hpp>
+#include <boost/fusion/support/category_of.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#endif
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ class binary_node_base;
+
+ template <
+ typename T
+ , typename Size = ::boost::uint32_t
+ , typename AllocatorSelector = ::boost::std_allocator_selector
+ >
+ struct binary_node;
+}} // namespace boost::tree_node
+
+//[reference__binary_node_base__at_data_key__const
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Size, typename Allocator>
+ typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::traits::data_type const&
+ get(
+ binary_node_base<Derived,T,Size,Allocator> const& node
+ , data_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename Key
+ , typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,data_key>
+ , typename binary_node_base<
+ Derived
+ , T
+ , Size
+ , Allocator
+ >::traits::data_type const&
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator> const& node);
+//<-
+#endif // BOOST_NO_SFINAE
+//->
+}} // namespace boost::tree_node
+//]
+
+//[reference__binary_node_base__at_data_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ typename binary_node_base<Derived,T,Size,Allocator>::traits::data_type&
+ get(
+ binary_node_base<Derived,T,Size,Allocator>& node
+ , data_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename Key
+ , typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,data_key>
+ , typename binary_node_base<Derived,T,Size,Allocator>::traits::data_type&
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator>& node);
+//<-
+#endif // BOOST_NO_SFINAE
+//->
+}} // namespace boost::tree_node
+//]
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+//[reference__binary_node_base__at_key__const
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename FusionKey
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ get(
+ binary_node_base<Derived,T,Size,Allocator> const& node
+ , FusionKey const& key
+ );
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator> const& node);
+}} // namespace boost::tree_node
+//]
+
+//[reference__binary_node_base__at_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename FusionKey
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator>& node, FusionKey const& key);
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ get(binary_node_base<Derived,T,Size,Allocator>& node);
+}} // namespace boost::tree_node
+//]
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+//[reference__binary_node_base__put_data
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename V
+ >
+ void
+ put(
+ binary_node_base<Derived,T,Size,Allocator>& node
+ , data_key const& key
+ , V const& value
+ );
+}} // namespace boost::tree_node
+//]
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+//[reference__binary_node_base__put
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Size
+ , typename Allocator
+ , typename FusionKey
+ , typename V
+ >
+ void
+ put(
+ binary_node_base<Derived,T,Size,Allocator>& node
+ , FusionKey const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ binary_node_base<Derived,T,Size,Allocator>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type = ::boost::mpl::true_()
+ );
+}} // namespace boost::tree_node
+//]
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+#endif // BOOST_TREE_NODE_BINARY_NODE_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/container/binode.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/container/binode.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,2028 @@
+// Copyright (C) 2013 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_CONTAINER_BINODE_HPP_INCLUDED
+#define BOOST_TREE_NODE_CONTAINER_BINODE_HPP_INCLUDED
+
+#include <boost/config.hpp>
+
+#if !defined BOOST_NO_CXX11_NULLPTR
+#include <cstddef>
+#endif
+
+#include <algorithm>
+#include <utility>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/utility/value_init.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/move/move.hpp>
+#include <boost/container/allocator_traits.hpp>
+#endif
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/key/data.hpp>
+#include <boost/tree_node/key/count.hpp>
+#include <boost/tree_node/iterator/in_order.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/value_at_key.hpp>
+#include <boost/tree_node/algorithm/binary_descendant_at_index.hpp>
+#include <boost/tree_node/container/binode_fwd.hpp>
+#include <boost/assert.hpp>
+
+namespace boost { namespace tree_node {
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ class binode_container
+ {
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ BOOST_COPYABLE_AND_MOVABLE(binode_container)
+#endif
+
+ public:
+ //[reference__binode_container__value_type
+ typedef T value_type;
+ //]
+
+ //[reference__binode_container__reference
+ typedef value_type& reference;
+ //]
+
+ //[reference__binode_container__const_reference
+ typedef value_type const& const_reference;
+ //]
+
+ //[reference__binode_container__pointer
+ typedef value_type* pointer;
+ //]
+
+ //[reference__binode_container__const_pointer
+ typedef value_type const* const_pointer;
+ //]
+
+ //[reference__binode_container__node
+ typedef typename ::boost::mpl::apply_wrap1<
+ NodeGenerator
+ , value_type
+ >::type
+ node;
+ //]
+
+ //[reference__binode_container__allocator_type
+ typedef typename node::traits::allocator allocator_type;
+ //]
+
+ private:
+ //[reference__binode_container__transform_function
+ struct transform_function
+ {
+ const_reference operator()(node const& n) const;
+ reference operator()(node& n) const;
+ };
+ //]
+
+ public:
+ //[reference__binode_container__iterator
+ typedef ::boost::transform_iterator<
+ transform_function
+ , in_order_iterator<node>
+ >
+ iterator;
+ //]
+
+ //[reference__binode_container__const_iterator
+ typedef ::boost::transform_iterator<
+ transform_function
+ , in_order_iterator<node const>
+ >
+ const_iterator;
+ //]
+
+ //[reference__binode_container__reverse_iterator
+ typedef ::boost::transform_iterator<
+ transform_function
+ , in_order_iterator<node,::boost::mpl::true_>
+ >
+ reverse_iterator;
+ //]
+
+ //[reference__binode_container__const_reverse_iterator
+ typedef ::boost::transform_iterator<
+ transform_function
+ , in_order_iterator<node const,::boost::mpl::true_>
+ >
+ const_reverse_iterator;
+ //]
+
+ //[reference__binode_container__size_type
+ typedef typename ::boost::mpl::eval_if<
+ result_of::has_key<node,count_key>
+ , result_of::value_at_key<node,count_key>
+ , typename node::size_type
+ >::type
+ size_type;
+ //]
+
+ private:
+ allocator_type _allocator;
+ typename node::pointer _root_ptr;
+
+ public:
+ //[reference__binode_container__default_ctor
+ binode_container();
+ //]
+
+ //[reference__binode_container__ctor_w_alloc
+ explicit binode_container(allocator_type const& allocator);
+ //]
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__binode_container__copy_ctor
+ binode_container(binode_container const& copy);
+ //]
+#else
+ binode_container(
+ BOOST_COPY_ASSIGN_REF(binode_container) copy
+ );
+#endif
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__binode_container__copy_ctor_w_alloc
+ binode_container(
+ binode_container const& copy
+ , allocator_type const& allocator
+ );
+ //]
+#else
+ binode_container(
+ BOOST_COPY_ASSIGN_REF(binode_container) copy
+ , allocator_type const& allocator
+ );
+#endif
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__binode_container__copy_assign
+ binode_container& operator=(binode_container const& copy);
+ //]
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binode_container(
+ BOOST_RV_REF(binode_container) source
+ );
+
+ binode_container(
+ BOOST_RV_REF(binode_container) source
+ , allocator_type const& allocator
+ );
+
+ binode_container& operator=(BOOST_RV_REF(binode_container) source);
+
+ binode_container&
+ operator=(BOOST_COPY_ASSIGN_REF(binode_container) copy);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ //[reference__binode_container__dtor
+ ~binode_container();
+ //]
+
+ //[reference__binode_container__data__const
+ typename node::const_pointer data() const;
+ //]
+
+ //[reference__binode_container__data
+ typename node::pointer data();
+ //]
+
+ //[reference__binode_container__cbegin
+ const_iterator cbegin() const;
+ const_iterator begin() const;
+ //]
+
+ //[reference__binode_container__begin
+ iterator begin();
+ //]
+
+ //[reference__binode_container__cend
+ const_iterator cend() const;
+ const_iterator end() const;
+ //]
+
+ //[reference__binode_container__end
+ iterator end();
+ //]
+
+ //[reference__binode_container__crbegin
+ const_reverse_iterator crbegin() const;
+ const_reverse_iterator rbegin() const;
+ //]
+
+ //[reference__binode_container__rbegin
+ reverse_iterator rbegin();
+ //]
+
+ //[reference__binode_container__crend
+ const_reverse_iterator crend() const;
+ const_reverse_iterator rend() const;
+ //]
+
+ //[reference__binode_container__rend
+ reverse_iterator rend();
+ //]
+
+ //[reference__binode_container__cback
+ const_reference back() const;
+ //]
+
+ //[reference__binode_container__back
+ reference back();
+ //]
+
+ //[reference__binode_container__push_back
+ void push_back(const_reference t);
+ //]
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__binode_container__emplace_back
+ template <typename ...Args>
+ void emplace_back(Args&& ...args);
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ void \
+ emplace_back( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ //[reference__binode_container__pop_back
+ void pop_back();
+ //]
+
+ //[reference__binode_container__cfront
+ const_reference front() const;
+ //]
+
+ //[reference__binode_container__front
+ reference front();
+ //]
+
+ //[reference__binode_container__push_front
+ void push_front(const_reference t);
+ //]
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__binode_container__emplace_front
+ template <typename ...Args>
+ void emplace_front(Args&& ...args);
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ void \
+ emplace_front( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ //[reference__binode_container__pop_front
+ void pop_front();
+ //]
+
+ //[reference__binode_container__insert
+ iterator insert(const_iterator itr, const_reference t);
+ //]
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__binode_container__emplace
+ template <typename ...Args>
+ iterator emplace(const_iterator itr, Args&& ...args);
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ iterator \
+ emplace( \
+ const_iterator itr \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ //[reference__binode_container__erase
+ iterator erase(const_iterator p);
+ //]
+
+ //[reference__binode_container__erase_range
+ void erase(const_iterator itr, const_iterator itr_end);
+ //]
+
+ //[reference__binode_container__empty
+ bool empty() const;
+ //]
+
+ //[reference__binode_container__clear
+ void clear();
+ //]
+
+ //[reference__binode_container__size
+ size_type size() const;
+ //]
+
+ //[reference__binode_container__index_operator__const
+ const_reference operator[](size_type index) const;
+ //]
+
+ //[reference__binode_container__index_operator
+ reference operator[](size_type index);
+ //]
+
+ private:
+ static typename node::pointer
+ _construct_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , value_type const& value
+ );
+
+ static typename node::pointer
+ _construct_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , value_type const& value
+ );
+
+ static typename node::pointer
+ _construct_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , typename node::pointer p
+ );
+
+ static typename node::pointer
+ _construct_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , typename node::pointer p
+ );
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename ...Args>
+ static typename node::pointer
+ _construct_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , Args&& ...args
+ );
+
+ template <typename ...Args>
+ static typename node::pointer
+ _construct_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , Args&& ...args
+ );
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ static typename node::pointer \
+ _construct_from( \
+ ::std::tr1::true_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ static typename node::pointer \
+ _construct_from( \
+ ::std::tr1::false_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ size_type _size(::boost::mpl::true_) const;
+
+ size_type _size(::boost::mpl::false_) const;
+
+ typename node::const_pointer _back() const;
+
+ typename node::pointer _back();
+ };
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::const_reference
+ binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::transform_function::operator()(node const& n) const
+ {
+ return get(n, data_key());
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::reference
+ binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::transform_function::operator()(node& n) const
+ {
+ return get(n, data_key());
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ binode_container<T,NodeGenerator,Balancer>::binode_container()
+ : _allocator()
+ , _root_ptr(
+#if defined BOOST_NO_CXX11_NULLPTR
+ 0
+#else
+ nullptr
+#endif
+ )
+ {
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ binode_container<T,NodeGenerator,Balancer>::binode_container(
+ allocator_type const& allocator
+ ) : _allocator(allocator)
+ , _root_ptr(
+#if defined BOOST_NO_CXX11_NULLPTR
+ 0
+#else
+ nullptr
+#endif
+ )
+ {
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer
+ binode_container<T,NodeGenerator,Balancer>::_construct_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , typename node::pointer p
+ )
+ {
+ if (p)
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(result, *p);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::construct(allocator, result, *p);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+ else
+ {
+ return p;
+ }
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer
+ binode_container<T,NodeGenerator,Balancer>::_construct_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , typename node::pointer p
+ )
+ {
+ if (p)
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(result, *p, allocator);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::construct(allocator, result, *p, allocator);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+ else
+ {
+ return p;
+ }
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ binode_container<T,NodeGenerator,Balancer>::binode_container(
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binode_container const& copy
+#else
+ BOOST_COPY_ASSIGN_REF(binode_container) copy
+#endif
+ ) : _allocator(copy._allocator)
+ , _root_ptr(
+ this->_construct_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , copy._root_ptr
+ )
+ )
+ {
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ binode_container<T,NodeGenerator,Balancer>::binode_container(
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binode_container const& copy
+#else
+ BOOST_COPY_ASSIGN_REF(binode_container) copy
+#endif
+ , allocator_type const& allocator
+ ) : _allocator(copy._allocator)
+ , _root_ptr(
+ this->_construct_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , copy._root_ptr
+ )
+ )
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename T, typename NodeGenerator, typename Balancer>
+ binode_container<T,NodeGenerator,Balancer>::binode_container(
+ BOOST_RV_REF(binode_container) source
+ ) : _allocator(::boost::move(source._allocator))
+ , _root_ptr(source._root_ptr)
+ {
+#if defined BOOST_NO_CXX11_NULLPTR
+ source._root_ptr = 0;
+#else
+ source._root_ptr = nullptr;
+#endif
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ binode_container<T,NodeGenerator,Balancer>::binode_container(
+ BOOST_RV_REF(binode_container) source
+ , allocator_type const& allocator
+ ) : _allocator(allocator), _root_ptr(source._root_ptr)
+ {
+#if defined BOOST_NO_CXX11_NULLPTR
+ source._root_ptr = 0;
+#else
+ source._root_ptr = nullptr;
+#endif
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline binode_container<T,NodeGenerator,Balancer>&
+ binode_container<T,NodeGenerator,Balancer>::operator=(
+ BOOST_RV_REF(binode_container) source
+ )
+ {
+ if (this != &static_cast<binode_container&>(source))
+ {
+ this->_allocator = ::boost::move(source._allocator);
+ this->clear();
+ this->_root_ptr = source._root_ptr;
+#if defined BOOST_NO_CXX11_NULLPTR
+ source._root_ptr = 0;
+#else
+ source._root_ptr = nullptr;
+#endif
+ }
+
+ return *this;
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline binode_container<T,NodeGenerator,Balancer>&
+ binode_container<T,NodeGenerator,Balancer>::operator=(
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binode_container const& copy
+#else
+ BOOST_COPY_ASSIGN_REF(binode_container) copy
+#endif
+ )
+ {
+ if (this != &copy)
+ {
+ if (copy._root_ptr)
+ {
+ if (this->_root_ptr)
+ {
+ *this->_root_ptr = *copy._root_ptr;
+ }
+ else
+ {
+ this->_root_ptr = this->_construct_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , copy._root_ptr
+ );
+ }
+ }
+ else
+ {
+ this->clear();
+ }
+ }
+
+ return *this;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ binode_container<T,NodeGenerator,Balancer>::~binode_container()
+ {
+ this->clear();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::node::const_pointer
+ binode_container<T,NodeGenerator,Balancer>::data() const
+ {
+ return this->_root_ptr;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::node::pointer
+ binode_container<T,NodeGenerator,Balancer>::data()
+ {
+ return this->_root_ptr;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::const_iterator
+ binode_container<T,NodeGenerator,Balancer>::cbegin() const
+ {
+ return this->_root_ptr ? const_iterator(
+ make_in_order_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->cend();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::const_iterator
+ binode_container<T,NodeGenerator,Balancer>::begin() const
+ {
+ return this->_root_ptr ? const_iterator(
+ make_in_order_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->end();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::iterator
+ binode_container<T,NodeGenerator,Balancer>::begin()
+ {
+ return this->_root_ptr ? iterator(
+ make_in_order_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->end();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::const_iterator
+ binode_container<T,NodeGenerator,Balancer>::cend() const
+ {
+ return const_iterator(
+ make_in_order_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::const_iterator
+ binode_container<T,NodeGenerator,Balancer>::end() const
+ {
+ return const_iterator(
+ make_in_order_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::iterator
+ binode_container<T,NodeGenerator,Balancer>::end()
+ {
+ return iterator(
+ make_in_order_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::const_reverse_iterator
+ binode_container<T,NodeGenerator,Balancer>::crbegin() const
+ {
+ return this->_root_ptr ? const_reverse_iterator(
+ make_in_order_reverse_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->crend();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::const_reverse_iterator
+ binode_container<T,NodeGenerator,Balancer>::rbegin() const
+ {
+ return this->_root_ptr ? const_reverse_iterator(
+ make_in_order_reverse_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->rend();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::reverse_iterator
+ binode_container<T,NodeGenerator,Balancer>::rbegin()
+ {
+ return this->_root_ptr ? reverse_iterator(
+ make_in_order_reverse_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->rend();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::const_reverse_iterator
+ binode_container<T,NodeGenerator,Balancer>::crend() const
+ {
+ return const_reverse_iterator(
+ make_in_order_reverse_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::const_reverse_iterator
+ binode_container<T,NodeGenerator,Balancer>::rend() const
+ {
+ return const_reverse_iterator(
+ make_in_order_reverse_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<
+ T
+ , NodeGenerator
+ , Balancer
+ >::reverse_iterator
+ binode_container<T,NodeGenerator,Balancer>::rend()
+ {
+ return reverse_iterator(
+ make_in_order_reverse_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::const_reference
+ binode_container<T,NodeGenerator,Balancer>::front() const
+ {
+ return *this->cbegin();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::reference
+ binode_container<T,NodeGenerator,Balancer>::front()
+ {
+ return *this->begin();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::const_reference
+ binode_container<T,NodeGenerator,Balancer>::back() const
+ {
+ return *this->crbegin();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::reference
+ binode_container<T,NodeGenerator,Balancer>::back()
+ {
+ return *this->rbegin();
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline void binode_container<T,NodeGenerator,Balancer>::pop_front()
+ {
+ this->erase(this->cbegin());
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ typename binode_container<T,NodeGenerator,Balancer>::node::const_pointer
+ binode_container<T,NodeGenerator,Balancer>::_back() const
+ {
+ typename node::const_pointer result = this->_root_ptr;
+
+ if (result)
+ {
+ while (result->get_right_child_ptr())
+ {
+ result = result->get_right_child_ptr();
+ }
+ }
+
+ return result;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer
+ binode_container<T,NodeGenerator,Balancer>::_back()
+ {
+ typename node::pointer result = this->_root_ptr;
+
+ if (result)
+ {
+ while (result->get_right_child_ptr())
+ {
+ result = result->get_right_child_ptr();
+ }
+ }
+
+ return result;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline void binode_container<T,NodeGenerator,Balancer>::pop_back()
+ {
+ this->erase(
+ iterator(
+ make_in_order_iterator_position(*this->_back())
+ , transform_function()
+ )
+ );
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer
+ binode_container<T,NodeGenerator,Balancer>::_construct_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , value_type const& value
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(result, value);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::construct(allocator, result, value);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer
+ binode_container<T,NodeGenerator,Balancer>::_construct_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , value_type const& value
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(
+ result
+ , ::boost::container::allocator_arg
+ , allocator
+ , value
+ );
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<allocator_type>::construct(
+ allocator
+ , result
+ , ::boost::container::allocator_arg
+ , allocator
+ , value
+ );
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ void
+ binode_container<T,NodeGenerator,Balancer>::push_front(
+ const_reference t
+ )
+ {
+ if (this->_root_ptr)
+ {
+ typename node::pointer p = this->_root_ptr;
+
+ while (p->get_left_child_ptr())
+ {
+ p = p->get_left_child_ptr();
+ }
+
+ p = Balancer::post_insert(p = &*p->emplace_left(t));
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+ else // if (!this->_root_ptr)
+ {
+ this->_root_ptr = this->_construct_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , t
+ );
+ }
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ void
+ binode_container<T,NodeGenerator,Balancer>::push_back(
+ const_reference t
+ )
+ {
+ if (this->_root_ptr)
+ {
+ typename node::pointer p = this->_root_ptr;
+
+ while (p->get_right_child_ptr())
+ {
+ p = p->get_right_child_ptr();
+ }
+
+ p = Balancer::post_insert(p = &*p->emplace_right(t));
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+ else // if (!this->_root_ptr)
+ {
+ this->_root_ptr = this->_construct_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , t
+ );
+ }
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ typename binode_container<T,NodeGenerator,Balancer>::iterator
+ binode_container<T,NodeGenerator,Balancer>::insert(
+ const_iterator itr
+ , const_reference t
+ )
+ {
+ if (itr.base())
+ {
+ typename node::pointer anc_ptr = const_cast<
+ typename node::pointer
+ >(&*itr.base());
+ typename node::pointer node_ptr = anc_ptr->get_left_child_ptr();
+
+ if (node_ptr)
+ {
+ while (node_ptr->get_right_child_ptr())
+ {
+ node_ptr = node_ptr->get_right_child_ptr();
+ }
+
+ node_ptr = &*node_ptr->emplace_right(t);
+ }
+ else
+ {
+ node_ptr = &*anc_ptr->emplace_left(t);
+ }
+
+ anc_ptr = Balancer::post_insert(node_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+
+ return iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ );
+ }
+ else // if (!itr)
+ {
+ this->push_back(t);
+ return this->end();
+ }
+ }
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename T, typename NodeGenerator, typename Balancer>
+ template <typename ...Args>
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer
+ binode_container<T,NodeGenerator,Balancer>::_construct_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , Args&& ...args
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(result, ::boost::forward<Args>(args)...);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::construct(allocator, result, ::boost::forward<Args>(args)...);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ template <typename ...Args>
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer
+ binode_container<T,NodeGenerator,Balancer>::_construct_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , Args&& ...args
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(
+ result
+ , ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ );
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<allocator_type>::construct(
+ allocator
+ , result
+ , ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ );
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ template <typename ...Args>
+ void
+ binode_container<T,NodeGenerator,Balancer>::emplace_front(
+ Args&& ...args
+ )
+ {
+ if (this->_root_ptr)
+ {
+ typename node::pointer p = this->_root;
+
+ while (p->get_left_child_ptr())
+ {
+ p = p->get_left_child_ptr();
+ }
+
+ p = Balancer::post_insert(
+ p = &*p->emplace_left(::boost::forward<Args>(args)...)
+ );
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+ else // if (!this->_root_ptr)
+ {
+ this->_root_ptr = this->_construct_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , ::boost::forward<Args>(args)...
+ );
+ }
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ template <typename ...Args>
+ void
+ binode_container<T,NodeGenerator,Balancer>::emplace_back(
+ Args&& ...args
+ )
+ {
+ if (this->_root_ptr)
+ {
+ typename node::pointer p = this->_root;
+
+ while (p->get_right_child_ptr())
+ {
+ p = p->get_right_child_ptr();
+ }
+
+ p = Balancer::post_insert(
+ p = &*p->emplace_right(::boost::forward<Args>(args)...)
+ );
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+ else // if (!this->_root_ptr)
+ {
+ this->_root_ptr = this->_construct_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , ::boost::forward<Args>(args)...
+ );
+ }
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ template <typename ...Args>
+ typename binode_container<T,NodeGenerator,Balancer>::iterator
+ binode_container<T,NodeGenerator,Balancer>::emplace(
+ const_iterator itr
+ , Args&& ...args
+ )
+ {
+ if (itr.base())
+ {
+ typename node::pointer anc_ptr = const_cast<
+ typename node::pointer
+ >(&*itr.base());
+ typename node::pointer node_ptr = anc_ptr->get_left_child_ptr();
+
+ if (node_ptr)
+ {
+ while (node_ptr->get_right_child_ptr())
+ {
+ node_ptr = node_ptr->get_right_child_ptr();
+ }
+
+ node_ptr = &*node_ptr->emplace_right(
+ ::boost::forward<Args>(args)...
+ );
+ }
+ else
+ {
+ node_ptr = &*anc_ptr->emplace_left(
+ ::boost::forward<Args>(args)...
+ );
+ }
+
+ anc_ptr = Balancer::post_insert(node_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+
+ return iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ );
+ }
+ else // if (!itr)
+ {
+ this->emplace_back(::boost::forward<Args>(args)...);
+ return this->end();
+ }
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ template <typename T, typename NodeGenerator, typename Balancer> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer \
+ binode_container<T,NodeGenerator,Balancer>::_construct_from( \
+ ::std::tr1::true_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename node::pointer result(allocator.allocate(1)); \
+ allocator.construct( \
+ result \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return result; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ template <typename T, typename NodeGenerator, typename Balancer> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer \
+ binode_container<T,NodeGenerator,Balancer>::_construct_from( \
+ ::std::tr1::false_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename node::pointer result(allocator.allocate(1)); \
+ allocator.construct( \
+ result \
+ , ::boost::container::allocator_arg \
+ , allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return result; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ template <typename T, typename NodeGenerator, typename Balancer> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer \
+ binode_container<T,NodeGenerator,Balancer>::_construct_from( \
+ ::std::tr1::true_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename node::pointer result( \
+ ::boost::container::allocator_traits< \
+ allocator_type \
+ >::allocate(allocator, 1) \
+ ); \
+ ::boost::container::allocator_traits<allocator_type>::construct( \
+ allocator \
+ , result \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return result; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ template <typename T, typename NodeGenerator, typename Balancer> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_container<T,NodeGenerator,Balancer>::node::pointer \
+ binode_container<T,NodeGenerator,Balancer>::_construct_from( \
+ ::std::tr1::false_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename node::pointer result( \
+ ::boost::container::allocator_traits< \
+ allocator_type \
+ >::allocate(allocator, 1) \
+ ); \
+ ::boost::container::allocator_traits<allocator_type>::construct( \
+ allocator \
+ , result \
+ , ::boost::container::allocator_arg \
+ , allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return result; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ template <typename T, typename NodeGenerator, typename Balancer> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ void \
+ binode_container<T,NodeGenerator,Balancer>::emplace_front( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (this->_root_ptr) \
+ { \
+ typename node::pointer p = this->_root; \
+ while (p->get_left_child_ptr()) \
+ { \
+ p = p->get_left_child_ptr(); \
+ } \
+ p = Balancer::post_insert( \
+ p = &*p->emplace_left( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ ); \
+ if (!p->get_parent_ptr()) \
+ { \
+ this->_root_ptr = p; \
+ } \
+ } \
+ else \
+ { \
+ this->_root_ptr = this->_construct_from( \
+ ::std::tr1::is_const< \
+ typename ::std::tr1::remove_reference< \
+ typename node::traits::allocator_reference \
+ >::type \
+ >() \
+ , this->_allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ template <typename T, typename NodeGenerator, typename Balancer> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ void \
+ binode_container<T,NodeGenerator,Balancer>::emplace_back( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (this->_root_ptr) \
+ { \
+ typename node::pointer p = this->_root; \
+ while (p->get_right_child_ptr()) \
+ { \
+ p = p->get_right_child_ptr(); \
+ } \
+ p = Balancer::post_insert( \
+ p = &*p->emplace_right( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ ); \
+ if (!p->get_parent_ptr()) \
+ { \
+ this->_root_ptr = p; \
+ } \
+ } \
+ else \
+ { \
+ this->_root_ptr = this->_construct_from( \
+ ::std::tr1::is_const< \
+ typename ::std::tr1::remove_reference< \
+ typename node::traits::allocator_reference \
+ >::type \
+ >() \
+ , this->_allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_MACRO(z, n, _) \
+ template <typename T, typename NodeGenerator, typename Balancer> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_container<T,NodeGenerator,Balancer>::iterator \
+ binode_container<T,NodeGenerator,Balancer>::emplace( \
+ const_iterator itr \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (itr.base()) \
+ { \
+ typename node::pointer anc_ptr = const_cast< \
+ typename node::pointer \
+ >(&*itr.base()); \
+ typename node::pointer node_ptr = ( \
+ anc_ptr->get_left_child_ptr() \
+ ); \
+ if (node_ptr) \
+ { \
+ while (node_ptr->get_right_child_ptr()) \
+ { \
+ node_ptr = node_ptr->get_right_child_ptr(); \
+ } \
+ node_ptr = &*node_ptr->emplace_right( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+ else \
+ { \
+ node_ptr = &*anc_ptr->emplace_left( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+ anc_ptr = Balancer::post_insert(node_ptr); \
+ if (!anc_ptr->get_parent_ptr()) \
+ { \
+ this->_root_ptr = anc_ptr; \
+ } \
+ return iterator( \
+ make_in_order_iterator_position(*node_ptr) \
+ , transform_function() \
+ ); \
+ } \
+ else \
+ { \
+ this->emplace_back( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return this->end(); \
+ } \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ typename binode_container<T,NodeGenerator,Balancer>::iterator
+ binode_container<T,NodeGenerator,Balancer>::erase(
+ const_iterator itr
+ )
+ {
+ if (itr.base()->empty() && (this->_root_ptr == &*itr.base()))
+ {
+ this->clear();
+ return this->end();
+ }
+
+ typename node::pointer anc_ptr = const_cast<typename node::pointer>(
+ &*itr.base()
+ );
+ iterator result(
+ make_in_order_iterator_position(*anc_ptr)
+ , transform_function()
+ );
+ bool must_erase_begin = (result == this->begin());
+
+ if (!must_erase_begin)
+ {
+ --result;
+ }
+
+ for (typename node::pointer desc_ptr;;)
+ {
+ if (
+ (desc_ptr = anc_ptr->get_left_child_ptr()) && (
+ !anc_ptr->get_right_child_ptr()
+ )
+ )
+ {
+ while (desc_ptr->get_right_child_ptr())
+ {
+ desc_ptr = desc_ptr->get_right_child_ptr();
+ }
+
+ if (desc_ptr->get_parent_ptr() == anc_ptr)
+ {
+ if (!anc_ptr->get_right_child_ptr())
+ {
+ put(*anc_ptr, data_key(), get(*desc_ptr, data_key()));
+
+ bool must_rebalance = Balancer::pre_erase(*desc_ptr);
+
+ anc_ptr->erase_left();
+
+ if (must_rebalance)
+ {
+ anc_ptr = Balancer::post_erase_left(anc_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+ }
+
+ break;
+ }
+ }
+ else // if (desc_ptr == anc_ptr->get_right_child_ptr())
+ {
+ put(*anc_ptr, data_key(), get(*desc_ptr, data_key()));
+
+ if (desc_ptr->get_left_child_ptr())
+ {
+ anc_ptr = desc_ptr;
+ }
+ else // if (desc_ptr->empty())
+ {
+ anc_ptr = desc_ptr->get_parent_ptr();
+
+ if (anc_ptr->get_left_child_ptr())
+ {
+ put(*desc_ptr, data_key(), get(*anc_ptr, data_key()));
+ }
+ else // desc_ptr is only child of anc_ptr
+ {
+ bool must_rebalance = Balancer::pre_erase(*desc_ptr);
+
+ anc_ptr->erase_right();
+
+ if (must_rebalance)
+ {
+ anc_ptr = Balancer::post_erase_right(anc_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+ }
+
+ break;
+ }
+ }
+
+ continue;
+ }
+ }
+
+ if ((desc_ptr = anc_ptr->get_right_child_ptr()))
+ {
+ while (desc_ptr->get_left_child_ptr())
+ {
+ desc_ptr = desc_ptr->get_left_child_ptr();
+ }
+
+ put(*anc_ptr, data_key(), get(*desc_ptr, data_key()));
+
+ if (desc_ptr->get_right_child_ptr())
+ {
+ if (desc_ptr->get_right_child_ptr()->empty())
+ {
+ bool must_rebalance = Balancer::pre_erase(*desc_ptr);
+
+ anc_ptr->erase_right();
+
+ if (must_rebalance)
+ {
+ anc_ptr = Balancer::post_erase_right(anc_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+ }
+ }
+ else
+ {
+ anc_ptr = desc_ptr;
+ }
+ }
+ else if (desc_ptr->get_parent_ptr() == anc_ptr)
+ {
+ bool must_rebalance = Balancer::pre_erase(*desc_ptr);
+
+ anc_ptr->erase_right();
+
+ if (must_rebalance)
+ {
+ anc_ptr = Balancer::post_erase_right(anc_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+ }
+
+ break;
+ }
+ else
+ {
+ BOOST_ASSERT(desc_ptr->empty());
+ anc_ptr = desc_ptr->get_parent_ptr();
+ BOOST_ASSERT(anc_ptr->get_left_child_ptr() == desc_ptr);
+
+ if (anc_ptr->get_right_child_ptr())
+ {
+ put(*desc_ptr, data_key(), get(*anc_ptr, data_key()));
+ }
+ else // desc_ptr is only child of anc_ptr
+ {
+ bool must_rebalance = Balancer::pre_erase(*desc_ptr);
+
+ anc_ptr->erase_left();
+
+ if (must_rebalance)
+ {
+ anc_ptr = Balancer::post_erase_left(anc_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+ }
+
+ break;
+ }
+ }
+ }
+ else // if (anc_ptr->empty())
+ {
+ desc_ptr = anc_ptr;
+ anc_ptr = anc_ptr->get_parent_ptr();
+
+ bool must_rebalance = Balancer::pre_erase(*desc_ptr);
+
+ if (anc_ptr->get_left_child_ptr() == desc_ptr)
+ {
+ anc_ptr->erase_left();
+
+ if (must_rebalance)
+ {
+ anc_ptr = Balancer::post_erase_left(anc_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+ }
+ }
+ else // if (anc_ptr->get_right_child_ptr() == desc_ptr)
+ {
+ anc_ptr->erase_right();
+
+ if (must_rebalance)
+ {
+ anc_ptr = Balancer::post_erase_right(anc_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+ }
+ }
+
+ break;
+ }
+ }
+
+ return must_erase_begin ? this->begin() : ++result;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ void
+ binode_container<T,NodeGenerator,Balancer>::erase(
+ const_iterator itr
+ , const_iterator itr_end
+ )
+ {
+ while (itr != itr_end)
+ {
+ itr = this->erase(itr);
+ }
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline bool binode_container<T,NodeGenerator,Balancer>::empty() const
+ {
+ return !this->_root_ptr;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ void binode_container<T,NodeGenerator,Balancer>::clear()
+ {
+ if (this->_root_ptr)
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ this->_allocator.destroy(this->_root_ptr);
+ this->_allocator.deallocate(this->_root_ptr, 1);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::destroy(this->_allocator, this->_root_ptr);
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::deallocate(this->_allocator, this->_root_ptr, 1);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_NO_CXX11_NULLPTR
+ this->_root_ptr = 0;
+#else
+ this->_root_ptr = nullptr;
+#endif
+ }
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::size_type
+ binode_container<T,NodeGenerator,Balancer>::_size(
+ ::boost::mpl::true_
+ ) const
+ {
+ return this->_root_ptr ? get(*this->_root_ptr, count_key()) : 0;
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::size_type
+ binode_container<T,NodeGenerator,Balancer>::_size(
+ ::boost::mpl::false_
+ ) const
+ {
+ return ::std::distance(this->cbegin(), this->cend());
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::size_type
+ binode_container<T,NodeGenerator,Balancer>::size() const
+ {
+ return this->_size(result_of::has_key<node,count_key>());
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::const_reference
+ binode_container<T,NodeGenerator,Balancer>::operator[](
+ size_type index
+ ) const
+ {
+ BOOST_ASSERT_MSG(
+ this->_root_ptr && (index < this->size())
+ , "index out of bounds"
+ );
+
+ typename node::const_pointer node_ptr = this->_root_ptr;
+
+ return transform_function()(
+ *binary_descendant_at_index(node_ptr, index)
+ );
+ }
+
+ template <typename T, typename NodeGenerator, typename Balancer>
+ inline typename binode_container<T,NodeGenerator,Balancer>::reference
+ binode_container<T,NodeGenerator,Balancer>::operator[](size_type index)
+ {
+ BOOST_ASSERT_MSG(
+ this->_root_ptr && (index < this->size())
+ , "index out of bounds"
+ );
+
+ return transform_function()(
+ *binary_descendant_at_index(this->_root_ptr, index)
+ );
+ }
+}} // namespace boost::tree_node
+
+#endif // BOOST_TREE_NODE_CONTAINER_BINODE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/container/binode_associative.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/container/binode_associative.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,4655 @@
+// Copyright (C) 2013 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_CONTAINER_BINODE_ASSOCIATIVE_HPP_INCLUDED
+#define BOOST_TREE_NODE_CONTAINER_BINODE_ASSOCIATIVE_HPP_INCLUDED
+
+#include <boost/config.hpp>
+
+#if !defined BOOST_NO_CXX11_NULLPTR
+#include <cstddef>
+#endif
+
+#include <algorithm>
+#include <utility>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/utility/value_init.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/move/move.hpp>
+#include <boost/container/allocator_traits.hpp>
+#endif
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/key/data.hpp>
+#include <boost/tree_node/key/count.hpp>
+#include <boost/tree_node/iterator/in_order.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/value_at_key.hpp>
+#include <boost/tree_node/algorithm/binary_descendant.hpp>
+#include <boost/tree_node/algorithm/binary_lower_bound.hpp>
+#include <boost/tree_node/algorithm/binary_upper_bound.hpp>
+#include <boost/tree_node/algorithm/binary_descendant_at_index.hpp>
+#include <boost/tree_node/container/binode_associative_fwd.hpp>
+#include <boost/assert.hpp>
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ class binode_associative_container
+ {
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ BOOST_COPYABLE_AND_MOVABLE(binode_associative_container)
+#endif
+
+ public:
+ //[reference__binode_associative_container__key_type
+ typedef T1 key_type;
+ //]
+
+ //[reference__binode_associative_container__value_type
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_void<T2>
+ , T1
+ , ::std::pair<T1 const,T2>
+ >::type
+ value_type;
+ //]
+
+ //[reference__binode_associative_container__reference
+ typedef value_type& reference;
+ //]
+
+ //[reference__binode_associative_container__const_reference
+ typedef value_type const& const_reference;
+ //]
+
+ //[reference__binode_associative_container__pointer
+ typedef value_type* pointer;
+ //]
+
+ //[reference__binode_associative_container__const_pointer
+ typedef value_type const* const_pointer;
+ //]
+
+ //[reference__binode_associative_container__node
+ typedef typename ::boost::mpl::apply_wrap1<
+ NodeGenerator
+ , typename ::boost::mpl::if_<
+ ::std::tr1::is_void<T2>
+ , T1
+ , ::std::pair<T1,T2>
+ >::type
+ >::type
+ node;
+ //]
+
+ //[reference__binode_associative_container__allocator_type
+ typedef typename node::traits::allocator allocator_type;
+ //]
+
+ private:
+ //[reference__binode_associative_container__transition_function
+ struct simple_transform_function
+ {
+ typedef const_reference const_result;
+ typedef const_reference mutable_result;
+ const_reference operator()(node const& n) const;
+ };
+
+ struct pair_associative_transform_function
+ {
+ typedef ::std::pair<T1 const&,T2 const&> const_result;
+ typedef ::std::pair<T1 const&,T2&> mutable_result;
+ const_result operator()(node const& n) const;
+ mutable_result operator()(node& n) const;
+ };
+
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_void<T2>
+ , simple_transform_function
+ , pair_associative_transform_function
+ >::type
+ transform_function;
+ //]
+
+ public:
+ //[reference__binode_associative_container__iterator
+ typedef ::boost::transform_iterator<
+ transform_function
+ , in_order_iterator<
+ typename ::boost::mpl::if_<
+ ::std::tr1::is_void<T2>
+ , node const
+ , node
+ >::type
+ >
+ >
+ iterator;
+ //]
+
+ //[reference__binode_associative_container__const_iterator
+ typedef ::boost::transform_iterator<
+ transform_function
+ , in_order_iterator<node const>
+ >
+ const_iterator;
+ //]
+
+ //[reference__binode_associative_container__reverse_iterator
+ typedef ::boost::transform_iterator<
+ transform_function
+ , in_order_iterator<
+ typename ::boost::mpl::if_<
+ ::std::tr1::is_void<T2>
+ , node const
+ , node
+ >::type
+ , ::boost::mpl::true_
+ >
+ >
+ reverse_iterator;
+ //]
+
+ //[reference__binode_associative_container__const_reverse_iterator
+ typedef ::boost::transform_iterator<
+ transform_function
+ , in_order_iterator<node const,::boost::mpl::true_>
+ >
+ const_reverse_iterator;
+ //]
+
+ //[reference__binode_associative_container__size_type
+ typedef typename ::boost::mpl::eval_if<
+ result_of::has_key<node,count_key>
+ , result_of::value_at_key<node,count_key>
+ , typename node::size_type
+ >::type
+ size_type;
+ //]
+
+ //[reference__binode_associative_container__key_compare
+ typedef typename ::boost::mpl::apply_wrap1<
+ CompareSelector
+ , key_type
+ >::type
+ key_compare;
+ //]
+
+ //[reference__binode_associative_container__value_compare
+ class value_compare
+ {
+ //<-
+ key_compare const& _compare;
+ //->
+
+ public:
+ typedef bool result_type;
+
+ explicit value_compare(key_compare const& compare);
+ result_type operator()(const_reference, const_reference) const;
+ result_type operator()(node const& n, key_type const& key) const;
+ result_type operator()(key_type const& key, node const& n) const;
+
+ //<-
+ private:
+ result_type
+ _evaluate(
+ const_reference arg1
+ , const_reference arg2
+ , ::std::tr1::true_type
+ ) const;
+ result_type
+ _evaluate(
+ const_reference arg1
+ , const_reference arg2
+ , ::std::tr1::false_type
+ ) const;
+ result_type
+ _evaluate(
+ node const& n
+ , key_type const& key
+ , ::std::tr1::true_type
+ ) const;
+ result_type
+ _evaluate(
+ node const& n
+ , key_type const& key
+ , ::std::tr1::false_type
+ ) const;
+ result_type
+ _evaluate(
+ key_type const& key
+ , node const& n
+ , ::std::tr1::true_type
+ ) const;
+ result_type
+ _evaluate(
+ key_type const& key
+ , node const& n
+ , ::std::tr1::false_type
+ ) const;
+ //->
+ };
+ //]
+
+ private:
+ class insert_compare
+ {
+ key_compare const& _compare;
+
+ public:
+ typedef bool result_type;
+
+ explicit insert_compare(key_compare const& compare);
+ result_type operator()(node const&, const_reference) const;
+ result_type operator()(const_reference, node const&) const;
+
+ private:
+ result_type
+ _evaluate(
+ node const& n
+ , const_reference value
+ , ::std::tr1::true_type
+ ) const;
+ result_type
+ _evaluate(
+ node const& n
+ , const_reference value
+ , ::std::tr1::false_type
+ ) const;
+ result_type
+ _evaluate(
+ const_reference value
+ , node const& n
+ , ::std::tr1::true_type
+ ) const;
+ result_type
+ _evaluate(
+ const_reference value
+ , node const& n
+ , ::std::tr1::false_type
+ ) const;
+ };
+
+ allocator_type _allocator;
+ typename node::pointer _root_ptr;
+ key_compare _key_compare;
+ value_compare _value_compare;
+
+ public:
+ //[reference__binode_associative_container__default_ctor
+ binode_associative_container();
+ //]
+
+ //[reference__binode_associative_container__ctor_w_alloc
+ explicit binode_associative_container(allocator_type const& allocator);
+ //]
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__binode_associative_container__copy_ctor
+ binode_associative_container(
+ binode_associative_container const& copy
+ );
+ //]
+#else
+ binode_associative_container(
+ BOOST_COPY_ASSIGN_REF(binode_associative_container) copy
+ );
+#endif
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__binode_associative_container__copy_ctor_w_alloc
+ binode_associative_container(
+ binode_associative_container const& copy
+ , allocator_type const& allocator
+ );
+ //]
+#else
+ binode_associative_container(
+ BOOST_COPY_ASSIGN_REF(binode_associative_container) copy
+ , allocator_type const& allocator
+ );
+#endif
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binode_associative_container(
+ BOOST_RV_REF(binode_associative_container) source
+ );
+
+ binode_associative_container(
+ BOOST_RV_REF(binode_associative_container) source
+ , allocator_type const& allocator
+ );
+
+ binode_associative_container&
+ operator=(BOOST_RV_REF(binode_associative_container) source);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__binode_associative_container__copy_assign
+ binode_associative_container&
+ operator=(binode_associative_container const& copy);
+ //]
+#else
+ binode_associative_container&
+ operator=(
+ BOOST_COPY_ASSIGN_REF(binode_associative_container) copy
+ );
+#endif
+
+ //[reference__binode_associative_container__dtor
+ ~binode_associative_container();
+ //]
+
+ //[reference__binode_associative_container__data
+ typename node::const_pointer data() const;
+ //]
+
+ //[reference__binode_associative_container__cbegin
+ const_iterator cbegin() const;
+ const_iterator begin() const;
+ //]
+
+ //[reference__binode_associative_container__begin
+ iterator begin();
+ //]
+
+ //[reference__binode_associative_container__cend
+ const_iterator cend() const;
+ const_iterator end() const;
+ //]
+
+ //[reference__binode_associative_container__end
+ iterator end();
+ //]
+
+ //[reference__binode_associative_container__crbegin
+ const_reverse_iterator crbegin() const;
+ const_reverse_iterator rbegin() const;
+ //]
+
+ //[reference__binode_associative_container__rbegin
+ reverse_iterator rbegin();
+ //]
+
+ //[reference__binode_associative_container__crend
+ const_reverse_iterator crend() const;
+ const_reverse_iterator rend() const;
+ //]
+
+ //[reference__binode_associative_container__rend
+ reverse_iterator rend();
+ //]
+
+ //[reference__binode_associative_container__cfind
+ const_iterator find(key_type const& key) const;
+ //]
+
+ //[reference__binode_associative_container__find
+ iterator find(key_type const& key);
+ //]
+
+ //[reference__binode_associative_container__lower_bound__const
+ const_iterator lower_bound(key_type const& key) const;
+ //]
+
+ //[reference__binode_associative_container__lower_bound
+ iterator lower_bound(key_type const& key);
+ //]
+
+ //[reference__binode_associative_container__upper_bound__const
+ const_iterator upper_bound(key_type const& key) const;
+ //]
+
+ //[reference__binode_associative_container__upper_bound
+ iterator upper_bound(key_type const& key);
+ //]
+
+ //[reference__binode_associative_container__equal_range__const
+ ::std::pair<const_iterator,const_iterator>
+ equal_range(key_type const& key) const;
+ //]
+
+ //[reference__binode_associative_container__equal_range
+ ::std::pair<iterator,iterator> equal_range(key_type const& key);
+ //]
+
+ //[reference__binode_associative_container__insert
+ typename ::boost::mpl::if_<
+ IsMultipleAssociative
+ , iterator
+ , ::std::pair<iterator,bool>
+ >::type
+ insert(value_type const& value);
+ //]
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__binode_associative_container__emplace
+ template <typename ...Args>
+ typename ::boost::mpl::if_<
+ IsMultipleAssociative
+ , iterator
+ , ::std::pair<iterator,bool>
+ >::type
+ emplace(Args&& ...args);
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename ::boost::mpl::if_< \
+ IsMultipleAssociative \
+ , iterator \
+ , ::std::pair<iterator,bool> \
+ >::type \
+ emplace( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ //[reference__binode_associative_container__erase
+ size_type erase(key_type const& key);
+ //]
+
+ //[reference__binode_associative_container__empty
+ bool empty() const;
+ //]
+
+ //[reference__binode_associative_container__clear
+ void clear();
+ //]
+
+ //[reference__binode_associative_container__size
+ size_type size() const;
+ //]
+
+ //[reference__binode_associative_container__index_operator__const
+ typename transform_function::const_result
+ operator[](size_type const& index) const;
+ //]
+
+ //[reference__binode_associative_container__index_operator
+ typename transform_function::mutable_result
+ operator[](size_type const& index);
+ //]
+
+ private:
+ static typename node::pointer
+ _construct_node_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , value_type const& value
+ );
+
+ static typename node::pointer
+ _construct_node_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , value_type const& value
+ );
+
+ static typename node::pointer
+ _construct_node_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , typename node::pointer p
+ );
+
+ static typename node::pointer
+ _construct_node_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , typename node::pointer p
+ );
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename ...Args>
+ static typename node::pointer
+ _construct_node_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , Args&& ...args
+ );
+
+ template <typename ...Args>
+ static typename node::pointer
+ _construct_node_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , Args&& ...args
+ );
+
+ template <typename ...Args>
+ static value_type
+ _construct_value_from(
+ ::std::tr1::true_type
+ , Args&& ...args
+ );
+
+ template <typename ...Args>
+ static value_type
+ _construct_value_from(
+ ::std::tr1::false_type
+ , key_type const& key
+ , Args&& ...args
+ );
+
+ template <typename ...Args>
+ iterator _emplace(::boost::mpl::true_, Args&& ...args);
+
+ template <typename ...Args>
+ ::std::pair<iterator,bool>
+ _emplace(::boost::mpl::false_, Args&& ...args);
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ static typename node::pointer \
+ _construct_node_from( \
+ ::std::tr1::true_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ static typename node::pointer \
+ _construct_node_from( \
+ ::std::tr1::false_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ static value_type \
+ _construct_value_from( \
+ ::std::tr1::true_type \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ static value_type \
+ _construct_value_from( \
+ ::std::tr1::false_type \
+ , key_type const& key \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_PP_DEC(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ iterator \
+ _emplace( \
+ ::boost::mpl::true_ \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ ::std::pair<iterator,bool> \
+ _emplace( \
+ ::boost::mpl::false_ \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ iterator _insert(value_type const& value, ::boost::mpl::true_);
+
+ ::std::pair<iterator,bool>
+ _insert(value_type const& value, ::boost::mpl::false_);
+
+ void _erase_one(typename node::pointer p);
+
+ size_type _erase(key_type const& key, ::boost::mpl::true_);
+
+ size_type _erase(key_type const& key, ::boost::mpl::false_);
+
+ size_type _size(::boost::mpl::true_) const;
+
+ size_type _size(::boost::mpl::false_) const;
+ };
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_reference
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::simple_transform_function::operator()(node const& n) const
+ {
+ return get(n, data_key());
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::pair_associative_transform_function::const_result
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::pair_associative_transform_function::operator()(node const& n) const
+ {
+ ::std::pair<T1,T2> const& p = get(n, data_key());
+ ::std::pair<T1 const&,T2 const&> result(p.first, p.second);
+ return result;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::pair_associative_transform_function::mutable_result
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::pair_associative_transform_function::operator()(node& n) const
+ {
+ ::std::pair<T1,T2>& p = get(n, data_key());
+ ::std::pair<T1 const&,T2&> result(p.first, p.second);
+ return result;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::value_compare(key_compare const& c) : _compare(c)
+ {
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::_evaluate(
+ const_reference arg1
+ , const_reference arg2
+ , ::std::tr1::true_type
+ ) const
+ {
+ return this->_compare(arg1, arg2);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::_evaluate(
+ const_reference arg1
+ , const_reference arg2
+ , ::std::tr1::false_type
+ ) const
+ {
+ return this->_compare(arg1.first, arg2.first);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::operator()(
+ const_reference arg1
+ , const_reference arg2
+ ) const
+ {
+ return this->_evaluate(arg1, arg2, ::std::tr1::is_void<T2>());
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::_evaluate(
+ node const& n
+ , key_type const& key
+ , ::std::tr1::true_type
+ ) const
+ {
+ return this->_compare(get(n, data_key()), key);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::_evaluate(
+ node const& n
+ , key_type const& key
+ , ::std::tr1::false_type
+ ) const
+ {
+ return this->_compare(get(n, data_key()).first, key);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::operator()(node const& n, key_type const& key) const
+ {
+ return this->_evaluate(n, key, ::std::tr1::is_void<T2>());
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::_evaluate(
+ key_type const& key
+ , node const& n
+ , ::std::tr1::true_type
+ ) const
+ {
+ return this->_compare(key, get(n, data_key()));
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::_evaluate(
+ key_type const& key
+ , node const& n
+ , ::std::tr1::false_type
+ ) const
+ {
+ return this->_compare(key, get(n, data_key()).first);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_compare::operator()(key_type const& key, node const& n) const
+ {
+ return this->_evaluate(key, n, ::std::tr1::is_void<T2>());
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::insert_compare(key_compare const& c) : _compare(c)
+ {
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::_evaluate(
+ const_reference value
+ , node const& n
+ , ::std::tr1::true_type
+ ) const
+ {
+ return this->_compare(value, get(n, data_key()));
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::_evaluate(
+ const_reference value
+ , node const& n
+ , ::std::tr1::false_type
+ ) const
+ {
+ return this->_compare(value.first, get(n, data_key()).first);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::operator()(
+ const_reference value
+ , node const& n
+ ) const
+ {
+ return this->_evaluate(value, n, ::std::tr1::is_void<T2>());
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::_evaluate(
+ node const& n
+ , const_reference value
+ , ::std::tr1::true_type
+ ) const
+ {
+ return this->_compare(get(n, data_key()), value);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::_evaluate(
+ node const& n
+ , const_reference value
+ , ::std::tr1::false_type
+ ) const
+ {
+ return this->_compare(get(n, data_key()).first, value.first);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::result_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert_compare::operator()(
+ node const& n
+ , const_reference value
+ ) const
+ {
+ return this->_evaluate(n, value, ::std::tr1::is_void<T2>());
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::binode_associative_container()
+ : _allocator()
+ , _root_ptr(
+#if defined BOOST_NO_CXX11_NULLPTR
+ 0
+#else
+ nullptr
+#endif
+ )
+ , _key_compare()
+ , _value_compare(this->_key_compare)
+ {
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::binode_associative_container(allocator_type const& allocator)
+ : _allocator(allocator)
+ , _root_ptr(
+#if defined BOOST_NO_CXX11_NULLPTR
+ 0
+#else
+ nullptr
+#endif
+ )
+ , _key_compare()
+ , _value_compare(this->_key_compare)
+ {
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::node::pointer
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_construct_node_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , typename node::pointer p
+ )
+ {
+ if (p)
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(result, *p);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::construct(allocator, result, *p);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+ else
+ {
+ return p;
+ }
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::node::pointer
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_construct_node_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , typename node::pointer p
+ )
+ {
+ if (p)
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(result, *p, allocator);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::construct(allocator, result, *p, allocator);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+ else
+ {
+ return p;
+ }
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::binode_associative_container(
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binode_associative_container const& copy
+#else
+ BOOST_COPY_ASSIGN_REF(binode_associative_container) copy
+#endif
+ ) : _allocator(copy._allocator)
+ , _root_ptr(
+ this->_construct_node_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , copy._root_ptr
+ )
+ )
+ , _key_compare(copy._key_compare)
+ , _value_compare(this->_key_compare)
+ {
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::binode_associative_container(
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binode_associative_container const& copy
+#else
+ BOOST_COPY_ASSIGN_REF(binode_associative_container) copy
+#endif
+ , allocator_type const& allocator
+ ) : _allocator(allocator)
+ , _root_ptr(
+ this->_construct_node_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , copy._root_ptr
+ )
+ )
+ , _key_compare(copy._key_compare)
+ , _value_compare(this->_key_compare)
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::binode_associative_container(
+ BOOST_RV_REF(binode_associative_container) source
+ ) : _allocator(::boost::move(source._allocator))
+ , _root_ptr(source._root_ptr)
+ , _key_compare(::boost::move(source._key_compare))
+ , _value_compare(this->_key_compare)
+ {
+#if defined BOOST_NO_CXX11_NULLPTR
+ source._root_ptr = 0;
+#else
+ source._root_ptr = nullptr;
+#endif
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::binode_associative_container(
+ BOOST_RV_REF(binode_associative_container) source
+ , allocator_type const& allocator
+ ) : _allocator(allocator)
+ , _root_ptr(source._root_ptr)
+ , _key_compare(::boost::move(source._key_compare))
+ , _value_compare(this->_key_compare)
+ {
+#if defined BOOST_NO_CXX11_NULLPTR
+ source._root_ptr = 0;
+#else
+ source._root_ptr = nullptr;
+#endif
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >&
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::operator=(BOOST_RV_REF(binode_associative_container) source)
+ {
+ if (this != &static_cast<binode_associative_container&>(source))
+ {
+ this->_allocator = ::boost::move(source._allocator);
+ this->clear();
+ this->_root_ptr = source._root_ptr;
+#if defined BOOST_NO_CXX11_NULLPTR
+ source._root_ptr = 0;
+#else
+ source._root_ptr = nullptr;
+#endif
+ this->_key_compare = ::boost::move(source._key_compare);
+ }
+
+ return *this;
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >&
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::operator=(
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ binode_associative_container const& copy
+#else
+ BOOST_COPY_ASSIGN_REF(binode_associative_container) copy
+#endif
+ )
+ {
+ if (this != &static_cast<binode_associative_container const&>(copy))
+ {
+ if (copy._root_ptr)
+ {
+ if (this->_root_ptr)
+ {
+ *this->_root_ptr = *copy._root_ptr;
+ }
+ else
+ {
+ this->_root_ptr = this->_construct_node_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , copy._root_ptr
+ );
+ }
+ }
+ else
+ {
+ this->clear();
+ }
+
+ this->_key_compare = copy._key_compare;
+ }
+
+ return *this;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::~binode_associative_container()
+ {
+ this->clear();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::node::const_pointer
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::data() const
+ {
+ return this->_root_ptr;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::cbegin() const
+ {
+ return this->_root_ptr ? const_iterator(
+ make_in_order_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->cend();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::begin() const
+ {
+ return this->_root_ptr ? const_iterator(
+ make_in_order_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->end();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::begin()
+ {
+ return this->_root_ptr ? iterator(
+ make_in_order_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->end();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::cend() const
+ {
+ return const_iterator(
+ make_in_order_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::end() const
+ {
+ return const_iterator(
+ make_in_order_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::end()
+ {
+ return iterator(
+ make_in_order_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_reverse_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::crbegin() const
+ {
+ return this->_root_ptr ? const_reverse_iterator(
+ make_in_order_reverse_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->crend();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_reverse_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::rbegin() const
+ {
+ return this->_root_ptr ? const_reverse_iterator(
+ make_in_order_reverse_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->rend();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::reverse_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::rbegin()
+ {
+ return this->_root_ptr ? reverse_iterator(
+ make_in_order_reverse_iterator(*this->_root_ptr)
+ , transform_function()
+ ) : this->rend();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_reverse_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::crend() const
+ {
+ return const_reverse_iterator(
+ make_in_order_reverse_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_reverse_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::rend() const
+ {
+ return const_reverse_iterator(
+ make_in_order_reverse_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::reverse_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::rend()
+ {
+ return reverse_iterator(
+ make_in_order_reverse_iterator_end(this->_root_ptr)
+ , transform_function()
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::find(key_type const& key) const
+ {
+ typename node::const_pointer node_ptr = this->_root_ptr;
+
+ node_ptr = binary_descendant(node_ptr, key, this->_value_compare);
+ return node_ptr ? const_iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ ) : this->cend();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::find(key_type const& key)
+ {
+ typename node::pointer node_ptr = binary_descendant(
+ this->_root_ptr
+ , key
+ , this->_value_compare
+ );
+
+ return node_ptr ? iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ ) : this->end();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::lower_bound(key_type const& key) const
+ {
+ typename node::const_pointer node_ptr = this->_root_ptr;
+
+ node_ptr = binary_lower_bound(node_ptr, key, this->_value_compare);
+ return node_ptr ? const_iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ ) : this->cend();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::lower_bound(key_type const& key)
+ {
+ typename node::pointer node_ptr = binary_lower_bound(
+ this->_root_ptr
+ , key
+ , this->_value_compare
+ );
+
+ return node_ptr ? iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ ) : this->end();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::upper_bound(key_type const& key) const
+ {
+ typename node::const_pointer node_ptr = this->_root_ptr;
+
+ node_ptr = binary_upper_bound(node_ptr, key, this->_value_compare);
+ return node_ptr ? const_iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ ) : this->cend();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::upper_bound(key_type const& key)
+ {
+ typename node::pointer node_ptr = binary_upper_bound(
+ this->_root_ptr
+ , key
+ , this->_value_compare
+ );
+
+ return node_ptr ? iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ ) : this->end();
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline ::std::pair<
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ , typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::const_iterator
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::equal_range(key_type const& key) const
+ {
+ return ::std::make_pair(
+ this->lower_bound(key)
+ , this->upper_bound(key)
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline ::std::pair<
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ , typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::equal_range(key_type const& key)
+ {
+ return ::std::make_pair(
+ this->lower_bound(key)
+ , this->upper_bound(key)
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::node::pointer
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_construct_node_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , value_type const& value
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(result, value);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::construct(allocator, result, value);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::node::pointer
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_construct_node_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , value_type const& value
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(
+ result
+ , ::boost::container::allocator_arg
+ , allocator
+ , value
+ );
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<allocator_type>::construct(
+ allocator
+ , result
+ , ::boost::container::allocator_arg
+ , allocator
+ , value
+ );
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_insert(value_type const& value, ::boost::mpl::true_)
+ {
+ if (!this->_root_ptr)
+ {
+ return iterator(
+ make_in_order_iterator(
+ *(
+ this->_root_ptr = this->_construct_node_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , value
+ )
+ )
+ )
+ , transform_function()
+ );
+ }
+
+ typename node::pointer node_ptr = binary_upper_bound(
+ this->_root_ptr
+ , value
+ , insert_compare(this->_key_compare)
+ );
+
+ if (node_ptr)
+ {
+ if (node_ptr->get_left_child_ptr())
+ {
+ for (
+ node_ptr = node_ptr->get_left_child_ptr();
+ node_ptr->get_right_child_ptr();
+ node_ptr = node_ptr->get_right_child_ptr()
+ )
+ {
+ }
+
+ node_ptr = &*node_ptr->emplace_right(value);
+ }
+ else
+ {
+ node_ptr = &*node_ptr->emplace_left(value);
+ }
+ }
+ else // if (!node_ptr)
+ {
+ for (
+ node_ptr = this->_root_ptr;
+ node_ptr->get_right_child_ptr();
+ node_ptr = node_ptr->get_right_child_ptr()
+ )
+ {
+ }
+
+ node_ptr = &*node_ptr->emplace_right(value);
+ }
+
+ node_ptr = Balancer::post_insert(node_ptr);
+
+ if (!node_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = node_ptr;
+ }
+
+ return iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ ::std::pair<
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ , bool
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_insert(value_type const& value, ::boost::mpl::false_)
+ {
+ if (!this->_root_ptr)
+ {
+ return ::std::make_pair(
+ iterator(
+ make_in_order_iterator(
+ *(
+ this->_root_ptr = this->_construct_node_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , value
+ )
+ )
+ )
+ , transform_function()
+ )
+ , true
+ );
+ }
+
+ insert_compare compare(this->_key_compare);
+ typename node::pointer p = this->_root_ptr;
+
+ for (;;)
+ {
+ if (compare(value, *p))
+ {
+ if (p->get_left_child_ptr())
+ {
+ p = p->get_left_child_ptr();
+ }
+ else
+ {
+ typename node::pointer n = Balancer::post_insert(
+ p = &*p->emplace_left(value)
+ );
+
+ if (!n->get_parent_ptr())
+ {
+ this->_root_ptr = n;
+ }
+
+ return ::std::make_pair(
+ iterator(
+ make_in_order_iterator_position(*p)
+ , transform_function()
+ )
+ , true
+ );
+ }
+ }
+ else if (compare(*p, value))
+ {
+ if (p->get_right_child_ptr())
+ {
+ p = p->get_right_child_ptr();
+ }
+ else
+ {
+ typename node::pointer n = Balancer::post_insert(
+ p = &*p->emplace_right(value)
+ );
+
+ if (!n->get_parent_ptr())
+ {
+ this->_root_ptr = n;
+ }
+
+ return ::std::make_pair(
+ iterator(
+ make_in_order_iterator_position(*p)
+ , transform_function()
+ )
+ , true
+ );
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return ::std::make_pair(
+ iterator(
+ make_in_order_iterator_position(*p)
+ , transform_function()
+ )
+ , false
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename ::boost::mpl::if_<
+ IsMultipleAssociative
+ , typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ , ::std::pair<
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ , bool
+ >
+ >::type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::insert(value_type const& value)
+ {
+ return this->_insert(value, IsMultipleAssociative());
+ }
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ template <typename ...Args>
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::node::pointer
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_construct_node_from(
+ ::std::tr1::true_type
+ , allocator_type& allocator
+ , Args&& ...args
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(result, ::boost::forward<Args>(args)...);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::construct(allocator, result, ::boost::forward<Args>(args)...);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ template <typename ...Args>
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::node::pointer
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_construct_node_from(
+ ::std::tr1::false_type
+ , allocator_type& allocator
+ , Args&& ...args
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(allocator.allocate(1));
+ allocator.construct(
+ result
+ , ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ );
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ typename node::pointer result(
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::allocate(allocator, 1)
+ );
+ ::boost::container::allocator_traits<allocator_type>::construct(
+ allocator
+ , result
+ , ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ );
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ return result;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ template <typename ...Args>
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_construct_value_from(
+ ::std::tr1::true_type
+ , Args&& ...args
+ )
+ {
+ return value_type(::boost::forward<Args>(args)...);
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ template <typename ...Args>
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::value_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_construct_value_from(
+ ::std::tr1::false_type
+ , key_type const& key
+ , Args&& ...args
+ )
+ {
+ return value_type(key, T2(::boost::forward<Args>(args)...));
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ template <typename ...Args>
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_emplace(::boost::mpl::true_, Args&& ...args)
+ {
+ if (!this->_root_ptr)
+ {
+ return iterator(
+ make_in_order_iterator(
+ *(
+ this->_root_ptr = this->_construct_node_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , ::boost::forward<Args>(args)...
+ )
+ )
+ )
+ , transform_function()
+ );
+ }
+
+ typename node::pointer node_ptr = binary_upper_bound(
+ this->_root_ptr
+ , this->_construct_value_from(
+ ::std::tr1::is_void<T2>()
+ , ::boost::forward<Args>(args)...
+ )
+ , insert_compare(this->_key_compare)
+ );
+
+ if (node_ptr)
+ {
+ if (node_ptr->get_left_child_ptr())
+ {
+ for (
+ node_ptr = node_ptr->get_left_child_ptr();
+ node_ptr->get_right_child_ptr();
+ node_ptr = node_ptr->get_right_child_ptr()
+ )
+ {
+ }
+
+ node_ptr = &*node_ptr->emplace_right(
+ ::boost::forward<Args>(args)...
+ );
+ }
+ else
+ {
+ node_ptr = &*node_ptr->emplace_left(
+ ::boost::forward<Args>(args)...
+ );
+ }
+ }
+ else // if (!node_ptr)
+ {
+ for (
+ node_ptr = this->_root_ptr;
+ node_ptr->get_right_child_ptr();
+ node_ptr = node_ptr->get_right_child_ptr()
+ )
+ {
+ }
+
+ node_ptr = &*node_ptr->emplace_right(
+ ::boost::forward<Args>(args)...
+ );
+ }
+
+ typename node::pointer anc_ptr = Balancer::post_insert(node_ptr);
+
+ if (!anc_ptr->get_parent_ptr())
+ {
+ this->_root_ptr = anc_ptr;
+ }
+
+ return iterator(
+ make_in_order_iterator_position(*node_ptr)
+ , transform_function()
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ template <typename ...Args>
+ ::std::pair<
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ , bool
+ >
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_emplace(::boost::mpl::false_, Args&& ...args)
+ {
+ if (!this->_root_ptr)
+ {
+ return ::std::make_pair(
+ iterator(
+ make_in_order_iterator(
+ *(
+ this->_root_ptr = this->_construct_node_from(
+ ::std::tr1::is_const<
+ typename ::std::tr1::remove_reference<
+ typename node::traits::allocator_reference
+ >::type
+ >()
+ , this->_allocator
+ , ::boost::forward<Args>(args)...
+ )
+ )
+ )
+ , transform_function()
+ )
+ , true
+ );
+ }
+
+ value_type value(
+ this->_construct_value_from(
+ ::std::tr1::is_void<T2>()
+ , ::boost::forward<Args>(args)...
+ )
+ );
+ insert_compare compare(this->_key_compare);
+ typename node::pointer p = this->_root_ptr;
+
+ for (;;)
+ {
+ if (compare(value, *p))
+ {
+ if (p->get_left_child_ptr())
+ {
+ p = p->get_left_child_ptr();
+ }
+ else
+ {
+ typename node::pointer n = Balancer::post_insert(
+ p = &*p->emplace_left(::boost::forward<Args>(args)...)
+ );
+
+ if (!n->get_parent_ptr())
+ {
+ this->_root_ptr = n;
+ }
+
+ return ::std::make_pair(
+ iterator(
+ make_in_order_iterator_position(*p)
+ , transform_function()
+ )
+ , true
+ );
+ }
+ }
+ else if (compare(*p, value))
+ {
+ if (p->get_right_child_ptr())
+ {
+ p = p->get_right_child_ptr();
+ }
+ else
+ {
+ typename node::pointer n = Balancer::post_insert(
+ p = &*p->emplace_right(::boost::forward<Args>(args)...)
+ );
+
+ if (!n->get_parent_ptr())
+ {
+ this->_root_ptr = n;
+ }
+
+ return ::std::make_pair(
+ iterator(
+ make_in_order_iterator_position(*p)
+ , transform_function()
+ )
+ , true
+ );
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return ::std::make_pair(
+ iterator(
+ make_in_order_iterator_position(*p)
+ , transform_function()
+ )
+ , false
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ template <typename ...Args>
+ inline typename ::boost::mpl::if_<
+ IsMultipleAssociative
+ , typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ , ::std::pair<
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::iterator
+ , bool
+ >
+ >::type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::emplace(Args&& ...args)
+ {
+ return this->_emplace(
+ IsMultipleAssociative()
+ , ::boost::forward<Args>(args)...
+ );
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::node::pointer \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::_construct_node_from( \
+ ::std::tr1::true_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename node::pointer result(allocator.allocate(1)); \
+ allocator.construct( \
+ result \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return result; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::node::pointer \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::_construct_node_from( \
+ ::std::tr1::false_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename node::pointer result(allocator.allocate(1)); \
+ allocator.construct( \
+ result \
+ , ::boost::container::allocator_arg \
+ , allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return result; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::node::pointer \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::_construct_node_from( \
+ ::std::tr1::true_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename node::pointer result( \
+ ::boost::container::allocator_traits< \
+ allocator_type \
+ >::allocate(allocator, 1) \
+ ); \
+ ::boost::container::allocator_traits<allocator_type>::construct( \
+ allocator \
+ , result \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return result; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::node::pointer \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::_construct_node_from( \
+ ::std::tr1::false_type \
+ , allocator_type& allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename node::pointer result( \
+ ::boost::container::allocator_traits< \
+ allocator_type \
+ >::allocate(allocator, 1) \
+ ); \
+ ::boost::container::allocator_traits<allocator_type>::construct( \
+ allocator \
+ , result \
+ , ::boost::container::allocator_arg \
+ , allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ return result; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ inline typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::value_type \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::_construct_value_from( \
+ ::std::tr1::true_type \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ return value_type( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ inline typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::value_type \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::_construct_value_from( \
+ ::std::tr1::false_type \
+ , key_type const& key \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ return value_type( \
+ key \
+ , T2( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ ); \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_PP_DEC(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::iterator \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::_emplace( \
+ ::boost::mpl::true_ \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (!this->_root_ptr) \
+ { \
+ return iterator( \
+ make_in_order_iterator( \
+ *( \
+ this->_root_ptr = this->_construct_node_from( \
+ ::std::tr1::is_const< \
+ typename ::std::tr1::remove_reference< \
+ typename node::traits::allocator_reference \
+ >::type \
+ >() \
+ , this->_allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ ) \
+ ) \
+ , transform_function() \
+ ); \
+ } \
+ typename node::pointer node_ptr = binary_upper_bound( \
+ this->_root_ptr \
+ , this->_construct_value_from( \
+ ::std::tr1::is_void<T2>() \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ , insert_compare(this->_key_compare) \
+ ); \
+ if (node_ptr) \
+ { \
+ if (node_ptr->get_left_child_ptr()) \
+ { \
+ for ( \
+ node_ptr = node_ptr->get_left_child_ptr(); \
+ node_ptr->get_right_child_ptr(); \
+ node_ptr = node_ptr->get_right_child_ptr() \
+ ) \
+ { \
+ } \
+ node_ptr = &*node_ptr->emplace_right( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+ else \
+ { \
+ node_ptr = &*node_ptr->emplace_left( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+ } \
+ else \
+ { \
+ for ( \
+ node_ptr = this->_root_ptr; \
+ node_ptr->get_right_child_ptr(); \
+ node_ptr = node_ptr->get_right_child_ptr() \
+ ) \
+ { \
+ } \
+ node_ptr = &*node_ptr->emplace_right( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+ node_ptr = Balancer::post_insert(node_ptr); \
+ if (!node_ptr->get_parent_ptr()) \
+ { \
+ this->_root_ptr = node_ptr; \
+ } \
+ return iterator( \
+ make_in_order_iterator_position(*node_ptr) \
+ , transform_function() \
+ ); \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ ::std::pair< \
+ typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::iterator \
+ , bool \
+ > \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::_emplace( \
+ ::boost::mpl::false_ \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ if (!this->_root_ptr) \
+ { \
+ return ::std::make_pair( \
+ iterator( \
+ make_in_order_iterator( \
+ *( \
+ this->_root_ptr = this->_construct_node_from( \
+ ::std::tr1::is_const< \
+ typename ::std::tr1::remove_reference< \
+ typename node::traits::allocator_reference \
+ >::type \
+ >() \
+ , this->_allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ ) \
+ ) \
+ , transform_function() \
+ ) \
+ , true \
+ ); \
+ } \
+ value_type value( \
+ this->_construct_value_from( \
+ ::std::tr1::is_void<T2>() \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ ); \
+ insert_compare compare(this->_key_compare); \
+ typename node::pointer p = this->_root_ptr; \
+ for (;;) \
+ { \
+ if (compare(value, *p)) \
+ { \
+ if (p->get_left_child_ptr()) \
+ { \
+ p = p->get_left_child_ptr(); \
+ } \
+ else \
+ { \
+ typename node::pointer n = Balancer::post_insert( \
+ p = &*p->emplace_left( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ ); \
+ if (!n->get_parent_ptr()) \
+ { \
+ this->_root_ptr = n; \
+ } \
+ return ::std::make_pair( \
+ iterator( \
+ make_in_order_iterator_position(*p) \
+ , transform_function() \
+ ) \
+ , true \
+ ); \
+ } \
+ } \
+ else if (compare(*p, value)) \
+ { \
+ if (p->get_right_child_ptr()) \
+ { \
+ p = p->get_right_child_ptr(); \
+ } \
+ else \
+ { \
+ typename node::pointer n = Balancer::post_insert( \
+ p = &*p->emplace_right( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ ); \
+ if (!n->get_parent_ptr()) \
+ { \
+ this->_root_ptr = n; \
+ } \
+ return ::std::make_pair( \
+ iterator( \
+ make_in_order_iterator_position(*p) \
+ , transform_function() \
+ ) \
+ , true \
+ ); \
+ } \
+ } \
+ else \
+ { \
+ break; \
+ } \
+ } \
+ return ::std::make_pair( \
+ iterator( \
+ make_in_order_iterator_position(*p) \
+ , transform_function() \
+ ) \
+ , false \
+ ); \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+
+#define BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO(z, n, _) \
+ template < \
+ typename NodeGenerator \
+ , typename T1 \
+ , typename T2 \
+ , typename IsMultipleAssociative \
+ , typename CompareSelector \
+ , typename Balancer \
+ > \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ inline typename ::boost::mpl::if_< \
+ IsMultipleAssociative \
+ , typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::iterator \
+ , ::std::pair< \
+ typename binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::iterator \
+ , bool \
+ > \
+ >::type \
+ binode_associative_container< \
+ NodeGenerator \
+ , T1 \
+ , T2 \
+ , IsMultipleAssociative \
+ , CompareSelector \
+ , Balancer \
+ >::emplace( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ return this->_emplace( \
+ IsMultipleAssociative() \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_CONTAINER_BINARY_ASSOCIATIVE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ void
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_erase_one(typename node::pointer p)
+ {
+ for (typename node::pointer s;;)
+ {
+ if (
+ (s = p->get_left_child_ptr()) && (
+ !p->get_right_child_ptr() || Balancer::choose_predecessor(
+ *typename node::const_pointer(p)
+ )
+ )
+ )
+ {
+ while (s->get_right_child_ptr())
+ {
+ s = s->get_right_child_ptr();
+ }
+
+ if (s->get_parent_ptr() == p)
+ {
+ if (!p->get_right_child_ptr())
+ {
+ put(*p, data_key(), get(*s, data_key()));
+
+ bool must_rebalance = Balancer::pre_erase(*s);
+
+ p->erase_left();
+
+ if (must_rebalance)
+ {
+ p = Balancer::post_erase_left(p);
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+
+ break;
+ }
+ }
+ else // if (s == s->get_parent_ptr()->get_right_child_ptr())
+ {
+ put(*p, data_key(), get(*s, data_key()));
+
+ if (s->get_left_child_ptr())
+ {
+ p = s;
+ }
+ else // if (s->empty())
+ {
+ p = s->get_parent_ptr();
+
+ if (p->get_left_child_ptr())
+ {
+ put(*s, data_key(), get(*p, data_key()));
+ }
+ else // s is only child of p
+ {
+ bool must_rebalance = Balancer::pre_erase(*s);
+
+ p->erase_right();
+
+ if (must_rebalance)
+ {
+ p = Balancer::post_erase_right(p);
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+
+ break;
+ }
+ }
+
+ continue;
+ }
+ }
+
+ if ((s = p->get_right_child_ptr()))
+ {
+ while (s->get_left_child_ptr())
+ {
+ s = s->get_left_child_ptr();
+ }
+
+ put(*p, data_key(), get(*s, data_key()));
+
+ if (s->get_right_child_ptr())
+ {
+ p = s;
+ }
+ else if (s->get_parent_ptr() == p)
+ {
+ bool must_rebalance = Balancer::pre_erase(*s);
+
+ p->erase_right();
+
+ if (must_rebalance)
+ {
+ p = Balancer::post_erase_right(p);
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+
+ break;
+ }
+ else
+ {
+ BOOST_ASSERT(s->empty());
+ p = s->get_parent_ptr();
+ BOOST_ASSERT(p->get_left_child_ptr() == s);
+
+ if (p->get_right_child_ptr())
+ {
+ put(*s, data_key(), get(*p, data_key()));
+ }
+ else // s is only child of p
+ {
+ bool must_rebalance = Balancer::pre_erase(*s);
+
+ p->erase_left();
+
+ if (must_rebalance)
+ {
+ p = Balancer::post_erase_left(p);
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+
+ break;
+ }
+ }
+ }
+ else // if (p->empty())
+ {
+ s = p;
+ p = p->get_parent_ptr();
+
+ bool must_rebalance = Balancer::pre_erase(*s);
+
+ if (p->get_left_child_ptr() == s)
+ {
+ p->erase_left();
+
+ if (must_rebalance)
+ {
+ p = Balancer::post_erase_left(p);
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+ }
+ else // if (p->get_right_child_ptr() == s)
+ {
+ p->erase_right();
+
+ if (must_rebalance)
+ {
+ p = Balancer::post_erase_right(p);
+
+ if (!p->get_parent_ptr())
+ {
+ this->_root_ptr = p;
+ }
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::size_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_erase(key_type const& key, ::boost::mpl::true_)
+ {
+ size_type result = ::boost::initialized_value;
+
+ for (
+ typename node::pointer p;
+ (
+ p = binary_descendant(
+ this->_root_ptr
+ , key
+ , this->_value_compare
+ )
+ );
+ ++result
+ )
+ {
+ this->_erase_one(p);
+ }
+
+ return result;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::size_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_erase(key_type const& key, ::boost::mpl::false_)
+ {
+ this->_erase_one(
+ binary_descendant(
+ this->_root_ptr
+ , key
+ , this->_value_compare
+ )
+ );
+ return 1;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::size_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::erase(key_type const& key)
+ {
+ if (this->_root_ptr)
+ {
+ if (this->_root_ptr->empty())
+ {
+ this->clear();
+ return 1;
+ }
+ else
+ {
+ return this->_erase(key, IsMultipleAssociative());
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline bool
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::empty() const
+ {
+ return !this->_root_ptr;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ void
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::clear()
+ {
+ if (this->_root_ptr)
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ this->_allocator.destroy(this->_root_ptr);
+ this->_allocator.deallocate(this->_root_ptr, 1);
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::destroy(this->_allocator, this->_root_ptr);
+ ::boost::container::allocator_traits<
+ allocator_type
+ >::deallocate(this->_allocator, this->_root_ptr, 1);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_NO_CXX11_NULLPTR
+ this->_root_ptr = 0;
+#else
+ this->_root_ptr = nullptr;
+#endif
+ }
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::size_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_size(::boost::mpl::true_) const
+ {
+ return this->_root_ptr ? get(*this->_root_ptr, count_key()) : 0;
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::size_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::_size(::boost::mpl::false_) const
+ {
+ return ::std::distance(this->cbegin(), this->cend());
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::size_type
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::size() const
+ {
+ return this->_size(result_of::has_key<node,count_key>());
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::transform_function::const_result
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::operator[](size_type const& index) const
+ {
+ BOOST_ASSERT_MSG(
+ this->_root_ptr && (index < this->size())
+ , "index out of bounds"
+ );
+
+ typename node::const_pointer node_ptr = this->_root_ptr;
+
+ return transform_function()(
+ *binary_descendant_at_index(node_ptr, index)
+ );
+ }
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ inline typename binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::transform_function::mutable_result
+ binode_associative_container<
+ NodeGenerator
+ , T1
+ , T2
+ , IsMultipleAssociative
+ , CompareSelector
+ , Balancer
+ >::operator[](size_type const& index)
+ {
+ BOOST_ASSERT_MSG(
+ this->_root_ptr && (index < this->size())
+ , "index out of bounds"
+ );
+
+ return transform_function()(
+ *binary_descendant_at_index(this->_root_ptr, index)
+ );
+ }
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename T
+ , typename NodeGenerator
+ , typename Balancer
+ , typename CompareSelector
+ >
+ class binode_set
+ : public
+ //[reference__binode_set__bases
+ binode_associative_container<
+ NodeGenerator
+ , T
+ , void
+ , ::boost::mpl::false_
+ , CompareSelector
+ , Balancer
+ >
+ //]
+ {
+ typedef binode_associative_container<
+ NodeGenerator
+ , T
+ , void
+ , ::boost::mpl::false_
+ , CompareSelector
+ , Balancer
+ >
+ super_t;
+
+ public:
+ BOOST_TREE_NODE_ASSOCIATIVE_CONTAINER_DERIVED_BODY(binode_set, super_t)
+ };
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename T
+ , typename NodeGenerator
+ , typename Balancer
+ , typename CompareSelector
+ >
+ class binode_multiset
+ : public
+ //[reference__binode_multiset__bases
+ binode_associative_container<
+ NodeGenerator
+ , T
+ , void
+ , ::boost::mpl::true_
+ , CompareSelector
+ , Balancer
+ >
+ //]
+ {
+ typedef binode_associative_container<
+ NodeGenerator
+ , T
+ , void
+ , ::boost::mpl::true_
+ , CompareSelector
+ , Balancer
+ >
+ super_t;
+
+ public:
+ BOOST_TREE_NODE_ASSOCIATIVE_CONTAINER_DERIVED_BODY(
+ binode_multiset
+ , super_t
+ )
+ };
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Key
+ , typename Mapped
+ , typename NodeGenerator
+ , typename Balancer
+ , typename CompareSelector
+ >
+ class binode_map
+ : public
+ //[reference__binode_map__bases
+ binode_associative_container<
+ NodeGenerator
+ , Key
+ , Mapped
+ , ::boost::mpl::false_
+ , CompareSelector
+ , Balancer
+ >
+ //]
+ {
+ typedef binode_associative_container<
+ NodeGenerator
+ , Key
+ , Mapped
+ , ::boost::mpl::false_
+ , CompareSelector
+ , Balancer
+ >
+ super_t;
+
+ public:
+ //[reference__binode_map__mapped_type
+ typedef Mapped mapped_type;
+ //]
+
+ BOOST_TREE_NODE_ASSOCIATIVE_CONTAINER_DERIVED_BODY(binode_map, super_t)
+ };
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Key
+ , typename Mapped
+ , typename NodeGenerator
+ , typename Balancer
+ , typename CompareSelector
+ >
+ class binode_multimap
+ : public
+ //[reference__binode_multimap__bases
+ binode_associative_container<
+ NodeGenerator
+ , Key
+ , Mapped
+ , ::boost::mpl::true_
+ , CompareSelector
+ , Balancer
+ >
+ //]
+ {
+ typedef binode_associative_container<
+ NodeGenerator
+ , Key
+ , Mapped
+ , ::boost::mpl::true_
+ , CompareSelector
+ , Balancer
+ >
+ super_t;
+
+ public:
+ //[reference__binode_multimap__mapped_type
+ typedef Mapped mapped_type;
+ //]
+
+ BOOST_TREE_NODE_ASSOCIATIVE_CONTAINER_DERIVED_BODY(
+ binode_multimap
+ , super_t
+ )
+ };
+}} // namespace boost::tree_node
+
+#endif // BOOST_TREE_NODE_CONTAINER_BINODE_ASSOCIATIVE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/container/binode_associative_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/container/binode_associative_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,61 @@
+// Copyright (C) 2013 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_CONTAINER_BINODE_ASSOCIATIVE_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_CONTAINER_BINODE_ASSOCIATIVE_FWD_HPP_INCLUDED
+
+#include <boost/container_gen/selectors.hpp>
+#include <boost/tree_node/binary_node.hpp>
+#include <boost/tree_node/balancer/null.hpp>
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename NodeGenerator
+ , typename T1
+ , typename T2
+ , typename IsMultipleAssociative
+ , typename CompareSelector
+ , typename Balancer
+ >
+ class binode_associative_container;
+
+ template <
+ typename T
+ , typename NodeGenerator = binary_node_default_gen
+ , typename Balancer = null_balancer
+ , typename CompareSelector = ::boost::default_ordering_selector
+ >
+ class binode_set;
+
+ template <
+ typename T
+ , typename NodeGenerator = binary_node_default_gen
+ , typename Balancer = null_balancer
+ , typename CompareSelector = ::boost::default_ordering_selector
+ >
+ class binode_multiset;
+
+ template <
+ typename Key
+ , typename Mapped
+ , typename NodeGenerator = binary_node_default_gen
+ , typename Balancer = null_balancer
+ , typename CompareSelector = ::boost::default_ordering_selector
+ >
+ class binode_map;
+
+ template <
+ typename Key
+ , typename Mapped
+ , typename NodeGenerator = binary_node_default_gen
+ , typename Balancer = null_balancer
+ , typename CompareSelector = ::boost::default_ordering_selector
+ >
+ class binode_multimap;
+}} // namespace boost::tree_node
+
+#endif // BOOST_TREE_NODE_CONTAINER_BINODE_ASSOCIATIVE_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/container/binode_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/container/binode_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,23 @@
+// Copyright (C) 2013 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_CONTAINER_BINODE_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_CONTAINER_BINODE_FWD_HPP_INCLUDED
+
+#include <boost/tree_node/binary_node.hpp>
+#include <boost/tree_node/balancer/null.hpp>
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename T
+ , typename NodeGenerator = binary_node_default_gen
+ , typename Balancer = null_balancer
+ >
+ class binode_container;
+}} // namespace boost::tree_node
+
+#endif // BOOST_TREE_NODE_CONTAINER_BINODE_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/nary_node.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/nary_node.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,2106 @@
+// Copyright (C) 2011-2013 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 <deque>
+#include <algorithm>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/utility/value_init.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/range.hpp>
+#include <boost/container_gen/container_gen.hpp>
+#include <boost/container_gen/emplace_function_gen.hpp>
+#include <boost/container_gen/splice_function_gen.hpp>
+#include <boost/container_gen/insert_range_result_gen.hpp>
+#include <boost/container_gen/is_recursive_selector.hpp>
+#include <boost/container_gen/is_reversible_selector.hpp>
+#include <boost/container_gen/is_random_access_selector.hpp>
+#include <boost/container_gen/is_ptr_selector.hpp>
+#include <boost/container_gen/has_stable_iters_selector.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/nary_node_fwd.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/get_keys.hpp>
+#include <boost/tree_node/iterator/depth_first_descendant.hpp>
+#include <boost/tree_node/iterator/post_order.hpp>
+#include <boost/detail/metafunction/container_reverse_iterator.hpp>
+#include <boost/assert.hpp>
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/container_gen/insert_range_function_gen.hpp>
+#else
+#include <boost/move/move.hpp>
+#include <boost/container_gen/selectors.hpp>
+#endif
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/enum_trailing.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/_detail/config_begin.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/type_traits/is_pod.hpp>
+
+namespace boost {
+
+ template <typename Derived, typename T, typename Selector>
+ struct is_POD<
+ ::boost::tree_node::nary_node_base<Derived,T,Selector>
+ > : ::boost::false_type
+ {
+ };
+
+ template <typename Derived, typename T, typename Selector>
+ struct is_pod<
+ ::boost::tree_node::nary_node_base<Derived,T,Selector>
+ > : ::boost::false_type
+ {
+ };
+} // namespace boost
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/transform_view.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/iterator/key_of.hpp>
+#include <boost/fusion/support/is_sequence.hpp>
+#include <boost/fusion/support/category_of.hpp>
+
+namespace boost { namespace tree_node { namespace result_of {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Selector
+ , typename FusionKey
+ >
+ struct has_key_impl<nary_node_base<Derived,T,Selector>,FusionKey>
+ : ::boost::mpl::eval_if<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::has_key<T,FusionKey>
+ , ::std::tr1::is_same<FusionKey,data_key>
+ >::type
+ {
+ };
+
+ template <typename Derived, typename T, typename Selector>
+ struct get_keys_impl<nary_node_base<Derived,T,Selector> >
+ : ::boost::mpl::eval_if<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::transform_view<
+ T
+ , ::boost::fusion::result_of::key_of< ::boost::mpl::_>
+ >
+ , ::boost::mpl::vector1<data_key>
+ >
+ {
+ };
+}}} // namespace boost::tree_node::result_of
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector>
+ class nary_node_base
+ : public
+ //[reference__nary_node_base__bases
+ tree_node_base<Derived>
+ //]
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , public data_key
+#endif
+ , private ::boost::noncopyable
+ {
+ BOOST_MPL_ASSERT((::boost::is_recursive_selector<Selector>));
+
+ typedef nary_node_base<Derived,T,Selector> self;
+
+ //[reference__nary_node_base__children
+ typedef typename ::boost::container_gen<Selector,Derived>::type
+ children;
+ //]
+
+ public:
+ //[reference__nary_node_base__super_t
+ typedef tree_node_base<Derived> super_t;
+ //]
+
+ //[reference__nary_node_base__traits
+ struct traits
+ {
+ typedef T data_type;
+ typedef typename children::allocator_type allocator;
+ typedef allocator const& allocator_reference;
+ };
+ //]
+
+ //[reference__nary_node_base__pointer
+ typedef typename super_t::pointer pointer;
+ //]
+
+ //[reference__nary_node_base__const_pointer
+ typedef typename super_t::const_pointer const_pointer;
+ //]
+
+ //[reference__nary_node_base__iterator
+ typedef typename children::iterator iterator;
+ //]
+
+ //[reference__nary_node_base__const_iterator
+ typedef typename children::const_iterator const_iterator;
+ //]
+
+ typedef typename ::boost::detail::metafunction
+ ::container_reverse_iterator<children>::type
+ reverse_iterator;
+ typedef typename ::boost::detail::metafunction
+ ::container_reverse_iterator<children const>::type
+ const_reverse_iterator;
+
+ //[reference__nary_node_base__size_type
+ typedef typename children::size_type size_type;
+ //]
+
+ private:
+ children _children;
+ typename traits::data_type _data;
+ pointer _parent;
+
+ protected:
+ //[reference__nary_node_base__derived_copy_ctor
+ nary_node_base(Derived const& copy);
+ //]
+
+ //[reference__nary_node_base__derived_copy_ctor_w_allocator
+ nary_node_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ );
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ nary_node_base(BOOST_RV_REF(Derived) source);
+
+ nary_node_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ );
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__nary_node_base__emplacement_ctor
+ template <typename ...Args>
+ explicit nary_node_base(Args&& ...args);
+ //]
+
+ //[reference__nary_node_base__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit nary_node_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_FWD_DECL
+ , nary_node_base
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_FWD_DECL
+ , nary_node_base
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ ~nary_node_base();
+
+ //[reference__nary_node_base__clone_descendants
+ void clone_descendants(Derived const& copy);
+ //]
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__nary_node_base__copy_assign
+ void copy_assign(Derived const& copy);
+ //]
+#else
+ void move_descendants(BOOST_RV_REF(Derived) source);
+
+ void copy_assign(BOOST_COPY_ASSIGN_REF(Derived) copy);
+
+ void move_assign(BOOST_RV_REF(Derived) source);
+#endif
+
+ //[reference__nary_node_base__on_post_assign
+ void on_post_assign();
+ //]
+
+ public:
+ //[reference__nary_node_base__data_key_value_operator__const
+ typename traits::data_type const& operator[](data_key const&) const;
+ //]
+
+ //[reference__nary_node_base__data_key_value_operator
+ typename traits::data_type& operator[](data_key const&);
+ //]
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ //[reference__nary_node_base__key_value_operator__const
+ template <typename FusionKey>
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ operator[](FusionKey const&) const;
+ //]
+
+ //[reference__nary_node_base__key_value_operator
+ template <typename FusionKey>
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ operator[](FusionKey const&);
+ //]
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+ //[reference__nary_node_base__get_parent_ptr__const
+ const_pointer get_parent_ptr() const;
+ //]
+
+ //[reference__nary_node_base__get_parent_ptr
+ pointer get_parent_ptr();
+ //]
+
+ //[reference__nary_node_base__cbegin
+ const_iterator cbegin() const;
+ const_iterator begin() const;
+ //]
+
+ //[reference__nary_node_base__begin
+ iterator begin();
+ //]
+
+ //[reference__nary_node_base__cend
+ const_iterator cend() const;
+ const_iterator end() const;
+ //]
+
+ //[reference__nary_node_base__end
+ iterator end();
+ //]
+
+ //[reference__nary_node_base__crbegin
+ const_reverse_iterator crbegin() const;
+ const_reverse_iterator rbegin() const;
+ //]
+
+ //[reference__nary_node_base__rbegin
+ reverse_iterator rbegin();
+ //]
+
+ //[reference__nary_node_base__crend
+ const_reverse_iterator crend() const;
+ const_reverse_iterator rend() const;
+ //]
+
+ //[reference__nary_node_base__rend
+ reverse_iterator rend();
+ //]
+
+ //[reference__nary_node_base__size
+ size_type size() const;
+ //]
+
+ //[reference__nary_node_base__empty
+ bool empty() const;
+ //]
+
+ //[reference__nary_node_base__clear
+ void clear();
+ //]
+
+ //[reference__nary_node_base__insert
+ iterator insert(Derived const& child);
+ //]
+
+#if 0//!defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ //[reference__nary_node_base__move_insert
+ iterator insert(BOOST_RV_REF(Derived) child);
+ //]
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__nary_node_base__emplace
+ template <typename ...Args>
+ iterator emplace(Args&& ...args);
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_NARY_NODE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ iterator \
+ emplace( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_NARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_NARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ //[reference__nary_node_base__splice
+ typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ splice(iterator pos, Derived& node);
+
+ typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ splice(iterator pos, Derived& node, iterator itr);
+
+ typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ splice(
+ iterator pos
+ , Derived& node
+ , iterator itr
+ , iterator itr_end
+ );
+ //]
+
+ private:
+ static void
+ _link_children_to_parent(
+ pointer const& p
+ , iterator itr
+ , iterator itr_end
+ );
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename ...Args>
+ iterator _add_child(Args&& ...args);
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_NARY_NODE_MACRO(z, n, _) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ iterator \
+ _add_child( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ); \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_NARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_NARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ void _clone_descendants(Derived const& copy);
+
+ void _clone_descendants(Derived const& copy, ::boost::mpl::true_);
+
+ void _clone_descendants(Derived const& copy, ::boost::mpl::false_);
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ void _move_descendants(BOOST_RV_REF(Derived) source);
+
+ void _move_descendants(Derived& source, ::boost::mpl::true_);
+
+ void _move_descendants(Derived& source, ::boost::mpl::false_);
+
+ void _move_descendants_non_ptr(Derived& source, ::boost::mpl::true_);
+
+ void _move_descendants_non_ptr(Derived& source, ::boost::mpl::false_);
+
+ template <typename A>
+ void
+ _on_post_insert(
+ iterator to_child
+ , ::boost::vector_selector< ::boost::mpl::true_,A>
+ );
+
+ template <typename A>
+ void _on_post_resize(::boost::vector_selector< ::boost::mpl::true_,A>);
+
+ template <typename A>
+ void _on_post_outsourced(::boost::stable_vector_selector<A>);
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename S>
+ void _on_post_insert(iterator to_child, S);
+
+ template <typename S>
+ void _on_post_resize(S);
+
+ template <typename S>
+ void _on_post_outsourced(S);
+
+ void _on_post_clone_or_move(::boost::mpl::true_);
+
+ void _on_post_clone_or_move(::boost::mpl::false_);
+
+ typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ _splice(
+ iterator pos
+ , Derived& node
+ , iterator itr
+ , iterator itr_end
+ , ::boost::mpl::true_
+ );
+
+ typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ _splice(
+ iterator pos
+ , Derived& node
+ , iterator itr
+ , iterator itr_end
+ , ::boost::mpl::false_
+ );
+
+ template <typename D, typename T0, typename S, typename V>
+ friend void
+ put(
+ nary_node_base<D,T0,S>& node
+ , data_key const& key
+ , V const& value
+ );
+
+ void _on_post_modify_value(data_key const& key);
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename FusionKey>
+ void _on_post_modify_value(FusionKey const& key);
+
+ template <
+ typename D
+ , typename T0
+ , typename S
+ , typename FusionKey
+ , typename V
+ >
+ friend void
+ put(
+ nary_node_base<D,T0,S>& node
+ , FusionKey const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T0>::type
+ , ::boost::fusion::traits::is_associative<T0>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<nary_node_base<D,T0,S>,FusionKey>
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type
+ );
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+ };
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::nary_node_base(Derived const& copy)
+ : _children(), _data(copy._data), _parent()
+ {
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::nary_node_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ ) : _children(allocator), _data(copy._data), _parent()
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::nary_node_base(
+ BOOST_RV_REF(Derived) source
+ ) : _children(), _data(::boost::move(source._data)), _parent()
+ {
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::nary_node_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ ) : _children(allocator), _data(::boost::move(source._data)), _parent()
+ {
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Derived, typename T, typename Selector>
+ template <typename ...Args>
+ nary_node_base<Derived,T,Selector>::nary_node_base(Args&& ...args)
+ : _children(), _data(::boost::forward<Args>(args)...), _parent()
+ {
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename ...Args>
+ nary_node_base<Derived,T,Selector>::nary_node_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : _children(allocator), _data(::boost::forward<Args>(args)...), _parent()
+ {
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_NARY_NODE_MACRO(z, n, _) \
+ template <typename Derived, typename T, typename Selector> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ nary_node_base<Derived,T,Selector>::nary_node_base( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) : _children() \
+ , _data( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ , _parent() \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_NARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_NARY_NODE_MACRO
+
+#define BOOST_TREE_NODE_NARY_NODE_MACRO(z, n, _) \
+ template <typename Derived, typename T, typename Selector> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ nary_node_base<Derived,T,Selector>::nary_node_base( \
+ ::boost::container::allocator_arg_t \
+ , typename traits::allocator_reference allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) : _children(allocator) \
+ , _data( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+ , _parent() \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_NARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_NARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename Derived, typename T, typename Selector>
+ nary_node_base<Derived,T,Selector>::~nary_node_base()
+ {
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::clone_descendants(
+ Derived const& copy
+ )
+ {
+ this->_clone_descendants(copy);
+ this->_on_post_clone_or_move(
+ ::boost::is_reversible_selector<Selector>()
+ );
+ }
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::copy_assign(Derived const& copy)
+ {
+ Derived twin(copy._data);
+
+ twin._clone_descendants(copy);
+ this->_children.clear();
+ this->_clone_descendants(twin);
+ this->clone_metadata(copy);
+ this->_data = twin._data;
+ }
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::move_descendants(
+ BOOST_RV_REF(Derived) source
+ )
+ {
+#if defined BOOST_NO_RVALUE_REFERENCES
+ this->_move_descendants(source);
+#else
+ this->_move_descendants(static_cast<Derived&&>(source));
+#endif
+ this->_on_post_clone_or_move(
+ ::boost::is_reversible_selector<Selector>()
+ );
+ source._on_post_outsourced(Selector());
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::copy_assign(
+ BOOST_COPY_ASSIGN_REF(Derived) copy
+ )
+ {
+ Derived twin(copy._data);
+
+ twin._clone_descendants(static_cast<Derived const&>(copy));
+ this->_children.clear();
+ this->_move_descendants(::boost::move(twin));
+ this->clone_metadata(copy);
+ this->_data = ::boost::move(twin._data);
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::move_assign(
+ BOOST_RV_REF(Derived) source
+ )
+ {
+ this->_children.clear();
+#if defined BOOST_NO_RVALUE_REFERENCES
+ this->_move_descendants(source);
+ this->move_metadata(source);
+#else
+ this->_move_descendants(static_cast<Derived&&>(source));
+ this->move_metadata(static_cast<Derived&&>(source));
+#endif
+ this->_on_post_clone_or_move(
+ ::boost::is_reversible_selector<Selector>()
+ );
+ this->_data = ::boost::move(source._data);
+ source._on_post_outsourced(Selector());
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename Derived, typename T, typename Selector>
+ inline void nary_node_base<Derived,T,Selector>::on_post_assign()
+ {
+ if (this->_parent)
+ {
+ this->_parent->on_post_propagate_value(data_key());
+ }
+ }
+
+ 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>::operator[](data_key const&) const
+ {
+ return this->_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>::operator[](data_key const&)
+ {
+ return this->_data;
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename Derived, typename T, typename Selector>
+ template <typename FusionKey>
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ nary_node_base<Derived,T,Selector>::operator[](FusionKey const&) const
+ {
+ return ::boost::fusion::at_key<FusionKey>(this->_data);
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename FusionKey>
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ nary_node_base<Derived,T,Selector>::operator[](FusionKey const&)
+ {
+ return ::boost::fusion::at_key<FusionKey>(this->_data);
+ }
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+ 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 this->_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 this->_parent;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::const_iterator
+ nary_node_base<Derived,T,Selector>::cbegin() const
+ {
+ return this->_children.cbegin();
+ }
+
+ 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 this->_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 this->_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>::cend() const
+ {
+ return this->_children.cend();
+ }
+
+ 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 this->_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 this->_children.end();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::const_reverse_iterator
+ nary_node_base<Derived,T,Selector>::crbegin() const
+ {
+ return this->_children.crbegin();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::const_reverse_iterator
+ nary_node_base<Derived,T,Selector>::rbegin() const
+ {
+ return this->_children.rbegin();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::reverse_iterator
+ nary_node_base<Derived,T,Selector>::rbegin()
+ {
+ return this->_children.rbegin();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::const_reverse_iterator
+ nary_node_base<Derived,T,Selector>::crend() const
+ {
+ return this->_children.crend();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::const_reverse_iterator
+ nary_node_base<Derived,T,Selector>::rend() const
+ {
+ return this->_children.rend();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::reverse_iterator
+ nary_node_base<Derived,T,Selector>::rend()
+ {
+ return this->_children.rend();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::size_type
+ nary_node_base<Derived,T,Selector>::size() const
+ {
+ return this->_children.size();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline bool nary_node_base<Derived,T,Selector>::empty() const
+ {
+ return this->_children.empty();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void nary_node_base<Derived,T,Selector>::clear()
+ {
+ this->_children.clear();
+ this->on_post_clear();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::insert(Derived const& child)
+ {
+ Derived twin(child._data);
+
+ twin._clone_descendants(child);
+
+ typename ::boost::emplace_function_gen<Selector>::type emplacer;
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ ::std::pair<iterator,bool> p = emplacer(this->_children, twin._data);
+#else
+ ::std::pair<iterator,bool> p = emplacer(
+ this->_children
+ , ::boost::move(twin._data)
+ );
+#endif
+
+ if (p.second)
+ {
+ this->_on_post_insert(p.first, Selector());
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ (*p.first)._clone_descendants(twin);
+#else
+ (*p.first)._move_descendants(::boost::move(twin));
+#endif
+ (*p.first).clone_metadata(child);
+ (*p.first).on_post_inserted(
+ p.first
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ }
+ else
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "This type does not yet handle associative selectors."
+ );
+ }
+
+ return p.first;
+ }
+
+#if 0//!defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::insert(BOOST_RV_REF(Derived) child)
+ {
+ typename ::boost::emplace_function_gen<Selector>::type emplacer;
+ ::std::pair<iterator,bool> p = emplacer(
+ this->_children
+ , ::boost::move(child._data)
+ );
+
+ if (p.second)
+ {
+ this->_on_post_insert(p.first, Selector());
+#if defined BOOST_NO_RVALUE_REFERENCES
+ (*p.first)._move_descendants(child);
+ (*p.first).move_metadata(child);
+#else
+ (*p.first)._move_descendants(static_cast<Derived&&>(child));
+ (*p.first).move_metadata(static_cast<Derived&&>(child));
+#endif
+ (*p.first)._on_post_clone_or_move(
+ ::boost::is_reversible_selector<Selector>()
+ );
+ (*p.first).on_post_inserted(
+ p.first
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ }
+ else
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "This type does not yet handle associative selectors."
+ );
+ }
+
+ return p.first;
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Derived, typename T, typename Selector>
+ template <typename ...Args>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::emplace(Args&& ...args)
+ {
+ typename ::boost::emplace_function_gen<Selector>::type emplacer;
+ ::std::pair<iterator,bool> p = emplacer(
+ this->_children
+ , ::boost::forward<Args>(args)...
+ );
+
+ if (p.second)
+ {
+ this->_on_post_insert(p.first, Selector());
+ (*p.first).on_post_inserted(
+ p.first
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ }
+ else
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "This type does not yet handle associative selectors."
+ );
+ }
+
+ return p.first;
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_NARY_NODE_MACRO(z, n, _) \
+ template <typename Derived, typename T, typename Selector> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ inline typename nary_node_base<Derived,T,Selector>::iterator \
+ nary_node_base<Derived,T,Selector>::emplace( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename ::boost::emplace_function_gen<Selector>::type emplacer; \
+ ::std::pair<iterator,bool> p = emplacer( \
+ this->_children \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ if (p.second) \
+ { \
+ this->_on_post_insert(p.first, Selector()); \
+ (*p.first).on_post_inserted( \
+ p.first \
+ , ::boost::has_stable_iterators_selector<Selector>() \
+ ); \
+ } \
+ else \
+ { \
+ BOOST_ASSERT_MSG( \
+ false \
+ , "This type does not yet handle associative selectors." \
+ ); \
+ } \
+ return p.first; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_NARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_NARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ nary_node_base<Derived,T,Selector>::splice(iterator pos, Derived& node)
+ {
+ typename ::boost::insert_range_result_gen<
+ Selector
+ , Derived
+ >::type result = this->_splice(
+ pos
+ , node
+ , ::boost::begin(node._children)
+ , ::boost::end(node._children)
+ , typename ::boost::mpl::if_<
+ ::boost::is_ptr_selector<Selector>
+ , ::boost::mpl::false_
+ , ::boost::is_random_access_selector<Selector>
+ >::type()
+ );
+
+ node.on_post_clear();
+ this->on_post_insert(
+ ::boost::begin(result)
+ , ::boost::end(result)
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ return result;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ nary_node_base<Derived,T,Selector>::splice(
+ iterator pos
+ , Derived& node
+ , iterator itr
+ )
+ {
+ iterator itr_end = itr;
+ return this->splice(
+ pos
+ , node
+ , itr
+ , ++itr_end
+ );
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ nary_node_base<Derived,T,Selector>::splice(
+ iterator pos
+ , Derived& node
+ , iterator itr
+ , iterator itr_end
+ )
+ {
+ typename ::boost::insert_range_result_gen<
+ Selector
+ , Derived
+ >::type result = this->_splice(
+ pos
+ , node
+ , itr
+ , itr_end
+ , typename ::boost::mpl::if_<
+ ::boost::is_ptr_selector<Selector>
+ , ::boost::mpl::false_
+ , ::boost::is_random_access_selector<Selector>
+ >::type()
+ );
+
+ node.on_post_erase();
+ this->on_post_insert(
+ ::boost::begin(result)
+ , ::boost::end(result)
+ , ::boost::has_stable_iterators_selector<Selector>()
+ );
+ return result;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ void
+ nary_node_base<Derived,T,Selector>::_link_children_to_parent(
+ pointer const& p
+ , iterator itr
+ , iterator itr_end
+ )
+ {
+ for (; itr != itr_end; ++itr)
+ {
+ (*itr)._parent = p;
+ }
+ }
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename Derived, typename T, typename Selector>
+ template <typename ...Args>
+ inline typename nary_node_base<Derived,T,Selector>::iterator
+ nary_node_base<Derived,T,Selector>::_add_child(Args&& ...args)
+ {
+ typename ::boost::emplace_function_gen<Selector>::type emplacer;
+ ::std::pair<iterator,bool> p = emplacer(
+ this->_children
+ , ::boost::forward<Args>(args)...
+ );
+
+ if (p.second)
+ {
+ (*p.first)._parent = this->get_derived();
+ }
+ else
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "This type does not yet handle associative selectors."
+ );
+ }
+
+ return p.first;
+ }
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_NARY_NODE_MACRO(z, n, _) \
+ template <typename Derived, typename T, typename Selector> \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ inline typename nary_node_base<Derived,T,Selector>::iterator \
+ nary_node_base<Derived,T,Selector>::_add_child( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+ { \
+ typename ::boost::emplace_function_gen<Selector>::type emplacer; \
+ ::std::pair<iterator,bool> p = emplacer( \
+ this->_children \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ); \
+ if (p.second) \
+ { \
+ (*p.first)._parent = this->get_derived(); \
+ } \
+ else \
+ { \
+ BOOST_ASSERT_MSG( \
+ false \
+ , "This type does not yet handle associative selectors." \
+ ); \
+ } \
+ return p.first; \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_NARY_NODE_MACRO
+ , _
+ )
+#undef BOOST_TREE_NODE_NARY_NODE_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::_clone_descendants(
+ Derived const& copy
+ )
+ {
+ this->_clone_descendants(
+ copy
+ , typename ::boost::mpl::if_<
+ ::boost::is_ptr_selector<Selector>
+ , ::boost::mpl::false_
+ , ::boost::is_random_access_selector<Selector>
+ >::type()
+ );
+ this->get_derived()->on_post_copy_or_move();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ void
+ nary_node_base<Derived,T,Selector>::_clone_descendants(
+ Derived const& copy
+ , ::boost::mpl::true_
+ )
+ {
+ pointer p = this->get_derived();
+ ::std::deque<size_type> indices;
+ size_type current_index = ::boost::initialized_value;
+
+ p->_children.resize(copy._children.size(), Derived(copy._data));
+ p->_on_post_resize(Selector());
+
+ for (
+ depth_first_descendant_iterator<Derived const> itr(copy);
+ itr;
+ ++itr
+ )
+ {
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ p->_children[current_index]._parent = p;
+ p = &p->_children[current_index];
+ indices.push_back(current_index);
+ p->_children.clear();
+ p->_children.resize(
+ (*itr)._children.size()
+ , Derived((*itr)._data)
+ );
+ p->_on_post_resize(Selector());
+ p->_data = (*itr)._data;
+ p->clone_metadata(*itr);
+ current_index = ::boost::initialized_value;
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ p->on_post_copy_or_move();
+ p = p->get_parent_ptr();
+ ++(current_index = indices.back());
+ indices.pop_back();
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "itr not at-the-end");
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ void
+ nary_node_base<Derived,T,Selector>::_clone_descendants(
+ Derived const& copy
+ , ::boost::mpl::false_
+ )
+ {
+ pointer p = this->get_derived();
+
+ for (
+ depth_first_descendant_iterator<Derived const> itr(copy);
+ itr;
+ ++itr
+ )
+ {
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ p = &*p->_add_child((*itr)._data);
+ p->clone_metadata(*itr);
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ p->on_post_copy_or_move();
+ p = p->get_parent_ptr();
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "itr not at-the-end");
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::_move_descendants(
+ BOOST_RV_REF(Derived) source
+ )
+ {
+ this->_move_descendants(
+ static_cast<Derived&>(source)
+ , ::boost::is_ptr_selector<Selector>()
+ );
+ this->get_derived()->on_post_copy_or_move();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::_move_descendants(
+ Derived& source
+ , ::boost::mpl::true_
+ )
+ {
+ this->_children.transfer(this->_children.begin(), source._children);
+ self::_link_children_to_parent(
+ this->get_derived()
+ , this->_children.begin()
+ , this->_children.end()
+ );
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::_move_descendants(
+ Derived& source
+ , ::boost::mpl::false_
+ )
+ {
+ this->_move_descendants_non_ptr(
+ source
+ , ::boost::is_random_access_selector<Selector>()
+ );
+ source._children.clear();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ void
+ nary_node_base<Derived,T,Selector>::_move_descendants_non_ptr(
+ Derived& source
+ , ::boost::mpl::true_
+ )
+ {
+ pointer p = this->get_derived();
+ ::std::deque<size_type> indices;
+ size_type current_index = ::boost::initialized_value;
+
+ p->_children.resize(source._children.size(), Derived(this->_data));
+ p->_on_post_resize(Selector());
+
+ for (depth_first_descendant_iterator<Derived> itr(source); itr; ++itr)
+ {
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ p->_children[current_index]._parent = p;
+ p = &p->_children[current_index];
+ indices.push_back(current_index);
+ p->_children.clear();
+ p->_children.resize(
+ (*itr)._children.size()
+ , Derived((*itr)._data)
+ );
+ p->_on_post_resize(Selector());
+ p->_data = ::boost::move((*itr)._data);
+ p->move_metadata(::boost::move(*itr));
+ current_index = ::boost::initialized_value;
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ (*itr)._children.clear();
+ p->on_post_copy_or_move();
+ p = p->get_parent_ptr();
+ ++(current_index = indices.back());
+ indices.pop_back();
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "itr not at-the-end");
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ void
+ nary_node_base<Derived,T,Selector>::_move_descendants_non_ptr(
+ Derived& source
+ , ::boost::mpl::false_
+ )
+ {
+ pointer p = this->get_derived();
+
+ for (depth_first_descendant_iterator<Derived> itr(source); itr; ++itr)
+ {
+ switch (::boost::tree_node::traversal_state(itr))
+ {
+ case ::boost::tree_node::pre_order_traversal:
+ {
+ p = &*p->_add_child(::boost::move((*itr)._data));
+ p->move_metadata(::boost::move(*itr));
+ break;
+ }
+
+ case ::boost::tree_node::post_order_traversal:
+ {
+ p->on_post_copy_or_move();
+ p = p->get_parent_ptr();
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT_MSG(
+ false
+ , "traversal_state must be pre- or post-order!"
+ );
+ }
+ }
+ }
+
+ BOOST_ASSERT_MSG(p == this->get_derived(), "itr not at-the-end");
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename A>
+ inline void
+ nary_node_base<Derived,T,Selector>::_on_post_insert(
+ iterator to_child
+ , ::boost::vector_selector< ::boost::mpl::true_,A>
+ )
+ {
+ self::_link_children_to_parent(
+ this->get_derived()
+ , this->_children.begin()
+ , this->_children.end()
+ );
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename A>
+ inline void
+ nary_node_base<Derived,T,Selector>::_on_post_resize(
+ ::boost::vector_selector< ::boost::mpl::true_,A>
+ )
+ {
+ self::_link_children_to_parent(
+ this->get_derived()
+ , this->_children.begin()
+ , this->_children.end()
+ );
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename A>
+ inline void
+ nary_node_base<Derived,T,Selector>::_on_post_outsourced(
+ ::boost::stable_vector_selector<A>
+ )
+ {
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename S>
+ inline void
+ nary_node_base<Derived,T,Selector>::_on_post_insert(
+ iterator to_child
+ , S
+ )
+ {
+ (*to_child)._parent = this->get_derived();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename S>
+ inline void
+ nary_node_base<Derived,T,Selector>::_on_post_resize(S)
+ {
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ template <typename S>
+ inline void nary_node_base<Derived,T,Selector>::_on_post_outsourced(S)
+ {
+ this->on_post_clear();
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::_on_post_clone_or_move(
+ ::boost::mpl::true_
+ )
+ {
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ void
+ nary_node_base<Derived,T,Selector>::_on_post_clone_or_move(
+ ::boost::mpl::false_
+ )
+ {
+ for (
+ post_order_iterator<Derived> itr(*this->get_derived());
+ itr;
+ ++itr
+ )
+ {
+ (*itr)._children.reverse();
+ }
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ nary_node_base<Derived,T,Selector>::_splice(
+ iterator pos
+ , Derived& node
+ , iterator itr
+ , iterator itr_end
+ , ::boost::mpl::true_
+ )
+ {
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ size_type const result_size = ::std::distance(itr, itr_end);
+ iterator result_itr = this->_children.insert(pos, itr, itr_end);
+
+ node._children.erase(itr, itr_end);
+ self::_link_children_to_parent(
+ this->get_derived()
+ , this->_children.begin()
+ , this->_children.end()
+ );
+ this->get_derived()->on_post_copy_or_move();
+ return ::std::pair<iterator,iterator>(
+ result_itr
+ , result_itr + result_size
+ );
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#if 1
+ size_type const result_size = ::std::distance(itr, itr_end);
+ iterator result_itr = this->_children.insert(
+ pos
+ , ::boost::move_iterator<iterator>(itr)
+ , ::boost::move_iterator<iterator>(itr_end)
+ );
+
+ node._children.erase(itr, itr_end);
+ self::_link_children_to_parent(
+ this->get_derived()
+ , this->_children.begin()
+ , this->_children.end()
+ );
+ this->get_derived()->on_post_copy_or_move();
+ return ::std::pair<iterator,iterator>(
+ result_itr
+ , result_itr + result_size
+ );
+#else
+ iterator result_itr = this->_children.insert(
+ pos
+ , ::std::distance(itr, itr_end)
+ , Derived(this->_data)
+ );
+
+ pos = result_itr;
+
+ for (iterator e_itr = itr; e_itr != itr_end; ++e_itr)
+ {
+ (*pos)._parent = this->get_derived();
+ (*pos)._data = ::boost::move((*e_itr)._data);
+ (*pos)._move_descendants_non_ptr(*e_itr, ::boost::mpl::true_());
+ (*pos).move_metadata(::boost::move(*e_itr));
+ (*pos).on_post_copy_or_move();
+ ++pos;
+ }
+
+ node._children.erase(itr, itr_end);
+ self::_link_children_to_parent(
+ this->get_derived()
+ , this->_children.begin()
+ , this->_children.end()
+ );
+ this->get_derived()->on_post_copy_or_move();
+ return ::std::pair<iterator,iterator>(result_itr, pos);
+#endif
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename ::boost::insert_range_result_gen<Selector,Derived>::type
+ nary_node_base<Derived,T,Selector>::_splice(
+ iterator pos
+ , Derived& node
+ , iterator itr
+ , iterator itr_end
+ , ::boost::mpl::false_
+ )
+ {
+ typename ::boost::splice_function_gen<Selector>::type splicer;
+ typename ::boost::insert_range_result_gen<
+ Selector
+ , Derived
+ >::type result = splicer(
+ this->_children
+ , pos
+ , node._children
+ , itr
+ , itr_end
+ );
+
+ self::_link_children_to_parent(
+ this->get_derived()
+ , ::boost::begin(result)
+ , ::boost::end(result)
+ );
+ return result;
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline void
+ nary_node_base<Derived,T,Selector>::_on_post_modify_value(
+ data_key const& key
+ )
+ {
+ this->on_post_propagate_value(key);
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <typename Derived, typename T, typename Selector>
+ template <typename FusionKey>
+ inline void
+ nary_node_base<Derived,T,Selector>::_on_post_modify_value(
+ FusionKey const& key
+ )
+ {
+ this->on_post_propagate_value(key);
+ }
+#endif
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<
+ Derived
+ , T
+ , Selector
+ >::traits::data_type const&
+ get(
+ nary_node_base<Derived,T,Selector> const& node
+ , data_key const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <typename Derived, typename T, typename Selector>
+ inline typename nary_node_base<Derived,T,Selector>::traits::data_type&
+ get(nary_node_base<Derived,T,Selector>& node, data_key const& key)
+ {
+ return node[key];
+ }
+
+#if !defined BOOST_NO_SFINAE
+ template <typename Key, typename Derived, typename T, typename Selector>
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,data_key>
+ , typename nary_node_base<
+ Derived
+ , T
+ , Selector
+ >::traits::data_type const&
+ >::type
+ get(nary_node_base<Derived,T,Selector> const& node)
+ {
+ return node[data_key()];
+ }
+
+ template <typename Key, typename Derived, typename T, typename Selector>
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,data_key>
+ , typename nary_node_base<
+ Derived
+ , T
+ , Selector
+ >::traits::data_type&
+ >::type
+ get(nary_node_base<Derived,T,Selector>& node)
+ {
+ return node[data_key()];
+ }
+#endif // BOOST_NO_SFINAE
+
+ template <typename Derived, typename T, typename Selector, typename V>
+ inline void
+ put(
+ nary_node_base<Derived,T,Selector>& node
+ , data_key const& key
+ , V const& value
+ )
+ {
+ node[key] = value;
+ node._on_post_modify_value(key);
+ }
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ template <
+ typename Derived
+ , typename T
+ , typename Selector
+ , typename FusionKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ get(
+ nary_node_base<Derived,T,Selector> const& node
+ , FusionKey const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <
+ typename Derived
+ , typename T
+ , typename Selector
+ , typename FusionKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ get(nary_node_base<Derived,T,Selector>& node, FusionKey const& key)
+ {
+ return node[key];
+ }
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename T
+ , typename Selector
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ get(nary_node_base<Derived,T,Selector> const& node)
+ {
+ return node[FusionKey()];
+ }
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename T
+ , typename Selector
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ get(nary_node_base<Derived,T,Selector>& node)
+ {
+ return node[FusionKey()];
+ }
+
+ template <
+ typename Derived
+ , typename T
+ , typename Selector
+ , typename FusionKey
+ , typename V
+ >
+ inline void
+ put(
+ nary_node_base<Derived,T,Selector>& node
+ , FusionKey const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type
+ )
+ {
+ node[key] = value;
+ node._on_post_modify_value(key);
+ }
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+}} // namespace boost::tree_node
+
+//[reference__nary_node_base_gen
+namespace boost { namespace tree_node {
+
+ template <typename Selector = ::boost::ptr_dequeS>
+ struct nary_node_base_gen
+ {
+ template <typename Derived, typename T>
+ struct apply
+ {
+ typedef nary_node_base<Derived,T,Selector> type;
+ };
+ };
+
+ typedef nary_node_base_gen<> nary_node_base_default_gen;
+}} // namespace boost::tree_node
+//]
+
+namespace boost { namespace tree_node {
+
+ template <typename T, typename Selector>
+ struct nary_node
+ : public
+ //[reference__nary_node__bases
+ nary_node_base<nary_node<T,Selector>,T,Selector>
+ //]
+ {
+ //[reference__nary_node__super_t
+ typedef nary_node_base<nary_node,T,Selector>
+ super_t;
+ //]
+
+ //[reference__nary_node__traits
+ typedef typename super_t::traits
+ traits;
+ //]
+
+ //[reference__nary_node__pointer
+ typedef typename super_t::pointer
+ pointer;
+ //]
+
+ //[reference__nary_node__const_pointer
+ typedef typename super_t::const_pointer
+ const_pointer;
+ //]
+
+ //[reference__nary_node__iterator
+ typedef typename super_t::iterator
+ iterator;
+ //]
+
+ //[reference__nary_node__const_iterator
+ typedef typename super_t::const_iterator
+ const_iterator;
+ //]
+
+ //[reference__nary_node__reverse_iterator
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ //]
+
+ //[reference__nary_node__const_reverse_iterator
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ //]
+
+ //[reference__nary_node__size_type
+ typedef typename super_t::size_type
+ size_type;
+ //]
+
+ BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(nary_node, super_t)
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__nary_node__emplacement_ctor
+ template <typename ...Args>
+ explicit nary_node(Args&& ...args);
+ //]
+
+ //[reference__nary_node__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit nary_node(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF
+ , (nary_node, super_t)
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF
+ , (nary_node, super_t)
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+ };
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename T, typename Selector>
+ template <typename ...Args>
+ inline nary_node<T,Selector>::nary_node(Args&& ...args)
+ : super_t(::boost::forward<Args>(args)...)
+ {
+ }
+
+ template <typename T, typename Selector>
+ template <typename ...Args>
+ inline nary_node<T,Selector>::nary_node(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ {
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+}} // namespace boost::tree_node
+
+//[reference__nary_node_gen
+namespace boost { namespace tree_node {
+
+ template <typename Selector = ::boost::ptr_dequeS>
+ struct nary_node_gen
+ {
+ template <typename T>
+ struct apply
+ {
+ typedef nary_node<T,Selector> type;
+ };
+ };
+
+ typedef nary_node_gen<> nary_node_default_gen;
+}} // namespace boost::tree_node
+//]
+
+#include <boost/tree_node/_detail/config_end.hpp>
+
+#endif // BOOST_TREE_NODE_NARY_NODE_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/nary_node_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/nary_node_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,254 @@
+// Copyright (C) 2013 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_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_NARY_NODE_FWD_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/container_gen/selectors.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/key/data.hpp>
+
+#if !defined BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/tr1/type_traits.hpp>
+#endif
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/fusion/sequence/intrinsic/has_key.hpp>
+#include <boost/fusion/support/is_sequence.hpp>
+#include <boost/fusion/support/category_of.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#endif
+
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector>
+ class nary_node_base;
+
+ template <typename T, typename Selector = ::boost::ptr_dequeS>
+ struct nary_node;
+}} // namespace boost::tree_node
+
+//[reference__nary_node_base__at_data_key__const
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector>
+ typename nary_node_base<
+ Derived
+ , T
+ , Selector
+ >::traits::data_type const&
+ get(
+ nary_node_base<Derived,T,Selector> const& node
+ , data_key const& key
+ );
+
+//<-
+#if defined BOOST_NO_SFINAE
+//->
+ template <typename Key, typename Derived, typename T, typename Selector>
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,data_key>
+ , typename nary_node_base<
+ Derived
+ , T
+ , Selector
+ >::traits::data_type const&
+ >::type
+ get(nary_node_base<Derived,T,Selector> const& node);
+//<-
+#endif // BOOST_NO_SFINAE
+//->
+}} // namespace boost::tree_node
+//]
+
+//[reference__nary_node_base__at_data_key
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector>
+ typename nary_node_base<Derived,T,Selector>::traits::data_type&
+ get(nary_node_base<Derived,T,Selector>& node, data_key const& key);
+
+//<-
+#if defined BOOST_NO_SFINAE
+//->
+ template <typename Key, typename Derived, typename T, typename Selector>
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,data_key>
+ , typename nary_node_base<
+ Derived
+ , T
+ , Selector
+ >::traits::data_type&
+ >::type
+ get(nary_node_base<Derived,T,Selector>& node);
+//<-
+#endif // BOOST_NO_SFINAE
+//->
+}} // namespace boost::tree_node
+//]
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+//[reference__nary_node_base__at_key__const
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Selector
+ , typename FusionKey
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ get(
+ nary_node_base<Derived,T,Selector> const& node
+ , FusionKey const& key
+ );
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename T
+ , typename Selector
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T const,FusionKey>
+ >::type
+ get(nary_node_base<Derived,T,Selector> const& node);
+}} // namespace boost::tree_node
+//]
+
+//[reference__nary_node_base__at_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Selector
+ , typename FusionKey
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ get(nary_node_base<Derived,T,Selector>& node, FusionKey const& key);
+
+ template <
+ typename FusionKey
+ , typename Derived
+ , typename T
+ , typename Selector
+ >
+ typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::fusion::result_of::at_key<T,FusionKey>
+ >::type
+ get(nary_node_base<Derived,T,Selector>& node);
+}} // namespace boost::tree_node
+//]
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+//[reference__nary_node_base__put_data
+namespace boost { namespace tree_node {
+
+ template <typename Derived, typename T, typename Selector, typename V>
+ void
+ put(
+ nary_node_base<Derived,T,Selector>& node
+ , data_key const& key
+ , V const& value
+ );
+}} // namespace boost::tree_node
+//]
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+//[reference__nary_node_base__put
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename T
+ , typename Selector
+ , typename FusionKey
+ , typename V
+ >
+ void
+ put(
+ nary_node_base<Derived,T,Selector>& node
+ , FusionKey const& key
+ , V const& value
+ , typename ::boost::enable_if<
+ typename ::boost::mpl::if_<
+ typename ::boost::mpl::eval_if<
+ typename ::boost::fusion::traits::is_sequence<T>::type
+ , ::boost::fusion::traits::is_associative<T>
+ , ::boost::mpl::false_
+ >::type
+ , result_of::has_key<
+ nary_node_base<Derived,T,Selector>
+ , FusionKey
+ >
+ , ::boost::mpl::false_
+ >::type
+ , ::boost::mpl::true_
+ >::type = ::boost::mpl::true_()
+ );
+}} // namespace boost::tree_node
+//]
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+#endif // BOOST_TREE_NODE_NARY_NODE_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/preprocessor.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/preprocessor.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,445 @@
+// Copyright (C) 2012-2013 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_PREPROCESSOR_HPP_INCLUDED
+#define BOOST_TREE_NODE_PREPROCESSOR_HPP_INCLUDED
+
+#include <boost/config.hpp>
+
+#if !defined BOOST_NO_SFINAE \
+ && !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION \
+ && !defined BOOST_TREE_NODE_CAN_USE_FUSION
+#define BOOST_TREE_NODE_CAN_USE_FUSION
+#endif
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION \
+ && defined BOOST_TYPEOF_NATIVE \
+ && !defined BOOST_TREE_NODE_CAN_USE_FUSION_WITH_TYPEOF
+#define BOOST_TREE_NODE_CAN_USE_FUSION_WITH_TYPEOF
+#endif
+
+#include <boost/container/scoped_allocator_fwd.hpp>
+#include <boost/container/detail/workaround.hpp>
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum_trailing.hpp>
+#include <boost/preprocessor/control/expr_if.hpp>
+#include <boost/preprocessor/control/expr_iif.hpp>
+#include <boost/preprocessor/comparison/equal.hpp>
+#include <boost/preprocessor/arithmetic/dec.hpp>
+#include <boost/preprocessor/tuple/elem.hpp>
+#include <boost/container/detail/preprocessor.hpp>
+
+//[reference__macro__emplacement_ctor_header
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_HEADER(z, n, Type) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ BOOST_PP_EXPR_IIF(BOOST_PP_EQUAL(n, 1), explicit) \
+ Type( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+//]
+
+//[reference__macro__emplacement_ctor_fwd_decl
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_FWD_DECL(z, n, Type) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_HEADER(z, n, Type); \
+//]
+
+//[reference__macro__emplacement_ctor_base_fwd
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_BASE_FWD(z, n, Base) \
+ : Base( \
+ BOOST_PP_CAT(BOOST_PP_ENUM_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+//]
+
+//[reference__macro__emplacement_ctor_inline_header
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_HEADER(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_HEADER( \
+ z \
+ , n \
+ , BOOST_PP_TUPLE_ELEM(2, 0, Tuple) \
+ ) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_BASE_FWD( \
+ z \
+ , n \
+ , BOOST_PP_TUPLE_ELEM(2, 1, Tuple) \
+ ) \
+//]
+
+//[reference__macro__emplacement_ctor_inline_def
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_HEADER(z, n, Tuple) \
+ { \
+ Base::on_post_emplacement_construct(); \
+ } \
+//]
+
+//[reference__macro__emplacement_ctor_w_alloc_header
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_HEADER(z, n, Type) \
+ BOOST_PP_EXPR_IF(n, template <) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename P) \
+ BOOST_PP_EXPR_IF(n, >) \
+ BOOST_PP_EXPR_IIF(BOOST_PP_EQUAL(n, 1), explicit) \
+ Type( \
+ ::boost::container::allocator_arg_t \
+ , typename traits::allocator_reference allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_LIST \
+ , _ \
+ ) \
+ ) \
+//]
+
+//[reference__macro__emplacement_ctor_w_alloc_fwd_decl
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_FWD_DECL(z, n, Type) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_HEADER(z, n, Type); \
+//]
+
+//[reference__macro__emplacement_ctor_w_alloc_base_fwd
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_BASE_FWD(z, n, Base) \
+ : Base( \
+ ::boost::container::allocator_arg \
+ , allocator \
+ BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, z)( \
+ n \
+ , BOOST_CONTAINER_PP_PARAM_FORWARD \
+ , _ \
+ ) \
+ ) \
+//]
+
+//[reference__macro__emplacement_ctor_w_alloc_inline_header
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_HEADER(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_HEADER( \
+ z \
+ , n \
+ , BOOST_PP_TUPLE_ELEM(2, 0, Tuple) \
+ ) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_BASE_FWD( \
+ z \
+ , n \
+ , BOOST_PP_TUPLE_ELEM(2, 1, Tuple) \
+ ) \
+//]
+
+//[reference__macro__emplacement_ctor_w_alloc_inline_def
+#define BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_HEADER(z, n, Tuple) \
+ { \
+ Base::on_post_emplacement_construct(); \
+ } \
+//]
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+//[reference__macro__copy_constructible
+#define BOOST_TREE_NODE_COPY_CONSTRUCTIBLE(Derived, Base) \
+ inline Derived(Derived const& copy) : Base(copy) \
+ { \
+ Base::clone_descendants(copy); \
+ } \
+ inline Derived( \
+ Derived const& copy \
+ , typename traits::allocator_reference a \
+ ) : Base(copy, a) \
+ { \
+ Base::clone_descendants(copy); \
+ } \
+ inline Derived(Derived& copy) \
+ : Base(const_cast<Derived const&>(copy)) \
+ { \
+ Base::clone_descendants(copy); \
+ } \
+ inline Derived( \
+ Derived& copy \
+ , typename traits::allocator_reference a \
+ ) : Base(const_cast<Derived const&>(copy), a) \
+ { \
+ Base::clone_descendants(copy); \
+ } \
+//]
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(Derived, Base) \
+ BOOST_TREE_NODE_COPY_CONSTRUCTIBLE(Derived, Base) \
+ inline Derived& operator=(Derived const& copy) \
+ { \
+ if (this != &copy) \
+ { \
+ Base::copy_assign(copy); \
+ Base::on_post_assign(); \
+ } \
+ return *this; \
+ } \
+ inline Derived& operator=(Derived& copy) \
+ { \
+ if (this != &copy) \
+ { \
+ Base::copy_assign(const_cast<Derived const&>(copy)); \
+ Base::on_post_assign(); \
+ } \
+ return *this; \
+ } \
+//!
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#if defined BOOST_NO_RVALUE_REFERENCES
+#include <boost/move/move.hpp>
+#define BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(Derived, Base) \
+ BOOST_TREE_NODE_COPY_CONSTRUCTIBLE(Derived, Base) \
+ inline Derived(::boost::rv<Derived>& source) : Base(source) \
+ { \
+ Base::move_descendants(source); \
+ } \
+ inline Derived( \
+ ::boost::rv<Derived>& source \
+ , typename traits::allocator_reference a \
+ ) : Base(source, a) \
+ { \
+ Base::move_descendants(source); \
+ } \
+ inline operator ::boost::rv<Derived> const&() const \
+ { \
+ return *static_cast< ::boost::rv<Derived> const*>(this); \
+ } \
+ inline operator ::boost::rv<Derived>&() \
+ { \
+ return *static_cast< ::boost::rv<Derived>*>(this); \
+ } \
+ inline Derived& operator=(::boost::rv<Derived> const& ca_ref) \
+ { \
+ Derived const& copy = static_cast<Derived const&>(ca_ref); \
+ if (this != &copy) \
+ { \
+ Base::copy_assign(copy); \
+ Base::on_post_assign(); \
+ } \
+ return *this; \
+ } \
+ inline Derived& operator=(::boost::rv<Derived>& rv_ref) \
+ { \
+ if (this != &static_cast<Derived&>(rv_ref)) \
+ { \
+ Base::move_assign(rv_ref); \
+ Base::on_post_assign(); \
+ } \
+ return *this; \
+ } \
+ inline Derived& operator=(Derived& copy) \
+ { \
+ if (this != &copy) \
+ { \
+ Base::copy_assign(const_cast<Derived const&>(copy)); \
+ Base::on_post_assign(); \
+ } \
+ return *this; \
+ } \
+//!
+#else // !defined BOOST_NO_RVALUE_REFERENCES
+//[reference__macro__copyable_and_movable
+#define BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(Derived, Base) \
+ BOOST_TREE_NODE_COPY_CONSTRUCTIBLE(Derived, Base) \
+ inline Derived(Derived&& source) \
+ : Base(static_cast<Derived&&>(source)) \
+ { \
+ Base::move_descendants(static_cast<Derived&&>(source)); \
+ } \
+ inline Derived( \
+ Derived&& source \
+ , typename traits::allocator_reference a \
+ ) : Base(static_cast<Derived&&>(source), a) \
+ { \
+ Base::move_descendants(static_cast<Derived&&>(source)); \
+ } \
+ inline Derived& operator=(Derived const& copy) \
+ { \
+ if (this != &copy) \
+ { \
+ Base::copy_assign(copy); \
+ Base::on_post_assign(); \
+ } \
+ return *this; \
+ } \
+ inline Derived& operator=(Derived&& source) \
+ { \
+ if (this != &static_cast<Derived&>(source)) \
+ { \
+ Base::move_assign(static_cast<Derived&&>(source)); \
+ Base::on_post_assign(); \
+ } \
+ return *this; \
+ } \
+//]
+#endif // BOOST_NO_RVALUE_REFERENCES
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+//[reference__macro__container_derived_impl
+#define BOOST_TREE_NODE_CONTAINER_DERIVED_IMPL(Derived, Base) \
+ typedef typename Base::reference reference; \
+ typedef typename Base::const_reference const_reference; \
+ typedef typename Base::pointer pointer; \
+ typedef typename Base::const_pointer const_pointer; \
+ typedef typename Base::iterator iterator; \
+ typedef typename Base::const_iterator const_iterator; \
+ typedef typename Base::size_type size_type; \
+ typedef typename Base::allocator_type allocator_type; \
+ inline Derived() : Base() \
+ { \
+ } \
+ inline explicit Derived(allocator_type const& a) : Base(a) \
+ { \
+ } \
+ inline Derived(Derived const& copy) \
+ : Base(static_cast<Base const&>(copy)) \
+ { \
+ } \
+ inline Derived(Derived const& copy, allocator_type const& a) \
+ : Base(static_cast<Base const&>(copy), a) \
+ { \
+ } \
+ inline Derived(Derived& copy) \
+ : Base( \
+ static_cast<Base const&>(const_cast<Derived const&>(copy)) \
+ ) \
+ { \
+ } \
+ inline Derived(Derived& copy, allocator_type const& a) \
+ : Base( \
+ static_cast<Base const&>(const_cast<Derived const&>(copy)) \
+ , a \
+ ) \
+ { \
+ } \
+//]
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#define BOOST_TREE_NODE_CONTAINER_DERIVED_BODY(Derived, Base) \
+ BOOST_TREE_NODE_CONTAINER_DERIVED_IMPL(Derived, Base) \
+ inline Derived& operator=(Derived const& copy) \
+ { \
+ if (this != &copy) \
+ { \
+ Base::operator=(const_cast<Base const&>(copy)); \
+ } \
+ return *this; \
+ } \
+ inline Derived& operator=(Derived& copy) \
+ { \
+ if (this != &copy) \
+ { \
+ Base::operator=(const_cast<Base const&>(copy)); \
+ } \
+ return *this; \
+ } \
+//!
+#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#if defined BOOST_NO_RVALUE_REFERENCES
+#include <boost/move/move.hpp>
+#define BOOST_TREE_NODE_CONTAINER_DERIVED_BODY(Derived, Base) \
+ BOOST_TREE_NODE_CONTAINER_DERIVED_IMPL(Derived, Base) \
+ inline Derived(::boost::rv<Derived>& source) \
+ : Base(::boost::move(static_cast<Base&>(source))) \
+ { \
+ } \
+ inline Derived( \
+ ::boost::rv<Derived>& source \
+ , allocator_type const& a \
+ ) : Base(::boost::move(static_cast<Base&>(source)), a) \
+ { \
+ } \
+ inline operator ::boost::rv<Derived> const&() const \
+ { \
+ return *static_cast< ::boost::rv<Derived> const*>(this); \
+ } \
+ inline operator ::boost::rv<Derived>&() \
+ { \
+ return *static_cast< ::boost::rv<Derived>*>(this); \
+ } \
+ inline Derived& operator=(::boost::rv<Derived> const& ca_ref) \
+ { \
+ Base const& copy = static_cast<Base const&>( \
+ static_cast<Derived const&>(ca_ref) \
+ ); \
+ if (this != &copy) \
+ { \
+ Base::operator=(copy); \
+ } \
+ return *this; \
+ } \
+ inline Derived& operator=(::boost::rv<Derived>& rv_ref) \
+ { \
+ if (this != &static_cast<Derived&>(rv_ref)) \
+ { \
+ Base::operator=(::boost::move(static_cast<Base&>(rv_ref))); \
+ } \
+ return *this; \
+ } \
+ inline Derived& operator=(Derived& copy) \
+ { \
+ if (this != &copy) \
+ { \
+ Base::operator=( \
+ static_cast<Base const&>( \
+ const_cast<Derived const&>(copy) \
+ ) \
+ ); \
+ } \
+ return *this; \
+ } \
+//!
+#else // !defined BOOST_NO_RVALUE_REFERENCES
+//[reference__macro__container_derived_body
+#define BOOST_TREE_NODE_CONTAINER_DERIVED_BODY(Derived, Base) \
+ BOOST_TREE_NODE_CONTAINER_DERIVED_IMPL(Derived, Base) \
+ inline Derived(Derived&& source) \
+ : Base(static_cast<Base&&>(source)) \
+ { \
+ } \
+ inline Derived(Derived&& source, allocator_type const& a) \
+ : Base(static_cast<Base&&>(source), a) \
+ { \
+ } \
+ inline Derived& operator=(Derived const& copy) \
+ { \
+ if (this != &copy) \
+ { \
+ Base::operator=(static_cast<Base const&>(copy)); \
+ } \
+ return *this; \
+ } \
+ inline Derived& operator=(Derived&& source) \
+ { \
+ if (this != &static_cast<Derived&>(source)) \
+ { \
+ Base::operator=(static_cast<Derived&&>(source)); \
+ } \
+ return *this; \
+ } \
+//]
+#endif // BOOST_NO_RVALUE_REFERENCES
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+//[reference__macro__associative_container_derived_body
+#define BOOST_TREE_NODE_ASSOCIATIVE_CONTAINER_DERIVED_BODY(Derived, Base) \
+ typedef typename Base::key_type key_type; \
+ typedef typename Base::value_type value_type; \
+ typedef typename Base::key_compare key_compare; \
+ typedef typename Base::value_compare value_compare; \
+ BOOST_TREE_NODE_CONTAINER_DERIVED_BODY(Derived, Base) \
+//]
+
+#endif // BOOST_TREE_NODE_PREPROCESSOR_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/traversal_state.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/traversal_state.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,24 @@
+// Copyright (C) 2011-2013 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
+#define BOOST_TREE_NODE_TRAVERSAL_STATE_HPP
+
+//[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
+

Added: sandbox/tree_node/boost/tree_node/with_accumulation.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_accumulation.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,2523 @@
+// Copyright (C) 2012-2013 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_ACCUMULATION_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_ACCUMULATION_HPP_INCLUDED
+
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/accumulators/framework/accumulator_set.hpp>
+#include <boost/accumulators/framework/extractor.hpp>
+#include <boost/accumulators/framework/features.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/with_accumulation_fwd.hpp>
+#include <boost/tree_node/key/accumulation.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/get_keys.hpp>
+#include <boost/tree_node/intrinsic/at_key.hpp>
+#include <boost/tree_node/iterator/breadth_first_descendant.hpp>
+#include <boost/tree_node/iterator/dereference.hpp>
+#include <boost/assert.hpp>
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/_detail/config_begin.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/mpl/vector.hpp>
+#include <boost/move/move.hpp>
+#include <boost/type_traits/is_pod.hpp>
+
+namespace boost {
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename AccumulationKey
+ >
+ struct is_POD<
+ ::boost::tree_node::with_accumulation<
+ BaseGenerator
+ , T1
+ , T2
+ , AccumulationKey
+ >
+ > : ::boost::false_type
+ {
+ };
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename AccumulationKey
+ >
+ struct is_pod<
+ ::boost::tree_node::with_accumulation<
+ BaseGenerator
+ , T1
+ , T2
+ , AccumulationKey
+ >
+ > : ::boost::false_type
+ {
+ };
+} // namespace boost
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ class with_accumulation_base
+ : public
+ //[reference__with_accumulation_base__bases
+ ::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
+ //]
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , public accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+#endif
+ , private ::boost::noncopyable
+ {
+ friend struct tree_node_base<Derived>;
+
+ typedef with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ self;
+
+ public:
+ 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;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ private:
+ typedef typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<Value>
+ , result_of::value_at_key<self,Key>
+ , ::boost::mpl::identity<Value>
+ >::type
+ AccumulationValue;
+
+ AccumulationValue _accumulation;
+
+ protected:
+ //[reference__with_accumulation_base__derived_copy_ctor
+ with_accumulation_base(Derived const& copy);
+ //]
+
+ //[reference__with_accumulation_base__derived_copy_ctor_w_allocator
+ with_accumulation_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ );
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ with_accumulation_base(BOOST_RV_REF(Derived) source);
+
+ with_accumulation_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ );
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_accumulation_base__emplacement_ctor
+ template <typename ...Args>
+ explicit with_accumulation_base(Args&& ...args);
+ //]
+
+ //[reference__with_accumulation_base__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_accumulation_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_WITH_ACCUMULATION_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_HEADER(z, n, Tuple) \
+ , _accumulation() \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_ACCUMULATION_MACRO
+ , (with_accumulation_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_ACCUMULATION_MACRO
+
+#define BOOST_TREE_NODE_WITH_ACCUMULATION_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_HEADER(z, n, Tuple) \
+ , _accumulation() \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_ACCUMULATION_MACRO
+ , (with_accumulation_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_ACCUMULATION_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ ~with_accumulation_base();
+
+ void clone_metadata_impl(Derived const& copy);
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ void move_metadata_impl(BOOST_RV_REF(Derived) source);
+#endif
+
+ void on_post_emplacement_construct();
+
+ void on_post_assign();
+
+ template <typename K>
+ void on_post_modify_value_impl(K const& key);
+
+ void on_post_modify_value_impl(Key const& key);
+
+ template <typename K>
+ void on_post_propagate_value_impl(K const& key);
+
+ void on_post_propagate_value_impl(Key const& key);
+
+ template <typename K>
+ void on_post_propagate_value_once_impl(K const& key);
+
+ void on_post_propagate_value_once_impl(Key const& key);
+
+ template <typename BooleanIntegralConstant>
+ void
+ on_post_inserted_impl(
+ iterator position
+ , BooleanIntegralConstant invalidates_sibling_positions
+ );
+
+ template <typename BooleanIntegralConstant>
+ void
+ on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , BooleanIntegralConstant invalidates_children_positions
+ );
+
+ void on_post_erase_impl();
+
+ void on_post_clear_impl();
+
+ void on_post_rotate_left_impl();
+
+ void on_post_rotate_right_impl();
+
+ public:
+ //[reference__with_accumulation_base__key_value_operator
+//<-
+#if 0
+//->
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<Value>
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , Key
+ >
+ , ::boost::mpl::identity<Value>
+ >::type const&
+//<-
+#endif
+ AccumulationValue const&
+//->
+ operator[](
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const&
+ )
+ const;
+ //]
+
+ private:
+ void
+ _set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const&
+ );
+
+ void _update();
+
+ static void
+ _update(
+ pointer p
+ , accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const&
+ );
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::with_accumulation_base(Derived const& copy)
+ : super_t(copy)
+ , _accumulation(static_cast<self const&>(copy)._accumulation)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::with_accumulation_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ ) : super_t(copy, allocator)
+ , _accumulation(static_cast<self const&>(copy)._accumulation)
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::with_accumulation_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ ) : super_t(source)
+#else
+ Derived&& source
+ ) : super_t(static_cast<Derived&&>(source))
+#endif
+ , _accumulation(static_cast<self&>(source)._accumulation)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::with_accumulation_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(source, allocator)
+#else
+ Derived&& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(static_cast<Derived&&>(source), allocator)
+#endif
+ , _accumulation(static_cast<self&>(source)._accumulation)
+ {
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ template <typename ...Args>
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::with_accumulation_base(Args&& ...args)
+ : super_t(::boost::forward<Args>(args)...), _accumulation()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ template <typename ...Args>
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::with_accumulation_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ , _accumulation()
+ {
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::~with_accumulation_base()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::clone_metadata_impl(Derived const& copy)
+ {
+ super_t::clone_metadata_impl(copy);
+ this->_accumulation = static_cast<self const&>(copy)._accumulation;
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::move_metadata_impl(BOOST_RV_REF(Derived) source)
+ {
+#if defined BOOST_NO_RVALUE_REFERENCES
+ super_t::move_metadata_impl(source);
+#else
+ super_t::move_metadata_impl(static_cast<Derived&&>(source));
+#endif
+ this->_accumulation = ::boost::move(
+ static_cast<self&>(source)._accumulation
+ );
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_emplacement_construct()
+ {
+ super_t::on_post_emplacement_construct();
+ self::_accumulation = IncludesRoot::value ? get<Key>(
+ *this->get_derived()
+ ) : ::boost::accumulators::extractor<Tag>()(
+ ::boost::accumulators::accumulator_set<
+ AccumulationValue
+ , ::boost::accumulators::features<Tag>
+ >()
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_assign()
+ {
+ super_t::on_post_assign();
+
+ if (IncludesRoot::value)
+ {
+ this->_update();
+ }
+ else if (pointer p = this->get_parent_ptr())
+ {
+ static_cast<self*>(p)->_update();
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ template <typename K>
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_modify_value_impl(K const& key)
+ {
+ super_t::on_post_modify_value_impl(key);
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_modify_value_impl(Key const& key)
+ {
+ super_t::on_post_modify_value_impl(key);
+
+ if (IncludesRoot::value)
+ {
+ this->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ this->on_post_modify_value(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ }
+
+ if (pointer p = this->get_parent_ptr())
+ {
+ static_cast<self*>(p)->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ p->on_post_modify_value(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ template <typename K>
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_propagate_value_impl(K const& key)
+ {
+ super_t::on_post_propagate_value_impl(key);
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_propagate_value_impl(Key const& key)
+ {
+ super_t::on_post_propagate_value_impl(key);
+
+ if (IncludesRoot::value)
+ {
+ this->_update();
+ }
+ else if (pointer p = this->get_parent_ptr())
+ {
+ static_cast<self*>(p)->_update();
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ template <typename K>
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_propagate_value_once_impl(K const& key)
+ {
+ super_t::on_post_propagate_value_once_impl(key);
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_propagate_value_once_impl(Key const& key)
+ {
+ super_t::on_post_propagate_value_once_impl(key);
+
+ if (IncludesRoot::value)
+ {
+ this->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ }
+
+ self* p = this->get_parent_ptr();
+
+ BOOST_ASSERT_MSG(
+ p
+ , "Do not call on_post_propagate_value_once() on root."
+ );
+ p->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+
+ if ((p = p->get_parent_ptr()))
+ {
+ p->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ template <typename BooleanIntegralConstant>
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_inserted_impl(
+ iterator position
+ , BooleanIntegralConstant invalidates_sibling_positions
+ )
+ {
+ super_t::on_post_inserted_impl(
+ position
+ , invalidates_sibling_positions
+ );
+ static_cast<self*>(this->get_parent_ptr())->_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ template <typename BooleanIntegralConstant>
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , BooleanIntegralConstant invalidates_children_positions
+ )
+ {
+ super_t::on_post_insert_impl(
+ itr
+ , itr_end
+ , invalidates_children_positions
+ );
+ this->_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_erase_impl()
+ {
+ super_t::on_post_erase_impl();
+ this->_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_clear_impl()
+ {
+ super_t::on_post_clear_impl();
+ this->_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_rotate_left_impl()
+ {
+ super_t::on_post_rotate_left_impl();
+ this->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ static_cast<self*>(this->get_parent_ptr())->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ this->on_post_propagate_value_once(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::on_post_rotate_right_impl()
+ {
+ super_t::on_post_rotate_right_impl();
+ this->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ static_cast<self*>(this->get_parent_ptr())->_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ this->on_post_propagate_value_once(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::AccumulationValue const&
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::operator[](
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const&
+ ) const
+ {
+ return self::_accumulation;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::_set_accumulation(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const&
+ )
+ {
+ ::boost::accumulators::accumulator_set<
+ AccumulationValue
+ , ::boost::accumulators::features<Tag>
+ > acc;
+
+ if (IncludesRoot::value)
+ {
+ acc(get<Key>(*this->get_derived()));
+ }
+
+ if (IncludesAllDescendants::value)
+ {
+ for (
+ ::boost::tree_node::breadth_first_descendant_iterator<
+ Derived const
+ > c_itr(*this->get_derived());
+ c_itr;
+ ++c_itr
+ )
+ {
+ acc(get<Key>(::boost::tree_node::dereference_iterator(c_itr)));
+ }
+ }
+ else
+ {
+ const_iterator c_end = this->end();
+
+ for (const_iterator c_itr = this->begin(); c_itr != c_end; ++c_itr)
+ {
+ acc(get<Key>(::boost::tree_node::dereference_iterator(c_itr)));
+ }
+ }
+
+ self::_accumulation = ::boost::accumulators::extractor<
+ Tag
+ >()(acc);
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::_update()
+ {
+ self::_update(
+ this->get_derived()
+ , accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ this->on_post_propagate_value(
+ accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >()
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ void
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::_update(
+ pointer p
+ , accumulation_key<
+ Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& key
+ )
+ {
+ do
+ {
+ static_cast<self*>(p)->_set_accumulation(key);
+ }
+ while ((p = p->get_parent_ptr()));
+ }
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ , typename AccumulationKey
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<
+ accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ , AccumulationKey
+ >
+ , typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<Value>
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , Key
+ >
+ , ::boost::mpl::identity<Value>
+ >::type const&
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ , AccumulationKey const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ , typename AccumulationKey
+ >
+ inline typename ::boost::lazy_disable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,AccumulationKey>
+ , ::std::tr1::is_same<
+ accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ , AccumulationKey
+ >
+ , ::boost::mpl::true_
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , AccumulationKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ , AccumulationKey const& key
+ )
+ {
+ return get(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t const&
+ >(node)
+ , key
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ , typename ExplicitKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,ExplicitKey>
+ , ::boost::mpl::false_
+ , ::boost::mpl::eval_if<
+ ::std::tr1::is_same<ExplicitKey,Key>
+ , ::boost::mpl::false_
+ , result_of::has_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , ExplicitKey
+ >
+ >
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const
+ , ExplicitKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ , ExplicitKey const& key
+ )
+ {
+ return get(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t const&
+ >(node)
+ , key
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ , typename ExplicitKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,ExplicitKey>
+ , ::boost::mpl::false_
+ , ::boost::mpl::eval_if<
+ ::std::tr1::is_same<ExplicitKey,Key>
+ , ::boost::mpl::false_
+ , result_of::has_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , ExplicitKey
+ >
+ >
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , ExplicitKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >& node
+ , ExplicitKey const& key
+ )
+ {
+ return get(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t&
+ >(node)
+ , key
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ , typename ExplicitKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,ExplicitKey>
+ , ::boost::mpl::false_
+ , ::std::tr1::is_same<ExplicitKey,Key>
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const
+ , ExplicitKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ , ExplicitKey const& key
+ )
+ {
+ return get(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t const&
+ >(node)
+ , key
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ , typename ExplicitKey
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,ExplicitKey>
+ , ::boost::mpl::false_
+ , ::std::tr1::is_same<ExplicitKey,Key>
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , ExplicitKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >& node
+ , ExplicitKey const& key
+ )
+ {
+ return get(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t&
+ >(node)
+ , key
+ );
+ }
+
+ template <
+ typename AccumulationKey
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<
+ accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ , AccumulationKey
+ >
+ , typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<Value>
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , Key
+ >
+ , ::boost::mpl::identity<Value>
+ >::type const&
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ )
+ {
+ return node[AccumulationKey()];
+ }
+
+ template <
+ typename AccumulationKey
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline typename ::boost::lazy_disable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,AccumulationKey>
+ , ::std::tr1::is_same<
+ accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ , AccumulationKey
+ >
+ , ::boost::mpl::true_
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , AccumulationKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ )
+ {
+ return get<AccumulationKey>(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t const&
+ >(node)
+ );
+ }
+
+ template <
+ typename ExplicitKey
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,ExplicitKey>
+ , ::boost::mpl::false_
+ , ::boost::mpl::eval_if<
+ ::std::tr1::is_same<ExplicitKey,Key>
+ , ::boost::mpl::false_
+ , result_of::has_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , ExplicitKey
+ >
+ >
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const
+ , ExplicitKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ )
+ {
+ return get<ExplicitKey>(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t const&
+ >(node)
+ );
+ }
+
+ template <
+ typename ExplicitKey
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,ExplicitKey>
+ , ::boost::mpl::false_
+ , ::boost::mpl::eval_if<
+ ::std::tr1::is_same<ExplicitKey,Key>
+ , ::boost::mpl::false_
+ , result_of::has_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , ExplicitKey
+ >
+ >
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , ExplicitKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >& node
+ )
+ {
+ return get<ExplicitKey>(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t&
+ >(node)
+ );
+ }
+
+ template <
+ typename ExplicitKey
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,ExplicitKey>
+ , ::boost::mpl::false_
+ , ::std::tr1::is_same<ExplicitKey,Key>
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const
+ , ExplicitKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ )
+ {
+ return get<Key>(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t const&
+ >(node)
+ );
+ }
+
+ template <
+ typename ExplicitKey
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ inline typename ::boost::lazy_enable_if<
+ typename ::boost::mpl::eval_if<
+ ::std::tr1::is_base_of<accumulation_key_base,ExplicitKey>
+ , ::boost::mpl::false_
+ , ::std::tr1::is_same<ExplicitKey,Key>
+ >::type
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , ExplicitKey
+ >
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >& node
+ )
+ {
+ return get<Key>(
+ static_cast<
+ typename with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >::super_t&
+ >(node)
+ );
+ }
+}} // namespace boost::tree_node
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+namespace boost { namespace tree_node { namespace result_of {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ struct has_key_impl<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ > : ::boost::mpl::true_
+ {
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ struct get_keys_impl<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ > : ::boost::mpl::vector1<
+ accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ >
+ {
+ };
+
+ template <
+ typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ struct at_key_impl<
+ accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ >
+ {
+ template <typename Node>
+ struct apply : apply<typename Node::super_t>
+ {
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ struct apply<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ > : ::boost::mpl::eval_if<
+ ::std::tr1::is_void<Value>
+ , value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , Key
+ >
+ , ::boost::mpl::identity<Value>
+ >
+ {
+ };
+ };
+}}} // namespace boost::tree_node::result_of
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+//[reference__with_accumulation_base_gen
+namespace boost { namespace tree_node {
+
+ template <
+ typename BaseGenerator
+ , typename AccumulationKey = default_accumulation_key
+ >
+ struct with_accumulation_base_gen
+ {
+ template <typename Derived, typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , typename AccumulationKey::key
+ , typename AccumulationKey::tag
+ , typename AccumulationKey::includes_all_descendants
+ , typename AccumulationKey::includes_root
+ , typename AccumulationKey::value
+ >
+ type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename AccumulationKey
+ >
+ struct with_accumulation
+ : public
+ //[reference__with_accumulation__bases
+ with_accumulation_base<
+ with_accumulation<
+ BaseGenerator
+ , T1
+ , T2
+ , AccumulationKey
+ >
+ , BaseGenerator
+ , T1
+ , T2
+ , typename AccumulationKey::key
+ , typename AccumulationKey::tag
+ , typename AccumulationKey::includes_all_descendants
+ , typename AccumulationKey::includes_root
+ , typename AccumulationKey::value
+ >
+ //]
+ {
+ //[reference__with_accumulator__super_t
+ typedef with_accumulation_base<
+ with_accumulation
+ , BaseGenerator
+ , T1
+ , T2
+ , typename AccumulationKey::key
+ , typename AccumulationKey::tag
+ , typename AccumulationKey::includes_all_descendants
+ , typename AccumulationKey::includes_root
+ , typename AccumulationKey::value
+ >
+ super_t;
+ //]
+
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(with_accumulation, super_t)
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_accumulation__emplacement_ctor
+ template <typename ...Args>
+ explicit with_accumulation(Args&& ...args);
+ //]
+
+ //[reference__with_accumulation__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_accumulation(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF
+ , (with_accumulation, super_t)
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF
+ , (with_accumulation, super_t)
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+ };
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename AccumulationKey
+ >
+ template <typename ...Args>
+ inline with_accumulation<
+ BaseGenerator
+ , T1
+ , T2
+ , AccumulationKey
+ >::with_accumulation(Args&& ...args)
+ : super_t(::boost::forward<Args>(args)...)
+ {
+ super_t::on_post_emplacement_construct();
+ }
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename AccumulationKey
+ >
+ template <typename ...Args>
+ inline with_accumulation<
+ BaseGenerator
+ , T1
+ , T2
+ , AccumulationKey
+ >::with_accumulation(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ {
+ super_t::on_post_emplacement_construct();
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+}} // namespace boost::tree_node
+
+//[reference__with_accumulation_gen
+namespace boost { namespace tree_node {
+
+ template <
+ typename BaseGenerator
+ , typename AccumulationKey = default_accumulation_key
+ >
+ struct with_accumulation_gen
+ {
+ template <typename Derived, typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_accumulation<BaseGenerator,T1,T2,AccumulationKey>
+ type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#include <boost/tree_node/_detail/config_end.hpp>
+
+#endif // BOOST_TREE_NODE_WITH_ACCUMULATION_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_accumulation_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_accumulation_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,158 @@
+// Copyright (C) 2013 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_ACCUMULATION_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_ACCUMULATION_FWD_HPP_INCLUDED
+
+#include <boost/config.hpp>
+
+#if defined BOOST_NO_SFINAE
+#error boost::tree_node::with_accumulation requires working boost::enable_if.
+#endif
+
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#error boost::tree_node::with_accumulation uses Boost.Accumulators,
+#error which requires working partial template specialization.
+#endif
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/tree_node/key/accumulation.hpp>
+#include <boost/tree_node/intrinsic/value_at_key.hpp>
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ class with_accumulation_base;
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2 = void
+ , typename AccumulationKey = default_accumulation_key
+ >
+ struct with_accumulation;
+}} // namespace boost::tree_node
+
+//[reference__with_accumulation_base__at_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ , typename AccumulationKey
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<
+ accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ , AccumulationKey
+ >
+ , typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<Value>
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , Key
+ >
+ , ::boost::mpl::identity<Value>
+ >::type const&
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ , AccumulationKey const& key
+ );
+
+ template <
+ typename AccumulationKey
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Key
+ , typename Tag
+ , typename IncludesAllDescendants
+ , typename IncludesRoot
+ , typename Value
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<
+ accumulation_key<Key,Tag,IncludesAllDescendants,IncludesRoot,Value>
+ , AccumulationKey
+ >
+ , typename ::boost::mpl::eval_if<
+ ::std::tr1::is_void<Value>
+ , result_of::value_at_key<
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ >
+ , Key
+ >
+ , ::boost::mpl::identity<Value>
+ >::type const&
+ >::type
+ get(
+ with_accumulation_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Key
+ , Tag
+ , IncludesAllDescendants
+ , IncludesRoot
+ , Value
+ > const& node
+ );
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_WITH_ACCUMULATION_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_count.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_count.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,994 @@
+// Copyright (C) 2012-2013 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_COUNT_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_COUNT_HPP_INCLUDED
+
+#include <cstddef>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/utility/value_init.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/with_count_fwd.hpp>
+#include <boost/tree_node/key/count.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/get_keys.hpp>
+#include <boost/tree_node/intrinsic/at_key.hpp>
+#include <boost/tree_node/iterator/dereference.hpp>
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/_detail/config_begin.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/mpl/vector.hpp>
+#include <boost/move/move.hpp>
+#include <boost/type_traits/is_pod.hpp>
+
+namespace boost {
+
+ template <typename BaseGenerator, typename T1, typename T2, typename Count>
+ struct is_POD<
+ ::boost::tree_node::with_count<BaseGenerator,T1,T2,Count>
+ > : ::boost::false_type
+ {
+ };
+
+ template <typename BaseGenerator, typename T1, typename T2, typename Count>
+ struct is_pod<
+ ::boost::tree_node::with_count<BaseGenerator,T1,T2,Count>
+ > : ::boost::false_type
+ {
+ };
+} // namespace boost
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ class with_count_base
+ : public
+ //[reference__with_count_base__bases
+ ::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
+ //]
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , public count_key
+#endif
+ , private ::boost::noncopyable
+ {
+ friend struct tree_node_base<Derived>;
+
+ typedef with_count_base<Derived,BaseGenerator,T1,T2,Count>
+ self;
+
+ public:
+ 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;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ //[reference__with_count_base__traits
+ struct traits : super_t::traits
+ {
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_void<Count>
+ , size_type
+ , Count
+ >::type
+ count;
+ };
+ //]
+
+ private:
+ typename traits::count _count;
+
+ protected:
+ //[reference__with_count_base__derived_copy_ctor
+ with_count_base(Derived const& copy);
+ //]
+
+ //[reference__with_count_base__derived_copy_ctor_w_allocator
+ with_count_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ );
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ with_count_base(BOOST_RV_REF(Derived) source);
+
+ with_count_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ );
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_count_base__emplacement_ctor
+ template <typename ...Args>
+ explicit with_count_base(Args&& ...args);
+ //]
+
+ //[reference__with_count_base__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_count_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_WITH_COUNT_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_HEADER(z, n, Tuple) \
+ , _count(::boost::initialized_value) \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_COUNT_MACRO
+ , (with_count_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_COUNT_MACRO
+
+#define BOOST_TREE_NODE_WITH_COUNT_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_HEADER(z, n, Tuple) \
+ , _count(::boost::initialized_value) \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_COUNT_MACRO
+ , (with_count_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_COUNT_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ ~with_count_base();
+
+ void clone_metadata_impl(Derived const& copy);
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ void move_metadata_impl(BOOST_RV_REF(Derived) source);
+#endif
+
+ void on_post_emplacement_construct();
+
+ void on_post_assign();
+
+ void on_post_inserted_impl(iterator position, ::boost::mpl::true_ t);
+
+ void on_post_inserted_impl(iterator position, ::boost::mpl::false_ f);
+
+ template <typename BooleanIntegralConstant>
+ void
+ on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , BooleanIntegralConstant invalidates_children_positions
+ );
+
+ void on_post_erase_impl();
+
+ void on_post_clear_impl();
+
+ void on_post_rotate_left_impl();
+
+ void on_post_rotate_right_impl();
+
+ public:
+ //[reference__with_count_base__key_value_operator
+ typename traits::count const& operator[](count_key const&) const;
+ //]
+
+ private:
+ void _shallow_update();
+
+ static typename traits::count
+ _get_count(const_iterator c_itr, const_iterator c_end);
+
+ static void
+ _update_less_count(
+ pointer p
+ , typename traits::count const& difference
+ );
+
+ static void
+ _update_greater_count(
+ pointer p
+ , typename traits::count const& difference
+ );
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::with_count_base(
+ Derived const& copy
+ ) : super_t(copy), _count(copy._count)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::with_count_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ ) : super_t(copy, allocator), _count(copy._count)
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::with_count_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ ) : super_t(source)
+#else
+ Derived&& source
+ ) : super_t(static_cast<Derived&&>(source))
+#endif
+ , _count(source._count)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::with_count_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(source, allocator)
+#else
+ Derived&& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(static_cast<Derived&&>(source), allocator)
+#endif
+ , _count(source._count)
+ {
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ template <typename ...Args>
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::with_count_base(
+ Args&& ...args
+ ) : super_t(::boost::forward<Args>(args)...)
+ , _count(::boost::initialized_value)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ template <typename ...Args>
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::with_count_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ , _count(::boost::initialized_value)
+ {
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::~with_count_base()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::clone_metadata_impl(Derived const& copy)
+ {
+ super_t::clone_metadata_impl(copy);
+ this->_count = copy._count;
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::move_metadata_impl(
+ BOOST_RV_REF(Derived) source
+ )
+ {
+#if defined BOOST_NO_RVALUE_REFERENCES
+ super_t::move_metadata_impl(source);
+#else
+ super_t::move_metadata_impl(static_cast<Derived&&>(source));
+#endif
+ this->_count = ::boost::move(source._count);
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_emplacement_construct()
+ {
+ super_t::on_post_emplacement_construct();
+ ++this->_count;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_assign()
+ {
+ super_t::on_post_assign();
+
+ if (this->get_parent_ptr())
+ {
+ static_cast<self*>(this->get_parent_ptr())->_shallow_update();
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_inserted_impl(iterator position, ::boost::mpl::true_ t)
+ {
+ super_t::on_post_inserted_impl(position, t);
+ self::_update_greater_count(this->get_derived(), this->_count);
+ this->on_post_propagate_value(count_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_inserted_impl(iterator position, ::boost::mpl::false_ f)
+ {
+ super_t::on_post_inserted_impl(position, f);
+ static_cast<self*>(this->get_parent_ptr())->_shallow_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ template <typename BooleanIntegralConstant>
+ void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , BooleanIntegralConstant invalidates_children_positions
+ )
+ {
+ super_t::on_post_insert_impl(
+ itr
+ , itr_end
+ , invalidates_children_positions
+ );
+ typename traits::count new_count = self::_get_count(itr, itr_end);
+ this->_count += new_count;
+
+ for (
+ self::_update_greater_count(this->get_derived(), new_count);
+ itr != itr_end;
+ ++itr
+ )
+ {
+ dereference_iterator(itr).on_post_modify_value(count_key());
+ }
+
+ this->on_post_propagate_value(count_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_erase_impl()
+ {
+ super_t::on_post_erase_impl();
+ this->_shallow_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_clear_impl()
+ {
+ super_t::on_post_clear_impl();
+ self::_update_less_count(this->get_derived(), --this->_count);
+ ++(this->_count = ::boost::initialized_value);
+ this->on_post_propagate_value(count_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_rotate_left_impl()
+ {
+ super_t::on_post_rotate_left_impl();
+
+ pointer p = this->get_parent_ptr();
+
+ if (p->get_right_child_ptr())
+ {
+ this->_count -= p->get_right_child_ptr()->_count;
+ }
+
+ if (this->get_left_child_ptr())
+ {
+ p->_count += this->get_left_child_ptr()->_count;
+ }
+
+ --this->_count;
+ ++p->_count;
+ this->on_post_propagate_value_once(count_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::on_post_rotate_right_impl()
+ {
+ super_t::on_post_rotate_right_impl();
+
+ pointer p = this->get_parent_ptr();
+
+ if (pointer l = p->get_left_child_ptr())
+ {
+ this->_count -= p->get_left_child_ptr()->_count;
+ }
+
+ if (this->get_right_child_ptr())
+ {
+ p->_count += this->get_right_child_ptr()->_count;
+ }
+
+ --this->_count;
+ ++p->_count;
+ this->on_post_propagate_value_once(count_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline typename with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::traits::count const&
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::operator[](
+ count_key const&
+ ) const
+ {
+ return this->_count;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline void
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>::_shallow_update()
+ {
+ typename traits::count new_count = self::_get_count(
+ this->cbegin()
+ , this->cend()
+ );
+
+ if (++new_count < this->_count)
+ {
+ self::_update_less_count(
+ this->get_derived()
+ , this->_count - new_count
+ );
+ this->_count = new_count;
+ this->on_post_propagate_value(count_key());
+ }
+ else if (this->_count < new_count)
+ {
+ self::_update_greater_count(
+ this->get_derived()
+ , new_count - this->_count
+ );
+ this->_count = new_count;
+ this->on_post_propagate_value(count_key());
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ typename with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::traits::count
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::_get_count(const_iterator c_itr, const_iterator c_end)
+ {
+ typename traits::count result = ::boost::initialized_value;
+
+ for (; c_itr != c_end; ++c_itr)
+ {
+ result += ::boost::tree_node::dereference_iterator(
+ c_itr
+ )._count;
+ }
+
+ return result;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::_update_less_count(
+ pointer p
+ , typename traits::count const& difference
+ )
+ {
+ while ((p = p->get_parent_ptr()))
+ {
+ p->_count -= difference;
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ void
+ with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::_update_greater_count(
+ pointer p
+ , typename traits::count const& difference
+ )
+ {
+ while ((p = p->get_parent_ptr()))
+ {
+ p->_count += difference;
+ }
+ }
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline typename with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::traits::count const&
+ get(
+ with_count_base<Derived,BaseGenerator,T1,T2,Count> const& node
+ , count_key const& key
+ )
+ {
+ return node[key];
+ }
+
+#if !defined BOOST_NO_SFINAE
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,count_key>
+ , typename with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::traits::count const&
+ >::type
+ get(with_count_base<Derived,BaseGenerator,T1,T2,Count> const& node)
+ {
+ return node[count_key()];
+ }
+#endif // BOOST_NO_SFINAE
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node { namespace result_of {
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ struct has_key_impl<
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>
+ , count_key
+ > : ::boost::mpl::true_
+ {
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ struct get_keys_impl<
+ with_count_base<Derived,BaseGenerator,T1,T2,Count>
+ > : ::boost::mpl::vector1<count_key>
+ {
+ };
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <>
+ struct at_key_impl<count_key>
+ {
+ template <typename Node>
+ struct apply
+ {
+ typedef typename Node::traits::count const& type;
+ };
+ };
+}}} // namespace boost::tree_node::result_of
+
+//[reference__with_count_base_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename Count = void>
+ struct with_count_base_gen
+ {
+ template <typename Derived, typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_count_base<Derived,BaseGenerator,T1,T2,Count> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename T1, typename T2, typename Count>
+ struct with_count
+ : public
+ //[reference__with_count__bases
+ with_count_base<
+ with_count<BaseGenerator,T1,T2,Count>
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >
+ //]
+ {
+ typedef with_count_base<with_count,BaseGenerator,T1,T2,Count>
+ super_t;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(with_count, super_t)
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_count__emplacement_ctor
+ template <typename ...Args>
+ explicit with_count(Args&& ...args);
+ //]
+
+ //[reference__with_count__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_count(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF
+ , (with_count, super_t)
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF
+ , (with_count, super_t)
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+ };
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename BaseGenerator, typename T1, typename T2, typename Count>
+ template <typename ...Args>
+ inline with_count<BaseGenerator,T1,T2,Count>::with_count(Args&& ...args)
+ : super_t(::boost::forward<Args>(args)...)
+ {
+ super_t::on_post_emplacement_construct();
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2, typename Count>
+ template <typename ...Args>
+ inline with_count<BaseGenerator,T1,T2,Count>::with_count(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ {
+ super_t::on_post_emplacement_construct();
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+}} // namespace boost::tree_node
+
+//[reference__with_count_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename Count = void>
+ struct with_count_gen
+ {
+ template <typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_count<BaseGenerator,T1,T2,Count> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#include <boost/tree_node/_detail/config_end.hpp>
+
+#endif // BOOST_TREE_NODE_WITH_COUNT_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_count_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_count_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,88 @@
+// Copyright (C) 2013 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_COUNT_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_COUNT_FWD_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/tree_node/key/count.hpp>
+
+#if !defined BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/tr1/type_traits.hpp>
+#endif
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ class with_count_base;
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2 = void
+ , typename Count = void
+ >
+ struct with_count;
+}} // namespace boost::tree_node
+
+//[reference__with_count_base__at_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ typename with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::traits::count const&
+ get(
+ with_count_base<Derived,BaseGenerator,T1,T2,Count> const& node
+ , count_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Count
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,count_key>
+ , typename with_count_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Count
+ >::traits::count const&
+ >::type
+ get(with_count_base<Derived,BaseGenerator,T1,T2,Count> const& node);
+//<-
+#endif // BOOST_NO_SFINAE
+//->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_WITH_COUNT_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_height.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_height.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,961 @@
+// Copyright (C) 2011-2013 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_HEIGHT_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_HEIGHT_HPP_INCLUDED
+
+#include <cstddef>
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/utility/value_init.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/with_height_fwd.hpp>
+#include <boost/tree_node/key/height.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/get_keys.hpp>
+#include <boost/tree_node/intrinsic/at_key.hpp>
+#include <boost/tree_node/iterator/dereference.hpp>
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/_detail/config_begin.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/mpl/vector.hpp>
+#include <boost/move/move.hpp>
+#include <boost/type_traits/is_pod.hpp>
+
+namespace boost {
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ struct is_POD<
+ ::boost::tree_node::with_height<BaseGenerator,T1,T2,Height>
+ > : ::boost::false_type
+ {
+ };
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ struct is_pod<
+ ::boost::tree_node::with_height<BaseGenerator,T1,T2,Height>
+ > : ::boost::false_type
+ {
+ };
+} // namespace boost
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ class with_height_base
+ : public
+ //[reference__with_height_base__bases
+ ::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
+ //]
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , public height_key
+#endif
+ , private ::boost::noncopyable
+ {
+ friend struct tree_node_base<Derived>;
+
+ typedef with_height_base<Derived,BaseGenerator,T1,T2,Height>
+ self;
+
+ public:
+ 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;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ //[reference__with_height_base__traits
+ struct traits : super_t::traits
+ {
+ typedef typename ::boost::mpl::if_<
+ ::std::tr1::is_void<Height>
+ , size_type
+ , Height
+ >::type
+ height;
+ };
+ //]
+
+ private:
+ typename traits::height _height;
+
+ protected:
+ //[reference__with_height_base__derived_copy_ctor
+ with_height_base(Derived const& copy);
+ //]
+
+ //[reference__with_height_base__derived_copy_ctor_w_allocator
+ with_height_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ );
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ with_height_base(BOOST_RV_REF(Derived) source);
+
+ with_height_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ );
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_height_base__emplacement_ctor
+ template <typename ...Args>
+ explicit with_height_base(Args&& ...args);
+ //]
+
+ //[reference__with_height_base__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_height_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_WITH_HEIGHT_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_HEADER(z, n, Tuple) \
+ , _height(::boost::initialized_value) \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_HEIGHT_MACRO
+ , (with_height_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_HEIGHT_MACRO
+
+#define BOOST_TREE_NODE_WITH_HEIGHT_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_HEADER(z, n, Tuple) \
+ , _height(::boost::initialized_value) \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_HEIGHT_MACRO
+ , (with_height_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_HEIGHT_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ ~with_height_base();
+
+ void clone_metadata_impl(Derived const& copy);
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ void move_metadata_impl(BOOST_RV_REF(Derived) source);
+#endif
+
+ void on_post_assign();
+
+ template <typename BooleanIntegralConstant>
+ void
+ on_post_inserted_impl(
+ iterator position
+ , BooleanIntegralConstant invalidates_sibling_positions
+ );
+
+ template <typename BooleanIntegralConstant>
+ void
+ on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , BooleanIntegralConstant invalidates_children_positions
+ );
+
+ void on_post_erase_impl();
+
+ void on_post_clear_impl();
+
+ void on_post_rotate_left_impl();
+
+ void on_post_rotate_right_impl();
+
+ public:
+ //[reference__with_height_base__key_value_operator
+ typename traits::height const& operator[](height_key const&) const;
+ //]
+
+ private:
+ void _shallow_update();
+
+ static typename traits::height
+ _get_max_height(const_iterator c_itr, const_iterator c_end);
+
+ static void _update_less_height(pointer p);
+
+ static void _update_greater_height(pointer p);
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>::with_height_base(
+ Derived const& copy
+ ) : super_t(copy), _height(copy._height)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>::with_height_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ ) : super_t(copy, allocator), _height(copy._height)
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>::with_height_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ ) : super_t(source)
+#else
+ Derived&& source
+ ) : super_t(static_cast<Derived&&>(source))
+#endif
+ , _height(source._height)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>::with_height_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(source, allocator)
+#else
+ Derived&& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(static_cast<Derived&&>(source), allocator)
+#endif
+ , _height(source._height)
+ {
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ template <typename ...Args>
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>::with_height_base(
+ Args&& ...args
+ ) : super_t(::boost::forward<Args>(args)...)
+ , _height(::boost::initialized_value)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ template <typename ...Args>
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>::with_height_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ , _height(::boost::initialized_value)
+ {
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>::~with_height_base()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::clone_metadata_impl(Derived const& copy)
+ {
+ super_t::clone_metadata_impl(copy);
+ this->_height = copy._height;
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::move_metadata_impl(BOOST_RV_REF(Derived) source)
+ {
+#if defined BOOST_NO_RVALUE_REFERENCES
+ super_t::move_metadata_impl(source);
+#else
+ super_t::move_metadata_impl(static_cast<Derived&&>(source));
+#endif
+ this->_height = ::boost::move(source._height);
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::on_post_assign()
+ {
+ super_t::on_post_assign();
+
+ if (this->get_parent_ptr())
+ {
+ this->get_parent_ptr()->_shallow_update();
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ template <typename BooleanIntegralConstant>
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::on_post_inserted_impl(
+ iterator position
+ , BooleanIntegralConstant invalidates_sibling_positions
+ )
+ {
+ super_t::on_post_inserted_impl(
+ position
+ , invalidates_sibling_positions
+ );
+ this->get_parent_ptr()->_shallow_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ template <typename BooleanIntegralConstant>
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , BooleanIntegralConstant invalidates_children_positions
+ )
+ {
+ super_t::on_post_insert_impl(
+ itr
+ , itr_end
+ , invalidates_children_positions
+ );
+ typename traits::height new_height = self::_get_max_height(
+ itr
+ , itr_end
+ );
+
+ if (this->_height < new_height)
+ {
+ this->_height = new_height;
+ self::_update_greater_height(this->get_derived());
+ this->on_post_propagate_value(height_key());
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::on_post_erase_impl()
+ {
+ super_t::on_post_erase_impl();
+ this->_shallow_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::on_post_clear_impl()
+ {
+ super_t::on_post_clear_impl();
+ this->_height = ::boost::initialized_value;
+ self::_update_less_height(this->get_derived());
+ this->on_post_propagate_value(height_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::on_post_rotate_left_impl()
+ {
+ super_t::on_post_rotate_left_impl();
+ this->_shallow_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::on_post_rotate_right_impl()
+ {
+ super_t::on_post_rotate_right_impl();
+ this->_shallow_update();
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline typename with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::traits::height const&
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::operator[](height_key const&) const
+ {
+ return this->_height;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ void
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>::_shallow_update()
+ {
+ typename traits::height new_height = self::_get_max_height(
+ this->begin()
+ , this->end()
+ );
+
+ if (new_height < this->_height)
+ {
+ this->_height = new_height;
+ self::_update_less_height(this->get_derived());
+ this->on_post_propagate_value(height_key());
+ }
+ else if (this->_height < new_height)
+ {
+ this->_height = new_height;
+ self::_update_greater_height(this->get_derived());
+ this->on_post_propagate_value(height_key());
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ typename with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::traits::height
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::_get_max_height(const_iterator c_itr, const_iterator c_end)
+ {
+ typename traits::height result = ::boost::initialized_value;
+
+ for (typename traits::height height_plus_1; c_itr != c_end; ++c_itr)
+ {
+ height_plus_1 = ::boost::tree_node::dereference_iterator(
+ c_itr
+ )._height;
+
+ if (result < ++height_plus_1)
+ {
+ result = height_plus_1;
+ }
+ }
+
+ return result;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::_update_less_height(pointer p)
+ {
+ typename traits::height new_height;
+
+ while ((p = p->get_parent_ptr()))
+ {
+ new_height = self::_get_max_height(p->begin(), p->end());
+
+ if (p->_height == new_height)
+ {
+ return;
+ }
+ else
+ {
+ // This is no longer the deepest branch.
+ p->_height = new_height;
+ }
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ void
+ with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::_update_greater_height(pointer p)
+ {
+ typename traits::height p_height = p->_height;
+
+ while ((p = p->get_parent_ptr()) && (p->_height < ++p_height))
+ {
+ // This is the new deepest branch.
+ p->_height = p_height;
+ }
+ }
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline typename with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::traits::height const&
+ get(
+ with_height_base<Derived,BaseGenerator,T1,T2,Height> const& node
+ , height_key const& key
+ )
+ {
+ return node[key];
+ }
+
+#if !defined BOOST_NO_SFINAE
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,height_key>
+ , typename with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::traits::height const&
+ >::type
+ get(with_height_base<Derived,BaseGenerator,T1,T2,Height> const& node)
+ {
+ return node[height_key()];
+ }
+#endif // BOOST_NO_SFINAE
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node { namespace result_of {
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ struct has_key_impl<
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>
+ , height_key
+ > : ::boost::mpl::true_
+ {
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ struct get_keys_impl<
+ with_height_base<Derived,BaseGenerator,T1,T2,Height>
+ > : ::boost::mpl::vector1<height_key>
+ {
+ };
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <>
+ struct at_key_impl<height_key>
+ {
+ template <typename Node>
+ struct apply
+ {
+ typedef typename Node::traits::height const& type;
+ };
+ };
+}}} // namespace boost::tree_node::result_of
+
+//[reference__with_height_base_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename Height = void>
+ struct with_height_base_gen
+ {
+ template <typename Derived, typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_height_base<Derived,BaseGenerator,T1,T2,Height> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ struct with_height
+ : public
+ //[reference__with_height__bases
+ with_height_base<
+ with_height<BaseGenerator,T1,T2,Height>
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >
+ //]
+ {
+ typedef with_height_base<with_height,BaseGenerator,T1,T2,Height>
+ super_t;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(with_height, super_t)
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_height__emplacement_ctor
+ template <typename ...Args>
+ explicit with_height(Args&& ...args);
+ //]
+
+ //[reference__with_height__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_height(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF
+ , (with_height, super_t)
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF
+ , (with_height, super_t)
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+ };
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ template <typename ...Args>
+ inline with_height<BaseGenerator,T1,T2,Height>::with_height(Args&& ...args)
+ : super_t(::boost::forward<Args>(args)...)
+ {
+ super_t::on_post_emplacement_construct();
+ }
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ template <typename ...Args>
+ inline with_height<BaseGenerator,T1,T2,Height>::with_height(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ {
+ super_t::on_post_emplacement_construct();
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+}} // namespace boost::tree_node
+
+//[reference__with_height_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename Height = void>
+ struct with_height_gen
+ {
+ template <typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_height<BaseGenerator,T1,T2,Height> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#include <boost/tree_node/_detail/config_end.hpp>
+
+#endif // BOOST_TREE_NODE_WITH_HEIGHT_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_height_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_height_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,88 @@
+// Copyright (C) 2013 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_HEIGHT_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_HEIGHT_FWD_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/tree_node/key/height.hpp>
+
+#if !defined BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/tr1/type_traits.hpp>
+#endif
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ class with_height_base;
+
+ template <
+ typename BaseGenerator
+ , typename T1
+ , typename T2 = void
+ , typename Height = void
+ >
+ struct with_height;
+}} // namespace boost::tree_node
+
+//[reference__with_height_base__at_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ typename with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::traits::height const&
+ get(
+ with_height_base<Derived,BaseGenerator,T1,T2,Height> const& node
+ , height_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ , typename Height
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,height_key>
+ , typename with_height_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ , Height
+ >::traits::height const&
+ >::type
+ get(with_height_base<Derived,BaseGenerator,T1,T2,Height> const& node);
+//<-
+#endif // BOOST_NO_SFINAE
+//->
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_WITH_HEIGHT_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_position.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_position.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,770 @@
+// Copyright (C) 2011-2013 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/noncopyable.hpp>
+#include <boost/detail/metafunction/container_iterator.hpp>
+#include <boost/detail/metafunction/is_random_access_iterator.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/with_position_fwd.hpp>
+#include <boost/tree_node/key/position.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/get_keys.hpp>
+#include <boost/tree_node/intrinsic/at_key.hpp>
+#include <boost/tree_node/iterator/dereference.hpp>
+#include <boost/assert.hpp>
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/_detail/config_begin.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/mpl/vector.hpp>
+#include <boost/move/move.hpp>
+#include <boost/type_traits/is_pod.hpp>
+
+namespace boost {
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ struct is_POD<
+ ::boost::tree_node::with_position<BaseGenerator,T1,T2>
+ > : ::boost::false_type
+ {
+ };
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ struct is_pod<
+ ::boost::tree_node::with_position<BaseGenerator,T1,T2>
+ > : ::boost::false_type
+ {
+ };
+} // namespace boost
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ class with_position_base
+ : public
+ //[reference__with_position_base__bases
+ ::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
+ //]
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , public position_key
+#endif
+ , private ::boost::noncopyable
+ {
+ friend struct tree_node_base<Derived>;
+
+ public:
+ 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;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ private:
+ iterator _position;
+
+ protected:
+ //[reference__with_position_base__derived_copy_ctor
+ with_position_base(Derived const& copy);
+ //]
+
+ //[reference__with_position_base__derived_copy_ctor_w_allocator
+ with_position_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ );
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ with_position_base(BOOST_RV_REF(Derived) source);
+
+ with_position_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ );
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_position_base__emplacement_ctor
+ template <typename ...Args>
+ explicit with_position_base(Args&& ...args);
+ //]
+
+ //[reference__with_position_base__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_position_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_WITH_POSITION_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_HEADER(z, n, Tuple) \
+ , _position() \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_POSITION_MACRO
+ , (with_position_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_POSITION_MACRO
+
+#define BOOST_TREE_NODE_WITH_POSITION_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_HEADER(z, n, Tuple) \
+ , _position() \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_POSITION_MACRO
+ , (with_position_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_POSITION_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ ~with_position_base();
+
+ void on_post_copy_or_move_impl();
+
+ void on_post_inserted_impl(iterator position, ::boost::mpl::true_);
+
+ void on_post_inserted_impl(iterator position, ::boost::mpl::false_);
+
+ void
+ on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , ::boost::mpl::true_
+ );
+
+ void
+ on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , ::boost::mpl::false_
+ );
+
+ public:
+ //[reference__with_position_base__key_value_operator__const
+ const_iterator operator[](position_key const&) const;
+ //]
+
+ //[reference__with_position_base__key_value_operator
+ iterator operator[](position_key const&);
+ //]
+
+ private:
+ static void
+ _set_child_positions(pointer to_parent, ::boost::mpl::true_);
+
+ static void
+ _set_child_positions(pointer to_parent, ::boost::mpl::false_);
+
+ static void _initialize(iterator to_child);
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_position_base<Derived,BaseGenerator,T1,T2>::with_position_base(
+ Derived const& copy
+ ) : super_t(copy), _position()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_position_base<Derived,BaseGenerator,T1,T2>::with_position_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ ) : super_t(copy, allocator), _position()
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_position_base<Derived,BaseGenerator,T1,T2>::with_position_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ ) : super_t(source)
+#else
+ Derived&& source
+ ) : super_t(static_cast<Derived&&>(source))
+#endif
+ , _position()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_position_base<Derived,BaseGenerator,T1,T2>::with_position_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(source, allocator)
+#else
+ Derived&& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(static_cast<Derived&&>(source), allocator)
+#endif
+ , _position()
+ {
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ template <typename ...Args>
+ with_position_base<Derived,BaseGenerator,T1,T2>::with_position_base(
+ Args&& ...args
+ ) : super_t(::boost::forward<Args>(args)...), _position()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ template <typename ...Args>
+ with_position_base<Derived,BaseGenerator,T1,T2>::with_position_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ , _position()
+ {
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_position_base<Derived,BaseGenerator,T1,T2>::~with_position_base()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_position_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::on_post_copy_or_move_impl()
+ {
+ super_t::on_post_copy_or_move_impl();
+ with_position_base<Derived,BaseGenerator,T1,T2>::_set_child_positions(
+ this->get_derived()
+ , ::boost::detail::metafunction::is_random_access_iterator<
+ iterator
+ >()
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_position_base<Derived,BaseGenerator,T1,T2>::on_post_inserted_impl(
+ iterator position
+ , ::boost::mpl::true_ t
+ )
+ {
+ super_t::on_post_inserted_impl(position, t);
+ this->_position = position;
+ this->on_post_modify_value(position_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void
+ with_position_base<Derived,BaseGenerator,T1,T2>::on_post_inserted_impl(
+ iterator position
+ , ::boost::mpl::false_ f
+ )
+ {
+ super_t::on_post_inserted_impl(position, f);
+ with_position_base<Derived,BaseGenerator,T1,T2>::_set_child_positions(
+ this->get_parent_ptr()
+ , ::boost::detail::metafunction::is_random_access_iterator<
+ iterator
+ >()
+ );
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void
+ with_position_base<Derived,BaseGenerator,T1,T2>::on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , ::boost::mpl::true_ t
+ )
+ {
+ for (
+ super_t::on_post_insert_impl(itr, itr_end, t);
+ itr != itr_end;
+ ++itr
+ )
+ {
+ with_position_base<Derived,BaseGenerator,T1,T2>::_initialize(itr);
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void
+ with_position_base<Derived,BaseGenerator,T1,T2>::on_post_insert_impl(
+ iterator itr
+ , iterator itr_end
+ , ::boost::mpl::false_ f
+ )
+ {
+ super_t::on_post_insert_impl(itr, itr_end, f);
+ with_position_base<Derived,BaseGenerator,T1,T2>::_set_child_positions(
+ this->get_derived()
+ , ::boost::detail::metafunction::is_random_access_iterator<
+ iterator
+ >()
+ );
+ }
+
+ 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>::operator[](
+ position_key const&
+ ) const
+ {
+ return this->_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>::operator[](
+ position_key const&
+ )
+ {
+ return this->_position;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void
+ with_position_base<Derived,BaseGenerator,T1,T2>::_set_child_positions(
+ pointer to_parent
+ , ::boost::mpl::true_
+ )
+ {
+ size_type const s = to_parent->size();
+
+ for (size_type i = 0; i < s; ++i)
+ {
+ with_position_base<Derived,BaseGenerator,T1,T2>::_initialize(
+ to_parent->begin() + i
+ );
+ BOOST_ASSERT(
+ to_parent == dereference_iterator(
+ dereference_iterator(to_parent->begin() + i)._position
+ ).get_parent_ptr()
+ );
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void
+ with_position_base<Derived,BaseGenerator,T1,T2>::_set_child_positions(
+ pointer to_parent
+ , ::boost::mpl::false_
+ )
+ {
+ iterator itr_end = to_parent->end();
+
+ for (iterator itr = to_parent->begin(); itr != itr_end; ++itr)
+ {
+ with_position_base<Derived,BaseGenerator,T1,T2>::_initialize(itr);
+ BOOST_ASSERT(
+ to_parent == dereference_iterator(
+ dereference_iterator(itr)._position
+ ).get_parent_ptr()
+ );
+ }
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_position_base<Derived,BaseGenerator,T1,T2>::_initialize(
+ iterator to_child
+ )
+ {
+ dereference_iterator(to_child)._position = to_child;
+ dereference_iterator(to_child).on_post_modify_value(position_key());
+ }
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline typename with_position_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::const_iterator
+ get(
+ with_position_base<Derived,BaseGenerator,T1,T2> const& node
+ , position_key const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline typename with_position_base<Derived,BaseGenerator,T1,T2>::iterator
+ get(
+ with_position_base<Derived,BaseGenerator,T1,T2>& node
+ , position_key const& key
+ )
+ {
+ return node[key];
+ }
+
+#if !defined BOOST_NO_SFINAE
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,position_key>
+ , typename with_position_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::const_iterator
+ >::type
+ get(with_position_base<Derived,BaseGenerator,T1,T2> const& node)
+ {
+ return node[position_key()];
+ }
+
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,position_key>
+ , typename with_position_base<Derived,BaseGenerator,T1,T2>::iterator
+ >::type
+ get(with_position_base<Derived,BaseGenerator,T1,T2>& node)
+ {
+ return node[position_key()];
+ }
+#endif // BOOST_NO_SFINAE
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node { namespace result_of {
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ struct has_key_impl<
+ with_position_base<Derived,BaseGenerator,T1,T2>
+ , position_key
+ > : ::boost::mpl::true_
+ {
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ struct get_keys_impl<
+ with_position_base<Derived,BaseGenerator,T1,T2>
+ > : ::boost::mpl::vector1<position_key>
+ {
+ };
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <>
+ struct at_key_impl<position_key>
+ {
+ template <typename Node>
+ struct apply
+ {
+ typedef typename ::boost::detail::metafunction::container_iterator<
+ Node
+ >::type
+ type;
+ };
+ };
+}}} // namespace boost::tree_node::result_of
+
+//[reference__with_position_base_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator>
+ struct with_position_base_gen
+ {
+ template <typename Derived, typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_position_base<Derived,BaseGenerator,T1,T2> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ struct with_position
+ : public
+ //[reference__with_position__bases
+ with_position_base<
+ with_position<BaseGenerator,T1,T2>
+ , BaseGenerator
+ , T1
+ , T2
+ >
+ //]
+ {
+ typedef with_position_base<with_position,BaseGenerator,T1,T2>
+ super_t;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(with_position, super_t)
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_position__emplacement_ctor
+ template <typename ...Args>
+ explicit with_position(Args&& ...args);
+ //]
+
+ //[reference__with_position__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_position(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF
+ , (with_position, super_t)
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF
+ , (with_position, super_t)
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+ };
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename BaseGenerator, typename T1, typename T2>
+ template <typename ...Args>
+ inline with_position<BaseGenerator,T1,T2>::with_position(Args&& ...args)
+ : super_t(::boost::forward<Args>(args)...)
+ {
+ super_t::on_post_emplacement_construct();
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ template <typename ...Args>
+ inline with_position<BaseGenerator,T1,T2>::with_position(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ {
+ super_t::on_post_emplacement_construct();
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+}} // namespace boost::tree_node
+
+//[reference__with_position_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator>
+ struct with_position_gen
+ {
+ template <typename T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_position<BaseGenerator,T1,T2> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#include <boost/tree_node/_detail/config_end.hpp>
+
+#endif // BOOST_TREE_NODE_WITH_POSITION_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_position_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_position_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,114 @@
+// Copyright (C) 2013 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_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_POSITION_FWD_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/tree_node/key/position.hpp>
+
+#if !defined BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/tr1/type_traits.hpp>
+#endif
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ class with_position_base;
+
+ template <typename BaseGenerator, typename T1, typename T2 = void>
+ struct with_position;
+}} // namespace boost::tree_node
+
+//[reference__with_position_base__at_key__const
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ typename with_position_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::const_iterator
+ get(
+ with_position_base<Derived,BaseGenerator,T1,T2> const& node
+ , position_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,position_key>
+ , typename with_position_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::const_iterator
+ >::type
+ get(with_position_base<Derived,BaseGenerator,T1,T2> const& node);
+//<-
+#endif
+//->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_position_base__at_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ typename with_position_base<Derived,BaseGenerator,T1,T2>::iterator
+ get(
+ with_position_base<Derived,BaseGenerator,T1,T2>& node
+ , position_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,position_key>
+ , typename with_position_base<Derived,BaseGenerator,T1,T2>::iterator
+ >::type
+ get(with_position_base<Derived,BaseGenerator,T1,T2>& node);
+//<-
+#endif
+//->
+}} // 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 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,755 @@
+// Copyright (C) 2011-2013 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/noncopyable.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+#include <boost/tree_node/base.hpp>
+#include <boost/tree_node/with_red_black_flag_fwd.hpp>
+#include <boost/tree_node/traits/red_black_node_fwd.hpp>
+#include <boost/tree_node/intrinsic/has_key.hpp>
+#include <boost/tree_node/intrinsic/get_keys.hpp>
+#include <boost/tree_node/intrinsic/at_key.hpp>
+
+#if !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#include <boost/preprocessor/repetition/repeat.hpp>
+#endif
+
+#include <boost/tree_node/_detail/config_begin.hpp>
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/mpl/vector.hpp>
+#include <boost/move/move.hpp>
+#include <boost/type_traits/is_pod.hpp>
+
+namespace boost {
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ struct is_POD<
+ ::boost::tree_node::with_red_black_flag<BaseGenerator,T1,T2>
+ > : ::boost::false_type
+ {
+ };
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ struct is_pod<
+ ::boost::tree_node::with_red_black_flag<BaseGenerator,T1,T2>
+ > : ::boost::false_type
+ {
+ };
+} // namespace boost
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ class with_red_black_flag_base
+ : public
+ //[reference__with_red_black_flag_base__bases
+ ::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
+ //]
+#if defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ , public red_flag_key
+ , public black_flag_key
+#endif
+ , private ::boost::noncopyable
+ {
+ friend struct tree_node_base<Derived>;
+
+ public:
+ 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;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ private:
+ bool _is_red;
+
+ protected:
+ //[reference__with_red_black_flag_base__derived_copy_ctor
+ with_red_black_flag_base(Derived const& copy);
+ //]
+
+ //[reference__with_red_black_flag_base__derived_copy_ctor_w_allocator
+ with_red_black_flag_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ );
+ //]
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ with_red_black_flag_base(BOOST_RV_REF(Derived) source);
+
+ with_red_black_flag_base(
+ BOOST_RV_REF(Derived) source
+ , typename traits::allocator_reference allocator
+ );
+#endif
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_red_black_flag_base__emplacement_ctor
+ template <typename ...Args>
+ explicit with_red_black_flag_base(Args&& ...args);
+ //]
+
+ //[reference__with_red_black_flag_base__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_red_black_flag_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+#define BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_HEADER(z, n, Tuple) \
+ , _is_red(false) \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_MACRO
+ , (with_red_black_flag_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_MACRO
+
+#define BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_MACRO(z, n, Tuple) \
+ BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_HEADER(z, n, Tuple) \
+ , _is_red(false) \
+ { \
+ } \
+//!
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_MACRO
+ , (with_red_black_flag_base, super_t)
+ )
+#undef BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_MACRO
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ ~with_red_black_flag_base();
+
+ void clone_metadata_impl(Derived const& copy);
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ void move_metadata_impl(BOOST_RV_REF(Derived) source);
+#endif
+
+ void on_post_assign();
+
+ public:
+ //[reference__with_red_black_flag_base__key_value_operator__red
+ bool operator[](red_flag_key const&) const;
+ //]
+
+ //[reference__with_red_black_flag_base__key_value_operator__black
+ bool operator[](black_flag_key const&) const;
+ //]
+
+ //[reference__with_red_black_flag_base__set_red_flag
+ void set_red_flag(bool flag);
+ //]
+
+ //[reference__with_red_black_flag_base__set_black_flag
+ void set_black_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(Derived const& copy)
+ : super_t(copy), _is_red(copy._is_red)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_red_black_flag_base(
+ Derived const& copy
+ , typename traits::allocator_reference allocator
+ ) : super_t(copy, allocator), _is_red(copy._is_red)
+ {
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_red_black_flag_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ ) : super_t(source)
+#else
+ Derived&& source
+ ) : super_t(static_cast<Derived&&>(source))
+#endif
+ , _is_red(source._is_red)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_red_black_flag_base(
+#if defined BOOST_NO_RVALUE_REFERENCES
+ ::boost::rv<Derived>& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(source, allocator)
+#else
+ Derived&& source
+ , typename traits::allocator_reference allocator
+ ) : super_t(static_cast<Derived&&>(source), allocator)
+#endif
+ , _is_red(source._is_red)
+ {
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ template <typename ...Args>
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_red_black_flag_base(Args&& ...args)
+ : super_t(::boost::forward<Args>(args)...), _is_red(false)
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ template <typename ...Args>
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::with_red_black_flag_base(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ , _is_red(false)
+ {
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::~with_red_black_flag_base()
+ {
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::clone_metadata_impl(Derived const& copy)
+ {
+ super_t::clone_metadata_impl(copy);
+ this->_is_red = copy._is_red;
+ }
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::move_metadata_impl(BOOST_RV_REF(Derived) source)
+ {
+#if defined BOOST_NO_RVALUE_REFERENCES
+ super_t::move_metadata_impl(source);
+#else
+ super_t::move_metadata_impl(static_cast<Derived&&>(source));
+#endif
+ this->_is_red = source._is_red;
+ }
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::on_post_assign()
+ {
+ super_t::on_post_assign();
+ this->on_post_modify_value(red_flag_key());
+ this->on_post_modify_value(black_flag_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline bool
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::operator[](red_flag_key const&) const
+ {
+ return this->_is_red;
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline bool
+ with_red_black_flag_base<
+ Derived
+ , BaseGenerator
+ , T1
+ , T2
+ >::operator[](black_flag_key const&) const
+ {
+ return !this->_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
+ )
+ {
+ this->_is_red = flag;
+ this->on_post_modify_value(red_flag_key());
+ this->on_post_modify_value(black_flag_key());
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>::set_black_flag(
+ bool flag
+ )
+ {
+ this->_is_red = !flag;
+ this->on_post_modify_value(red_flag_key());
+ this->on_post_modify_value(black_flag_key());
+ }
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline bool
+ get(
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2> const& node
+ , red_flag_key const& key
+ )
+ {
+ return node[key];
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline bool
+ get(
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2> const& node
+ , black_flag_key const& key
+ )
+ {
+ return node[key];
+ }
+
+#if !defined BOOST_NO_SFINAE
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,red_flag_key>
+ , bool
+ >::type
+ get(with_red_black_flag_base<Derived,BaseGenerator,T1,T2> const& node)
+ {
+ return node[red_flag_key()];
+ }
+
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,black_flag_key>
+ , bool
+ >::type
+ get(with_red_black_flag_base<Derived,BaseGenerator,T1,T2> const& node)
+ {
+ return node[black_flag_key()];
+ }
+#endif // BOOST_NO_SFINAE
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ put(
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>& node
+ , red_flag_key const& key
+ , bool value
+ )
+ {
+ node.set_red_flag(value);
+ }
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ inline void
+ put(
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>& node
+ , black_flag_key const& key
+ , bool value
+ )
+ {
+ node.set_black_flag(value);
+ }
+}} // namespace boost::tree_node
+
+namespace boost { namespace tree_node { namespace result_of {
+
+#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ struct has_key_impl<
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>
+ , red_flag_key
+ > : ::boost::mpl::true_
+ {
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ struct has_key_impl<
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>
+ , black_flag_key
+ > : ::boost::mpl::true_
+ {
+ };
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ struct get_keys_impl<
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>
+ > : ::boost::mpl::vector2<red_flag_key,black_flag_key>
+ {
+ };
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ template <>
+ struct at_key_impl<red_flag_key>
+ {
+ template <typename Node>
+ struct apply
+ {
+ typedef bool type;
+ };
+ };
+
+ template <>
+ struct at_key_impl<black_flag_key>
+ {
+ template <typename Node>
+ struct apply
+ {
+ typedef bool type;
+ };
+ };
+}}} // namespace boost::tree_node::result_of
+
+//[reference__with_red_black_flag_base_gen
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator>
+ struct with_red_black_flag_base_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
+//]
+
+namespace boost { namespace tree_node {
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ struct with_red_black_flag
+ : public
+ //[reference__with_red_black_flag__bases
+ 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;
+ 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;
+ typedef typename super_t::reverse_iterator
+ reverse_iterator;
+ typedef typename super_t::const_reverse_iterator
+ const_reverse_iterator;
+ typedef typename super_t::size_type
+ size_type;
+
+ BOOST_TREE_NODE_COPYABLE_AND_MOVABLE(with_red_black_flag, super_t)
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ //[reference__with_red_black_flag__emplacement_ctor
+ template <typename ...Args>
+ explicit with_red_black_flag(Args&& ...args);
+ //]
+
+ //[reference__with_red_black_flag__emplacement_ctor_w_allocator
+ template <typename ...Args>
+ explicit with_red_black_flag(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ );
+ //]
+#else // !defined BOOST_CONTAINER_PERFECT_FORWARDING
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_INLINE_DEF
+ , (with_red_black_flag, super_t)
+ )
+
+ BOOST_PP_REPEAT(
+ BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS
+ , BOOST_TREE_NODE_EMPLACEMENT_CTOR_W_ALLOC_INLINE_DEF
+ , (with_red_black_flag, super_t)
+ )
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+ };
+
+#if defined BOOST_CONTAINER_PERFECT_FORWARDING
+ template <typename BaseGenerator, typename T1, typename T2>
+ template <typename ...Args>
+ inline with_red_black_flag<BaseGenerator,T1,T2>::with_red_black_flag(
+ Args&& ...args
+ ) : super_t(::boost::forward<Args>(args)...)
+ {
+ super_t::on_post_emplacement_construct();
+ }
+
+ template <typename BaseGenerator, typename T1, typename T2>
+ template <typename ...Args>
+ inline with_red_black_flag<BaseGenerator,T1,T2>::with_red_black_flag(
+ ::boost::container::allocator_arg_t
+ , typename traits::allocator_reference allocator
+ , Args&& ...args
+ ) : super_t(
+ ::boost::container::allocator_arg
+ , allocator
+ , ::boost::forward<Args>(args)...
+ )
+ {
+ super_t::on_post_emplacement_construct();
+ }
+#endif // BOOST_CONTAINER_PERFECT_FORWARDING
+}} // 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 T1, typename T2 = void>
+ struct apply
+ {
+ typedef with_red_black_flag<BaseGenerator,T1,T2> type;
+ };
+ };
+}} // namespace boost::tree_node
+//]
+
+#include <boost/tree_node/_detail/config_end.hpp>
+
+#endif // BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/tree_node/with_red_black_flag_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/tree_node/with_red_black_flag_fwd.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,140 @@
+// Copyright (C) 2013 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_FWD_HPP_INCLUDED
+#define BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_FWD_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/tree_node/key/red_black_flag.hpp>
+
+#if !defined BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/tr1/type_traits.hpp>
+#endif
+
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ class with_red_black_flag_base;
+
+ template <typename BaseGenerator, typename T1, typename T2 = void>
+ struct with_red_black_flag;
+}} // namespace boost::tree_node
+
+//[reference__with_red_black_flag_base__at_red_flag_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ bool
+ get(
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2> const& node
+ , red_flag_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,red_flag_key>
+ , bool
+ >::type
+ get(with_red_black_flag_base<Derived,BaseGenerator,T1,T2> const& node);
+//<-
+#endif
+//->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_red_black_flag_base__at_black_flag_key
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ bool
+ get(
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2> const& node
+ , black_flag_key const& key
+ );
+
+//<-
+#if !defined BOOST_NO_SFINAE
+//->
+ template <
+ typename Key
+ , typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ typename ::boost::enable_if<
+ ::std::tr1::is_same<Key,black_flag_key>
+ , bool
+ >::type
+ get(with_red_black_flag_base<Derived,BaseGenerator,T1,T2> const& node);
+//<-
+#endif
+//->
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_red_black_flag_base__put__red
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void
+ put(
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>& node
+ , red_flag_key const& key
+ , bool value
+ );
+}} // namespace boost::tree_node
+//]
+
+//[reference__with_red_black_flag_base__put__black
+namespace boost { namespace tree_node {
+
+ template <
+ typename Derived
+ , typename BaseGenerator
+ , typename T1
+ , typename T2
+ >
+ void
+ put(
+ with_red_black_flag_base<Derived,BaseGenerator,T1,T2>& node
+ , black_flag_key const& key
+ , bool value
+ );
+}} // namespace boost::tree_node
+//]
+
+#endif // BOOST_TREE_NODE_WITH_RED_BLACK_FLAG_FWD_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/typeof/boost/tree_node/balancer/adelson_velskii_landis.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/typeof/boost/tree_node/balancer/adelson_velskii_landis.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,19 @@
+// Copyright (C) 2013 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_TYPEOF_BOOST_TREE_NODE_BALANCER_ADELSON_VELSKII_LANDIS_HPP
+#define BOOST_TYPEOF_BOOST_TREE_NODE_BALANCER_ADELSON_VELSKII_LANDIS_HPP
+
+#include <boost/typeof/typeof.hpp>
+#include <boost/tree_node/balancer/adelson_velskii_landis.hpp>
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TYPE(::boost::tree_node::adelson_velskii_landis_balancer)
+BOOST_TYPEOF_REGISTER_TYPE(
+ ::boost::tree_node::balancer::adelson_velskii_landis
+)
+
+#endif // BOOST_TYPEOF_BOOST_TREE_NODE_BALANCER_ADELSON_VELSKII_LANDIS_HPP
+

Added: sandbox/tree_node/boost/typeof/boost/tree_node/balancer/null.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/typeof/boost/tree_node/balancer/null.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,17 @@
+// Copyright (C) 2013 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_TYPEOF_BOOST_TREE_NODE_BALANCER_NULL_HPP_INCLUDED
+#define BOOST_TYPEOF_BOOST_TREE_NODE_BALANCER_NULL_HPP_INCLUDED
+
+#include <boost/typeof/typeof.hpp>
+#include <boost/tree_node/balancer/null.hpp>
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TYPE(::boost::tree_node::null_balancer)
+BOOST_TYPEOF_REGISTER_TYPE(::boost::tree_node::balancer::null)
+
+#endif // BOOST_TYPEOF_BOOST_TREE_NODE_BALANCER_NULL_HPP_INCLUDED
+

Added: sandbox/tree_node/boost/typeof/boost/tree_node/balancer/red_black.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/typeof/boost/tree_node/balancer/red_black.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,17 @@
+// Copyright (C) 2013 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_TYPEOF_BOOST_TREE_NODE_BALANCER_RED_BLACK_HPP
+#define BOOST_TYPEOF_BOOST_TREE_NODE_BALANCER_RED_BLACK_HPP
+
+#include <boost/typeof/typeof.hpp>
+#include <boost/tree_node/balancer/red_black.hpp>
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TYPE(::boost::tree_node::red_black_balancer)
+BOOST_TYPEOF_REGISTER_TYPE(::boost::tree_node::balancer::red_black)
+
+#endif // BOOST_TYPEOF_BOOST_TREE_NODE_BALANCER_RED_BLACK_HPP
+

Added: sandbox/tree_node/boost/typeof/boost/tree_node/container/binode.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/typeof/boost/tree_node/container/binode.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,21 @@
+// Copyright (C) 2013 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_TYPEOF_BOOST_TREE_NODE_CONTAINER_BINODE_HPP
+#define BOOST_TYPEOF_BOOST_TREE_NODE_CONTAINER_BINODE_HPP
+
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/boost/container_gen/selectors.hpp>
+#include <boost/typeof/boost/tree_node/binary_node.hpp>
+#include <boost/typeof/boost/tree_node/balancer/null.hpp>
+#include <boost/tree_node/container/binode.hpp>
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_container, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_container, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_container, 3)
+
+#endif // BOOST_TYPEOF_BOOST_TREE_NODE_CONTAINER_BINODE_HPP
+

Added: sandbox/tree_node/boost/typeof/boost/tree_node/container/binode_associative.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/boost/typeof/boost/tree_node/container/binode_associative.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,37 @@
+// Copyright (C) 2013 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_TYPEOF_BOOST_TREE_NODE_CONTAINER_BINODE_ASSOCIATIVE_HPP
+#define BOOST_TYPEOF_BOOST_TREE_NODE_CONTAINER_BINODE_ASSOCIATIVE_HPP
+
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/boost/container_gen/selectors.hpp>
+#include <boost/typeof/boost/tree_node/balancer/red_black.hpp>
+#include <boost/tree_node/container/binode_associative.hpp>
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TEMPLATE(
+ ::boost::tree_node::binode_associative_container
+ , 6
+)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_set, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_set, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_set, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_set, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_multiset, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_multiset, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_multiset, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_multiset, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_map, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_map, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_map, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_map, 5)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_multimap, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_multimap, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_multimap, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::tree_node::binode_multimap, 5)
+
+#endif // BOOST_TYPEOF_BOOST_TREE_NODE_CONTAINER_BINODE_ASSOCIATIVE_HPP
+

Added: sandbox/tree_node/libs/tree_node/example/assoc_iterator_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/tree_node/libs/tree_node/example/assoc_iterator_functions.hpp 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,83 @@
+// Copyright (C) 2011-2013 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_ASSOC_ITERATOR_FUNCTIONS_HPP_INCLUDED
+#define LIBS_TREE_NODE_EXAMPLE_ASSOC_ITERATOR_FUNCTIONS_HPP_INCLUDED
+
+#include <iostream>
+#include <boost/tree_node/traversal_state.hpp>
+#include <boost/tree_node/iterator/breadth_first_descendant.hpp>
+#include <boost/tree_node/iterator/pre_order_descendant.hpp>
+#include <boost/tree_node/iterator/post_order_descendant.hpp>
+#include <boost/tree_node/iterator/depth_first_descendant.hpp>
+#include <boost/tree_node/iterator/dereference.hpp>
+
+template <typename NodeIterator, typename Function>
+void associative_iterator_out(NodeIterator itr, Function f, unsigned int n)
+{
+ for (unsigned int i = 0; itr; ++itr)
+ {
+ if (!i)
+ {
+ std::cout << std::endl << " ";
+ }
+
+ f(itr->first, boost::tree_node::dereference_iterator(itr));
+
+ if (++i == n)
+ {
+ i = 0;
+ }
+ }
+}
+
+template <typename NodeIterator, typename Function>
+void associative_iterator_out(NodeIterator itr, Function f, char const* text)
+{
+ for (std::cout << ';' << std::endl << text; itr; ++itr)
+ {
+ f(
+ itr->first
+ , boost::tree_node::dereference_iterator(itr)
+ , boost::tree_node::traversal_state(itr)
+ );
+ }
+}
+
+template <typename Node, typename Function>
+void associative_out_bf_pre_post(Node const& node, Function f, unsigned int n)
+{
+ std::cout << ';' << std::endl << " emplacer[bf_d_vals]";
+ associative_iterator_out(
+ boost::tree_node::make_breadth_first_descendant_iterator(node)
+ , f
+ , n
+ );
+ std::cout << ';' << std::endl << " emplacer[pre_d_vals]";
+ associative_iterator_out(
+ boost::tree_node::make_pre_order_descendant_iterator(node)
+ , f
+ , n
+ );
+ std::cout << ';' << std::endl << " emplacer[post_d_vals]";
+ associative_iterator_out(
+ boost::tree_node::make_post_order_descendant_iterator(node)
+ , f
+ , n
+ );
+}
+
+template <typename Node, typename Function>
+void associative_out_df(Node const& node, Function f)
+{
+ associative_iterator_out(
+ boost::tree_node::make_depth_first_descendant_iterator(node)
+ , f
+ , " emplacer[df_d_vals]"
+ );
+}
+
+#endif // LIBS_TREE_NODE_EXAMPLE_ASSOC_ITERATOR_FUNCTIONS_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 2013-04-07 12:06:43 EDT (Sun, 07 Apr 2013)
@@ -0,0 +1,920 @@
+// Copyright (C) 2011-2013 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/config.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/container_gen/is_unique_assoc_selector.hpp>
+#include <boost/typeof/boost/rational.hpp>
+#include <boost/typeof/boost/tree_node/associative_node.hpp>
+#include <boost/typeof/boost/tree_node/with_count.hpp>
+#include <boost/typeof/boost/tree_node/with_height.hpp>
+#include <boost/typeof/boost/tree_node/with_position.hpp>
+#include <boost/tree_node/iterator/breadth_first.hpp>
+#include <boost/tree_node/iterator/breadth_first_descendant.hpp>
+#include <boost/tree_node/iterator/pre_order.hpp>
+#include <boost/tree_node/iterator/post_order.hpp>
+#include <boost/tree_node/iterator/depth_first.hpp>
+#include <boost/tree_node/iterator/dereference.hpp>
+#include <boost/tree_node/preprocessor.hpp>
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+#include <boost/typeof/boost/tree_node/with_accumulation.hpp>
+#endif
+
+#include "type_definitions.hpp"
+#include "output_preamble.hpp"
+#include "output_functions.hpp"
+#include "iterator_functions.hpp"
+#include "assoc_iterator_functions.hpp"
+
+char const* names[] = {"able", "baker", "chuck", "dog", "easy", "fox"};
+
+template <typename Node>
+void initialize(Node& root)
+{
+ for (boost::tree_node::breadth_first_iterator<Node> itr(root); itr; ++itr)
+ {
+ typename Node::traits::data_type const& data = get(
+ *itr
+ , boost::tree_node::data_key()
+ );
+
+ if (1 < data)
+ {
+ for (std::size_t i = 0; i < data; ++i)
+ {
+ for (std::size_t j = 0; j + i < data; ++j)
+ {
+ itr->emplace(names[j], i);
+ }
+ }
+ }
+ }
+}
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+template <typename DNode, typename ANode>
+void out_with_them(DNode const& d_node, ANode const& a_node)
+{
+ std::cout << std::endl << "#if defined BOOST_TREE_NODE_CAN_USE_FUSION";
+ iterator_out_bf_pre_post(a_node, output_node<boost::mpl::true_>(), 1);
+ associative_out_bf_pre_post(a_node, output_node<boost::mpl::true_>(), 1);
+ associative_out_df(a_node, output_tree<boost::mpl::true_>(4, 9, false));
+ iterator_out_df(a_node, output_tree<boost::mpl::true_>(4, 9, false));
+ std::cout << "#else // !defined BOOST_TREE_NODE_CAN_USE_FUSION";
+ iterator_out_bf_pre_post(d_node, output_node<boost::mpl::false_>(), 6);
+ associative_out_bf_pre_post(d_node, output_node<boost::mpl::false_>(), 3);
+ associative_out_df(d_node, output_tree<boost::mpl::false_>(2, 5, true));
+ iterator_out_df(d_node, output_tree<boost::mpl::false_>(2, 7, true));
+ std::cout << "#endif // BOOST_NO_SFINAE" << std::endl;
+}
+#else // !defined BOOST_TREE_NODE_CAN_USE_FUSION
+template <typename DNode>
+void out_with_it(DNode const& d_node)
+{
+ iterator_out_bf_pre_post(d_node, output_node<boost::mpl::false_>(), 6);
+ associative_out_bf_pre_post(d_node, output_node<boost::mpl::false_>(), 3);
+ associative_out_df(d_node, output_tree<boost::mpl::false_>(2, 5, true));
+ iterator_out_df(d_node, output_tree<boost::mpl::false_>(2, 7, true));
+}
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION_WITH_TYPEOF
+template <typename FNode>
+void out_with_all(FNode const& f_node)
+{
+ iterator_out_bf_pre_post(f_node, output_uint_char_node(), 5);
+ associative_out_bf_pre_post(f_node, output_uint_char_node(), 3);
+ associative_out_df(f_node, output_uint_char_tree(4, 9, false));
+ iterator_out_df(f_node, output_uint_char_tree(4, 9, false));
+}
+#endif
+
+template <typename Selector>
+void output_driver()
+{
+ typedef boost::tree_node::with_height<
+ boost::tree_node::with_position_base_gen<
+ boost::tree_node::with_count_base_gen<
+ boost::tree_node::associative_node_base_gen<Selector>
+ >
+ >
+ , char const*
+ , boost::rational<long>
+ >
+ DNode;
+
+ DNode d_root(5);
+
+ initialize(d_root);
+
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ typedef boost::tree_node::with_accumulation<
+ boost::tree_node::with_height_base_gen<
+ boost::tree_node::with_accumulation_base_gen<
+ boost::tree_node::with_position_base_gen<
+ boost::tree_node::with_accumulation_base_gen<
+ boost::tree_node::with_count_base_gen<
+ boost::tree_node::with_accumulation_base_gen<
+ boost::tree_node::associative_node_base_gen<Selector>
+ >
+ >
+ , AccuAccuKey
+ >
+ >
+ , AccuCountKey
+ >
+ >
+ , char const*
+ , boost::rational<long>
+ , AccuHeightKey
+ >
+ ANode;
+
+ ANode a_root(5);
+
+ initialize(a_root);
+#endif // BOOST_TREE_NODE_CAN_USE_FUSION
+
+ std::cout << std::endl << "template <typename Selector>";
+ std::cout << std::endl << (
+ boost::is_unique_associative_selector<Selector>::value
+ ? "void test_unique_associative()"
+ : "void test_multiple_associative()"
+ ) << std::endl << '{' << std::endl;
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ std::cout << "#if defined BOOST_TREE_NODE_CAN_USE_FUSION" << std::endl << (
+ " typedef boost::tree_node::with_accumulation<"
+ ) << std::endl << " boost::tree_node::with_height_base_gen<";
+ std::cout << std::endl << (
+ " boost::tree_node::with_accumulation_base_gen<"
+ ) << std::endl << (
+ " boost::tree_node::with_position_base_gen<"
+ ) << std::endl << (
+ " boost::tree_node::with_accumulation_base_gen<"
+ ) << std::endl << (
+ " boost::tree_node::with_count_base_gen<"
+ ) << std::endl << " boost";
+ std::cout << "::tree_node::with_accumulation_base_gen<" << std::endl << (
+ " boost::tree_node::associative_node_base_gen"
+ ) << "<Selector>" << std::endl << " >" << std::endl;
+ std::cout << " >" << std::endl;
+ std::cout << " , AccuAccuKey" << std::endl;
+ std::cout << " >" << std::endl;
+ std::cout << " >" << std::endl;
+ std::cout << " , AccuCountKey" << std::endl;
+ std::cout << " >" << std::endl;
+ std::cout << " >" << std::endl;
+ std::cout << " , char const*" << std::endl;
+ std::cout << " , boost::rational<long>" << std::endl;
+ std::cout << " , AccuHeightKey" << std::endl << " >";
+ std::cout << std::endl << " ANode;" << std::endl << (
+ "#else // !defined BOOST_TREE_NODE_CAN_USE_FUSION"
+ ) << std::endl;
+#endif // BOOST_NO_SFINAE
+ std::cout << " typedef boost::tree_node::with_height<" << std::endl << (
+ " boost::tree_node::with_position_base_gen<"
+ ) << std::endl << (
+ " boost::tree_node::with_count_base_gen<"
+ ) << std::endl << " ";
+ std::cout << "boost::tree_node::associative_node_base_gen<Selector>";
+ std::cout << std::endl << " >" << std::endl;
+ std::cout << " >" << std::endl;
+ std::cout << " , char const*" << std::endl;
+ std::cout << " , boost::rational<long>" << std::endl;
+ std::cout << " >" << std::endl;
+ std::cout << " ANode;" << std::endl;
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ std::cout << "#endif // BOOST_TREE_NODE_CAN_USE_FUSION" << std::endl;
+#endif
+ output_container_type_preamble();
+ std::cout << " typedef typename boost::container_gen<" << std::endl;
+ std::cout << " boost::dequeS" << std::endl;
+ std::cout << " , boost::tuples::tuple<" << std::endl;
+ std::cout << " typename ANode::traits::key_type";
+ std::cout << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , boost::tree_node::data_key";
+ std::cout << std::endl << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , boost::tree_node::height_key";
+ std::cout << std::endl << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , boost::tree_node::count_key";
+ std::cout << std::endl << " >::type" << std::endl;
+ std::cout << "#if defined BOOST_TREE_NODE_CAN_USE_FUSION" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl << (
+ " , boost::tree_node::accumulation_key<>"
+ ) << std::endl << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , AccuHeightKey" << std::endl;
+ std::cout << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , AccuCountKey" << std::endl;
+ std::cout << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , AccuAccuKey" << std::endl;
+ std::cout << " >::type" << std::endl;
+ std::cout << "#endif // BOOST_TREE_NODE_CAN_USE_FUSION" << std::endl;
+ std::cout << " >" << std::endl << " >::type";
+ std::cout << std::endl << " KeyValues;" << std::endl;
+ std::cout << " typedef typename boost::container_gen<" << std::endl;
+ std::cout << " boost::dequeS" << std::endl;
+ std::cout << " , boost::tuples::tuple<" << std::endl;
+ std::cout << " boost::tree_node::traversal_state";
+ std::cout << std::endl << (
+ " , typename ANode::traits::key_type"
+ ) << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , boost::tree_node::data_key";
+ std::cout << std::endl << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , boost::tree_node::height_key";
+ std::cout << std::endl << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , boost::tree_node::count_key";
+ std::cout << std::endl << " >::type" << std::endl;
+ std::cout << "#if defined BOOST_TREE_NODE_CAN_USE_FUSION" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl << (
+ " , boost::tree_node::accumulation_key<>"
+ ) << std::endl << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , AccuHeightKey" << std::endl;
+ std::cout << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , AccuCountKey" << std::endl;
+ std::cout << " >::type" << std::endl << (
+ " , typename boost::tree_node::result_of::value_at_"
+ ) << "key<" << std::endl;
+ std::cout << " ANode const" << std::endl;
+ std::cout << " , AccuAccuKey" << std::endl;
+ std::cout << " >::type" << std::endl;
+ std::cout << "#endif // BOOST_TREE_NODE_CAN_USE_FUSION" << std::endl;
+ std::cout << " >" << std::endl << " >::type";
+ std::cout << std::endl << " DFKeyValues;" << std::endl;
+ std::cout << std::endl << " ANode a_root(5);" << std::endl;
+ std::cout << std::endl << " BOOST_CHECK(" << std::endl;
+ std::cout << " !a_root.get_parent_ptr()" << std::endl;
+ std::cout << "// , \"Parent member uninitialized.\"" << std::endl;
+ std::cout << " );" << std::endl << std::endl;
+ std::cout << " initialize<Selector>(a_root);" << std::endl << std::endl;
+ std::cout << " {" << std::endl;
+ std::cout << " Values bf_vals, pre_vals, post_vals;" << std::endl;
+ std::cout << " KeyValues bf_d_vals, pre_d_vals, post_d_vals;";
+ std::cout << std::endl << " DFValues df_vals;" << std::endl;
+ std::cout << " DFKeyValues df_d_vals;" << std::endl;
+ std::cout << " Emplacer emplacer;" << std::endl;
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ out_with_them(d_root, a_root);
+#else
+ out_with_it(d_root);
+#endif
+ std::cout << " test_associative_node<a_node_case>(" << std::endl;
+ std::cout << " a_root" << std::endl;
+ std::cout << " , bf_vals" << std::endl;
+ std::cout << " , bf_d_vals" << std::endl;
+ std::cout << " , pre_vals" << std::endl;
+ std::cout << " , pre_d_vals" << std::endl;
+ std::cout << " , post_vals" << std::endl;
+ std::cout << " , post_d_vals" << std::endl;
+ std::cout << " , df_vals" << std::endl;
+ std::cout << " , df_d_vals" << std::endl;
+ std::cout << " );" << std::endl << " }" << std::endl;
+
+ {
+ typename DNode::iterator d_child_itr(
+ boost::tree_node::dereference_iterator(
+ d_root.find(names[2])
+ ).insert(names[5], d_root)
+ );
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ typename ANode::iterator a_child_itr(
+ boost::tree_node::dereference_iterator(
+ a_root.find(names[2])
+ ).insert(names[5], a_root)
+ );
+#endif
+
+ std::cout << std::endl << " {" << std::endl;
+ std::cout << " ANode a_copy(a_root);" << std::endl << (
+ " boost::tree_node::breadth_first_iterator<ANode const>"
+ ) << std::endl << (
+ " bf_root_itr(a_root), bf_copy_itr(a_copy);"
+ ) << std::endl << " boost::tree_node::breadth_first";
+ std::cout << "_descendant_iterator<ANode const>" << std::endl << (
+ " bf_d_root_itr(a_root), bf_d_copy_itr(a_copy);"
+ ) << std::endl << (
+ " boost::tree_node::pre_order_iterator<ANode const>"
+ ) << std::endl << (
+ " pre_root_itr(a_root), pre_copy_itr(a_copy);"
+ ) << std::endl << " boost::tree_node::pre_order";
+ std::cout << "_descendant_iterator<ANode const>" << std::endl << (
+ " pre_d_root_itr(a_root), pre_d_copy_itr(a_copy);"
+ ) << std::endl << (
+ " boost::tree_node::post_order_iterator<ANode const>"
+ ) << std::endl << (
+ " post_root_itr(a_root), post_copy_itr(a_copy);"
+ ) << std::endl << " boost::tree_node::post_order";
+ std::cout << "_descendant_iterator<ANode const>" << std::endl << (
+ " post_d_root_itr(a_root), post_d_copy_itr(a_copy);"
+ ) << std::endl << (
+ " boost::tree_node::depth_first_iterator<ANode const>"
+ ) << std::endl << (
+ " df_root_itr(a_root), df_copy_itr(a_copy);"
+ ) << std::endl << " boost::tree_node::depth_first";
+ std::cout << "_descendant_iterator<ANode const>" << std::endl << (
+ " df_d_root_itr(a_root), df_d_copy_itr(a_copy);"
+ ) << std::endl << std::endl << " BOOST_CHECK(" << (
+ "test_node_copies(bf_root_itr, bf_copy_itr));"
+ ) << std::endl << " BOOST_CHECK(" << std::endl << " " << (
+ " test_associative_node_copies(bf_d_root_itr, bf_d_copy_itr)"
+ ) << std::endl << " );" << std::endl << " " << (
+ "BOOST_CHECK(test_node_copies(pre_root_itr, pre_copy_itr));"
+ ) << std::endl << " BOOST_CHECK(" << std::endl << " " << (
+ " test_associative_node_copies(pre_d_root_itr, pre_d_copy_itr)"
+ ) << std::endl << " );" << std::endl << " " << (
+ "BOOST_CHECK(test_node_copies(post_root_itr, post_copy_itr));"
+ ) << std::endl << " BOOST_CHECK(" << std::endl << " " << (
+ " test_associative_node_copies(post_d_root_itr, post_d_copy_it"
+ ) << "r)" << std::endl << " );" << std::endl << " " << (
+ "BOOST_CHECK(test_node_copies(df_root_itr, df_copy_itr));"
+ ) << std::endl << " BOOST_CHECK(" << std::endl << " " << (
+ " test_associative_node_copies(df_d_root_itr, df_d_copy_itr)"
+ ) << std::endl << " );" << std::endl << " }" << std::endl;
+ std::cout << std::endl << " {" << std::endl << (
+ " typename ANode::iterator a_child_itr("
+ ) << std::endl << " boost::tree_node::dereference_iterator(";
+ std::cout << std::endl << " a_root.find(names[2])";
+ std::cout << std::endl << " ).insert(names[5], a_root)";
+ std::cout << std::endl << " );" << std::endl << (
+ " Values bf_vals, pre_vals, post_vals;"
+ ) << std::endl;
+ std::cout << " KeyValues bf_d_vals, pre_d_vals, post_d_vals;";
+ std::cout << std::endl << " DFValues df_vals;" << std::endl;
+ std::cout << " DFKeyValues df_d_vals;" << std::endl;
+ std::cout << " Emplacer emplacer;" << std::endl;
+#if defined BOOST_TREE_NODE_CAN_USE_FUSION
+ out_with_them(d_root, a_root);
+#else
+ out_with_it(d_root);
+#endif
+ std::cout << " test_associative_node<a_node_case>(";
+ std::cout << std::endl << " a_root" << std::endl;
+ std::cout << " , bf_vals" << std::endl;
+ std::cout << " , bf_d_vals" << std::endl;
+ std::cout << " , pre_vals" << std::endl;
+ std::cout << " , pre_d_vals" << std::endl;
+ std::cout << " , post_vals" << std::endl;
+ std::cout << " , post_d_vals" << std::endl;
+ std::cout << " , df_vals" << std::endl; <