$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r53730 - in branches/release: boost boost/multi_index/detail libs/multi_index/doc libs/multi_index/example libs/multi_index/test
From: joaquin_at_[hidden]
Date: 2009-06-07 14:44:01
Author: joaquin
Date: 2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
New Revision: 53730
URL: http://svn.boost.org/trac/boost/changeset/53730
Log:
merged up to [53676] from trunk
Text files modified: 
   branches/release/boost/multi_index/detail/rnd_index_ops.hpp   |     4 +                                       
   branches/release/boost/multi_index_container.hpp              |     4 +-                                      
   branches/release/libs/multi_index/doc/examples.html           |    12 +++---                                  
   branches/release/libs/multi_index/example/bimap.cpp           |    13 +++++-                                  
   branches/release/libs/multi_index/test/pair_of_ints.hpp       |    21 ++++++++----                            
   branches/release/libs/multi_index/test/test_composite_key.cpp |     8 ++-                                     
   branches/release/libs/multi_index/test/test_list_ops.cpp      |    11 +++++                                   
   branches/release/libs/multi_index/test/test_modifiers.cpp     |    67 ++++++++++++++++++++++++++++++++++++++- 
   8 files changed, 114 insertions(+), 26 deletions(-)
Modified: branches/release/boost/multi_index/detail/rnd_index_ops.hpp
==============================================================================
--- branches/release/boost/multi_index/detail/rnd_index_ops.hpp	(original)
+++ branches/release/boost/multi_index/detail/rnd_index_ops.hpp	2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
@@ -1,4 +1,4 @@
-/* Copyright 2003-2008 Joaquin M Lopez Munoz.
+/* Copyright 2003-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -174,6 +174,8 @@
    *     solution adopted.
    */
 
+  if(ptrs.size()<=1)return;
+
   typedef typename Node::value_type         value_type;
   typedef typename Node::impl_pointer       impl_pointer;
   typedef typename Node::impl_ptr_pointer   impl_ptr_pointer;
Modified: branches/release/boost/multi_index_container.hpp
==============================================================================
--- branches/release/boost/multi_index_container.hpp	(original)
+++ branches/release/boost/multi_index_container.hpp	2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
@@ -1,6 +1,6 @@
 /* Multiply indexed container.
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -522,9 +522,9 @@
 
   void erase_(node_type* x)
   {
+    --node_count;
     super::erase_(x);
     deallocate_node(x);
-    --node_count;
   }
 
   void delete_node_(node_type* x)
Modified: branches/release/libs/multi_index/doc/examples.html
==============================================================================
--- branches/release/libs/multi_index/doc/examples.html	(original)
+++ branches/release/libs/multi_index/doc/examples.html	2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
@@ -104,10 +104,10 @@
 <p>
 This example shows how to construct a bidirectional map with
 <code>multi_index_container</code>. By a <i>bidirectional map</i> we mean
-a container of elements of <code>std::pair<const FromType,const ToType></code>
-such that no two elements exists with the same <code>first</code>
-<i>or</i> <code>second</code> value (<code>std::map</code> only
-guarantees uniqueness of the first member). Fast lookup is provided
+a container of <code>(const FromType,const ToType)</code> pairs
+such that no two elements exists with the same first
+<i>or</i> second component (<code>std::map</code> only
+guarantees uniqueness of the first component). Fast lookup is provided
 for both keys. The program features a tiny Spanish-English
 dictionary with online query of words in both languages.
 </p>
@@ -450,9 +450,9 @@
 
 <br>
 
-<p>Revised July 16th 2007</p>
+<p>Revised May 26th 2009</p>
 
-<p>© Copyright 2003-2007 Joaquín M López Muñoz.
+<p>© Copyright 2003-2009 Joaquín M López Muñoz.
 Distributed under the Boost Software 
 License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
 LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: branches/release/libs/multi_index/example/bimap.cpp
==============================================================================
--- branches/release/libs/multi_index/example/bimap.cpp	(original)
+++ branches/release/libs/multi_index/example/bimap.cpp	2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
@@ -1,6 +1,6 @@
 /* Boost.MultiIndex example of a bidirectional map.
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -18,7 +18,6 @@
 #include <boost/multi_index/ordered_index.hpp>
 #include <iostream>
 #include <string>
-#include <utility>
 
 using boost::multi_index_container;
 using namespace boost::multi_index;
@@ -35,7 +34,15 @@
 template<typename FromType,typename ToType>
 struct bidirectional_map
 {
-  typedef std::pair<FromType,ToType> value_type;
+  struct value_type
+  {
+    value_type(const FromType& first_,const ToType& second_):
+      first(first_),second(second_)
+    {}
+
+    FromType first;
+    ToType   second;
+  };
 
 #if defined(BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS) ||\
     defined(BOOST_MSVC)&&(BOOST_MSVC<1300) ||\
Modified: branches/release/libs/multi_index/test/pair_of_ints.hpp
==============================================================================
--- branches/release/libs/multi_index/test/pair_of_ints.hpp	(original)
+++ branches/release/libs/multi_index/test/pair_of_ints.hpp	2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
@@ -1,6 +1,6 @@
 /* Used in Boost.MultiIndex tests.
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -13,9 +13,20 @@
 
 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
 #include <boost/serialization/nvp.hpp>
-#include <utility>
 
-typedef std::pair<int,int> pair_of_ints;
+struct pair_of_ints
+{
+  pair_of_ints(int first_=0,int second_=0):first(first_),second(second_){}
+
+  bool operator==(const pair_of_ints& x)const
+  {
+    return first==x.first&&second==x.second;
+  }
+
+  bool operator!=(const pair_of_ints& x)const{return !(*this==x);}
+
+  int first,second;
+};
 
 inline void increment_first(pair_of_ints& p)
 {
@@ -50,8 +61,6 @@
 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
 namespace boost{
 namespace serialization{
-#else
-namespace std{
 #endif
 
 template<class Archive>
@@ -64,8 +73,6 @@
 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
 } /* namespace serialization */
 } /* namespace boost*/
