Commit Graph

674 Commits

Author SHA1 Message Date
Daniel James
81aefde94e Use const_key_type internally 2017-02-23 20:14:27 +00:00
Daniel James
96602df8a8 Remove const volatile when picking bucket policy
Could possibly do this in a more portable manner by using some sort of
function overload.
2017-02-23 20:14:27 +00:00
Daniel James
c0b72d97b3 Stricter about rebinding the allocator 2017-02-23 20:14:27 +00:00
Daniel James
ddee1b686a Move config and declaration to the start of implementataion.hpp 2017-02-23 20:14:26 +00:00
Daniel James
2231586033 Remove duplicate includes 2017-02-23 20:14:26 +00:00
Daniel James
bf5ef9824d Reformat with clang-format 2017-02-19 13:05:17 +00:00
Daniel James
f2af10c746 Protect preprocess sequence from clang format 2017-02-19 13:05:17 +00:00
Daniel James
67ab88b064 Combine most of the detail headers into a single header 2017-02-19 13:05:17 +00:00
Daniel James
67f1f65174 Linearise the detail includes
The current organisation of the headers has been making less and less
sense over the years, so to simplify things, I'm just going to combine
them into a single header. This change will make it easier to do that.
2017-02-19 13:05:17 +00:00
Daniel James
57cc6d4bac Fix exception safety when constructing pairs 2017-01-01 18:35:50 +00:00
Daniel James
33f701dd09 Fix assigning hash/key equality functions for empty containers 2016-11-21 10:24:51 +00:00
Daniel James
a7546e298e Support 10 arguments in emplace_args
Which was the intent, but only supported up to 9 arguments. I doubt
this will make much of a difference.
2016-11-02 07:30:41 +00:00
Daniel James
98cce956f9 Try to fix a 64-bit powerpc g++ 7 warning
Warning is:

allocate.hpp:335:19: warning: conversion to ???unsigned int??? from
???long unsigned int??? may alter its value [-Wconversion]

I'm not sure, but I think it's because the sizeof is a long unsigned
int, and the template parameter is an unsigned int. The sizeof isn't
even used, it's just there to get a value for expression SFINAE.
2016-10-28 09:06:53 +01:00
Daniel James
e3f534a148 Allocator aware constructors 2016-10-23 13:33:25 +01:00
Daniel James
1bcd5b0003 Make no argument constructor implicit 2016-10-23 13:32:52 +01:00
Daniel James
0d1cfba823 Rename functions in allocate.hpp 2016-10-22 10:28:53 +01:00
Daniel James
e986b70981 Stricter iterator types 2016-10-22 10:04:36 +01:00
Daniel James
9b7b485c33 Use node_pointer in equality. 2016-10-22 10:04:36 +01:00
Daniel James
c680fa7418 Remove find_matching_node.
FWIW the standard says that equality is undefined behaviour if the Hash
and Pred function objects behave differently. But I think we should
support different hash functions, e.g. so that randomized hash functions
will work.
2016-10-22 10:04:36 +01:00
Daniel James
9772c01161 Replace several uses of iterators with node pointers.
Which is to some extent going in circles, as this is how the containers
were originally implemented. But I think this is cleaner. It also fixes
a minor problem where the internal and external iterator types are
different for some containers, as the external iterators are all const.
2016-10-22 10:04:36 +01:00
Daniel James
ad2256b13c Add const cast for piecewise construction 2016-10-22 09:42:56 +01:00
Daniel James
dad0d48c9c 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>>).
2016-10-17 08:06:19 +01:00
Daniel James
e03a8732a6 Use static_cast for allocator_traits::construct
std::allocator::construct uses a C-style cast to void pointer, so it can
accept const pointers, but allocator_traits::construct uses a static_cast
by default, so const pointers don't work. This means the implementation
needs to cast away const when constructing members of a std::pair. This
wouldn't happen if piecewise construction was used, as the members could
be constructed normally.
2016-10-17 07:54:06 +01:00
Daniel James
b907cee691 Use std::allocator_traits where available.
Might have to revert this when implementing C++17 features.
2016-10-14 09:27:40 +01:00
Daniel James
da6e8e8041 Better allocator rebind support 2016-10-14 09:27:40 +01:00
Daniel James
71d19820ac Fix signed conversion warnings. 2016-10-05 09:45:53 +01:00
Daniel James
d14c1dec59 Revert "Allocator aware constructors."
This reverts commit b00bc15c3e.

