Jan B - 10 months ago 36

C++ Question

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`

`stxxl:vector`

`std::pair`

`uint32_t`

`uint64_t`

`pair.first`

`pair.second`

Answer Source

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)
{
//...
}
```