Adding Boost.Assign to BoostParts

This commit is contained in:
Strahinja Val Markovic 2013-05-26 10:35:18 -07:00
parent 34b997c4d6
commit fd3cf1e56d
25 changed files with 5046 additions and 1 deletions

View File

@ -19,7 +19,7 @@
# the BCP tool: # the BCP tool:
# http://www.boost.org/doc/libs/1_52_0/tools/bcp/doc/html/index.html # http://www.boost.org/doc/libs/1_52_0/tools/bcp/doc/html/index.html
# #
# bcp call: bcp boost/utility.hpp boost/python.hpp boost/bind.hpp boost/lambda/lambda.hpp boost/exception/all.hpp boost/tuple/tuple_io.hpp boost/tuple/tuple_comparison.hpp boost/regex.hpp boost/foreach.hpp boost/smart_ptr.hpp boost/algorithm/string_regex.hpp boost/thread.hpp boost/unordered_map.hpp boost/unordered_set.hpp boost/format.hpp boost/ptr_container/ptr_container.hpp boost/filesystem.hpp boost/filesystem/fstream.hpp boost/utility.hpp boost/algorithm/cxx11/any_of.hpp atomic lockfree ../BoostParts # bcp call: bcp boost/utility.hpp boost/python.hpp boost/bind.hpp boost/lambda/lambda.hpp boost/exception/all.hpp boost/tuple/tuple_io.hpp boost/tuple/tuple_comparison.hpp boost/regex.hpp boost/foreach.hpp boost/smart_ptr.hpp boost/algorithm/string_regex.hpp boost/thread.hpp boost/unordered_map.hpp boost/unordered_set.hpp boost/format.hpp boost/ptr_container/ptr_container.hpp boost/filesystem.hpp boost/filesystem/fstream.hpp boost/utility.hpp boost/algorithm/cxx11/any_of.hpp atomic lockfree assign ../BoostParts
cmake_minimum_required( VERSION 2.8 ) cmake_minimum_required( VERSION 2.8 )

View File

@ -0,0 +1,24 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_HPP
#define BOOST_ASSIGN_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/std.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/assign/list_inserter.hpp>
#include <boost/assign/assignment_exception.hpp>
#endif

View File

@ -0,0 +1,43 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_ASSIGNMENT_EXCEPTION_HPP
#define BOOST_ASSIGN_ASSIGNMENT_EXCEPTION_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <exception>
namespace boost
{
namespace assign
{
class assignment_exception : public std::exception
{
public:
assignment_exception( const char* _what )
: what_( _what )
{ }
virtual const char* what() const throw()
{
return what_;
}
private:
const char* what_;
};
}
}
#endif

View File