I messed that up a bit, will get back to it later.
2016-10-03 20:58:15 +01:00
Daniel James
ff0228e752 Support for std::piecewise_construct. 2016-10-02 17:56:01 +01:00
Daniel James
b00bc15c3e Allocator aware constructors. 2016-10-02 17:56:01 +01:00
Daniel James
e7b20d2877 Fix exception bug in asssignment.
The hash and key equality functions were assigned before allocating new
buckets. If that allocation failed, then the existing elements would be
left in place - so if accessed after the exception they could be in the
wrong buckets or equivalent elements could be incorrectly grouped
together.
2016-10-02 13:04:25 +01:00
Daniel James
e174af2286 Try not using boost::forward in emplace_args constructor.
AFAICT it's not needed since the construct arguments and the members are
the same reference type. Maybe it was for older compilers? And it appears
to be causing issues with string literals in older versions of Visual
C++.
2016-09-30 00:32:19 +01:00
Daniel James
9decbe0cbd Manually write out emplace_args for small numbers.
Still need some macros to handle rvalue reference support.
2016-09-30 00:32:19 +01:00
Daniel James
cc32bfb96f Pointless change to extract_key. 2016-09-07 09:26:25 +01:00
Daniel James
7434e116a7 Try using boost::long_long_type to avoid warning. 2016-08-29 23:03:06 +01:00
Daniel James
cae72eec2f Insert/emplace with hint. 2016-08-17 12:08:15 +01:00
Daniel James
e58370b4ff Move emplace before emplace_impl in equivalent.hpp 2016-08-17 12:08:15 +01:00
Daniel James
e92f7d86c1 Remove array_constructor.
I was using SFINAE for everything because some old compilers had issues.
But that's hopefully in the distant past now.
2016-08-14 20:55:40 +01:00
Daniel James
93a33ba15f Remove a couple of unneeded includes. 2016-08-14 20:55:40 +01:00
Daniel James
ad353c8e3d Move some of the includes up into allocate.hpp 2016-08-14 20:55:40 +01:00
Daniel James
09717ffca4 Remove a few unnecessary internal includes. 2016-08-14 20:55:40 +01:00
Daniel James
ce4b840299 Map/set details types in individual headers. 2016-08-14 20:55:40 +01:00
Daniel James
5a8df0ebe4 Hopefully a bit more readable. 2016-08-14 20:55:40 +01:00
Daniel James
6029d1cfd0 Trim down node_tmp code. 2016-08-14 20:55:40 +01:00
Daniel James
3fe46a1769 Cleaner emplace_impl in equivalent. 2016-08-14 20:55:40 +01:00
Daniel James
5490bcfe95 Remove node_tmp overload of add_node. 2016-08-14 20:55:40 +01:00
Daniel James
078c562b6c Pull some common code into a function. 2016-08-14 20:55:40 +01:00
Daniel James
88612a8be4 Less faffing around with node_constructor. 2016-08-14 20:55:40 +01:00
Daniel James
37a6903831 Move node construction into allocate.hpp 2016-08-14 20:55:40 +01:00
Daniel James
8017d9e684 Change how node construction works.
Split node_constructor into two classes, one for constructing a node
without a value, and then another for holding it once the value is
constructed.

Do the work of constructing values in convenience functions in
allocate.hpp (construct_value_generic, construct_value, construct_pair).
2016-08-14 20:55:40 +01:00
Daniel James
609ae6cb4e Expand out fill_buckets. 2016-08-14 20:55:40 +01:00