Not sure if I have a simple typo somewhere, but I'm running into issues in sorting a deque of tuples.
So, my deque looks like this:
std::deque<boost::tuple<unsigned int, unsigned int> > messages;
And then I have my call to sort:
sort(messages.begin(), messages.end(), msg_sort_criteria);
And my sorting function:
bool msg_sort_criteria(boost::tuple<unsigned int, unsigned int> lhs, boost::tuple<unsigned int, unsigned int> rhs)
{
return boost::get<1>(lhs) < boost::get<1>(rhs);
}
What happens is that I get errors in stl_heap.h and stl_algo.h. For instance,
Called object type '
<bound member function type>
' is not a function or function parameter.
Edit:
For clarification, this is all taking place within private members of a class.
class Messages::MessageImpl{
private:
std::deque<boost::tuple<unsigned int, unsigned int> > messages;
bool msg_sort_criteria(boost::tuple<unsigned int, unsigned int> lhs, boost::tuple<unsigned int, unsigned int> rhs)
{
return boost::get<1>(lhs) < boost::get<1>(rhs);
}
void fn()
{
sort(msg_queue_.begin(), msg_queue_.end(), msg_sort_criteria);
}
}
Mostly reposting from comment.
Change your implementation to:
class Messages::MessageImpl{
private:
std::deque<boost::tuple<unsigned int, unsigned int> > messages;
static bool msg_sort_criteria(boost::tuple<unsigned int, unsigned int> lhs,
boost::tuple<unsigned int, unsigned int> rhs)
{
return boost::get<1>(lhs) < boost::get<1>(rhs);
}
void fn()
{
sort(msg_queue_.begin(), msg_queue_.end(), &MessageImpl::msg_sort_criteria);
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With