lundi 4 mai 2015

std::tuple as template argument?

I'm trying to write an std::sort template compare class that should receive an unknown number of tuples (variadic template). Each tuple should be consisted of a column (some type we have in our code) and a bool, specifying if this column should be sorted in ascending or descending order.

Basically, I want something similar to this:

// doesn't compile - conceptual code
template <typename std::tuple<Col, bool>>
struct Comparator
{
    bool operator() (int lhs, int rhs)
    {
         // lhs and rhs are row indices. Depending on the columns
         // and the bools received, decide which index should come first
    } 
}

Is this sort of thing possible in C++ 11?

Aucun commentaire:

Enregistrer un commentaire