Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52883 - in sandbox/move: boost/unordered boost/unordered/detail libs/unordered/test/unordered
From: daniel_james_at_[hidden]
Date: 2009-05-10 17:24:03


Author: danieljames
Date: 2009-05-10 17:24:02 EDT (Sun, 10 May 2009)
New Revision: 52883
URL: http://svn.boost.org/trac/boost/changeset/52883

Log:
Extract some of the preprocessor code to make things a little cleaner.
Text files modified:
   sandbox/move/boost/unordered/detail/hash_table.hpp | 15 ++++++++--
   sandbox/move/boost/unordered/detail/hash_table_impl.hpp | 54 ++++++++++++++++++++--------------------
   sandbox/move/boost/unordered/unordered_map.hpp | 24 ++++++++--------
   sandbox/move/boost/unordered/unordered_set.hpp | 24 ++++++++--------
   sandbox/move/libs/unordered/test/unordered/unnecessary_copy_tests.cpp | 2
   5 files changed, 64 insertions(+), 55 deletions(-)

Modified: sandbox/move/boost/unordered/detail/hash_table.hpp
==============================================================================
--- sandbox/move/boost/unordered/detail/hash_table.hpp (original)
+++ sandbox/move/boost/unordered/detail/hash_table.hpp 2009-05-10 17:24:02 EDT (Sun, 10 May 2009)
@@ -48,13 +48,22 @@
 
 #if !(defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL))
 
-#include <boost/preprocessor/cat.hpp>
 #include <boost/preprocessor/repetition/enum.hpp>
 #include <boost/preprocessor/repetition/enum_params.hpp>
 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
 
-#define BOOST_UNORDERED_PARAMS_FWD_REF(z, n, data) BOOST_FWD_REF(Arg##n) arg##n
-#define BOOST_UNORDERED_PARAMS_FORWARD(z, n, data) boost::forward<Arg##n>(arg##n)
+#define BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg)
+
+#define BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _)
+#define BOOST_UNORDERED_PARAMS_FWD_REF(z, n, data) \
+ BOOST_FWD_REF(Arg##n) arg##n
+
+#define BOOST_UNORDERED_CALL_PARAMS(z, n) \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _)
+#define BOOST_UNORDERED_PARAMS_FORWARD(z, n, data) \
+ boost::forward<Arg##n>(arg##n)
 
 #endif
 

Modified: sandbox/move/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- sandbox/move/boost/unordered/detail/hash_table_impl.hpp (original)
+++ sandbox/move/boost/unordered/detail/hash_table_impl.hpp 2009-05-10 17:24:02 EDT (Sun, 10 May 2009)
@@ -266,48 +266,48 @@
 
 #define BOOST_UNORDERED_CONSTRUCT_IMPL(z, n, _) \
                 template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
                 void construct( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
                 ) \
                 { \
                     construct_preamble(); \
                     construct_impl( \
                         (value_type*) 0, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                     ); \
                     value_constructed_ = true; \
                 } \
                                                                                 \
                 template < \
                     typename T, \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
                 void construct_impl( \
                     T*, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
                 ) \
                 { \
                     new(node_->address()) value_type( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                     ); \
                 } \
                                                                                 \
                                                                                 
 #define BOOST_UNORDERED_CONSTRUCT_IMPL2(z, n, _) \
                 template <typename First, typename Second, typename Key, \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
                 void construct_impl( \
                     std::pair<First, Second>*, \
                     BOOST_FWD_REF(Key) k, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
                 ) \
                 { \
                     new(node_->address()) value_type(boost::forward<Key>(k), \
                         Second( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                         ) \
                     ); \
                 }
@@ -1812,29 +1812,29 @@
 
 #define BOOST_UNORDERED_INSERT_IMPL(z, n, _) \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator_base emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 node_constructor a(data_.allocators_); \
                 a.construct( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 ); \
                 return emplace_impl(a); \
             } \
                                                                                     \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator_base emplace_hint(iterator_base const& it, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 node_constructor a(data_.allocators_); \
                 a.construct( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 ); \
                 return emplace_hint_impl(it, a); \
             }
