Code simplification to support gcc-3.4 & gcc-4.0

[SVN r76226]
This commit is contained in:
Ion Gaztañaga
2011-12-30 09:03:45 +00:00
parent c0eb4fe944
commit 73963d75af
7 changed files with 73 additions and 24 deletions

View File

@@ -74,7 +74,7 @@ class circular_slist_algorithms
//!
//! <b>Effects</b>: Returns true is "this_node" is the only node of a circular list:
//! or it's a not inserted node:
//! <tt>return false == NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node</tt>
//! <tt>return node_ptr() == NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node</tt>
//!
//! <b>Complexity</b>: Constant
//!

View File

@@ -21,6 +21,11 @@
#include <boost/static_assert.hpp>
#include <boost/move/move.hpp>
//Mark that we don't support 0 arg calls due to compiler ICE
#if defined(__GNUC__) && !defined(__clang__) && ((__GNUC__*100 + __GNUC_MINOR__*10) >= 340) && ((__GNUC__*100 + __GNUC_MINOR__*10) < 430)
#define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED
#endif
namespace boost_intrusive_has_member_function_callable_with {
struct dont_care
@@ -107,6 +112,17 @@
#if !defined(_MSC_VER) || (_MSC_VER != 1600)
#if defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED)
template<typename Fun>
struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl)
<Fun, true BOOST_PP_ENUM_TRAILING(BOOST_PP_SUB(BOOST_PP_ITERATION_FINISH(), BOOST_PP_ITERATION()), BOOST_INTRUSIVE_PP_IDENTITY, void)>
{
//GCC [4.4-4.3) gives ICE when instantiating the 0 arg version so it is not supported.
static const bool value = true;
};
#else
//Special case for 0 args
template< class F
, std::size_t N =
@@ -141,6 +157,7 @@
static const bool value = sizeof(Test< Fun >(0))
== sizeof(boost_intrusive_has_member_function_callable_with::yes_type);
};
#endif
#else //#if !defined(_MSC_VER) || (_MSC_VER != 1600)
template<typename Fun>

View File

@@ -69,13 +69,42 @@ struct LowPriorityConversion
static const bool value = (1 == sizeof(test<T>(0, 0))); \
\
typedef typename \
::boost::intrusive::detail::if_c<value, T, DefaultWrap>::type::TNAME type; \
} \
::boost::intrusive::detail::if_c \
<value, T, DefaultWrap>::type::TNAME type; \
}; \
\
template <typename T, typename DefaultType> \
struct boost_intrusive_eval_default_type_ ## TNAME \
{ \
template <typename X> \
static char test(int, typename X::TNAME*); \
\
template <typename X> \
static int test(boost::intrusive::detail:: \
LowPriorityConversion<int>, void*); \
\
struct DefaultWrap \
{ typedef typename DefaultType::type TNAME; }; \
\
static const bool value = (1 == sizeof(test<T>(0, 0))); \
\
typedef typename \
::boost::intrusive::detail::eval_if_c \
< value \
, ::boost::intrusive::detail::identity<T> \
, ::boost::intrusive::detail::identity<DefaultWrap> \
>::type::TNAME type; \
}; \
//
#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \
typename INSTANTIATION_NS_PREFIX \
boost_intrusive_default_type_ ## TNAME<T, TIMPL>::type \
#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \
typename INSTANTIATION_NS_PREFIX \
boost_intrusive_default_type_ ## TNAME< T, TIMPL >::type \
//
#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \
typename INSTANTIATION_NS_PREFIX \
boost_intrusive_eval_default_type_ ## TNAME< T, TIMPL >::type \
//
}}} //namespace boost::intrusive::detail

View File