@ -0,0 +1,400 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_LIST_INSERTER_HPP
#define BOOST_ASSIGN_LIST_INSERTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/detail/workaround.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/config.hpp>
#include <cstddef>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/iteration/local.hpp>
#include <boost/preprocessor/arithmetic/inc.hpp>
namespace boost
{
namespace assign_detail
{
template< class T >
struct repeater
{
std::size_t sz;
T val;
repeater( std::size_t sz_, T r ) : sz( sz_ ), val( r )
{ }
};
template< class Fun >
struct fun_repeater
{
std::size_t sz;
Fun val;
fun_repeater( std::size_t sz_, Fun r ) : sz( sz_ ), val( r )
{ }
};
template< class C >
class call_push_back
{
C& c_;
public:
call_push_back( C& c ) : c_( c )
{ }
template< class T >
void operator()( T r )
{
c_.push_back( r );
}
};
template< class C >
class call_push_front
{
C& c_;
public:
call_push_front( C& c ) : c_( c )
{ }
template< class T >
void operator()( T r )
{
c_.push_front( r );
}
};
template< class C >
class call_push
{
C& c_;
public:
call_push( C& c ) : c_( c )
{ }
template< class T >
void operator()( T r )
{
c_.push( r );
}
};
template< class C >
class call_insert
{
C& c_;
public:
call_insert( C& c ) : c_( c )
{ }
template< class T >
void operator()( T r )
{
c_.insert( r );
}
};
template< class C >
class call_add_edge
{
C& c_;
public:
call_add_edge( C& c ) : c_(c)
{ }
template< class T >
void operator()( T l, T r )
{
add_edge( l, r, c_ );
}
template< class T, class EP >
void operator()( T l, T r, const EP& ep )
{
add_edge( l, r, ep, c_ );
}
};
struct forward_n_arguments {};
} // namespace 'assign_detail'
namespace assign
{
template< class T >
inline assign_detail::repeater<T>
repeat( std::size_t sz, T r )
{
return assign_detail::repeater<T>( sz, r );
}
template< class Function >
inline assign_detail::fun_repeater<Function>
repeat_fun( std::size_t sz, Function r )
{
return assign_detail::fun_repeater<Function>( sz, r );
}
template< class Function, class Argument = assign_detail::forward_n_arguments >
class list_inserter
{
struct single_arg_type {};
struct n_arg_type {};
typedef BOOST_DEDUCED_TYPENAME mpl::if_c< is_same<Argument,assign_detail::forward_n_arguments>::value,
n_arg_type,
single_arg_type >::type arg_type;
public:
list_inserter( Function fun ) : insert_( fun )
{}
template< class Function2, class Arg >
list_inserter( const list_inserter<Function2,Arg>& r )
: insert_( r.fun_private() )
{}
list_inserter( const list_inserter& r ) : insert_( r.insert_ )
{}
list_inserter& operator()()
{
insert_( Argument() );
return *this;
}
template< class T >
list_inserter& operator=( const T& r )
{
insert_( r );
return *this;
}
template< class T >
list_inserter& operator=( assign_detail::repeater<T> r )
{
return operator,( r );
}
template< class Nullary_function >
list_inserter& operator=( const assign_detail::fun_repeater<Nullary_function>& r )
{
return operator,( r );
}
template< class T >
list_inserter& operator,( const T& r )
{
insert_( r );
return *this;
}
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
template< class T >
list_inserter& operator,( const assign_detail::repeater<T> & r )
{
return repeat( r.sz, r.val );
}
#else
template< class T >
list_inserter& operator,( assign_detail::repeater<T> r )
{
return repeat( r.sz, r.val );
}
#endif
template< class Nullary_function >
list_inserter& operator,( const assign_detail::fun_repeater<Nullary_function>& r )
{
return repeat_fun( r.sz, r.val );
}
template< class T >
list_inserter& repeat( std::size_t sz, T r )
{
std::size_t i = 0;
while( i++ != sz )
insert_( r );
return *this;
}
template< class Nullary_function >
list_inserter& repeat_fun( std::size_t sz, Nullary_function fun )
{
std::size_t i = 0;
while( i++ != sz )
insert_( fun() );
return *this;
}
template< class SinglePassIterator >
list_inserter& range( SinglePassIterator first,
SinglePassIterator last )
{
for( ; first != last; ++first )
insert_( *first );
return *this;
}
template< class SinglePassRange >
list_inserter& range( const SinglePassRange& r )
{
return range( boost::begin(r), boost::end(r) );
}
template< class T >
list_inserter& operator()( const T& t )
{
insert_( t );
return *this;
}
#ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
#define BOOST_ASSIGN_MAX_PARAMS 5
#endif
#define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
#define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class T)
#define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& t)
#define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, t)
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class T, BOOST_ASSIGN_PARAMS1(n) > \
list_inserter& operator()(T t, BOOST_ASSIGN_PARAMS2(n) ) \
{ \
BOOST_PP_CAT(insert, BOOST_PP_INC(n))(t, BOOST_ASSIGN_PARAMS3(n), arg_type()); \
return *this; \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class T, BOOST_ASSIGN_PARAMS1(n) > \
void BOOST_PP_CAT(insert, BOOST_PP_INC(n))(T const& t, BOOST_ASSIGN_PARAMS2(n), single_arg_type) \
{ \
insert_( Argument(t, BOOST_ASSIGN_PARAMS3(n) )); \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class T, BOOST_ASSIGN_PARAMS1(n) > \
void BOOST_PP_CAT(insert, BOOST_PP_INC(n))(T const& t, BOOST_ASSIGN_PARAMS2(n), n_arg_type) \
{ \
insert_(t, BOOST_ASSIGN_PARAMS3(n) ); \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
Function fun_private() const
{
return insert_;
}
private:
list_inserter& operator=( const list_inserter& );
Function insert_;
};
template< class Function >
inline list_inserter< Function >
make_list_inserter( Function fun )
{
return list_inserter< Function >( fun );
}
template< class Function, class Argument >
inline list_inserter<Function,Argument>
make_list_inserter( Function fun, Argument* )
{
return list_inserter<Function,Argument>( fun );
}
template< class C >
inline list_inserter< assign_detail::call_push_back<C>,
BOOST_DEDUCED_TYPENAME C::value_type >
push_back( C& c )
{
static BOOST_DEDUCED_TYPENAME C::value_type* p = 0;
return make_list_inserter( assign_detail::call_push_back<C>( c ),
p );
}
template< class C >
inline list_inserter< assign_detail::call_push_front<C>,
BOOST_DEDUCED_TYPENAME C::value_type >
push_front( C& c )
{
static BOOST_DEDUCED_TYPENAME C::value_type* p = 0;
return make_list_inserter( assign_detail::call_push_front<C>( c ),
p );
}
template< class C >
inline list_inserter< assign_detail::call_insert<C>,
BOOST_DEDUCED_TYPENAME C::value_type >
insert( C& c )
{
static BOOST_DEDUCED_TYPENAME C::value_type* p = 0;
return make_list_inserter( assign_detail::call_insert<C>( c ),
p );
}
template< class C >
inline list_inserter< assign_detail::call_push<C>,
BOOST_DEDUCED_TYPENAME C::value_type >
push( C& c )
{
static BOOST_DEDUCED_TYPENAME C::value_type* p = 0;
return make_list_inserter( assign_detail::call_push<C>( c ),
p );
}
template< class C >
inline list_inserter< assign_detail::call_add_edge<C> >
add_edge( C& c )
{
return make_list_inserter( assign_detail::call_add_edge<C>( c ) );
}
} // namespace 'assign'
} // namespace 'boost'
#undef BOOST_ASSIGN_PARAMS1
#undef BOOST_ASSIGN_PARAMS2
#undef BOOST_ASSIGN_PARAMS3
#undef BOOST_ASSIGN_MAX_PARAMETERS
#endif

View File

@ -0,0 +1,681 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_LIST_OF_HPP
#define BOOST_ASSIGN_LIST_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/assignment_exception.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/config.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/type_traits/decay.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/mpl/if.hpp>
#include <deque>
#include <cstddef>
#include <utility>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/iteration/local.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// BCB requires full type definition for is_array<> to work correctly.
#include <boost/array.hpp>
#endif
namespace boost
{
// this here is necessary to avoid compiler error in <boost/array.hpp>
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template< class T, std::size_t sz >
class array;
#endif
namespace assign_detail
{
/////////////////////////////////////////////////////////////////////////
// Part 0: common conversion code
/////////////////////////////////////////////////////////////////////////
template< class T >
struct assign_decay
{
//
// Add constness to array parameters
// to support string literals properly
//
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
::boost::is_array<T>,
::boost::decay<const T>,
::boost::decay<T> >::type type;
};
template< class T, std::size_t sz >
type_traits::yes_type assign_is_array( const array<T,sz>* );
type_traits::no_type assign_is_array( ... );
template< class T, class U >
type_traits::yes_type assign_is_pair( const std::pair<T,U>* );
type_traits::no_type assign_is_pair( ... );
struct array_type_tag
{
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
private:
char dummy_; // BCB would by default use 8 bytes
#endif
};
struct adapter_type_tag
{
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
private:
char dummy_; // BCB would by default use 8 bytes
#endif
};
struct pair_type_tag
{
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
private:
char dummy_; // BCB would by default use 8 bytes
#endif
};
struct default_type_tag
{
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
private:
char dummy_; // BCB would by default use 8 bytes
#endif
};
template< class DerivedTAssign, class Iterator >
class converter
{
public: // Range operations
typedef Iterator iterator;
typedef Iterator const_iterator;
iterator begin() const
{
return static_cast<const DerivedTAssign*>(this)->begin();
}
iterator end() const
{
return static_cast<const DerivedTAssign*>(this)->end();
}
public:
template< class Container >
Container convert_to_container() const
{
static Container* c = 0;
BOOST_STATIC_CONSTANT( bool, is_array_flag = sizeof( assign_detail::assign_is_array( c ) )
== sizeof( type_traits::yes_type ) );
typedef BOOST_DEDUCED_TYPENAME mpl::if_c< is_array_flag,
array_type_tag,
default_type_tag >::type tag_type;
return convert<Container>( c, tag_type() );
}
private:
template< class Container >
Container convert( const Container*, default_type_tag ) const
{
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
// old Dinkumware doesn't support iterator type as template
Container result;
iterator it = begin(),
e = end();
while( it != e )
{
result.insert( result.end(), *it );
++it;
}
return result;
#else
return Container( begin(), end() );
#endif
}
template< class Array >
Array convert( const Array*, array_type_tag ) const
{
typedef BOOST_DEDUCED_TYPENAME Array::value_type value_type;
#if BOOST_WORKAROUND(BOOST_INTEL, <= 910 ) || BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580 )
BOOST_DEDUCED_TYPENAME remove_const<Array>::type ar;
#else
Array ar;
#endif
const std::size_t sz = ar.size();
if( sz < static_cast<const DerivedTAssign*>(this)->size() )
throw assign::assignment_exception( "array initialized with too many elements" );
std::size_t n = 0;
iterator i = begin(),
e = end();
for( ; i != e; ++i, ++n )
ar[n] = *i;
for( ; n < sz; ++n )
ar[n] = value_type();
return ar;
}
template< class Adapter >
Adapter convert_to_adapter( const Adapter* = 0 ) const
{
Adapter a;
iterator i = begin(),
e = end();
for( ; i != e; ++i )
a.push( *i );
return a;
}
private:
struct adapter_converter;
friend struct adapter_converter;
struct adapter_converter
{
const converter& gl;
adapter_converter( const converter& this_ ) : gl( this_ )
{}
adapter_converter( const adapter_converter& r )
: gl( r.gl )
{ }
template< class Adapter >
operator Adapter() const
{
return gl.convert_to_adapter<Adapter>();
}
};
public:
template< class Container >
Container to_container( Container& c ) const
{
return convert( &c, default_type_tag() );
}
adapter_converter to_adapter() const
{
return adapter_converter( *this );
}
template< class Adapter >
Adapter to_adapter( Adapter& a ) const
{
return this->convert_to_adapter( &a );
}
template< class Array >
Array to_array( Array& a ) const
{
return convert( &a, array_type_tag() );
}
};
template< class T, class I, class Range >
inline bool operator==( const converter<T,I>& l, const Range& r )
{
return ::boost::iterator_range_detail::equal( l, r );
}
template< class T, class I, class Range >
inline bool operator==( const Range& l, const converter<T,I>& r )
{
return r == l;
}
template< class T, class I, class Range >
inline bool operator!=( const converter<T,I>& l, const Range& r )
{
return !( l == r );
}
template< class T, class I, class Range >
inline bool operator!=( const Range& l, const converter<T,I>& r )
{
return !( l == r );
}
template< class T, class I, class Range >
inline bool operator<( const converter<T,I>& l, const Range& r )
{
return ::boost::iterator_range_detail::less_than( l, r );
}
template< class T, class I, class Range >
inline bool operator<( const Range& l, const converter<T,I>& r )
{
return ::boost::iterator_range_detail::less_than( l, r );
}
template< class T, class I, class Range >
inline bool operator>( const converter<T,I>& l, const Range& r )
{
return r < l;
}
template< class T, class I, class Range >
inline bool operator>( const Range& l, const converter<T,I>& r )
{
return r < l;
}
template< class T, class I, class Range >
inline bool operator<=( const converter<T,I>& l, const Range& r )
{
return !( l > r );
}
template< class T, class I, class Range >
inline bool operator<=( const Range& l, const converter<T,I>& r )
{
return !( l > r );
}
template< class T, class I, class Range >
inline bool operator>=( const converter<T,I>& l, const Range& r )
{
return !( l < r );
}
template< class T, class I, class Range >
inline bool operator>=( const Range& l, const converter<T,I>& r )
{
return !( l < r );
}
template< class T, class I, class Elem, class Traits >
inline std::basic_ostream<Elem,Traits>&
operator<<( std::basic_ostream<Elem, Traits>& Os,
const converter<T,I>& r )
{
return Os << ::boost::make_iterator_range( r.begin(), r.end() );
}
/////////////////////////////////////////////////////////////////////////
// Part 1: flexible, but inefficient interface
/////////////////////////////////////////////////////////////////////////
template< class T >
class generic_list :
public converter< generic_list< BOOST_DEDUCED_TYPENAME assign_decay<T>::type >,
BOOST_DEDUCED_TYPENAME std::deque<BOOST_DEDUCED_TYPENAME
assign_decay<T>::type>::iterator >
{
typedef BOOST_DEDUCED_TYPENAME assign_decay<T>::type Ty;
typedef std::deque<Ty> impl_type;
mutable impl_type values_;
public:
typedef BOOST_DEDUCED_TYPENAME impl_type::iterator iterator;
typedef iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME impl_type::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME impl_type::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME impl_type::difference_type difference_type;
public:
iterator begin() const { return values_.begin(); }
iterator end() const { return values_.end(); }
bool empty() const { return values_.empty(); }
size_type size() const { return values_.size(); }
private:
void push_back( value_type r ) { values_.push_back( r ); }
public:
generic_list& operator,( const Ty& u )
{
this->push_back( u );
return *this;
}
generic_list& operator()()
{
this->push_back( Ty() );
return *this;
}
generic_list& operator()( const Ty& u )
{
this->push_back( u );
return *this;
}
#ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
#define BOOST_ASSIGN_MAX_PARAMS 5
#endif
#define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
#define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class U)
#define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, U, const& u)
#define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, u)
#define BOOST_ASSIGN_PARAMS4(n) BOOST_PP_ENUM_PARAMS(n, U)
#define BOOST_ASSIGN_PARAMS2_NO_REF(n) BOOST_PP_ENUM_BINARY_PARAMS(n, U, u)
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class U, BOOST_ASSIGN_PARAMS1(n) > \
generic_list& operator()(U const& u, BOOST_ASSIGN_PARAMS2(n) ) \
{ \
this->push_back( Ty(u, BOOST_ASSIGN_PARAMS3(n))); \
return *this; \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
template< class U >
generic_list& repeat( std::size_t sz, U u )
{
std::size_t i = 0;
while( i++ != sz )
this->push_back( u );
return *this;
}
template< class Nullary_function >
generic_list& repeat_fun( std::size_t sz, Nullary_function fun )
{
std::size_t i = 0;
while( i++ != sz )
this->push_back( fun() );
return *this;
}
template< class SinglePassIterator >
generic_list& range( SinglePassIterator first,
SinglePassIterator last )
{
for( ; first != last; ++first )
this->push_back( *first );
return *this;
}
template< class SinglePassRange >
generic_list& range( const SinglePassRange& r )
{
return range( boost::begin(r), boost::end(r) );
}
template< class Container >
operator Container() const
{
return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
}
};
/////////////////////////////////////////////////////////////////////////
// Part 2: efficient, but inconvenient interface
/////////////////////////////////////////////////////////////////////////
template< class T >
struct assign_reference
{
assign_reference()
{ /* intentionally empty */ }
assign_reference( T& r ) : ref_(&r)
{ }
void operator=( T& r )
{
ref_ = &r;
}
operator T&() const
{
return *ref_;
}
void swap( assign_reference& r )
{
std::swap( *ref_, *r.ref_ );
}
T& get_ref() const
{
return *ref_;
}
private:
T* ref_;
};
template< class T >
inline bool operator<( const assign_reference<T>& l,
const assign_reference<T>& r )
{
return l.get_ref() < r.get_ref();
}
template< class T >
inline bool operator>( const assign_reference<T>& l,
const assign_reference<T>& r )
{
return l.get_ref() > r.get_ref();
}
template< class T >
inline void swap( assign_reference<T>& l,
assign_reference<T>& r )
{
l.swap( r );
}
template< class T, int N >
struct static_generic_list :
public converter< static_generic_list<T,N>, assign_reference<T>* >
{
private:
typedef T internal_value_type;
public:
typedef assign_reference<internal_value_type> value_type;
typedef value_type* iterator;
typedef value_type* const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
static_generic_list( T& r ) :
current_(1)
{
refs_[0] = r;
}
static_generic_list& operator()( T& r )
{
insert( r );
return *this;
}
iterator begin() const
{
return &refs_[0];
}
iterator end() const
{
return &refs_[current_];
}
size_type size() const
{
return static_cast<size_type>( current_ );
}
bool empty() const
{
return false;
}
template< class ForwardIterator >
static_generic_list& range( ForwardIterator first,
ForwardIterator last )
{
for( ; first != last; ++first )
this->insert( *first );
return *this;
}
template< class ForwardRange >
static_generic_list& range( ForwardRange& r )
{
return range( boost::begin(r), boost::end(r) );
}
template< class ForwardRange >
static_generic_list& range( const ForwardRange& r )
{
return range( boost::begin(r), boost::end(r) );
}
template< class Container >
operator Container() const
{
return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
}
private:
void insert( T& r )
{
refs_[current_] = r;
++current_;
}
static_generic_list();
mutable assign_reference<internal_value_type> refs_[N];
int current_;
};
} // namespace 'assign_detail'
namespace assign
{
template< class T >
inline assign_detail::generic_list<T>
list_of()
{
return assign_detail::generic_list<T>()( T() );
}
template< class T >
inline assign_detail::generic_list<T>
list_of( const T& t )
{
return assign_detail::generic_list<T>()( t );
}
template< int N, class T >
inline assign_detail::static_generic_list< BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type,N>
ref_list_of( T& t )
{
return assign_detail::static_generic_list<BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type,N>( t );
}
template< int N, class T >
inline assign_detail::static_generic_list<const BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type,N>
cref_list_of( const T& t )
{
return assign_detail::static_generic_list<const BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type,N>( t );
}
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class T, class U, BOOST_ASSIGN_PARAMS1(n) > \
inline assign_detail::generic_list<T> \
list_of(U const& u, BOOST_ASSIGN_PARAMS2(n) ) \
{ \
return assign_detail::generic_list<T>()(u, BOOST_ASSIGN_PARAMS3(n)); \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class U, BOOST_ASSIGN_PARAMS1(n) > \
inline assign_detail::generic_list< tuple<U, BOOST_ASSIGN_PARAMS4(n)> > \
tuple_list_of(U u, BOOST_ASSIGN_PARAMS2_NO_REF(n) ) \
{ \
return assign_detail::generic_list< tuple<U, BOOST_ASSIGN_PARAMS4(n)> >()( tuple<U,BOOST_ASSIGN_PARAMS4(n)>( u, BOOST_ASSIGN_PARAMS3(n) )); \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
template< class Key, class T >
inline assign_detail::generic_list< std::pair
<
BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<Key>::type,
BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type
> >
map_list_of( const Key& k, const T& t )
{
typedef BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<Key>::type k_type;
typedef BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type t_type;
return assign_detail::generic_list< std::pair<k_type,t_type> >()( k, t );
}
template< class F, class S >
inline assign_detail::generic_list< std::pair
<
BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<F>::type,
BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<S>::type
> >
pair_list_of( const F& f, const S& s )
{
return map_list_of( f, s );
}
} // namespace 'assign'
} // namespace 'boost'
#undef BOOST_ASSIGN_PARAMS1
#undef BOOST_ASSIGN_PARAMS2
#undef BOOST_ASSIGN_PARAMS3
#undef BOOST_ASSIGN_PARAMS4
#undef BOOST_ASSIGN_PARAMS2_NO_REF
#undef BOOST_ASSIGN_MAX_PARAMETERS
#endif

View File

@ -0,0 +1,164 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_PTR_LIST_INSERTER_HPP
#define BOOST_ASSIGN_PTR_LIST_INSERTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_pointer.hpp>
namespace boost
{
namespace assign
{
template< class Function, class Obj >
class ptr_list_inserter
{
typedef BOOST_DEDUCED_TYPENAME
remove_pointer< BOOST_DEDUCED_TYPENAME
remove_reference<Obj>::type >::type
obj_type;
public:
ptr_list_inserter( Function fun ) : insert_( fun )
{}
template< class Function2, class Obj2 >
ptr_list_inserter( const ptr_list_inserter<Function2,Obj2>& r )
: insert_( r.fun_private() )
{}
ptr_list_inserter( const ptr_list_inserter& r ) : insert_( r.insert_ )
{}
ptr_list_inserter& operator()()
{
insert_( new obj_type() );
return *this;
}
template< class T >
ptr_list_inserter& operator()( const T& t )
{
insert_( new obj_type(t) );
return *this;
}
#ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
#define BOOST_ASSIGN_MAX_PARAMS 5
#endif
#define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
#define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class T)
#define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& t)
#define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, t)
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class T, BOOST_ASSIGN_PARAMS1(n) > \
ptr_list_inserter& operator()( const T& t, BOOST_ASSIGN_PARAMS2(n) ) \
{ \
insert_( new obj_type(t, BOOST_ASSIGN_PARAMS3(n) )); \
return *this; \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
private:
ptr_list_inserter& operator=( const ptr_list_inserter& );
Function insert_;
};
template< class Obj, class Function >
inline ptr_list_inserter< Function, Obj >
make_ptr_list_inserter( Function fun )
{
return ptr_list_inserter< Function, Obj >( fun );
}
template< class C >
inline ptr_list_inserter< assign_detail::call_push_back<C>,
BOOST_DEDUCED_TYPENAME C::reference >
ptr_push_back( C& c )
{
return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
( assign_detail::call_push_back<C>( c ) );
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class T, class C >
inline ptr_list_inserter< assign_detail::call_push_back<C>, T >
ptr_push_back( C& c )
{
return make_ptr_list_inserter<T>(
assign_detail::call_push_back<C>( c ) );
}
#endif
template< class C >
inline ptr_list_inserter< assign_detail::call_push_front<C>,
BOOST_DEDUCED_TYPENAME C::reference >
ptr_push_front( C& c )
{
return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
( assign_detail::call_push_front<C>( c ) );
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class T, class C >
inline ptr_list_inserter< assign_detail::call_push_front<C>, T >
ptr_push_front( C& c )
{
return make_ptr_list_inserter<T>(
assign_detail::call_push_front<C>( c ) );
}
#endif
template< class C >
inline ptr_list_inserter< assign_detail::call_insert<C>,
BOOST_DEDUCED_TYPENAME C::reference>
ptr_insert( C& c )
{
return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
( assign_detail::call_insert<C>( c ) );
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class T, class C >
inline ptr_list_inserter< assign_detail::call_insert<C>, T >
ptr_insert( C& c )
{
return make_ptr_list_inserter<T>( assign_detail::call_insert<C>( c ) );
}
#endif
} // namespace 'assign'
} // namespace 'boost'
#undef BOOST_ASSIGN_PARAMS1
#undef BOOST_ASSIGN_PARAMS2
#undef BOOST_ASSIGN_PARAMS3
#undef BOOST_ASSIGN_MAX_PARAMETERS
#endif

View File

@ -0,0 +1,191 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_PTR_LIST_OF_HPP
#define BOOST_ASSIGN_PTR_LIST_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_of.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/type_traits/decay.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/mpl/if.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/iteration/local.hpp>
namespace boost
{
namespace assign_detail
{
/////////////////////////////////////////////////////////////////////////
// Part 1: flexible and efficient interface
/////////////////////////////////////////////////////////////////////////
template< class T >
class generic_ptr_list :
public converter< generic_ptr_list<T>,
BOOST_DEDUCED_TYPENAME boost::ptr_vector<T>::iterator >
{
protected:
typedef boost::ptr_vector<T> impl_type;
typedef std::auto_ptr<impl_type> release_type;
mutable impl_type values_;
public:
typedef BOOST_DEDUCED_TYPENAME impl_type::iterator iterator;
typedef iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME impl_type::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME impl_type::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME impl_type::difference_type difference_type;
public:
generic_ptr_list() : values_( 32u )
{ }
generic_ptr_list( release_type r ) : values_(r)
{ }
release_type release()
{
return values_.release();
}
public:
iterator begin() const { return values_.begin(); }
iterator end() const { return values_.end(); }
bool empty() const { return values_.empty(); }
size_type size() const { return values_.size(); }
public:
operator impl_type() const
{
return values_;
}
template< template<class,class,class> class Seq, class U,
class CA, class A >
operator Seq<U,CA,A>() const
{
Seq<U,CA,A> result;
result.transfer( result.end(), values_ );
BOOST_ASSERT( empty() );
return result;
}
template< class PtrContainer >
std::auto_ptr<PtrContainer> convert( const PtrContainer* c ) const
{
std::auto_ptr<PtrContainer> res( new PtrContainer() );
while( !empty() )
res->insert( res->end(),
values_.pop_back().release() );
return res;
}
template< class PtrContainer >
std::auto_ptr<PtrContainer> to_container( const PtrContainer& c ) const
{
return convert( &c );
}
protected:
void push_back( T* r ) { values_.push_back( r ); }
public:
generic_ptr_list& operator()()
{
this->push_back( new T() );
return *this;
}
template< class U >
generic_ptr_list& operator()( const U& u )
{
this->push_back( new T(u) );
return *this;
}
#ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
#define BOOST_ASSIGN_MAX_PARAMS 5
#endif
#define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
#define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class U)
#define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, U, const& u)
#define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, u)
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class U, BOOST_ASSIGN_PARAMS1(n) > \
generic_ptr_list& operator()(U const& u, BOOST_ASSIGN_PARAMS2(n) ) \
{ \
this->push_back( new T(u, BOOST_ASSIGN_PARAMS3(n))); \
return *this; \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
}; // class 'generic_ptr_list'
} // namespace 'assign_detail'
namespace assign
{
template< class T >
inline assign_detail::generic_ptr_list<T>
ptr_list_of()
{
return assign_detail::generic_ptr_list<T>()();
}
template< class T, class U >
inline assign_detail::generic_ptr_list<T>
ptr_list_of( const U& t )
{
return assign_detail::generic_ptr_list<T>()( t );
}
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class T, class U, BOOST_ASSIGN_PARAMS1(n) > \
inline assign_detail::generic_ptr_list<T> \
ptr_list_of(U const& u, BOOST_ASSIGN_PARAMS2(n) ) \
{ \
return assign_detail::generic_ptr_list<T>()(u, BOOST_ASSIGN_PARAMS3(n)); \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
} // namespace 'assign'
} // namespace 'boost'
#undef BOOST_ASSIGN_PARAMS1
#undef BOOST_ASSIGN_PARAMS2
#undef BOOST_ASSIGN_PARAMS3
#undef BOOST_ASSIGN_MAX_PARAMETERS
#endif

View File

@ -0,0 +1,103 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_PTR_CONTAINER_PTR_MAP_INSERTER_HPP
#define BOOST_ASSIGN_PTR_CONTAINER_PTR_MAP_INSERTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_pointer.hpp>
namespace boost
{
namespace assign
{
template< class PtrMap, class Obj >
class ptr_map_inserter
{
typedef BOOST_DEDUCED_TYPENAME
remove_pointer< BOOST_DEDUCED_TYPENAME
remove_reference<Obj>::type >::type
obj_type;
typedef BOOST_DEDUCED_TYPENAME PtrMap::key_type
key_type;
public:
ptr_map_inserter( PtrMap& m ) : m_( m )
{}
template< class Key >
ptr_map_inserter& operator()( const Key& t )
{
key_type k(t);
m_.insert( k, new obj_type );
return *this;
}
#ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
#define BOOST_ASSIGN_MAX_PARAMS 6
#endif
#define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
#define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class T)
#define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& t)
#define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, t)
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
#define BOOST_PP_LOCAL_MACRO(n) \
template< class T, BOOST_ASSIGN_PARAMS1(n) > \
ptr_map_inserter& operator()( const T& t, BOOST_ASSIGN_PARAMS2(n) ) \
{ \
key_type k(t); \
m_.insert( k, new obj_type( BOOST_ASSIGN_PARAMS3(n) ) ); \
return *this; \
} \
/**/
#include BOOST_PP_LOCAL_ITERATE()
private:
ptr_map_inserter& operator=( const ptr_map_inserter& );
PtrMap& m_;
};
template< class PtrMap >
inline ptr_map_inserter< PtrMap, typename PtrMap::mapped_reference >
ptr_map_insert( PtrMap& m )
{
return ptr_map_inserter< PtrMap, typename PtrMap::mapped_reference >( m );
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class T, class PtrMap >
inline ptr_map_inserter< PtrMap, T >
ptr_map_insert( PtrMap& m )
{
return ptr_map_inserter< PtrMap, T >( m );
}
#endif
} // namespace 'assign'
} // namespace 'boost'
#undef BOOST_ASSIGN_PARAMS1
#undef BOOST_ASSIGN_PARAMS2
#undef BOOST_ASSIGN_PARAMS3
#undef BOOST_ASSIGN_MAX_PARAMETERS
#endif

View File

@ -0,0 +1,27 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_HPP
#define BOOST_ASSIGN_STD_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/std/vector.hpp>
#include <boost/assign/std/deque.hpp>
#include <boost/assign/std/list.hpp>
#include <boost/assign/std/slist.hpp>
#include <boost/assign/std/stack.hpp>
#include <boost/assign/std/queue.hpp>
#include <boost/assign/std/set.hpp>
#include <boost/assign/std/map.hpp>
#endif

View File

@ -0,0 +1,38 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_DEQUE_HPP
#define BOOST_ASSIGN_STD_DEQUE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/config.hpp>
#include <deque>
namespace boost
{
namespace assign
{
template< class V, class A, class V2 >
inline list_inserter< assign_detail::call_push_back< std::deque<V,A> >, V >
operator+=( std::deque<V,A>& c, V2 v )
{
return push_back( c )( v );
}
}
}
#endif

View File

@ -0,0 +1,38 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_LIST_HPP
#define BOOST_ASSIGN_STD_LIST_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/config.hpp>
#include <list>
namespace boost
{
namespace assign
{
template< class V, class A, class V2 >
inline list_inserter< assign_detail::call_push_back< std::list<V,A> >, V >
operator+=( std::list<V,A>& c, V2 v )
{
return push_back( c )( v );
}
}
}
#endif

View File

@ -0,0 +1,45 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_MAP_HPP
#define BOOST_ASSIGN_STD_MAP_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/config.hpp>
#include <map>
namespace boost
{
namespace assign
{
template< class K, class V, class C, class A, class P >
inline list_inserter< assign_detail::call_insert< std::map<K,V,C,A> >, P >
operator+=( std::map<K,V,C,A>& m, const P& p )
{
return insert( m )( p );
}
template< class K, class V, class C, class A, class P >
inline list_inserter< assign_detail::call_insert< std::multimap<K,V,C,A> >, P >
operator+=( std::multimap<K,V,C,A>& m, const P& p )
{
return insert( m )( p );
}
}
}
#endif

View File

@ -0,0 +1,45 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_QUEUE_HPP
#define BOOST_ASSIGN_STD_QUEUE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/config.hpp>
#include <queue>
namespace boost
{
namespace assign
{
template< class V, class C, class V2 >
inline list_inserter< assign_detail::call_push< std::queue<V,C> >, V >
operator+=( std::queue<V,C>& c, V2 v )
{
return push( c )( v );
}
template< class V, class C, class V2 >
inline list_inserter< assign_detail::call_push< std::priority_queue<V,C> >, V >
operator+=( std::priority_queue<V,C>& c, V2 v )
{
return push( c )( v );
}
}
}
#endif

View File

@ -0,0 +1,44 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_SET_HPP
#define BOOST_ASSIGN_STD_SET_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/config.hpp>
#include <set>
namespace boost
{
namespace assign
{
template< class K, class C, class A, class K2 >
inline list_inserter< assign_detail::call_insert< std::set<K,C,A> >, K >
operator+=( std::set<K,C,A>& c, K2 k )
{
return insert( c )( k );
}
template< class K, class C, class A, class K2 >
inline list_inserter< assign_detail::call_insert< std::multiset<K,C,A> >, K >
operator+=( std::multiset<K,C,A>& c, K2 k )
{
return insert( c )( k );
}
}
}
#endif

View File

@ -0,0 +1,45 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_SLIST_HPP
#define BOOST_ASSIGN_STD_SLIST_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_SLIST
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#ifdef BOOST_SLIST_HEADER
# include BOOST_SLIST_HEADER
#else
# include <slist>
#endif
namespace boost
{
namespace assign
{
template< class V, class A, class V2 >
inline list_inserter< assign_detail::call_push_back< BOOST_STD_EXTENSION_NAMESPACE::slist<V,A> >, V >
operator+=( BOOST_STD_EXTENSION_NAMESPACE::slist<V,A>& c, V2 v )
{
return push_back( c )( v );
}
}
}
#endif // BOOST_HAS_SLIST
#endif

View File

@ -0,0 +1,37 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_STACK_HPP
#define BOOST_ASSIGN_STD_STACK_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/config.hpp>
#include <stack>
namespace boost
{
namespace assign
{
template< class V, class C, class V2 >
inline list_inserter< assign_detail::call_push< std::stack<V,C> >, V >
operator+=( std::stack<V,C>& c, V2 v )
{
return push( c )( v );
}
}
}
#endif

View File

@ -0,0 +1,37 @@
// Boost.Assign library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/assign/
//
#ifndef BOOST_ASSIGN_STD_VECTOR_HPP
#define BOOST_ASSIGN_STD_VECTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assign/list_inserter.hpp>
#include <boost/config.hpp>
#include <vector>
namespace boost
{
namespace assign
{
template< class V, class A, class V2 >
inline list_inserter< assign_detail::call_push_back< std::vector<V,A> >, V >
operator+=( std::vector<V,A>& c, V2 v )
{
return push_back( c )( v );
}
}
}
#endif

View File

@ -0,0 +1,548 @@
// ------------------------------------------------------------------------------
// Copyright (c) 2000 Cadenza New Zealand Ltd
// Distributed under the Boost Software License, Version 1.0. (See accompany-
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// ------------------------------------------------------------------------------
// Boost functional.hpp header file
// See http://www.boost.org/libs/functional for documentation.
// ------------------------------------------------------------------------------
// $Id: functional.hpp 36246 2006-12-02 14:17:26Z andreas_huber69 $
// ------------------------------------------------------------------------------
#ifndef BOOST_FUNCTIONAL_HPP
#define BOOST_FUNCTIONAL_HPP
#include <boost/config.hpp>
#include <boost/call_traits.hpp>
#include <functional>
namespace boost
{
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// --------------------------------------------------------------------------
// The following traits classes allow us to avoid the need for ptr_fun
// because the types of arguments and the result of a function can be
// deduced.
//
// In addition to the standard types defined in unary_function and
// binary_function, we add
//
// - function_type, the type of the function or function object itself.
//
// - param_type, the type that should be used for passing the function or
// function object as an argument.
// --------------------------------------------------------------------------
namespace detail
{
template <class Operation>
struct unary_traits_imp;
template <class Operation>
struct unary_traits_imp<Operation*>
{
typedef Operation function_type;
typedef const function_type & param_type;
typedef typename Operation::result_type result_type;
typedef typename Operation::argument_type argument_type;
};
template <class R, class A>
struct unary_traits_imp<R(*)(A)>
{
typedef R (*function_type)(A);
typedef R (*param_type)(A);
typedef R result_type;
typedef A argument_type;
};
template <class Operation>
struct binary_traits_imp;
template <class Operation>
struct binary_traits_imp<Operation*>
{
typedef Operation function_type;
typedef const function_type & param_type;
typedef typename Operation::result_type result_type;
typedef typename Operation::first_argument_type first_argument_type;
typedef typename Operation::second_argument_type second_argument_type;
};
template <class R, class A1, class A2>
struct binary_traits_imp<R(*)(A1,A2)>
{
typedef R (*function_type)(A1,A2);
typedef R (*param_type)(A1,A2);
typedef R result_type;
typedef A1 first_argument_type;
typedef A2 second_argument_type;
};
} // namespace detail
template <class Operation>
struct unary_traits
{
typedef typename detail::unary_traits_imp<Operation*>::function_type function_type;
typedef typename detail::unary_traits_imp<Operation*>::param_type param_type;
typedef typename detail::unary_traits_imp<Operation*>::result_type result_type;
typedef typename detail::unary_traits_imp<Operation*>::argument_type argument_type;
};
template <class R, class A>
struct unary_traits<R(*)(A)>
{
typedef R (*function_type)(A);
typedef R (*param_type)(A);
typedef R result_type;
typedef A argument_type;
};
template <class Operation>
struct binary_traits
{
typedef typename detail::binary_traits_imp<Operation*>::function_type function_type;
typedef typename detail::binary_traits_imp<Operation*>::param_type param_type;
typedef typename detail::binary_traits_imp<Operation*>::result_type result_type;
typedef typename detail::binary_traits_imp<Operation*>::first_argument_type first_argument_type;
typedef typename detail::binary_traits_imp<Operation*>::second_argument_type second_argument_type;
};
template <class R, class A1, class A2>
struct binary_traits<R(*)(A1,A2)>
{
typedef R (*function_type)(A1,A2);
typedef R (*param_type)(A1,A2);
typedef R result_type;
typedef A1 first_argument_type;
typedef A2 second_argument_type;
};
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// --------------------------------------------------------------------------
// If we have no partial specialisation available, decay to a situation
// that is no worse than in the Standard, i.e., ptr_fun will be required.
// --------------------------------------------------------------------------
template <class Operation>
struct unary_traits
{
typedef Operation function_type;
typedef const Operation& param_type;
typedef typename Operation::result_type result_type;
typedef typename Operation::argument_type argument_type;
};
template <class Operation>
struct binary_traits
{
typedef Operation function_type;
typedef const Operation & param_type;
typedef typename Operation::result_type result_type;
typedef typename Operation::first_argument_type first_argument_type;
typedef typename Operation::second_argument_type second_argument_type;
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// --------------------------------------------------------------------------
// unary_negate, not1
// --------------------------------------------------------------------------
template <class Predicate>
class unary_negate
: public std::unary_function<typename unary_traits<Predicate>::argument_type,bool>
{
public:
explicit unary_negate(typename unary_traits<Predicate>::param_type x)
:
pred(x)
{}
bool operator()(typename call_traits<typename unary_traits<Predicate>::argument_type>::param_type x) const
{
return !pred(x);
}
private:
typename unary_traits<Predicate>::function_type pred;
};
template <class Predicate>
unary_negate<Predicate> not1(const Predicate &pred)
{
// The cast is to placate Borland C++Builder in certain circumstances.
// I don't think it should be necessary.
return unary_negate<Predicate>((typename unary_traits<Predicate>::param_type)pred);
}
template <class Predicate>
unary_negate<Predicate> not1(Predicate &pred)
{
return unary_negate<Predicate>(pred);
}
// --------------------------------------------------------------------------
// binary_negate, not2
// --------------------------------------------------------------------------
template <class Predicate>
class binary_negate
: public std::binary_function<typename binary_traits<Predicate>::first_argument_type,
typename binary_traits<Predicate>::second_argument_type,
bool>
{
public:
explicit binary_negate(typename binary_traits<Predicate>::param_type x)
:
pred(x)
{}
bool operator()(typename call_traits<typename binary_traits<Predicate>::first_argument_type>::param_type x,
typename call_traits<typename binary_traits<Predicate>::second_argument_type>::param_type y) const
{
return !pred(x,y);
}
private:
typename binary_traits<Predicate>::function_type pred;
};
template <class Predicate>
binary_negate<Predicate> not2(const Predicate &pred)
{
// The cast is to placate Borland C++Builder in certain circumstances.
// I don't think it should be necessary.
return binary_negate<Predicate>((typename binary_traits<Predicate>::param_type)pred);
}
template <class Predicate>
binary_negate<Predicate> not2(Predicate &pred)
{
return binary_negate<Predicate>(pred);
}
// --------------------------------------------------------------------------
// binder1st, bind1st
// --------------------------------------------------------------------------
template <class Operation>
class binder1st
: public std::unary_function<typename binary_traits<Operation>::second_argument_type,
typename binary_traits<Operation>::result_type>
{
public:
binder1st(typename binary_traits<Operation>::param_type x,
typename call_traits<typename binary_traits<Operation>::first_argument_type>::param_type y)
:
op(x), value(y)
{}
typename binary_traits<Operation>::result_type
operator()(typename call_traits<typename binary_traits<Operation>::second_argument_type>::param_type x) const
{
return op(value, x);
}
protected:
typename binary_traits<Operation>::function_type op;
typename binary_traits<Operation>::first_argument_type value;
};
template <class Operation>
inline binder1st<Operation> bind1st(const Operation &op,
typename call_traits<
typename binary_traits<Operation>::first_argument_type
>::param_type x)
{
// The cast is to placate Borland C++Builder in certain circumstances.
// I don't think it should be necessary.
return binder1st<Operation>((typename binary_traits<Operation>::param_type)op, x);
}
template <class Operation>
inline binder1st<Operation> bind1st(Operation &op,
typename call_traits<
typename binary_traits<Operation>::first_argument_type
>::param_type x)
{
return binder1st<Operation>(op, x);
}
// --------------------------------------------------------------------------
// binder2nd, bind2nd
// --------------------------------------------------------------------------
template <class Operation>
class binder2nd
: public std::unary_function<typename binary_traits<Operation>::first_argument_type,
typename binary_traits<Operation>::result_type>
{
public:
binder2nd(typename binary_traits<Operation>::param_type x,
typename call_traits<typename binary_traits<Operation>::second_argument_type>::param_type y)
:
op(x), value(y)
{}
typename binary_traits<Operation>::result_type
operator()(typename call_traits<typename binary_traits<Operation>::first_argument_type>::param_type x) const
{
return op(x, value);
}
protected:
typename binary_traits<Operation>::function_type op;
typename binary_traits<Operation>::second_argument_type value;
};
template <class Operation>
inline binder2nd<Operation> bind2nd(const Operation &op,
typename call_traits<
typename binary_traits<Operation>::second_argument_type
>::param_type x)
{
// The cast is to placate Borland C++Builder in certain circumstances.
// I don't think it should be necessary.
return binder2nd<Operation>((typename binary_traits<Operation>::param_type)op, x);
}
template <class Operation>
inline binder2nd<Operation> bind2nd(Operation &op,
typename call_traits<
typename binary_traits<Operation>::second_argument_type
>::param_type x)
{
return binder2nd<Operation>(op, x);
}
// --------------------------------------------------------------------------
// mem_fun, etc
// --------------------------------------------------------------------------
template <class S, class T>
class mem_fun_t : public std::unary_function<T*, S>
{
public:
explicit mem_fun_t(S (T::*p)())
:
ptr(p)
{}
S operator()(T* p) const
{
return (p->*ptr)();
}
private:
S (T::*ptr)();
};
template <class S, class T, class A>
class mem_fun1_t : public std::binary_function<T*, A, S>
{
public:
explicit mem_fun1_t(S (T::*p)(A))
:
ptr(p)
{}
S operator()(T* p, typename call_traits<A>::param_type x) const
{
return (p->*ptr)(x);
}
private:
S (T::*ptr)(A);
};
template <class S, class T>
class const_mem_fun_t : public std::unary_function<const T*, S>
{
public:
explicit const_mem_fun_t(S (T::*p)() const)
:
ptr(p)
{}
S operator()(const T* p) const
{
return (p->*ptr)();
}
private:
S (T::*ptr)() const;
};
template <class S, class T, class A>
class const_mem_fun1_t : public std::binary_function<const T*, A, S>
{
public:
explicit const_mem_fun1_t(S (T::*p)(A) const)
:
ptr(p)
{}
S operator()(const T* p, typename call_traits<A>::param_type x) const
{
return (p->*ptr)(x);
}
private:
S (T::*ptr)(A) const;
};
template<class S, class T>
inline mem_fun_t<S,T> mem_fun(S (T::*f)())
{
return mem_fun_t<S,T>(f);
}
template<class S, class T, class A>
inline mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A))
{
return mem_fun1_t<S,T,A>(f);
}
#ifndef BOOST_NO_POINTER_TO_MEMBER_CONST
template<class S, class T>
inline const_mem_fun_t<S,T> mem_fun(S (T::*f)() const)
{
return const_mem_fun_t<S,T>(f);
}
template<class S, class T, class A>
inline const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const)
{
return const_mem_fun1_t<S,T,A>(f);
}
#endif // BOOST_NO_POINTER_TO_MEMBER_CONST
// --------------------------------------------------------------------------
// mem_fun_ref, etc
// --------------------------------------------------------------------------
template <class S, class T>
class mem_fun_ref_t : public std::unary_function<T&, S>
{
public:
explicit mem_fun_ref_t(S (T::*p)())
:
ptr(p)
{}
S operator()(T& p) const
{
return (p.*ptr)();
}
private:
S (T::*ptr)();
};
template <class S, class T, class A>
class mem_fun1_ref_t : public std::binary_function<T&, A, S>
{
public:
explicit mem_fun1_ref_t(S (T::*p)(A))
:
ptr(p)
{}
S operator()(T& p, typename call_traits<A>::param_type x) const
{
return (p.*ptr)(x);
}
private:
S (T::*ptr)(A);
};
template <class S, class T>
class const_mem_fun_ref_t : public std::unary_function<const T&, S>
{
public:
explicit const_mem_fun_ref_t(S (T::*p)() const)
:
ptr(p)
{}
S operator()(const T &p) const
{
return (p.*ptr)();
}
private:
S (T::*ptr)() const;
};
template <class S, class T, class A>
class const_mem_fun1_ref_t : public std::binary_function<const T&, A, S>
{
public:
explicit const_mem_fun1_ref_t(S (T::*p)(A) const)
:
ptr(p)
{}
S operator()(const T& p, typename call_traits<A>::param_type x) const
{
return (p.*ptr)(x);
}
private:
S (T::*ptr)(A) const;
};
template<class S, class T>
inline mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)())
{
return mem_fun_ref_t<S,T>(f);
}
template<class S, class T, class A>
inline mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A))
{
return mem_fun1_ref_t<S,T,A>(f);
}
#ifndef BOOST_NO_POINTER_TO_MEMBER_CONST
template<class S, class T>
inline const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const)
{
return const_mem_fun_ref_t<S,T>(f);
}
template<class S, class T, class A>
inline const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const)
{
return const_mem_fun1_ref_t<S,T,A>(f);
}
#endif // BOOST_NO_POINTER_TO_MEMBER_CONST
// --------------------------------------------------------------------------
// ptr_fun
// --------------------------------------------------------------------------
template <class Arg, class Result>
class pointer_to_unary_function : public std::unary_function<Arg,Result>
{
public:
explicit pointer_to_unary_function(Result (*f)(Arg))
:
func(f)
{}
Result operator()(typename call_traits<Arg>::param_type x) const
{
return func(x);
}
private:
Result (*func)(Arg);
};
template <class Arg, class Result>
inline pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg))
{
return pointer_to_unary_function<Arg,Result>(f);
}
template <class Arg1, class Arg2, class Result>
class pointer_to_binary_function : public std::binary_function<Arg1,Arg2,Result>
{
public:
explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2))
:
func(f)
{}
Result operator()(typename call_traits<Arg1>::param_type x, typename call_traits<Arg2>::param_type y) const
{
return func(x,y);
}
private:
Result (*func)(Arg1, Arg2);
};
template <class Arg1, class Arg2, class Result>
inline pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1, Arg2))
{
return pointer_to_binary_function<Arg1,Arg2,Result>(f);
}
} // namespace boost
#endif

