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

View File

@@ -107,7 +107,7 @@
#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
/* 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 val = 1;
int cmp = 0;
@@ -118,7 +118,7 @@
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);
int prev = 0;
int ret;

View File

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

View File

@@ -593,9 +593,12 @@ class flat_map
//!
//! Complexity: Logarithmic.
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
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
//! @copydoc ::boost::container::flat_set::nth(size_type)

View File

@@ -481,8 +481,12 @@ class map
//!
//! Complexity: Logarithmic.
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
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
//! 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).
template <class InputIterator>
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
typename container_detail::disable_if_or
< iterator
, container_detail::is_convertible<InputIterator, size_type>
, container_detail::is_not_input_iterator<InputIterator>
>::type
#else
iterator
#endif
insert(const_iterator p, InputIterator first, InputIterator last)
iterator insert(const_iterator p, InputIterator first, InputIterator last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//Put this as argument instead of the return type as old GCC's like 3.4
//detect this and the next disable_if_or as overloads
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<InputIterator, size_type>
, container_detail::is_not_input_iterator<InputIterator>
>::type* = 0
#endif
)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
STABLE_VECTOR_CHECK_INVARIANT;
@@ -1630,9 +1631,8 @@ class stable_vector
//! plus linear to the elements between p and the last element.
iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(first <= last);
BOOST_ASSERT(first == last || this->priv_in_range(first));
BOOST_ASSERT(first == last || this->priv_in_range_or_end(last));
BOOST_ASSERT(first == last ||
(first < last && this->priv_in_range(first) && this->priv_in_range_or_end(last)));
STABLE_VECTOR_CHECK_INVARIANT;
const const_iterator cbeg(this->cbegin());
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; };
//!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)
, m_offset(offset), m_allocations(0){ }

View File

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

View File

@@ -31,7 +31,7 @@ class SimpleAllocator
public:
typedef Ty value_type;
explicit SimpleAllocator(int value)
explicit SimpleAllocator(int value = 0)
: m_state(value)
{}
@@ -356,7 +356,8 @@ bool one_level_allocator_propagation_test()
typedef typename ContainerWrapper::allocator_type allocator_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();
iterator it = c.emplace(c.cbegin(), 42);
@@ -365,7 +366,8 @@ bool one_level_allocator_propagation_test()
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)));
c.clear();

View File

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