Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75743 - in trunk/boost/unordered: . detail
From: dnljms_at_[hidden]
Date: 2011-11-30 03:21:40


Author: danieljames
Date: 2011-11-30 03:21:38 EST (Wed, 30 Nov 2011)
New Revision: 75743
URL: http://svn.boost.org/trac/boost/changeset/75743

Log:
Unordered: Manually write out some overloads for emplace.

Clang creates horrific error messages for Boost.Preprocessor based code,
so for small number of arguments manually write out a few important
functions. Not doing this everywhere.
Text files modified:
   trunk/boost/unordered/detail/emplace_args.hpp | 27 ++++++++
   trunk/boost/unordered/unordered_map.hpp | 124 ++++++++++++++++++++++++++++++++++++++-
   trunk/boost/unordered/unordered_set.hpp | 124 ++++++++++++++++++++++++++++++++++++++-
   3 files changed, 266 insertions(+), 9 deletions(-)

Modified: trunk/boost/unordered/detail/emplace_args.hpp
==============================================================================
--- trunk/boost/unordered/detail/emplace_args.hpp (original)
+++ trunk/boost/unordered/detail/emplace_args.hpp 2011-11-30 03:21:38 EST (Wed, 30 Nov 2011)
@@ -379,7 +379,32 @@
                 args.a)); \
     }
 
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
+ template <typename T, typename A0>
+ inline void construct_impl(T* address, emplace_args1<A0> const& args)
+ {
+ new((void*) address) T(boost::forward<A0>(args.a0));
+ }
+
+ template <typename T, typename A0, typename A1>
+ inline void construct_impl(T* address, emplace_args2<A0, A1> const& args)
+ {
+ new((void*) address) T(
+ boost::forward<A0>(args.a0),
+ boost::forward<A1>(args.a1)
+ );
+ }
+
+ template <typename T, typename A0, typename A1, typename A2>
+ inline void construct_impl(T* address, emplace_args3<A0, A1, A2> const& args)
+ {
+ new((void*) address) T(
+ boost::forward<A0>(args.a0),
+ boost::forward<A1>(args.a1),
+ boost::forward<A2>(args.a2)
+ );
+ }
+
+ BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
         BOOST_UNORDERED_CONSTRUCT_IMPL, _)
 
 #undef BOOST_UNORDERED_CONSTRUCT_IMPL

Modified: trunk/boost/unordered/unordered_map.hpp
==============================================================================
--- trunk/boost/unordered/unordered_map.hpp (original)
+++ trunk/boost/unordered/unordered_map.hpp 2011-11-30 03:21:38 EST (Wed, 30 Nov 2011)
@@ -222,6 +222,64 @@
         }
 #else
 
+ template <typename A0>
+ std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0)
+ );
+ }
+
+ template <typename A0>
+ iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0)
+ ).first;
+ }
+
+ template <typename A0, typename A1>
+ std::pair<iterator, bool> emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1)
+ );
+ }
+
+ template <typename A0, typename A1>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1)
+ ).first;
+ }
+
+ template <typename A0, typename A1, typename A2>
+ std::pair<iterator, bool> emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1, a2)
+ );
+ }
+
+ template <typename A0, typename A1, typename A2>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1, a2)
+ ).first;
+ }
+
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
             template < \
                 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
@@ -245,14 +303,14 @@
                     BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
             ) \
             { \
- return iterator(table_.emplace( \
+ return table_.emplace( \
                     boost::unordered::detail::create_emplace_args( \
                         BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
                             a) \
- )).first); \
+ )).first; \
             }
 
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
+ BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
             BOOST_UNORDERED_EMPLACE, _)
 
 #undef BOOST_UNORDERED_EMPLACE
@@ -609,6 +667,64 @@
         }
 #else
 
+ template <typename A0>
+ iterator emplace(BOOST_FWD_REF(A0) a0)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0)
+ ));
+ }
+
+ template <typename A0>
+ iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0)
+ ));
+ }
+
+ template <typename A0, typename A1>
+ iterator emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1)
+ ));
+ }
+
+ template <typename A0, typename A1>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1)
+ ));
+ }
+
+ template <typename A0, typename A1, typename A2>
+ iterator emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1, a2)
+ ));
+ }
+
+ template <typename A0, typename A1, typename A2>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1, a2)
+ ));
+ }
+
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
             template < \
                 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
@@ -639,7 +755,7 @@
                 ))); \
             }
 
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
+ BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
             BOOST_UNORDERED_EMPLACE, _)
 
 #undef BOOST_UNORDERED_EMPLACE

Modified: trunk/boost/unordered/unordered_set.hpp
==============================================================================
--- trunk/boost/unordered/unordered_set.hpp (original)
+++ trunk/boost/unordered/unordered_set.hpp 2011-11-30 03:21:38 EST (Wed, 30 Nov 2011)
@@ -220,6 +220,64 @@
         }
 #else
 
+ template <typename A0>
+ std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0)
+ );
+ }
+
+ template <typename A0>
+ iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0)
+ ).first;
+ }
+
+ template <typename A0, typename A1>
+ std::pair<iterator, bool> emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1)
+ );
+ }
+
+ template <typename A0, typename A1>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1)
+ ).first;
+ }
+
+ template <typename A0, typename A1, typename A2>
+ std::pair<iterator, bool> emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1, a2)
+ );
+ }
+
+ template <typename A0, typename A1, typename A2>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1, a2)
+ ).first;
+ }
+
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
             template < \
                 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
@@ -243,14 +301,14 @@
                     BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
             ) \
             { \
- return iterator(table_.emplace( \
+ return table_.emplace( \
                     boost::unordered::detail::create_emplace_args( \
                         BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
                             a) \
- )).first); \
+ )).first; \
             }
 
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
+ BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
             BOOST_UNORDERED_EMPLACE, _)
 
 #undef BOOST_UNORDERED_EMPLACE
@@ -592,6 +650,64 @@
         }
 #else
 
+ template <typename A0>
+ iterator emplace(BOOST_FWD_REF(A0) a0)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0)
+ ));
+ }
+
+ template <typename A0>
+ iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0)
+ ));
+ }
+
+ template <typename A0, typename A1>
+ iterator emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1)
+ ));
+ }
+
+ template <typename A0, typename A1>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1)
+ ));
+ }
+
+ template <typename A0, typename A1, typename A2>
+ iterator emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1, a2)
+ ));
+ }
+
+ template <typename A0, typename A1, typename A2>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return iterator(table_.emplace(
+ boost::unordered::detail::create_emplace_args(a0, a1, a2)
+ ));
+ }
+
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
             template < \
                 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
@@ -622,7 +738,7 @@
                 ))); \
             }
 
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
+ BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
             BOOST_UNORDERED_EMPLACE, _)
 
 #undef BOOST_UNORDERED_EMPLACE


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