View File

@ -0,0 +1,120 @@
/* Copyright 2003-2008 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)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_DUPLICATES_ITERATOR_HPP
#define BOOST_MULTI_INDEX_DETAIL_DUPLICATES_ITERATOR_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <cstddef>
#include <iterator>
namespace boost{
namespace multi_index{
namespace detail{
/* duplicates_operator is given a range of ordered elements and
* passes only over those which are duplicated.
*/
template<typename Node,typename Predicate>
class duplicates_iterator
{
public:
typedef typename Node::value_type value_type;
typedef std::ptrdiff_t difference_type;
typedef const typename Node::value_type* pointer;
typedef const typename Node::value_type& reference;
typedef std::forward_iterator_tag iterator_category;
duplicates_iterator(Node* node_,Node* end_,Predicate pred_):
node(node_),begin_chunk(0),end(end_),pred(pred_)
{
advance();
}
duplicates_iterator(Node* end_,Predicate pred_):
node(end_),begin_chunk(end_),end(end_),pred(pred_)
{
}
reference operator*()const
{
return node->value();
}
pointer operator->()const
{
return &node->value();
}
duplicates_iterator& operator++()
{
Node::increment(node);
sync();
return *this;
}
duplicates_iterator operator++(int)
{
duplicates_iterator tmp(*this);
++(*this);
return tmp;
}
Node* get_node()const{return node;}
private:
void sync()
{
if(node!=end&&pred(begin_chunk->value(),node->value()))advance();
}
void advance()
{
for(Node* node2=node;node!=end;node=node2){
Node::increment(node2);
if(node2!=end&&!pred(node->value(),node2->value()))break;
}
begin_chunk=node;
}
Node* node;
Node* begin_chunk;
Node* end;
Predicate pred;
};
template<typename Node,typename Predicate>
bool operator==(
const duplicates_iterator<Node,Predicate>& x,
const duplicates_iterator<Node,Predicate>& y)
{
return x.get_node()==y.get_node();
}
template<typename Node,typename Predicate>
bool operator!=(
const duplicates_iterator<Node,Predicate>& x,
const duplicates_iterator<Node,Predicate>& y)
{
return !(x==y);
}
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#endif

