|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79679 - trunk/boost/unordered/detail
From: dnljms_at_[hidden]
Date: 2012-07-22 16:14:21
Author: danieljames
Date: 2012-07-22 16:14:20 EDT (Sun, 22 Jul 2012)
New Revision: 79679
URL: http://svn.boost.org/trac/boost/changeset/79679
Log:
Unordered: Remove use of try..catch.
So that it'll work when exceptions are disabled.
Text files modified:
trunk/boost/unordered/detail/allocate.hpp | 41 ++++++++++++++++++++++++++++++++-------
1 files changed, 33 insertions(+), 8 deletions(-)
Modified: trunk/boost/unordered/detail/allocate.hpp
==============================================================================
--- trunk/boost/unordered/detail/allocate.hpp (original)
+++ trunk/boost/unordered/detail/allocate.hpp 2012-07-22 16:14:20 EDT (Sun, 22 Jul 2012)
@@ -1120,17 +1120,42 @@
#else
+ template <typename AllocTraits, typename T>
+ struct value_construct
+ {
+ typedef BOOST_DEDUCED_TYPENAME AllocTraits::allocator_type allocator;
+
+ allocator& alloc;
+ T* ptr;
+
+ value_construct(allocator& a, T* p) : alloc(a), ptr(p)
+ {
+ AllocTraits::construct(alloc, ptr, T());
+ }
+
+ void release()
+ {
+ ptr = 0;
+ }
+
+ ~value_construct()
+ {
+ if (ptr) AllocTraits::destroy(alloc, ptr);
+ }
+
+ private:
+ value_construct(value_construct const&);
+ value_construct& operator=(value_construct const&);
+ };
+
template <typename Alloc, typename T, BOOST_UNORDERED_EMPLACE_TEMPLATE>
inline void construct_node(Alloc& a, T* p, BOOST_UNORDERED_EMPLACE_ARGS)
{
- boost::unordered::detail::allocator_traits<Alloc>::construct(a, p, T());
- try {
- boost::unordered::detail::construct_impl(
- p->value_ptr(), BOOST_UNORDERED_EMPLACE_FORWARD);
- } catch(...) {
- boost::unordered::detail::allocator_traits<Alloc>::destroy(a, p);
- throw;
- }
+ value_construct<boost::unordered::detail::allocator_traits<Alloc>, T>
+ construct_guard(a, p);
+ boost::unordered::detail::construct_impl(
+ p->value_ptr(), BOOST_UNORDERED_EMPLACE_FORWARD);
+ construct_guard.release();
}
template <typename Alloc, typename T>
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