@@ -2072,38 +2072,38 @@
 
 #define BOOST_UNORDERED_INSERT_IMPL(z, n, _) \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             std::pair<iterator_base, bool> emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return emplace_impl( \
                     extract_key(arg0, arg1), \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 ); \
             } \
                                                                                     \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator_base emplace_hint(iterator_base const& it, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return emplace_impl( \
                     extract_key(arg0, arg1), \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 ).first; \
             } \
             BOOST_UNORDERED_INSERT_IMPL2(z, n, _)
 
 #define BOOST_UNORDERED_INSERT_IMPL2(z, n, _) \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             std::pair<iterator_base, bool> emplace_impl(key_type const& k, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 size_type hash_value = hash_function()(k); \
@@ -2116,7 +2116,7 @@
                 } else { \
                     node_constructor a(data_.allocators_); \
                     a.construct( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                     ); \
                                                                                     \
                     if(reserve_for_insert(size() + 1)) \
@@ -2128,15 +2128,15 @@
             } \
                                                                                     \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             std::pair<iterator_base, bool> emplace_impl(no_key, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 node_constructor a(data_.allocators_); \
                 a.construct( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 ); \
                 return emplace_impl_with_node(a); \
             }

Modified: sandbox/move/boost/unordered/unordered_map.hpp
==============================================================================
--- sandbox/move/boost/unordered/unordered_map.hpp (original)
+++ sandbox/move/boost/unordered/unordered_map.hpp 2009-05-10 17:24:02 EDT (Sun, 10 May 2009)
@@ -240,27 +240,27 @@
 
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             std::pair<iterator, bool> emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return boost::unordered_detail::pair_cast<iterator, bool>( \
                     base.emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                     )); \
             } \
                                                                                 \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator emplace_hint(const_iterator hint, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return iterator(base.emplace_hint(get(hint), \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 )); \
             }
 
@@ -685,27 +685,27 @@
 
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return iterator( \
                     base.emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                     )); \
             } \
                                                                                 \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator emplace_hint(const_iterator hint, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return iterator(base.emplace_hint(get(hint), \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 )); \
             }
 

Modified: sandbox/move/boost/unordered/unordered_set.hpp
==============================================================================
--- sandbox/move/boost/unordered/unordered_set.hpp (original)
+++ sandbox/move/boost/unordered/unordered_set.hpp 2009-05-10 17:24:02 EDT (Sun, 10 May 2009)
@@ -239,27 +239,27 @@
 
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             std::pair<iterator, bool> emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return boost::unordered_detail::pair_cast<iterator, bool>( \
                     base.emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                     )); \
             } \
                                                                                 \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator emplace_hint(const_iterator hint, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return iterator(base.emplace_hint(get(hint), \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 )); \
             }
 
@@ -653,27 +653,27 @@
 
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return iterator( \
                     base.emplace( \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                     )); \
             } \
                                                                                 \
             template < \
- BOOST_PP_ENUM_PARAMS_Z(z, n, typename Arg) \
+ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
             iterator emplace_hint(const_iterator hint, \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FWD_REF, _) \
+ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
                 return iterator(base.emplace_hint(get(hint), \
- BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_PARAMS_FORWARD, _) \
+ BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 )); \
             }
 

Modified: sandbox/move/libs/unordered/test/unordered/unnecessary_copy_tests.cpp
==============================================================================
--- sandbox/move/libs/unordered/test/unordered/unnecessary_copy_tests.cpp (original)
+++ sandbox/move/libs/unordered/test/unordered/unnecessary_copy_tests.cpp 2009-05-10 17:24:02 EDT (Sun, 10 May 2009)
@@ -171,7 +171,7 @@
 
         // The container will have to create a copy in order to compare with
         // the existing element.
- reset();
+ reset();
         x.emplace();
 #if defined(BOOST_HAS_RVALUE_REFS)
         COPY_COUNT(1); MOVE_COUNT(0);


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