Changes to support GCC 3.4

This commit is contained in:
Ion Gaztañaga
2015-10-12 18:51:08 +02:00
parent f8a4f01a86
commit 7764e05444
10 changed files with 45 additions and 33 deletions

View File

@@ -1672,9 +1672,8 @@ class deque : protected deque_base<Allocator>
//! if(pos is near the beginning). //! if(pos is near the beginning).
iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(first <= last); BOOST_ASSERT(first == last ||
BOOST_ASSERT(first == last || this->priv_in_range(first)); (first < last && this->priv_in_range(first) && this->priv_in_range_or_end(last)));
BOOST_ASSERT(first == last || this->priv_in_range_or_end(last));
if (first == this->members_.m_start && last == this->members_.m_finish) { if (first == this->members_.m_start && last == this->members_.m_finish) {
this->clear(); this->clear();
return this->members_.m_finish; return this->members_.m_finish;
@@ -2052,8 +2051,7 @@ class deque : protected deque_base<Allocator>
} }
template <class InIt> template <class InIt>
typename iterator_enable_if_tag<InIt, std::input_iterator_tag>::type void priv_range_initialize(InIt first, InIt last, typename iterator_enable_if_tag<InIt, std::input_iterator_tag>::type* =0)
priv_range_initialize(InIt first, InIt last)
{ {
this->priv_initialize_map(0); this->priv_initialize_map(0);
BOOST_TRY { BOOST_TRY {
@@ -2068,8 +2066,7 @@ class deque : protected deque_base<Allocator>
} }
template <class FwdIt> template <class FwdIt>
typename iterator_disable_if_tag<FwdIt, std::input_iterator_tag>::type void priv_range_initialize(FwdIt first, FwdIt last, typename iterator_disable_if_tag<FwdIt, std::input_iterator_tag>::type* =0)
priv_range_initialize(FwdIt first, FwdIt last)
{ {
size_type n = 0; size_type n = 0;
n = boost::container::iterator_distance(first, last); n = boost::container::iterator_distance(first, last);

View File

@@ -107,7 +107,7 @@
#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) #elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
/* Custom spin locks for older gcc on x86 */ /* Custom spin locks for older gcc on x86 */
static FORCEINLINE int boost_container_x86_cas_lock(int *sl) { static inline int boost_container_x86_cas_lock(int *sl) {
int ret; int ret;
int val = 1; int val = 1;
int cmp = 0; int cmp = 0;
@@ -118,7 +118,7 @@
return ret; return ret;
} }
static FORCEINLINE void boost_container_x86_clear_lock(int* sl) { static inline void boost_container_x86_clear_lock(int* sl) {
assert(*sl != 0); assert(*sl != 0);
int prev = 0; int prev = 0;
int ret; int ret;

View File

@@ -408,13 +408,12 @@ struct key_node_compare
}; };
template<class T> template<class T>
typename enable_if_c<is_node<T>::value, const typename KeyValueCompare::value_type &>::type const typename KeyValueCompare::value_type &
key_forward(const T &node) const key_forward(const T &node, typename enable_if_c<is_node<T>::value>::type* =0) const
{ return node.get_data(); } { return node.get_data(); }
template<class T> template<class T>
typename enable_if_c<!is_node<T>::value, const T &>::type const T &key_forward(const T &key, typename enable_if_c<!is_node<T>::value>::type* =0) const
key_forward(const T &key) const
{ return key; } { return key; }
template<class KeyType, class KeyType2> template<class KeyType, class KeyType2>

View File

@@ -593,9 +593,12 @@ class flat_map
//! //!
//! Complexity: Logarithmic. //! Complexity: Logarithmic.
mapped_type &operator[](key_type &&k) ; mapped_type &operator[](key_type &&k) ;
#elif defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN)
//in compilers like GCC 3.4, we can't catch temporaries
mapped_type& operator[](const key_type &k) { return this->priv_subscript(k); }
mapped_type& operator[](BOOST_RV_REF(key_type) k) { return this->priv_subscript(::boost::move(k)); }
#else #else
BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
#endif #endif
//! @copydoc ::boost::container::flat_set::nth(size_type) //! @copydoc ::boost::container::flat_set::nth(size_type)

View File

@@ -481,8 +481,12 @@ class map
//! //!
//! Complexity: Logarithmic. //! Complexity: Logarithmic.
mapped_type& operator[](key_type &&k); mapped_type& operator[](key_type &&k);
#elif defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN)
//in compilers like GCC 3.4, we can't catch temporaries
mapped_type& operator[](const key_type &k) { return this->priv_subscript(k); }
mapped_type& operator[](BOOST_RV_REF(key_type) k) { return this->priv_subscript(::boost::move(k)); }
#else #else
BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
#endif #endif
//! Returns: A reference to the element whose key is equivalent to x. //! Returns: A reference to the element whose key is equivalent to x.

View File

@@ -1531,16 +1531,17 @@ class stable_vector
//! //!
//! <b>Complexity</b>: Linear to distance [first, last). //! <b>Complexity</b>: Linear to distance [first, last).
template <class InputIterator> template <class InputIterator>
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) iterator insert(const_iterator p, InputIterator first, InputIterator last
typename container_detail::disable_if_or #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
< iterator //Put this as argument instead of the return type as old GCC's like 3.4
, container_detail::is_convertible<InputIterator, size_type> //detect this and the next disable_if_or as overloads
, container_detail::is_not_input_iterator<InputIterator> , typename container_detail::disable_if_or
>::type < void
#else , container_detail::is_convertible<InputIterator, size_type>
iterator , container_detail::is_not_input_iterator<InputIterator>
#endif >::type* = 0
insert(const_iterator p, InputIterator first, InputIterator last) #endif
)
{ {
BOOST_ASSERT(this->priv_in_range_or_end(p)); BOOST_ASSERT(this->priv_in_range_or_end(p));
STABLE_VECTOR_CHECK_INVARIANT; STABLE_VECTOR_CHECK_INVARIANT;
@@ -1630,9 +1631,8 @@ class stable_vector
//! plus linear to the elements between p and the last element. //! plus linear to the elements between p and the last element.
iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(first <= last); BOOST_ASSERT(first == last ||
BOOST_ASSERT(first == last || this->priv_in_range(first)); (first < last && this->priv_in_range(first) && this->priv_in_range_or_end(last)));
BOOST_ASSERT(first == last || this->priv_in_range_or_end(last));
STABLE_VECTOR_CHECK_INVARIANT; STABLE_VECTOR_CHECK_INVARIANT;
const const_iterator cbeg(this->cbegin()); const const_iterator cbeg(this->cbegin());
const size_type d1 = static_cast<size_type>(first - cbeg), const size_type d1 = static_cast<size_type>(first - cbeg),

View File

@@ -79,7 +79,7 @@ class expand_bwd_test_allocator
{ typedef expand_bwd_test_allocator<T2> other; }; { typedef expand_bwd_test_allocator<T2> other; };
//!Constructor from the segment manager. Never throws //!Constructor from the segment manager. Never throws
expand_bwd_test_allocator(T *buffer, size_type sz, difference_type offset) expand_bwd_test_allocator(T *buffer = 0, size_type sz = 0, difference_type offset = 0)
: mp_buffer(buffer), m_size(sz) : mp_buffer(buffer), m_size(sz)
, m_offset(offset), m_allocations(0){ } , m_offset(offset), m_allocations(0){ }

View File

@@ -92,6 +92,10 @@ struct stateful
struct rebind struct rebind
{ typedef stateful other; }; { typedef stateful other; };
stateful()
: m_u(0u)
{}
char *allocate(std::size_t n) char *allocate(std::size_t n)
{ allocate_size = n; return allocate_return; } { allocate_size = n; return allocate_return; }

View File

@@ -31,7 +31,7 @@ class SimpleAllocator
public: public:
typedef Ty value_type; typedef Ty value_type;
explicit SimpleAllocator(int value) explicit SimpleAllocator(int value = 0)
: m_state(value) : m_state(value)
{} {}
@@ -356,7 +356,8 @@ bool one_level_allocator_propagation_test()
typedef typename ContainerWrapper::allocator_type allocator_type; typedef typename ContainerWrapper::allocator_type allocator_type;
typedef typename ContainerWrapper::value_type value_type; typedef typename ContainerWrapper::value_type value_type;
{ {
ContainerWrapper c(allocator_type(SimpleAllocator<value_type>(5))); allocator_type al(SimpleAllocator<value_type>(5));
ContainerWrapper c(al);
c.clear(); c.clear();
iterator it = c.emplace(c.cbegin(), 42); iterator it = c.emplace(c.cbegin(), 42);
@@ -365,7 +366,8 @@ bool one_level_allocator_propagation_test()
return false; return false;
} }
{ {
ContainerWrapper c2(allocator_type(SimpleAllocator<value_type>(4))); allocator_type al(SimpleAllocator<value_type>(4));
ContainerWrapper c2(al);
ContainerWrapper c(::boost::move(c2), allocator_type(SimpleAllocator<value_type>(5))); ContainerWrapper c(::boost::move(c2), allocator_type(SimpleAllocator<value_type>(5)));
c.clear(); c.clear();

View File

@@ -95,6 +95,9 @@ int test_expand_bwd()
class recursive_vector class recursive_vector
{ {
public: public:
recursive_vector & operator=(const recursive_vector &x)
{ this->vector_ = x.vector_; return *this; }
int id_; int id_;
vector<recursive_vector> vector_; vector<recursive_vector> vector_;
vector<recursive_vector>::iterator it_; vector<recursive_vector>::iterator it_;