|
Boost-Commit : |
From: nesotto_at_[hidden]
Date: 2008-06-24 10:18:54
Author: nesotto
Date: 2008-06-24 10:18:54 EDT (Tue, 24 Jun 2008)
New Revision: 46642
URL: http://svn.boost.org/trac/boost/changeset/46642
Log:
merge of changes from trunk
Text files modified:
branches/release/boost/assign/list_inserter.hpp | 4 -
branches/release/boost/assign/list_of.hpp | 140 ++++++++++++++++++++++++++++++++-------
branches/release/boost/assign/ptr_list_of.hpp | 14 +--
3 files changed, 119 insertions(+), 39 deletions(-)
Modified: branches/release/boost/assign/list_inserter.hpp
==============================================================================
--- branches/release/boost/assign/list_inserter.hpp (original)
+++ branches/release/boost/assign/list_inserter.hpp 2008-06-24 10:18:54 EDT (Tue, 24 Jun 2008)
@@ -203,10 +203,6 @@
template< class Nullary_function >
list_inserter& operator=( const assign_detail::fun_repeater<Nullary_function>& r )
{
- //BOOST_STATIC_ASSERT( function_traits<Nullary_function>::arity == 0 );
- //BOOST_STATIC_ASSERT( is_convertible< BOOST_DEDUCED_TYPENAME function_traits<
- // Nullary_function>::result_type >,T>::value );
-
return operator,( r );
}
Modified: branches/release/boost/assign/list_of.hpp
==============================================================================
--- branches/release/boost/assign/list_of.hpp (original)
+++ branches/release/boost/assign/list_of.hpp 2008-06-24 10:18:54 EDT (Tue, 24 Jun 2008)
@@ -17,8 +17,7 @@
#endif
#include <boost/assign/assignment_exception.hpp>
-#include <boost/range/begin.hpp>
-#include <boost/range/end.hpp>
+#include <boost/range/iterator_range.hpp>
#include <boost/config.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/type_traits/remove_const.hpp>
@@ -110,9 +109,23 @@
- template< class DerivedTAssign >
+ 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 >
@@ -138,18 +151,16 @@
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
// old Dinkumware doesn't support iterator type as template
Container result;
- BOOST_DEDUCED_TYPENAME DerivedTAssign::iterator
- it = static_cast<const DerivedTAssign*>(this)->begin(),
- end = static_cast<const DerivedTAssign*>(this)->end();
- while( it != end )
+ iterator it = begin(),
+ e = end();
+ while( it != e )
{
result.insert( result.end(), *it );
++it;
}
return result;
#else
- return Container( static_cast<const DerivedTAssign*>(this)->begin(),
- static_cast<const DerivedTAssign*>(this)->end() );
+ return Container( begin(), end() );
#endif
}
@@ -167,10 +178,9 @@
if( sz < static_cast<const DerivedTAssign*>(this)->size() )
throw assign::assignment_exception( "array initialized with too many elements" );
std::size_t n = 0;
- BOOST_DEDUCED_TYPENAME DerivedTAssign::iterator
- i = static_cast<const DerivedTAssign*>(this)->begin(),
- end = static_cast<const DerivedTAssign*>(this)->end();
- for( ; i != end; ++i, ++n )
+ iterator i = begin(),
+ e = end();
+ for( ; i != e; ++i, ++n )
ar[n] = *i;
for( ; n < sz; ++n )
ar[n] = value_type();
@@ -181,10 +191,9 @@
Adapter convert_to_adapter( const Adapter* = 0 ) const
{
Adapter a;
- BOOST_DEDUCED_TYPENAME DerivedTAssign::iterator
- i = static_cast<const DerivedTAssign*>(this)->begin(),
- end = static_cast<const DerivedTAssign*>(this)->end();
- for( ; i != end; ++i )
+ iterator i = begin(),
+ e = end();
+ for( ; i != e; ++i )
a.push( *i );
return a;
}
@@ -234,6 +243,86 @@
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
@@ -241,17 +330,17 @@
template< class T >
class generic_list :
- public converter< generic_list< BOOST_DEDUCED_TYPENAME assign_decay<T>::type > >
+ 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 converter< generic_list< BOOST_DEDUCED_TYPENAME assign_decay<T>::type > >
- base_type;
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 BOOST_DEDUCED_TYPENAME impl_type::const_iterator const_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;
@@ -347,7 +436,7 @@
return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
}
};
-
+
/////////////////////////////////////////////////////////////////////////
// Part 2: efficient, but inconvenient interface
/////////////////////////////////////////////////////////////////////////
@@ -411,16 +500,15 @@
template< class T, int N >
struct static_generic_list :
- public converter< static_generic_list<T,N> >
+ public converter< static_generic_list<T,N>, assign_reference<T>* >
{
private:
- typedef converter< static_generic_list<T,N> > base_class;
- typedef T internal_value_type;
+ typedef T internal_value_type;
public:
typedef assign_reference<internal_value_type> value_type;
typedef value_type* iterator;
- typedef const value_type* const_iterator;
+ typedef value_type* const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
Modified: branches/release/boost/assign/ptr_list_of.hpp
==============================================================================
--- branches/release/boost/assign/ptr_list_of.hpp (original)
+++ branches/release/boost/assign/ptr_list_of.hpp 2008-06-24 10:18:54 EDT (Tue, 24 Jun 2008)
@@ -16,7 +16,7 @@
# pragma once
#endif
-#include <boost/assign/assignment_exception.hpp>
+#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>
@@ -41,7 +41,9 @@
/////////////////////////////////////////////////////////////////////////
template< class T >
- class generic_ptr_list
+ 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;
@@ -50,7 +52,7 @@
public:
typedef BOOST_DEDUCED_TYPENAME impl_type::iterator iterator;
- typedef BOOST_DEDUCED_TYPENAME impl_type::const_iterator const_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;
@@ -58,12 +60,6 @@
generic_ptr_list() : values_( 32u )
{ }
- /*
- generic_ptr_list( const generic_ptr_list& r )
- {
- values_.swap(r.values_);
- }*/
-
generic_ptr_list( release_type r ) : values_(r)
{ }
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk