-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
The readme says it's possible to use the containers with std::vector instead of std::deque. However, after changing that in ordered_set.h, the following code crashes under GCC 7.2.0, probably due to the strange specialization of std::vector<bool>.
#include <iostream>
#include "include/tsl/ordered_set.h"
int main() {
tsl::ordered_set<bool> a;
a.insert(true);
tsl::ordered_set<bool> b;
b.insert(a.begin(), a.end());
std::cout << b.size() << std::endl;
}There is also a warning:
lib/tsl/ordered_hash.h:387:43: warning: returning reference to temporary [-Wreturn-local-addr]
reference operator*() const { return *m_iterator; }
^~~~~~~~~~
A workaround is to keep std::deque just for bool.
class ValueTypeContainer = typename std::conditional<
std::is_same<Key, bool>::value,
typename std::deque<Key, Allocator>,
typename std::vector<Key, Allocator>>::type,Is this the reason why std::deque is used by default? I've found that std::vector makes the containers somewhat faster (though they're much faster than the default unordered containers in STL anyway).
Metadata
Metadata
Assignees
Labels
No labels