@@ -208,14 +208,14 @@ struct key_nodeptr_comp
};
template<class T>
typename enable_if_c<is_node_ptr<T>::value, const value_type &>::type
key_forward(const T &node) const
const value_type & key_forward
(const T &node, typename enable_if_c<is_node_ptr<T>::value>::type * = 0) const
{ return *cont_->get_real_value_traits().to_value_ptr(node); }
template<class T>
typename enable_if_c<!is_node_ptr<T>::value, const T &>::type
key_forward(const T &key) const
{ return key;}
const T & key_forward(const T &key, typename enable_if_c<!is_node_ptr<T>::value>::type* = 0) const
{ return key; }
template<class KeyType, class KeyType2>
bool operator()(const KeyType &key1, const KeyType2 &key2) const
@@ -596,20 +596,20 @@ class exception_disposer
}
};
template<class Container, class Disposer>
template<class Container, class Disposer, class SizeType>
class exception_array_disposer
{
Container *cont_;
Disposer &disp_;
typename Container::size_type &constructed_;
SizeType &constructed_;
exception_array_disposer(const exception_array_disposer&);
exception_array_disposer &operator=(const exception_array_disposer&);
public:
typedef typename Container::size_type size_type;
exception_array_disposer
(Container &cont, Disposer &disp, size_type &constructed)
(Container &cont, Disposer &disp, SizeType &constructed)
: cont_(&cont), disp_(disp), constructed_(constructed)
{}
@@ -618,7 +618,7 @@ class exception_array_disposer
~exception_array_disposer()
{
size_type n = constructed_;
SizeType n = constructed_;
if(cont_){
while(n--){
cont_[n].clear_and_dispose(disp_);

View File

@@ -30,6 +30,7 @@
#include <boost/intrusive/link_mode.hpp>
#include <boost/intrusive/detail/ebo_functor_holder.hpp>
#include <boost/intrusive/detail/clear_on_destructor_base.hpp>
#include <boost/intrusive/detail/utilities.hpp>
//Implementation utilities
#include <boost/intrusive/trivial_value_traits.hpp>
#include <boost/intrusive/unordered_set_hook.hpp>
@@ -1131,7 +1132,7 @@ class hashtable_impl
typedef node_cast_adaptor<detail::node_cloner<Cloner, hashtable_impl> > NodeCloner;
NodeDisposer node_disp(disposer, this);
detail::exception_array_disposer<bucket_type, NodeDisposer>
detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
rollback(dst_buckets[0], node_disp, constructed);
for( constructed = 0
; constructed < dst_bucket_count
@@ -2080,10 +2081,12 @@ class hashtable_impl
//is harmless, because all elements have been already unlinked and destroyed
typedef detail::init_disposer<node_algorithms> NodeDisposer;
NodeDisposer node_disp;
detail::exception_array_disposer<bucket_type, NodeDisposer>
rollback1(new_buckets[0], node_disp, new_buckets_len);
detail::exception_array_disposer<bucket_type, NodeDisposer>
rollback2(old_buckets[0], node_disp, old_buckets_len);
bucket_type & newbuck = new_buckets[0];
bucket_type & oldbuck = old_buckets[0];
detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
rollback1(newbuck, node_disp, new_buckets_len);
detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
rollback2(oldbuck, node_disp, old_buckets_len);
//Put size in a safe value for rollback exception
size_type size_backup = this->priv_size_traits().get_size();

View File

@@ -73,7 +73,7 @@ class linear_slist_algorithms
//!
//! <b>Effects</b>: Returns true is "this_node" is the only node of a circular list:
//! or it's a not inserted node:
//! <tt>return false == NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node</tt>
//! <tt>return node_ptr() == NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node</tt>
//!
//! <b>Complexity</b>: Constant
//!

View File

@@ -67,9 +67,9 @@ struct pointer_traits
#else
typedef Ptr pointer;
//
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT
( boost::intrusive::detail::, Ptr, element_type
, typename boost::intrusive::detail::first_param<Ptr>::type) element_type;
, boost::intrusive::detail::first_param<Ptr>) element_type;
//
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT
(boost::intrusive::detail::, Ptr, difference_type, std::ptrdiff_t) difference_type;