Open kalaxy opened 4 years ago
Here is an example which triggers the compiler error.
#include <boost/heap/skew_heap.hpp>
struct MoveOnlyInt {
MoveOnlyInt(int i) : i(i) {}
MoveOnlyInt(MoveOnlyInt &&) = default;
MoveOnlyInt& operator=(MoveOnlyInt &&) = default;
friend bool operator<( MoveOnlyInt const &lhs, MoveOnlyInt const &rhs ) {
return lhs.i < rhs.i;
}
int i;
};
int main() {
using PQ = boost::heap::skew_heap<MoveOnlyInt>;
PQ pq;
pq.emplace(1);
}
Switching skew_heap
for another like binomial_heap
allows it to compile.
boost.heap is in maintenance mode. but i'm more than happy to integrate PRs
Hey Tim, curious what this "maintenance mode" is? Does that mean deprecated?
The
skew_heap_node
constructor taking an rvalue reference makes a copy instead of moving it in. This prevents the use of move only types withskew_heap
.I'm pretty sure that you just need to add
std::move
to the initializer list construction. E.g.