View File

@ -0,0 +1,650 @@
/* Copyright 2003-2008 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)
*
* See http://www.boost.org/libs/multi_index for library home page.
*
* The internal implementation of red-black trees is based on that of SGI STL
* stl_tree.h file:
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_NODE_HPP
#define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_NODE_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <cstddef>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/multi_index/detail/prevent_eti.hpp>
#if !defined(BOOST_MULTI_INDEX_DISABLE_COMPRESSED_ORDERED_INDEX_NODES)
#include <boost/mpl/and.hpp>
#include <boost/mpl/if.hpp>
#include <boost/multi_index/detail/uintptr_type.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/is_same.hpp>
#endif
namespace boost{
namespace multi_index{
namespace detail{
/* definition of red-black nodes for ordered_index */
enum ordered_index_color{red=false,black=true};
enum ordered_index_side{to_left=false,to_right=true};
template<typename Allocator>
struct ordered_index_node_impl; /* fwd decl. */
template<typename Allocator>
struct ordered_index_node_std_base
{
typedef typename prevent_eti<
Allocator,
typename boost::detail::allocator::rebind_to<
Allocator,
ordered_index_node_impl<Allocator>
>::type
>::type::pointer pointer;
typedef typename prevent_eti<
Allocator,
typename boost::detail::allocator::rebind_to<
Allocator,
ordered_index_node_impl<Allocator>
>::type
>::type::const_pointer const_pointer;
typedef ordered_index_color& color_ref;
typedef pointer& parent_ref;
ordered_index_color& color(){return color_;}
ordered_index_color color()const{return color_;}
pointer& parent(){return parent_;}
pointer parent()const{return parent_;}
pointer& left(){return left_;}
pointer left()const{return left_;}
pointer& right(){return right_;}
pointer right()const{return right_;}
private:
ordered_index_color color_;
pointer parent_;
pointer left_;
pointer right_;
};
#if !defined(BOOST_MULTI_INDEX_DISABLE_COMPRESSED_ORDERED_INDEX_NODES)
/* If ordered_index_node_impl has even alignment, we can use the least
* significant bit of one of the ordered_index_node_impl pointers to
* store color information. This typically reduces the size of
* ordered_index_node_impl by 25%.
*/
#if defined(BOOST_MSVC)
/* This code casts pointers to an integer type that has been computed
* to be large enough to hold the pointer, however the metaprogramming
* logic is not always spotted by the VC++ code analyser that issues a
* long list of warnings.
*/
#pragma warning(push)
#pragma warning(disable:4312 4311)
#endif
template<typename Allocator>
struct ordered_index_node_compressed_base
{
typedef ordered_index_node_impl<Allocator>* pointer;
typedef const ordered_index_node_impl<Allocator>* const_pointer;
struct color_ref
{
color_ref(uintptr_type* r_):r(r_){}
operator ordered_index_color()const
{
return ordered_index_color(*r&uintptr_type(1));
}
color_ref& operator=(ordered_index_color c)
{
*r&=~uintptr_type(1);
*r|=uintptr_type(c);
return *this;
}
color_ref& operator=(const color_ref& x)
{
return operator=(x.operator ordered_index_color());
}
private:
uintptr_type* r;
};
struct parent_ref
{
parent_ref(uintptr_type* r_):r(r_){}
operator pointer()const
{
return (pointer)(void*)(*r&~uintptr_type(1));
}
parent_ref& operator=(pointer p)
{
*r=((uintptr_type)(void*)p)|(*r&uintptr_type(1));
return *this;
}
parent_ref& operator=(const parent_ref& x)
{
return operator=(x.operator pointer());
}
pointer operator->()const
{
return operator pointer();
}
private:
uintptr_type* r;
};
color_ref color(){return color_ref(&parentcolor_);}
ordered_index_color color()const
{
return ordered_index_color(parentcolor_&std::size_t(1ul));
}
parent_ref parent(){return parent_ref(&parentcolor_);}
pointer parent()const
{
return (pointer)(void*)(parentcolor_&~uintptr_type(1));
}
pointer& left(){return left_;}
pointer left()const{return left_;}
pointer& right(){return right_;}
pointer right()const{return right_;}
private:
uintptr_type parentcolor_;
pointer left_;
pointer right_;
};
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
#endif
template<typename Allocator>
struct ordered_index_node_impl_base:
#if !defined(BOOST_MULTI_INDEX_DISABLE_COMPRESSED_ORDERED_INDEX_NODES)
mpl::if_c<
!(has_uintptr_type::value)||
(alignment_of<ordered_index_node_compressed_base<Allocator> >::value%2)||
!(is_same<
typename prevent_eti<
Allocator,
typename boost::detail::allocator::rebind_to<
Allocator,
ordered_index_node_impl<Allocator>
>::type
>::type::pointer,
ordered_index_node_impl<Allocator>*>::value),
ordered_index_node_std_base<Allocator>,
ordered_index_node_compressed_base<Allocator>
>::type
#else
ordered_index_node_std_base<Allocator>
#endif
{};
template<typename Allocator>
struct ordered_index_node_impl:ordered_index_node_impl_base<Allocator>
{
private:
typedef ordered_index_node_impl_base<Allocator> super;
public:
typedef typename super::color_ref color_ref;
typedef typename super::parent_ref parent_ref;
typedef typename super::pointer pointer;
typedef typename super::const_pointer const_pointer;
/* interoperability with bidir_node_iterator */
static void increment(pointer& x)
{
if(x->right()!=pointer(0)){
x=x->right();
while(x->left()!=pointer(0))x=x->left();
}
else{
pointer y=x->parent();
while(x==y->right()){
x=y;
y=y->parent();
}
if(x->right()!=y)x=y;
}
}
static void decrement(pointer& x)
{
if(x->color()==red&&x->parent()->parent()==x){
x=x->right();
}
else if(x->left()!=pointer(0)){
pointer y=x->left();
while(y->right()!=pointer(0))y=y->right();
x=y;
}else{
pointer y=x->parent();
while(x==y->left()){
x=y;
y=y->parent();
}
x=y;
}
}
/* algorithmic stuff */
static void rotate_left(pointer x,parent_ref root)
{
pointer y=x->right();
x->right()=y->left();
if(y->left()!=pointer(0))y->left()->parent()=x;
y->parent()=x->parent();
if(x==root) root=y;
else if(x==x->parent()->left())x->parent()->left()=y;
else x->parent()->right()=y;
y->left()=x;
x->parent()=y;
}
static pointer minimum(pointer x)
{
while(x->left()!=pointer(0))x=x->left();
return x;
}
static pointer maximum(pointer x)
{
while(x->right()!=pointer(0))x=x->right();
return x;
}
static void rotate_right(pointer x,parent_ref root)
{
pointer y=x->left();
x->left()=y->right();
if(y->right()!=pointer(0))y->right()->parent()=x;
y->parent()=x->parent();
if(x==root) root=y;
else if(x==x->parent()->right())x->parent()->right()=y;
else x->parent()->left()=y;
y->right()=x;
x->parent()=y;
}
static void rebalance(pointer x,parent_ref root)
{
x->color()=red;
while(x!=root&&x->parent()->color()==red){
if(x->parent()==x->parent()->parent()->left()){
pointer y=x->parent()->parent()->right();
if(y!=pointer(0)&&y->color()==red){
x->parent()->color()=black;
y->color()=black;
x->parent()->parent()->color()=red;
x=x->parent()->parent();
}
else{
if(x==x->parent()->right()){
x=x->parent();
rotate_left(x,root);
}
x->parent()->color()=black;
x->parent()->parent()->color()=red;
rotate_right(x->parent()->parent(),root);
}
}
else{
pointer y=x->parent()->parent()->left();
if(y!=pointer(0)&&y->color()==red){
x->parent()->color()=black;
y->color()=black;
x->parent()->parent()->color()=red;
x=x->parent()->parent();
}
else{
if(x==x->parent()->left()){
x=x->parent();
rotate_right(x,root);
}
x->parent()->color()=black;
x->parent()->parent()->color()=red;
rotate_left(x->parent()->parent(),root);
}
}
}
root->color()=black;
}
static void link(
pointer x,ordered_index_side side,pointer position,pointer header)
{
if(side==to_left){
position->left()=x; /* also makes leftmost=x when parent==header */
if(position==header){
header->parent()=x;
header->right()=x;
}
else if(position==header->left()){
header->left()=x; /* maintain leftmost pointing to min node */
}
}
else{
position->right()=x;
if(position==header->right()){
header->right()=x; /* maintain rightmost pointing to max node */
}
}
x->parent()=position;
x->left()=pointer(0);
x->right()=pointer(0);
ordered_index_node_impl::rebalance(x,header->parent());
}
static pointer rebalance_for_erase(
pointer z,parent_ref root,pointer& leftmost,pointer& rightmost)
{
pointer y=z;
pointer x=pointer(0);
pointer x_parent=pointer(0);
if(y->left()==pointer(0)){ /* z has at most one non-null child. y==z. */
x=y->right(); /* x might be null */
}
else{
if(y->right()==pointer(0)){ /* z has exactly one non-null child. y==z. */
x=y->left(); /* x is not null */
}
else{ /* z has two non-null children. Set y to */
y=y->right(); /* z's successor. x might be null. */
while(y->left()!=pointer(0))y=y->left();
x=y->right();
}
}
if(y!=z){
z->left()->parent()=y; /* relink y in place of z. y is z's successor */
y->left()=z->left();
if(y!=z->right()){
x_parent=y->parent();
if(x!=pointer(0))x->parent()=y->parent();
y->parent()->left()=x; /* y must be a child of left */
y->right()=z->right();
z->right()->parent()=y;
}
else{
x_parent=y;
}
if(root==z) root=y;
else if(z->parent()->left()==z)z->parent()->left()=y;
else z->parent()->right()=y;
y->parent()=z->parent();
ordered_index_color c=y->color();
y->color()=z->color();
z->color()=c;
y=z; /* y now points to node to be actually deleted */
}
else{ /* y==z */
x_parent=y->parent();
if(x!=pointer(0))x->parent()=y->parent();
if(root==z){
root=x;
}
else{
if(z->parent()->left()==z)z->parent()->left()=x;
else z->parent()->right()=x;
}
if(leftmost==z){
if(z->right()==pointer(0)){ /* z->left() must be null also */
leftmost=z->parent();
}
else{
leftmost=minimum(x); /* makes leftmost==header if z==root */
}
}
if(rightmost==z){
if(z->left()==pointer(0)){ /* z->right() must be null also */
rightmost=z->parent();
}
else{ /* x==z->left() */
rightmost=maximum(x); /* makes rightmost==header if z==root */
}
}
}
if(y->color()!=red){
while(x!=root&&(x==pointer(0)|| x->color()==black)){
if(x==x_parent->left()){
pointer w=x_parent->right();
if(w->color()==red){
w->color()=black;
x_parent->color()=red;
rotate_left(x_parent,root);
w=x_parent->right();
}
if((w->left()==pointer(0)||w->left()->color()==black) &&
(w->right()==pointer(0)||w->right()->color()==black)){
w->color()=red;
x=x_parent;
x_parent=x_parent->parent();
}
else{
if(w->right()==pointer(0 )
|| w->right()->color()==black){
if(w->left()!=pointer(0)) w->left()->color()=black;
w->color()=red;
rotate_right(w,root);
w=x_parent->right();
}
w->color()=x_parent->color();
x_parent->color()=black;
if(w->right()!=pointer(0))w->right()->color()=black;
rotate_left(x_parent,root);
break;
}
}
else{ /* same as above,with right <-> left */
pointer w=x_parent->left();
if(w->color()==red){
w->color()=black;
x_parent->color()=red;
rotate_right(x_parent,root);
w=x_parent->left();
}
if((w->right()==pointer(0)||w->right()->color()==black) &&
(w->left()==pointer(0)||w->left()->color()==black)){
w->color()=red;
x=x_parent;
x_parent=x_parent->parent();
}
else{
if(w->left()==pointer(0)||w->left()->color()==black){
if(w->right()!=pointer(0))w->right()->color()=black;
w->color()=red;
rotate_left(w,root);
w=x_parent->left();
}
w->color()=x_parent->color();
x_parent->color()=black;
if(w->left()!=pointer(0))w->left()->color()=black;
rotate_right(x_parent,root);
break;
}
}
}
if(x!=pointer(0))x->color()=black;
}
return y;
}
static void restore(pointer x,pointer position,pointer header)
{
if(position->left()==pointer(0)||position->left()==header){
link(x,to_left,position,header);
}
else{
decrement(position);
link(x,to_right,position,header);
}
}
#if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
/* invariant stuff */
static std::size_t black_count(pointer node,pointer root)
{
if(node==pointer(0))return 0;
std::size_t sum=0;
for(;;){
if(node->color()==black)++sum;
if(node==root)break;
node=node->parent();
}
return sum;
}
#endif
};
template<typename Super>
struct ordered_index_node_trampoline:
prevent_eti<
Super,
ordered_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename Super::allocator_type,
char
>::type
>
>::type
{
typedef typename prevent_eti<
Super,
ordered_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename Super::allocator_type,
char
>::type
>
>::type impl_type;
};
template<typename Super>
struct ordered_index_node:Super,ordered_index_node_trampoline<Super>
{
private:
typedef ordered_index_node_trampoline<Super> trampoline;
public:
typedef typename trampoline::impl_type impl_type;
typedef typename trampoline::color_ref impl_color_ref;
typedef typename trampoline::parent_ref impl_parent_ref;
typedef typename trampoline::pointer impl_pointer;
typedef typename trampoline::const_pointer const_impl_pointer;
impl_color_ref color(){return trampoline::color();}
ordered_index_color color()const{return trampoline::color();}
impl_parent_ref parent(){return trampoline::parent();}
impl_pointer parent()const{return trampoline::parent();}
impl_pointer& left(){return trampoline::left();}
impl_pointer left()const{return trampoline::left();}
impl_pointer& right(){return trampoline::right();}
impl_pointer right()const{return trampoline::right();}
impl_pointer impl()
{
return static_cast<impl_pointer>(
static_cast<impl_type*>(static_cast<trampoline*>(this)));
}
const_impl_pointer impl()const
{
return static_cast<const_impl_pointer>(
static_cast<const impl_type*>(static_cast<const trampoline*>(this)));
}
static ordered_index_node* from_impl(impl_pointer x)
{
return static_cast<ordered_index_node*>(
static_cast<trampoline*>(&*x));
}
static const ordered_index_node* from_impl(const_impl_pointer x)
{
return static_cast<const ordered_index_node*>(
static_cast<const trampoline*>(&*x));
}
/* interoperability with bidir_node_iterator */
static void increment(ordered_index_node*& x)
{
impl_pointer xi=x->impl();
trampoline::increment(xi);
x=from_impl(xi);
}
static void decrement(ordered_index_node*& x)
{
impl_pointer xi=x->impl();
trampoline::decrement(xi);
x=from_impl(xi);
}
};
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#endif

