矢量的对与通用矢量和对类型,模板模板 [英] Vector of pairs with generic vector and pair type, template of template

查看:157
本文介绍了矢量的对与通用矢量和对类型,模板模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想传递一个对的向量到一个函数。实际的向量实现以及对的类型应该是模板参数。



我想到这样的东西:

 模板< 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>

前三个是其他模板参数。最后一个模板参数应该允许传递向量 std stxxl: uint32_t uint64_t 的 code>作为 pair.first pair.second 的类型。

解决方案

您可以使用:

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

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.

解决方案

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

这篇关于矢量的对与通用矢量和对类型,模板模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