forked from boostorg/unordered
Update node set to conditionally use strong vs weak typedef
This commit is contained in:
@ -39,30 +39,15 @@ namespace boost {
|
||||
using init_type = Key;
|
||||
using value_type = Key;
|
||||
|
||||
// struct element_type
|
||||
// {
|
||||
// value_type* p;
|
||||
// };
|
||||
|
||||
// static value_type& value_from(element_type x) { return *x.p; }
|
||||
static Key const& extract(value_type const& key) { return key; }
|
||||
|
||||
#if 1
|
||||
using element_type = value_type*;
|
||||
static value_type& value_from(element_type x) { return *x; }
|
||||
|
||||
static Key const& extract(value_type const& key) { return key; }
|
||||
// static Key const& extract(element_type k) { return *k.p; }
|
||||
// static element_type&& move(element_type& x) { return std::move(x); }
|
||||
|
||||
static Key const& extract(element_type k) { return *k; }
|
||||
static element_type&& move(element_type& x) { return std::move(x); }
|
||||
|
||||
// template <class A>
|
||||
// static void construct(A&, element_type* p, element_type&& x)
|
||||
// {
|
||||
// p->p = x.p;
|
||||
// x.p = nullptr;
|
||||
// }
|
||||
|
||||
template <class A>
|
||||
static void construct(A&, element_type* p, element_type&& x)
|
||||
{
|
||||
@ -70,35 +55,20 @@ namespace boost {
|
||||
x = nullptr;
|
||||
}
|
||||
|
||||
// template <class A>
|
||||
// static void construct(A& al, element_type* p, element_type const& copy)
|
||||
// {
|
||||
// p->p = boost::to_address(boost::allocator_allocate(al, 1));
|
||||
// try {
|
||||
// boost::allocator_construct(al, p->p, *copy.p);
|
||||
// } catch (...) {
|
||||
// boost::allocator_deallocate(al,
|
||||
// boost::pointer_traits<
|
||||
// typename boost::allocator_pointer<A>::type>::pointer_to(*p->p),
|
||||
// 1);
|
||||
// throw;
|
||||
// }
|
||||
// }
|
||||
|
||||
// template <class A, class... Args>
|
||||
// static void construct(A& al, element_type* p, Args&&... args)
|
||||
// {
|
||||
// p->p = boost::to_address(boost::allocator_allocate(al, 1));
|
||||
// try {
|
||||
// boost::allocator_construct(al, p->p, std::forward<Args>(args)...);
|
||||
// } catch (...) {
|
||||
// boost::allocator_deallocate(al,
|
||||
// boost::pointer_traits<
|
||||
// typename boost::allocator_pointer<A>::type>::pointer_to(*p->p),
|
||||
// 1);
|
||||
// throw;
|
||||
// }
|
||||
// }
|
||||
template <class A, class... Args>
|
||||
static void construct(A& al, element_type* p, element_type const& x)
|
||||
{
|
||||
*p = boost::to_address(boost::allocator_allocate(al, 1));
|
||||
try {
|
||||
boost::allocator_construct(al, *p, *x);
|
||||
} catch (...) {
|
||||
boost::allocator_deallocate(al,
|
||||
boost::pointer_traits<
|
||||
typename boost::allocator_pointer<A>::type>::pointer_to(**p),
|
||||
1);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <class A, class... Args>
|
||||
static void construct(A& al, element_type* p, Args&&... args)
|
||||
@ -115,20 +85,9 @@ namespace boost {
|
||||
}
|
||||
}
|
||||
|
||||
// template <class A> static void destroy(A& al, element_type* p) noexcept
|
||||
// {
|
||||
// if (p->p) {
|
||||
// boost::allocator_destroy(al, p->p);
|
||||
// boost::allocator_deallocate(al,
|
||||
// boost::pointer_traits<
|
||||
// typename boost::allocator_pointer<A>::type>::pointer_to(*p->p),
|
||||
// 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
template <class A> static void destroy(A& al, element_type* p) noexcept
|
||||
{
|
||||
if (p) {
|
||||
if (*p) {
|
||||
boost::allocator_destroy(al, *p);
|
||||
boost::allocator_deallocate(al,
|
||||
boost::pointer_traits<
|
||||
@ -136,13 +95,63 @@ namespace boost {
|
||||
1);
|
||||
}
|
||||
}
|
||||
#else
|
||||
struct element_type
|
||||
{
|
||||
value_type* p;
|
||||
};
|
||||
|
||||
static value_type& value_from(element_type x) { return *x.p; }
|
||||
static Key const& extract(element_type k) { return *k.p; }
|
||||
static element_type&& move(element_type& x) { return std::move(x); }
|
||||
|
||||
template <class A>
|
||||
static void construct(A& al, element_type* p, element_type const& copy)
|
||||
{
|
||||
construct(al, p, *copy.p);
|
||||
}
|
||||
|
||||
template <typename Allocator>
|
||||
static void construct(
|
||||
Allocator&, element_type* p, element_type&& x) noexcept
|
||||
{
|
||||
p->p = x.p;
|
||||
x.p = nullptr;
|
||||
}
|
||||
|
||||
template <class A, class... Args>
|
||||
static void construct(A& al, element_type* p, Args&&... args)
|
||||
{
|
||||
p->p = boost::to_address(boost::allocator_allocate(al, 1));
|
||||
try {
|
||||
boost::allocator_construct(al, p->p, std::forward<Args>(args)...);
|
||||
} catch (...) {
|
||||
boost::allocator_deallocate(al,
|
||||
boost::pointer_traits<
|
||||
typename boost::allocator_pointer<A>::type>::pointer_to(*p->p),
|
||||
1);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <class A> static void destroy(A& al, element_type* p) noexcept
|
||||
{
|
||||
if (p->p) {
|
||||
boost::allocator_destroy(al, p->p);
|
||||
boost::allocator_deallocate(al,
|
||||
boost::pointer_traits<
|
||||
typename boost::allocator_pointer<A>::type>::pointer_to(*p->p),
|
||||
1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template <class Key, class Hash, class KeyEqual, class Allocator>
|
||||
class unordered_node_set
|
||||
{
|
||||
using set_types = detail::flat_set_types<Key>;
|
||||
using set_types = detail::node_set_types<Key>;
|
||||
|
||||
using table_type = detail::foa::table<set_types, Hash, KeyEqual,
|
||||
typename boost::allocator_rebind<Allocator,
|
||||
|
Reference in New Issue
Block a user