implemented N4190

This commit is contained in:
joaquintides 2015-03-25 20:44:06 +01:00
parent 19505ffa5f
commit 7683cec919
14 changed files with 106 additions and 65 deletions

View File

@ -30,6 +30,7 @@ Acknowledgements
<h2>Contents</h2> <h2>Contents</h2>
<ul> <ul>
<li><a href="#boost_1_59">Boost 1.59 release</a></li>
<li><a href="#boost_1_58">Boost 1.58 release</a></li> <li><a href="#boost_1_58">Boost 1.58 release</a></li>
<li><a href="#boost_1_57">Boost 1.57 release</a></li> <li><a href="#boost_1_57">Boost 1.57 release</a></li>
<li><a href="#boost_1_56">Boost 1.56 release</a></li> <li><a href="#boost_1_56">Boost 1.56 release</a></li>
@ -51,6 +52,14 @@ Acknowledgements
<li><a href="#boost_1_33">Boost 1.33 release</a></li> <li><a href="#boost_1_33">Boost 1.33 release</a></li>
</ul> </ul>
<h2><a name="boost_1_59">Boost 1.59 release</a></h2>
<p>
<ul>
<li>Maintenance fixes.</li>
</ul>
</p>
<h2><a name="boost_1_58">Boost 1.58 release</a></h2> <h2><a name="boost_1_58">Boost 1.58 release</a></h2>
<p> <p>
@ -491,9 +500,9 @@ Acknowledgements
<br> <br>
<p>Revised November 12th 2014</p> <p>Revised March 25th 2015</p>
<p>&copy; Copyright 2003-2014 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz. <p>&copy; Copyright 2003-2015 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
Distributed under the Boost Software Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt"> 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"> LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">

View File

@ -527,15 +527,16 @@ indices), but induces important limitations in non key-based indices:
<span class=special>&gt;</span> <span class=special>&gt;</span>
<span class=special>&gt;</span> <span class=identifier>container</span><span class=special>;</span> <span class=special>&gt;</span> <span class=identifier>container</span><span class=special>;</span>
<span class=identifier>container</span> <span class=identifier>c</span><span class=special>;</span> <span class=identifier>container</span> <span class=identifier>c</span><span class=special>;</span>
<span class=identifier>std</span><span class=special>::</span><span class=identifier>mt19937</span> <span class=identifier>rng</span><span class=special>;</span>
<span class=special>...</span> <span class=special>...</span>
<span class=comment>// compiler error: assignment to read-only objects</span> <span class=comment>// compiler error: assignment to read-only objects</span>
<span class=identifier>std</span><span class=special>::</span><span class=identifier>random_shuffle</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>shuffle</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>rng</span><span class=special>);</span>
</pre></blockquote> </pre></blockquote>
<p> <p>
What is unfortunate about the previous example is that the operation What is unfortunate about the previous example is that the operation
performed by <code>std::random_shuffle</code> is potentially compatible performed by <code>std::shuffle</code> is potentially compatible
with <code>multi_index_container</code> invariants, as its result can be with <code>multi_index_container</code> invariants, as its result can be
described by a permutation of the elements in the random access index described by a permutation of the elements in the random access index
with no actual modifications to the elements themselves. There are many with no actual modifications to the elements themselves. There are many
@ -561,7 +562,7 @@ container:
<span class=identifier>BOOST_FOREACH</span><span class=special>(</span><span class=keyword>const</span> <span class=keyword>int</span><span class=special>&amp;</span> <span class=identifier>i</span><span class=special>,</span><span class=identifier>c</span><span class=special>)</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>push_back</span><span class=special>(</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>cref</span><span class=special>(</span><span class=identifier>i</span><span class=special>));</span> <span class=identifier>BOOST_FOREACH</span><span class=special>(</span><span class=keyword>const</span> <span class=keyword>int</span><span class=special>&amp;</span> <span class=identifier>i</span><span class=special>,</span><span class=identifier>c</span><span class=special>)</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>push_back</span><span class=special>(</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>cref</span><span class=special>(</span><span class=identifier>i</span><span class=special>));</span>
<span class=comment>// this compiles OK, as reference_wrappers are swappable</span> <span class=comment>// this compiles OK, as reference_wrappers are swappable</span>
<span class=identifier>std</span><span class=special>::</span><span class=identifier>random_shuffle</span><span class=special>(</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>shuffle</span><span class=special>(</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>rng</span><span class=special>);</span>
</pre></blockquote> </pre></blockquote>
<p> <p>
@ -569,7 +570,7 @@ Elements of <code>v</code> are <code>reference_wrapper</code>s (from
<a href="../../../../doc/html/ref.html">Boost.Ref</a>) to the actual elements <a href="../../../../doc/html/ref.html">Boost.Ref</a>) to the actual elements
in the multi-index container. These objects still do not allow modification in the multi-index container. These objects still do not allow modification
of the referenced entities, but they are swappable, of the referenced entities, but they are swappable,
which is the only requirement <code>std::random_shuffle</code> imposes. Once which is the only requirement <code>std::shuffle</code> imposes. Once
we have our desired rearrange stored in the view, we can transfer it to we have our desired rearrange stored in the view, we can transfer it to
the container with the container with
</p> </p>
@ -716,9 +717,9 @@ Key extraction
<br> <br>
<p>Revised July 7th 2013</p> <p>Revised March 25th 2015</p>
<p>&copy; Copyright 2003-2013 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz. <p>&copy; Copyright 2003-2015 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
Distributed under the Boost Software Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt"> 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"> LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">

