Jan B Jan B - 2 months ago 7
C++ Question

Vector of pairs with generic vector and pair type, template of template

I'd like to pass a vector of pairs to a function. The actual vector implementation as well as the types of the pair should be a template parameter.

I thought of something like this:

template<uint8_t t_k,
typename t_bv,
typename t_rank,
template <template <template<typename t_x,
typename t_y> class std::pair>
typename t_vector>> typename t_vector>


The first 3 are other template parameters. The last template parameter should allow to pass a
vector
(
std
or
stxxl:vector
) of
std::pair
with either
uint32_t
or
uint64_t
as type of the
pair.first
and
pair.second
.

Answer

You can use this:

template<typename X,
         typename Y,
         template<typename, typename> class Pair,
         template<typename...> class Vector>
void fun(Vector<Pair<X, Y>> vec)
{
     //...
}