mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
Support containers with const value type
Currently just storing the value without a const. Can do better with C++11 constructors, so maybe should do that, and cast away const on compilers without support. Another problem is that std::allocator<const int> doesn't compile for libstdc++ (and potentially other standard libraries), so boost::unordered_set<const int> can't compile. I'm not sure if I should work around that, as it means changing the type of the container (i.e. to boost::unordered_set<const int,... , std::allocator<int>>).
This commit is contained in:
@ -359,21 +359,6 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline node_pointer copy_of(T const& v) {
|
inline node_pointer copy_of(T const& v) {
|
||||||
if (nodes_) {
|
|
||||||
node_tmp<NodeAlloc> a(pop_node(), constructor_.alloc_);
|
|
||||||
a.node_->value() = v;
|
|
||||||
return a.release();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
constructor_.create_node();
|
|
||||||
boost::unordered::detail::func::call_construct(
|
|
||||||
constructor_.alloc_, constructor_.node_->value_ptr(), v);
|
|
||||||
return constructor_.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T1, typename T2>
|
|
||||||
inline node_pointer copy_of(std::pair<T1 const, T2> const& v) {
|
|
||||||
if (nodes_) {
|
if (nodes_) {
|
||||||
constructor_.reclaim(pop_node());
|
constructor_.reclaim(pop_node());
|
||||||
}
|
}
|
||||||
@ -387,22 +372,6 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline node_pointer move_copy_of(T& v) {
|
inline node_pointer move_copy_of(T& v) {
|
||||||
if (nodes_) {
|
|
||||||
node_tmp<NodeAlloc> a(pop_node(), constructor_.alloc_);
|
|
||||||
a.node_->value() = boost::move(v);
|
|
||||||
return a.release();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
constructor_.create_node();
|
|
||||||
boost::unordered::detail::func::call_construct(
|
|
||||||
constructor_.alloc_, constructor_.node_->value_ptr(),
|
|
||||||
boost::move(v));
|
|
||||||
return constructor_.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T1, typename T2>
|
|
||||||
inline node_pointer move_copy_of(std::pair<T1 const, T2>& v) {
|
|
||||||
if (nodes_) {
|
if (nodes_) {
|
||||||
constructor_.reclaim(pop_node());
|
constructor_.reclaim(pop_node());
|
||||||
}
|
}
|
||||||
|
@ -110,9 +110,11 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
template <typename A, typename T>
|
template <typename A, typename T>
|
||||||
struct pick_grouped_node
|
struct pick_grouped_node
|
||||||
{
|
{
|
||||||
|
typedef typename boost::remove_const<T>::type nonconst;
|
||||||
|
|
||||||
typedef boost::unordered::detail::allocator_traits<
|
typedef boost::unordered::detail::allocator_traits<
|
||||||
typename boost::unordered::detail::rebind_wrap<A,
|
typename boost::unordered::detail::rebind_wrap<A,
|
||||||
boost::unordered::detail::grouped_ptr_node<T> >::type
|
boost::unordered::detail::grouped_ptr_node<nonconst> >::type
|
||||||
> tentative_node_traits;
|
> tentative_node_traits;
|
||||||
|
|
||||||
typedef boost::unordered::detail::allocator_traits<
|
typedef boost::unordered::detail::allocator_traits<
|
||||||
@ -120,7 +122,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
boost::unordered::detail::ptr_bucket >::type
|
boost::unordered::detail::ptr_bucket >::type
|
||||||
> tentative_bucket_traits;
|
> tentative_bucket_traits;
|
||||||
|
|
||||||
typedef pick_grouped_node2<A, T,
|
typedef pick_grouped_node2<A, nonconst,
|
||||||
typename tentative_node_traits::pointer,
|
typename tentative_node_traits::pointer,
|
||||||
typename tentative_bucket_traits::pointer> pick;
|
typename tentative_bucket_traits::pointer> pick;
|
||||||
|
|
||||||
|
@ -106,9 +106,11 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
template <typename A, typename T>
|
template <typename A, typename T>
|
||||||
struct pick_node
|
struct pick_node
|
||||||
{
|
{
|
||||||
|
typedef typename boost::remove_const<T>::type nonconst;
|
||||||
|
|
||||||
typedef boost::unordered::detail::allocator_traits<
|
typedef boost::unordered::detail::allocator_traits<
|
||||||
typename boost::unordered::detail::rebind_wrap<A,
|
typename boost::unordered::detail::rebind_wrap<A,
|
||||||
boost::unordered::detail::ptr_node<T> >::type
|
boost::unordered::detail::ptr_node<nonconst> >::type
|
||||||
> tentative_node_traits;
|
> tentative_node_traits;
|
||||||
|
|
||||||
typedef boost::unordered::detail::allocator_traits<
|
typedef boost::unordered::detail::allocator_traits<
|
||||||
@ -116,7 +118,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
boost::unordered::detail::ptr_bucket >::type
|
boost::unordered::detail::ptr_bucket >::type
|
||||||
> tentative_bucket_traits;
|
> tentative_bucket_traits;
|
||||||
|
|
||||||
typedef pick_node2<A, T,
|
typedef pick_node2<A, nonconst,
|
||||||
typename tentative_node_traits::pointer,
|
typename tentative_node_traits::pointer,
|
||||||
typename tentative_bucket_traits::pointer> pick;
|
typename tentative_bucket_traits::pointer> pick;
|
||||||
|
|
||||||
|
@ -24,15 +24,15 @@ template class boost::unordered_map<
|
|||||||
std::equal_to<int>,
|
std::equal_to<int>,
|
||||||
test::minimal::allocator<std::pair<int const, int> > >;
|
test::minimal::allocator<std::pair<int const, int> > >;
|
||||||
template class boost::unordered_multimap<
|
template class boost::unordered_multimap<
|
||||||
int,
|
int const,
|
||||||
int,
|
int const,
|
||||||
boost::hash<int>,
|
boost::hash<int>,
|
||||||
std::equal_to<int>,
|
std::equal_to<int>,
|
||||||
test::minimal::allocator<std::pair<int const, int> > >;
|
test::minimal::allocator<std::pair<int const, int> > >;
|
||||||
|
|
||||||
template class boost::unordered_map<
|
template class boost::unordered_map<
|
||||||
test::minimal::assignable,
|
test::minimal::assignable const,
|
||||||
test::minimal::default_assignable,
|
test::minimal::default_assignable const,
|
||||||
test::minimal::hash<test::minimal::assignable>,
|
test::minimal::hash<test::minimal::assignable>,
|
||||||
test::minimal::equal_to<test::minimal::assignable>,
|
test::minimal::equal_to<test::minimal::assignable>,
|
||||||
test::minimal::allocator<test::minimal::assignable> >;
|
test::minimal::allocator<test::minimal::assignable> >;
|
||||||
|
@ -23,13 +23,13 @@ template class boost::unordered_set<
|
|||||||
std::equal_to<int>,
|
std::equal_to<int>,
|
||||||
test::minimal::allocator<int> >;
|
test::minimal::allocator<int> >;
|
||||||
template class boost::unordered_multiset<
|
template class boost::unordered_multiset<
|
||||||
int,
|
int const,
|
||||||
boost::hash<int>,
|
boost::hash<int>,
|
||||||
std::equal_to<int>,
|
std::equal_to<int>,
|
||||||
test::minimal::allocator<int> >;
|
test::minimal::allocator<int> >;
|
||||||
|
|
||||||
template class boost::unordered_set<
|
template class boost::unordered_set<
|
||||||
test::minimal::assignable,
|
test::minimal::assignable const,
|
||||||
test::minimal::hash<test::minimal::assignable>,
|
test::minimal::hash<test::minimal::assignable>,
|
||||||
test::minimal::equal_to<test::minimal::assignable>,
|
test::minimal::equal_to<test::minimal::assignable>,
|
||||||
test::minimal::allocator<test::minimal::assignable> >;
|
test::minimal::allocator<test::minimal::assignable> >;
|
||||||
|
Reference in New Issue
Block a user