|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76226 - in trunk/boost/intrusive: . detail
From: igaztanaga_at_[hidden]
Date: 2011-12-30 04:03:46
Author: igaztanaga
Date: 2011-12-30 04:03:45 EST (Fri, 30 Dec 2011)
New Revision: 76226
URL: http://svn.boost.org/trac/boost/changeset/76226
Log:
Code simplification to support gcc-3.4 & gcc-4.0
Text files modified:
trunk/boost/intrusive/circular_slist_algorithms.hpp | 2 +-
trunk/boost/intrusive/detail/has_member_function_callable_with.hpp | 17 +++++++++++++++++
trunk/boost/intrusive/detail/memory_util.hpp | 39 ++++++++++++++++++++++++++++++++++-----
trunk/boost/intrusive/detail/utilities.hpp | 20 ++++++++++----------
trunk/boost/intrusive/hashtable.hpp | 13 ++++++++-----
trunk/boost/intrusive/linear_slist_algorithms.hpp | 2 +-
trunk/boost/intrusive/pointer_traits.hpp | 4 ++--
7 files changed, 73 insertions(+), 24 deletions(-)
Modified: trunk/boost/intrusive/circular_slist_algorithms.hpp
==============================================================================
--- trunk/boost/intrusive/circular_slist_algorithms.hpp (original)
+++ trunk/boost/intrusive/circular_slist_algorithms.hpp 2011-12-30 04:03:45 EST (Fri, 30 Dec 2011)
@@ -74,7 +74,7 @@
//!
//! <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
//!
Modified: trunk/boost/intrusive/detail/has_member_function_callable_with.hpp
==============================================================================
--- trunk/boost/intrusive/detail/has_member_function_callable_with.hpp (original)
+++ trunk/boost/intrusive/detail/has_member_function_callable_with.hpp 2011-12-30 04:03:45 EST (Fri, 30 Dec 2011)
@@ -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>
Modified: trunk/boost/intrusive/detail/memory_util.hpp
==============================================================================
--- trunk/boost/intrusive/detail/memory_util.hpp (original)
+++ trunk/boost/intrusive/detail/memory_util.hpp 2011-12-30 04:03:45 EST (Fri, 30 Dec 2011)
@@ -69,13 +69,42 @@
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
Modified: trunk/boost/intrusive/detail/utilities.hpp
==============================================================================
--- trunk/boost/intrusive/detail/utilities.hpp (original)
+++ trunk/boost/intrusive/detail/utilities.hpp 2011-12-30 04:03:45 EST (Fri, 30 Dec 2011)
@@ -208,14 +208,14 @@
};
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 @@
}
};
-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 @@
~exception_array_disposer()
{
- size_type n = constructed_;
+ SizeType n = constructed_;
if(cont_){
while(n--){
cont_[n].clear_and_dispose(disp_);
Modified: trunk/boost/intrusive/hashtable.hpp
==============================================================================
--- trunk/boost/intrusive/hashtable.hpp (original)
+++ trunk/boost/intrusive/hashtable.hpp 2011-12-30 04:03:45 EST (Fri, 30 Dec 2011)
@@ -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 @@
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 @@
//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();
Modified: trunk/boost/intrusive/linear_slist_algorithms.hpp
==============================================================================
--- trunk/boost/intrusive/linear_slist_algorithms.hpp (original)
+++ trunk/boost/intrusive/linear_slist_algorithms.hpp 2011-12-30 04:03:45 EST (Fri, 30 Dec 2011)
@@ -73,7 +73,7 @@
//!
//! <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
//!
Modified: trunk/boost/intrusive/pointer_traits.hpp
==============================================================================
--- trunk/boost/intrusive/pointer_traits.hpp (original)
+++ trunk/boost/intrusive/pointer_traits.hpp 2011-12-30 04:03:45 EST (Fri, 30 Dec 2011)
@@ -67,9 +67,9 @@
#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;
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