-#else
-} /* namespace std */
 #endif
 
 #endif
Modified: branches/release/libs/multi_index/test/test_composite_key.cpp
==============================================================================
--- branches/release/libs/multi_index/test/test_composite_key.cpp	(original)
+++ branches/release/libs/multi_index/test/test_composite_key.cpp	2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
@@ -1,6 +1,6 @@
 /* Boost.MultiIndex test for composite_key.
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -637,9 +637,11 @@
   ch4=ch2; /* prevent unused var */
 
   BOOST_CHECK(
-    ch1(ck6(xystr(0,0,"hello")))==ch1(make_tuple(std::string("hello"),0,0)));
+    ch1(ck6(xystr(0,0,"hello")))==
+    ch1(boost::make_tuple(std::string("hello"),0,0)));
   BOOST_CHECK(
-    ch1(ck6(xystr(4,5,"world")))==ch1(make_tuple(std::string("world"),4,5)));
+    ch1(ck6(xystr(4,5,"world")))==
+    ch1(boost::make_tuple(std::string("world"),4,5)));
 
   typedef boost::hash<composite_key_result<ckey_t3> > ckeyres_hash_t;
 
Modified: branches/release/libs/multi_index/test/test_list_ops.cpp
==============================================================================
--- branches/release/libs/multi_index/test/test_list_ops.cpp	(original)
+++ branches/release/libs/multi_index/test/test_list_ops.cpp	2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
@@ -1,6 +1,6 @@
 /* Boost.MultiIndex test for standard list operations.
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -148,6 +148,15 @@
   si.merge(si2,std::greater<int>());
   BOOST_CHECK(is_sorted(si,std::greater<int>()));
   BOOST_CHECK(si2.empty());
+
+  /* testcase for bug reported at
+   * https://svn.boost.org/trac/boost/ticket/3076
+   */
+  {
+    Sequence         ss3;
+    sequenced_index &si3=get<1>(ss3);
+    si3.sort();
+  }
 }
 
 template<typename Sequence>
Modified: branches/release/libs/multi_index/test/test_modifiers.cpp
==============================================================================
--- branches/release/libs/multi_index/test/test_modifiers.cpp	(original)
+++ branches/release/libs/multi_index/test/test_modifiers.cpp	2009-06-07 14:44:00 EDT (Sun, 07 Jun 2009)
@@ -1,6 +1,6 @@
 /* Boost.MultiIndex test for modifier memfuns.
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -11,14 +11,17 @@
 #include "test_modifiers.hpp"
 
 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/enable_shared_from_this.hpp>
 #include <boost/next_prior.hpp>
+#include <boost/shared_ptr.hpp>
 #include <iterator>
 #include <vector>
 #include "pre_multi_index.hpp"
 #include "employee.hpp"
-#include <boost/next_prior.hpp>
 #include <boost/test/test_tools.hpp>
 
+using namespace boost::multi_index;
+
 class always_one
 {
 public:
@@ -49,7 +52,58 @@
 } /* namespace boost */
 #endif
 
-using namespace boost::multi_index;
+class linked_object
+{
+  struct impl:boost::enable_shared_from_this<impl>
+  {
+    typedef boost::shared_ptr<const impl> ptr;
+
+    impl(int n_,ptr next_=ptr()):n(n_),next(next_){}
+
+    int n;
+    ptr next;
+  };
+
+  typedef multi_index_container<
+    impl,
+    indexed_by<
+
+#if BOOST_WORKAROUND(__IBMCPP__,BOOST_TESTED_AT(1010))
+      ordered_unique<member<impl,int,&linked_object::impl::n> >,
+      hashed_non_unique<member<impl,int,&linked_object::impl::n> >,
+#else
+      ordered_unique<member<impl,int,&impl::n> >,
+      hashed_non_unique<member<impl,int,&impl::n> >,
+#endif
+
+      sequenced<>,
+      random_access<>
+    >
+  > impl_repository_t;
+
+  static impl_repository_t impl_repository;
+
+public:
+  linked_object(int n):pimpl(init(impl(n))){}
+  linked_object(int n,const linked_object& x):pimpl(init(impl(n,x.pimpl))){}
+
+private:
+  impl::ptr init(const impl& x)
+  {
+    std::pair<impl_repository_t::iterator,bool> p=impl_repository.insert(x);
+    if(p.second)return impl::ptr(&*p.first,&erase_impl);
+    else        return p.first->shared_from_this();
+  }
+
+  static void erase_impl(const impl* p)
+  {
+    impl_repository.erase(p->n);
+  }
+
+  impl::ptr pimpl;
+};
+
+linked_object::impl_repository_t linked_object::impl_repository;
 
 void test_modifiers()
 {
@@ -312,4 +366,11 @@
   BOOST_CHECK(std::distance(c.begin(),c.insert(c.upper_bound(1),1))==8);
   BOOST_CHECK(std::distance(c.begin(),c.insert(boost::prior(c.end()),1))==9);
   BOOST_CHECK(std::distance(c.begin(),c.insert(c.end(),1))==10);
+
+  /* testcase for erase() reentrancy */
+  {
+    linked_object o1(1);
+    linked_object o2(2,o1);
+    o1=o2;
+  }
 }