View File

@ -0,0 +1,147 @@
/* Copyright 2003-2008 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)
*
* See http://www.boost.org/libs/multi_index for library home page.
*
* The internal implementation of red-black trees is based on that of SGI STL
* stl_tree.h file:
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_OPS_HPP
#define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_OPS_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <utility>
namespace boost{
namespace multi_index{
namespace detail{
/* Common code for index memfuns having templatized and
* non-templatized versions.
*/
template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline Node* ordered_index_find(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp)
{
Node* y0=y;
while (top){
if(!comp(key(top->value()),x)){
y=top;
top=Node::from_impl(top->left());
}
else top=Node::from_impl(top->right());
}
return (y==y0||comp(x,key(y->value())))?y0:y;
}
template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline Node* ordered_index_lower_bound(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp)
{
while(top){
if(!comp(key(top->value()),x)){
y=top;
top=Node::from_impl(top->left());
}
else top=Node::from_impl(top->right());
}
return y;
}
template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline Node* ordered_index_upper_bound(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp)
{
while(top){
if(comp(x,key(top->value()))){
y=top;
top=Node::from_impl(top->left());
}
else top=Node::from_impl(top->right());
}
return y;
}
template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::pair<Node*,Node*> ordered_index_equal_range(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp)
{
while(top){
if(comp(key(top->value()),x)){
top=Node::from_impl(top->right());
}
else if(comp(x,key(top->value()))){
y=top;
top=Node::from_impl(top->left());
}
else{
return std::pair<Node*,Node*>(
ordered_index_lower_bound(Node::from_impl(top->left()),top,key,x,comp),
ordered_index_upper_bound(Node::from_impl(top->right()),y,key,x,comp));
}
}
return std::pair<Node*,Node*>(y,y);
}
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#endif