View File

@ -675,7 +675,7 @@ pointers to <code>employee</code> are:
<ul> <ul>
<li><code>employee *</code>,</li> <li><code>employee *</code>,</li>
<li><code>const employee *</code>,</li> <li><code>const employee *</code>,</li>
<li><code>std::auto_ptr&lt;employee></code>,</li> <li><code>std::unique_ptr&lt;employee></code>,</li>
<li><code>std::list&lt;boost::reference_wrapper&lt;employee> >::iterator</code>,</li> <li><code>std::list&lt;boost::reference_wrapper&lt;employee> >::iterator</code>,</li>
<li><code>employee **</code>,</li> <li><code>employee **</code>,</li>
<li><code>boost::shared_ptr&lt;const employee *></code>.</li> <li><code>boost::shared_ptr&lt;const employee *></code>.</li>
@ -955,9 +955,9 @@ Container creation
<br> <br>
<p>Revised August 20th 2014</p> <p>Revised March 25th 2015</p>
<p>&copy; Copyright 2003-2014 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz. <p>&copy; Copyright 2003-2015 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
Distributed under the Boost Software Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt"> 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"> LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">

View File

@ -1,6 +1,6 @@
/* Boost.MultiIndex example of use of rearrange facilities. /* Boost.MultiIndex example of use of rearrange facilities.
* *
* Copyright 2003-2008 Joaquin M Lopez Munoz. * Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -25,6 +25,10 @@
#include <iterator> #include <iterator>
#include <vector> #include <vector>
#if !defined(BOOST_NO_CXX11_HDR_RANDOM)
#include <random>
#endif
using boost::multi_index_container; using boost::multi_index_container;
using namespace boost::multi_index; using namespace boost::multi_index;
@ -178,22 +182,38 @@ private:
}; };
/* A truly random shuffle (up to stdlib implementation quality) using /* A truly random shuffle (up to stdlib implementation quality) using
* std::random_shuffle. * std::shuffle.
*/ */
struct random_shuffler struct random_shuffler
{ {
void operator()(deck& d)const void operator()(deck& d)
{ {
dv.clear(); dv.clear();
dv.reserve(d.size()); dv.reserve(d.size());
std::copy(d.begin(),d.end(),std::back_inserter(dv)); std::copy(d.begin(),d.end(),std::back_inserter(dv));
std::random_shuffle(dv.begin(),dv.end()); /* do the shuffling */ shuffle_view();
d.rearrange(dv.begin()); /* apply to the deck */ d.rearrange(dv.begin()); /* apply to the deck */
} }
private: private:
mutable deck_view dv; deck_view dv;
#if !defined(BOOST_NO_CXX11_HDR_RANDOM)
std::mt19937 e;
void shuffle_view()
{
std::shuffle(dv.begin(),dv.end(),e);
}
#else
/* for pre-C++11 compilers we use std::random_shuffle */
void shuffle_view()
{
std::random_shuffle(dv.begin(),dv.end());
}
#endif
}; };
/* Repeat a given shuffling algorithm repeats_num times /* Repeat a given shuffling algorithm repeats_num times

View File

@ -16,7 +16,6 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm> #include <algorithm>
#include <boost/multi_index/detail/rnd_index_ptr_array.hpp> #include <boost/multi_index/detail/rnd_index_ptr_array.hpp>
#include <functional>
namespace boost{ namespace boost{
@ -123,11 +122,12 @@ void random_access_index_inplace_merge(
/* auxiliary stuff */ /* auxiliary stuff */
template<typename Node,typename Compare> template<typename Node,typename Compare>
struct random_access_index_sort_compare: struct random_access_index_sort_compare
std::binary_function<
typename Node::impl_pointer,
typename Node::impl_pointer,bool>
{ {
typedef typename Node::impl_pointer first_argument_type;
typedef typename Node::impl_pointer second_argument_type;
typedef bool result_type;
random_access_index_sort_compare(Compare comp_=Compare()):comp(comp_){} random_access_index_sort_compare(Compare comp_=Compare()):comp(comp_){}
bool operator()( bool operator()(

View File

@ -1,4 +1,4 @@
/* Copyright 2003-2013 Joaquin M Lopez Munoz. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -15,7 +15,6 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/call_traits.hpp> #include <boost/call_traits.hpp>
#include <functional>
namespace boost{ namespace boost{
@ -24,8 +23,12 @@ namespace multi_index{
namespace detail{ namespace detail{
template<typename Value,typename KeyFromValue,typename Compare> template<typename Value,typename KeyFromValue,typename Compare>
struct value_comparison:std::binary_function<Value,Value,bool> struct value_comparison
{ {
typedef Value first_argument_type;
typedef Value second_argument_type;
typedef bool result_type;
value_comparison( value_comparison(
const KeyFromValue& key_=KeyFromValue(),const Compare& comp_=Compare()): const KeyFromValue& key_=KeyFromValue(),const Compare& comp_=Compare()):
key(key_),comp(comp_) key(key_),comp(comp_)

View File

@ -1,4 +1,4 @@
/* Copyright 2003-2013 Joaquin M Lopez Munoz. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -43,7 +43,7 @@ namespace detail{
* pointer to T we mean a type P such that, given a p of Type P * pointer to T we mean a type P such that, given a p of Type P
* *...n...*x is convertible to T&, for some n>=1. * *...n...*x is convertible to T&, for some n>=1.
* Examples of chained pointers are raw and smart pointers, iterators and * Examples of chained pointers are raw and smart pointers, iterators and
* arbitrary combinations of these (vg. T** or auto_ptr<T*>.) * arbitrary combinations of these (vg. T** or unique_ptr<T*>.)
*/ */
template<class Value,typename Type,Type (*PtrToFunction)(Value)> template<class Value,typename Type,Type (*PtrToFunction)(Value)>

View File

@ -1,4 +1,4 @@
/* Copyright 2003-2013 Joaquin M Lopez Munoz. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -39,7 +39,7 @@ namespace detail{
* mean a type P such that, given a p of type P * mean a type P such that, given a p of type P
* *...n...*x is convertible to Type&, for some n>=1. * *...n...*x is convertible to Type&, for some n>=1.
* Examples of chained pointers are raw and smart pointers, iterators and * Examples of chained pointers are raw and smart pointers, iterators and
* arbitrary combinations of these (vg. Type** or auto_ptr<Type*>.) * arbitrary combinations of these (vg. Type** or unique_ptr<Type*>.)
*/ */
template<typename Type> template<typename Type>

View File

@ -1,4 +1,4 @@
/* Copyright 2003-2013 Joaquin M Lopez Munoz. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -36,7 +36,7 @@ namespace multi_index{
* to T we mean a type P such that, given a p of Type P * to T we mean a type P such that, given a p of Type P
* *...n...*x is convertible to T&, for some n>=1. * *...n...*x is convertible to T&, for some n>=1.
* Examples of chained pointers are raw and smart pointers, iterators and * Examples of chained pointers are raw and smart pointers, iterators and
* arbitrary combinations of these (vg. T** or auto_ptr<T*>.) * arbitrary combinations of these (vg. T** or unique_ptr<T*>.)
*/ */
template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()const> template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()const>

View File

@ -1,4 +1,4 @@
/* Copyright 2003-2013 Joaquin M Lopez Munoz. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -38,7 +38,7 @@ namespace detail{
* a type P such that, given a p of Type P * a type P such that, given a p of Type P
* *...n...*x is convertible to T&, for some n>=1. * *...n...*x is convertible to T&, for some n>=1.
* Examples of chained pointers are raw and smart pointers, iterators and * Examples of chained pointers are raw and smart pointers, iterators and
* arbitrary combinations of these (vg. T** or auto_ptr<T*>.) * arbitrary combinations of these (vg. T** or unique_ptr<T*>.)
*/ */
template<class Class,typename Type,Type Class::*PtrToMember> template<class Class,typename Type,Type Class::*PtrToMember>

View File

@ -1,4 +1,4 @@
/* Copyright 2003-2014 Joaquin M Lopez Munoz. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -15,6 +15,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm> #include <algorithm>
#include <boost/bind.hpp>
#include <boost/call_traits.hpp> #include <boost/call_traits.hpp>
#include <boost/detail/no_exceptions_support.hpp> #include <boost/detail/no_exceptions_support.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
@ -49,7 +50,6 @@
#endif #endif
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
#include <boost/bind.hpp>
#include <boost/multi_index/detail/rnd_index_loader.hpp> #include <boost/multi_index/detail/rnd_index_loader.hpp>
#endif #endif
@ -583,7 +583,8 @@ public:
difference_type n= difference_type n=
end()-make_iterator( end()-make_iterator(
random_access_index_remove<node_type>( random_access_index_remove<node_type>(
ptrs,std::bind2nd(std::equal_to<value_type>(),value))); ptrs,
::boost::bind(std::equal_to<value_type>(),::boost::arg<1>(),value)));
while(n--)pop_back(); while(n--)pop_back();
} }

View File

@ -1,4 +1,4 @@
/* Copyright 2003-2014 Joaquin M Lopez Munoz. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -14,6 +14,7 @@
#endif #endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/bind.hpp>
#include <boost/call_traits.hpp> #include <boost/call_traits.hpp>
#include <boost/detail/allocator_utilities.hpp> #include <boost/detail/allocator_utilities.hpp>
#include <boost/detail/no_exceptions_support.hpp> #include <boost/detail/no_exceptions_support.hpp>
@ -516,7 +517,8 @@ public:
void remove(value_param_type value) void remove(value_param_type value)
{ {
sequenced_index_remove( sequenced_index_remove(
*this,std::bind2nd(std::equal_to<value_type>(),value)); *this,
::boost::bind(std::equal_to<value_type>(),::boost::arg<1>(),value));
} }
template<typename Predicate> template<typename Predicate>

View File

@ -1,6 +1,6 @@
/* Boost.MultiIndex test for key extractors. /* Boost.MultiIndex test for key extractors.
* *
* Copyright 2003-2013 Joaquin M Lopez Munoz. * Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -17,7 +17,6 @@
#include <boost/ref.hpp> #include <boost/ref.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <list> #include <list>
#include <memory>
using namespace boost::multi_index; using namespace boost::multi_index;
using namespace boost::tuples; using namespace boost::tuples;
@ -188,8 +187,8 @@ void test_key_extractors()
test_class** tpp=&tp; test_class** tpp=&tp;
const test_class** ctpp=&ctp; const test_class** ctpp=&ctp;
std::auto_ptr<test_class*> tap(new test_class*(tp)); boost::scoped_ptr<test_class*> tap(new test_class*(tp));
std::auto_ptr<const test_class*> ctap(new const test_class*(ctp)); boost::scoped_ptr<const test_class*> ctap(new const test_class*(ctp));
boost::reference_wrapper<test_class> tw(tr); boost::reference_wrapper<test_class> tw(tr);
boost::reference_wrapper<const test_class> ctw(tr); boost::reference_wrapper<const test_class> ctw(tr);

View File

@ -1,6 +1,6 @@
/* Boost.MultiIndex test for range(). /* Boost.MultiIndex test for range().
* *
* Copyright 2003-2013 Joaquin M Lopez Munoz. * Copyright 2003-2015 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -12,14 +12,14 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm> #include <algorithm>
#include <functional> #include <boost/bind.hpp>
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include "pre_multi_index.hpp" #include "pre_multi_index.hpp"
#include <boost/multi_index_container.hpp> #include <boost/multi_index_container.hpp>
#include <boost/multi_index/identity.hpp> #include <boost/multi_index/identity.hpp>
#include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/ordered_index.hpp>
#include <boost/preprocessor/seq/enum.hpp> #include <boost/preprocessor/seq/enum.hpp>
#include <functional>
using namespace boost::multi_index; using namespace boost::multi_index;
@ -38,6 +38,12 @@ typedef int_set::iterator int_set_iterator;
#undef CHECK_VOID_RANGE #undef CHECK_VOID_RANGE
#define CHECK_VOID_RANGE(p) BOOST_TEST((p).first==(p).second) #define CHECK_VOID_RANGE(p) BOOST_TEST((p).first==(p).second)
#undef BIND1ST
#define BIND1ST(f,x) ::boost::bind(f,x,::boost::arg<1>())
#undef BIND2ND
#define BIND2ND(f,x) ::boost::bind(f,::boost::arg<1>(),x)
void test_range() void test_range()
{ {
int_set is; int_set is;
@ -50,70 +56,70 @@ void test_range()
CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)); CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7)(8)(9)(10));
p=is.range( p=is.range(
std::bind1st(std::less<int>(),5), /* 5 < x */ BIND1ST(std::less<int>(),5), /* 5 < x */
unbounded); unbounded);
CHECK_RANGE(p,(6)(7)(8)(9)(10)); CHECK_RANGE(p,(6)(7)(8)(9)(10));
p=is.range( p=is.range(
std::bind1st(std::less_equal<int>(),8), /* 8 <= x */ BIND1ST(std::less_equal<int>(),8), /* 8 <= x */
unbounded); unbounded);
CHECK_RANGE(p,(8)(9)(10)); CHECK_RANGE(p,(8)(9)(10));
p=is.range( p=is.range(
std::bind1st(std::less_equal<int>(),11), /* 11 <= x */ BIND1ST(std::less_equal<int>(),11), /* 11 <= x */
unbounded); unbounded);
CHECK_VOID_RANGE(p); CHECK_VOID_RANGE(p);
p=is.range( p=is.range(
unbounded, unbounded,
std::bind2nd(std::less<int>(),8)); /* x < 8 */ BIND2ND(std::less<int>(),8)); /* x < 8 */
CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7)); CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7));
p=is.range( p=is.range(
unbounded, unbounded,
std::bind2nd(std::less_equal<int>(),4)); /* x <= 4 */ BIND2ND(std::less_equal<int>(),4)); /* x <= 4 */
CHECK_RANGE(p,(1)(2)(3)(4)); CHECK_RANGE(p,(1)(2)(3)(4));
p=is.range( p=is.range(
unbounded, unbounded,
std::bind2nd(std::less_equal<int>(),0)); /* x <= 0 */ BIND2ND(std::less_equal<int>(),0)); /* x <= 0 */
CHECK_VOID_RANGE(p); CHECK_VOID_RANGE(p);
p=is.range( p=is.range(
std::bind1st(std::less<int>(),6), /* 6 < x */ BIND1ST(std::less<int>(),6), /* 6 < x */
std::bind2nd(std::less_equal<int>(),9)); /* x <= 9 */ BIND2ND(std::less_equal<int>(),9)); /* x <= 9 */
CHECK_RANGE(p,(7)(8)(9)); CHECK_RANGE(p,(7)(8)(9));
p=is.range( p=is.range(
std::bind1st(std::less_equal<int>(),4), /* 4 <= x */ BIND1ST(std::less_equal<int>(),4), /* 4 <= x */
std::bind2nd(std::less<int>(),5)); /* x < 5 */ BIND2ND(std::less<int>(),5)); /* x < 5 */
CHECK_RANGE(p,(4)); CHECK_RANGE(p,(4));
p=is.range( p=is.range(
std::bind1st(std::less_equal<int>(),10), /* 10 <= x */ BIND1ST(std::less_equal<int>(),10), /* 10 <= x */
std::bind2nd(std::less_equal<int>(),10)); /* x <= 10 */ BIND2ND(std::less_equal<int>(),10)); /* x <= 10 */
CHECK_RANGE(p,(10)); CHECK_RANGE(p,(10));
p=is.range( p=is.range(
std::bind1st(std::less<int>(),0), /* 0 < x */ BIND1ST(std::less<int>(),0), /* 0 < x */
std::bind2nd(std::less<int>(),11)); /* x < 11 */ BIND2ND(std::less<int>(),11)); /* x < 11 */
CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)); CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7)(8)(9)(10));
p=is.range( p=is.range(
std::bind1st(std::less<int>(),7), /* 7 < x */ BIND1ST(std::less<int>(),7), /* 7 < x */
std::bind2nd(std::less_equal<int>(),7)); /* x <= 7 */ BIND2ND(std::less_equal<int>(),7)); /* x <= 7 */
CHECK_VOID_RANGE(p); CHECK_VOID_RANGE(p);
BOOST_TEST(p.first==is.upper_bound(7)); BOOST_TEST(p.first==is.upper_bound(7));
p=is.range( p=is.range(
std::bind1st(std::less_equal<int>(),8), /* 8 <= x */ BIND1ST(std::less_equal<int>(),8), /* 8 <= x */
std::bind2nd(std::less<int>(),2)); /* x < 2 */ BIND2ND(std::less<int>(),2)); /* x < 2 */
CHECK_VOID_RANGE(p); CHECK_VOID_RANGE(p);
BOOST_TEST(p.first==is.lower_bound(8)); BOOST_TEST(p.first==is.lower_bound(8));
p=is.range( p=is.range(
std::bind1st(std::less<int>(),4), /* 4 < x */ BIND1ST(std::less<int>(),4), /* 4 < x */
std::bind2nd(std::less<int>(),5)); /* x < 5 */ BIND2ND(std::less<int>(),5)); /* x < 5 */
CHECK_VOID_RANGE(p); CHECK_VOID_RANGE(p);
BOOST_TEST(p.first!=is.end()); BOOST_TEST(p.first!=is.end());
} }