mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
Unordered: Remove use of try..catch.
So that it'll work when exceptions are disabled. [SVN r79679]
This commit is contained in:
@ -1120,17 +1120,42 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
#else
|
#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>
|
template <typename Alloc, typename T, BOOST_UNORDERED_EMPLACE_TEMPLATE>
|
||||||
inline void construct_node(Alloc& a, T* p, BOOST_UNORDERED_EMPLACE_ARGS)
|
inline void construct_node(Alloc& a, T* p, BOOST_UNORDERED_EMPLACE_ARGS)
|
||||||
{
|
{
|
||||||
boost::unordered::detail::allocator_traits<Alloc>::construct(a, p, T());
|
value_construct<boost::unordered::detail::allocator_traits<Alloc>, T>
|
||||||
try {
|
construct_guard(a, p);
|
||||||
boost::unordered::detail::construct_impl(
|
boost::unordered::detail::construct_impl(
|
||||||
p->value_ptr(), BOOST_UNORDERED_EMPLACE_FORWARD);
|
p->value_ptr(), BOOST_UNORDERED_EMPLACE_FORWARD);
|
||||||
} catch(...) {
|
construct_guard.release();
|
||||||
boost::unordered::detail::allocator_traits<Alloc>::destroy(a, p);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Alloc, typename T>
|
template <typename Alloc, typename T>
|
||||||
|
Reference in New Issue
Block a user