View File

@ -0,0 +1,76 @@
/* Copyright 2003-2008 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)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_UINTPTR_TYPE_HPP
#define BOOST_MULTI_INDEX_DETAIL_UINTPTR_TYPE_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/mpl/bool.hpp>
namespace boost{
namespace multi_index{
namespace detail{
/* has_uintptr_type is an MPL integral constant determining whether
* there exists an unsigned integral type with the same size as
* void *.
* uintptr_type is such a type if has_uintptr is true, or unsigned int
* otherwise.
* Note that uintptr_type is more restrictive than C99 uintptr_t,
* where an integral type with size greater than that of void *
* would be conformant.
*/
template<int N>struct uintptr_candidates;
template<>struct uintptr_candidates<-1>{typedef unsigned int type;};
template<>struct uintptr_candidates<0> {typedef unsigned int type;};
template<>struct uintptr_candidates<1> {typedef unsigned short type;};
template<>struct uintptr_candidates<2> {typedef unsigned long type;};
#if defined(BOOST_HAS_LONG_LONG)
template<>struct uintptr_candidates<3> {typedef boost::ulong_long_type type;};
#else
template<>struct uintptr_candidates<3> {typedef unsigned int type;};
#endif
#if defined(BOOST_HAS_MS_INT64)
template<>struct uintptr_candidates<4> {typedef unsigned __int64 type;};
#else
template<>struct uintptr_candidates<4> {typedef unsigned int type;};
#endif
struct uintptr_aux
{
BOOST_STATIC_CONSTANT(int,index=
sizeof(void*)==sizeof(uintptr_candidates<0>::type)?0:
sizeof(void*)==sizeof(uintptr_candidates<1>::type)?1:
sizeof(void*)==sizeof(uintptr_candidates<2>::type)?2:
sizeof(void*)==sizeof(uintptr_candidates<3>::type)?3:
sizeof(void*)==sizeof(uintptr_candidates<4>::type)?4:-1);
BOOST_STATIC_CONSTANT(bool,has_uintptr_type=(index>=0));
typedef uintptr_candidates<index>::type type;
};
typedef mpl::bool_<uintptr_aux::has_uintptr_type> has_uintptr_type;
typedef uintptr_aux::type uintptr_type;
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#endif

View File

@ -0,0 +1,83 @@
/* Copyright 2003-2008 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)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_UNBOUNDED_HPP
#define BOOST_MULTI_INDEX_DETAIL_UNBOUNDED_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/detail/workaround.hpp>
namespace boost{
namespace multi_index{
/* dummy type and variable for use in ordered_index::range() */
#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
/* The default branch actually works for MSVC 6.0, but seems like
* this implementation of unbounded improves the performance of ordered
* indices! This behavior is hard to explain and probably a test artifact,
* but it does not hurt to have the workaround anyway.
*/
namespace detail{struct unbounded_type{};}
namespace{
static detail::unbounded_type unbounded_obj=detail::unbounded_type();
static detail::unbounded_type& unbounded=unbounded_obj;
} /* unnamed */
#else
/* ODR-abiding technique shown at the example attached to
* http://lists.boost.org/Archives/boost/2006/07/108355.php
*/
namespace detail{class unbounded_helper;}
detail::unbounded_helper unbounded(detail::unbounded_helper);
namespace detail{
class unbounded_helper
{
unbounded_helper(){}
unbounded_helper(const unbounded_helper&){}
friend unbounded_helper multi_index::unbounded(unbounded_helper);
};
typedef unbounded_helper (*unbounded_type)(unbounded_helper);
} /* namespace multi_index::detail */
inline detail::unbounded_helper unbounded(detail::unbounded_helper)
{
return detail::unbounded_helper();
}
#endif
/* tags used in the implementation of range */
namespace detail{
struct none_unbounded_tag{};
struct lower_unbounded_tag{};
struct upper_unbounded_tag{};
struct both_unbounded_tag{};
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#endif

View File

@ -0,0 +1,53 @@
/* Copyright 2003-2008 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)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_VALUE_COMPARE_HPP
#define BOOST_MULTI_INDEX_DETAIL_VALUE_COMPARE_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/call_traits.hpp>
#include <functional>
namespace boost{
namespace multi_index{
namespace detail{
template<typename Value,typename KeyFromValue,typename Compare>
struct value_comparison:std::binary_function<Value,Value,bool>
{
value_comparison(
const KeyFromValue& key_=KeyFromValue(),const Compare& comp_=Compare()):
key(key_),comp(comp_)
{
}
bool operator()(
typename call_traits<Value>::param_type x,
typename call_traits<Value>::param_type y)const
{
return comp(key(x),key(y));
}
private:
KeyFromValue key;
Compare comp;
};
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#endif

File diff suppressed because it is too large Load Diff