【问题标题】:Error when template parameter passed to boost multi index container传递模板参数以提升多索引容器时出错
【发布时间】:2019-04-09 14:59:14
【问题描述】:

我正在尝试将 multi_index_container 与模板一起使用。下面是我的代码。

template < class ValueType >
class anrQueue
{
private:
    typedef boost::multi_index_container<
    ValueType,
    indexed_by<
    sequenced<>,
    ordered_unique<identity<ValueType> >
    >
    > a_queue;

a_queue mQueue;

public:
size_t remove(const ValueType& x) {
    return mQueue.get<1>().erase(x);
}
-------------------------^
error: expected primary-expression before ‘)’ token

如何解决这个问题

【问题讨论】:

    标签: templates parameters containers boost-multi-index


    【解决方案1】:

    写:

    return mQueue.template get<1>().erase(x);
    

    查看here 以了解有关template 在依赖上下文中的用法的说明。

    【讨论】:

      猜你喜欢
      • 2011-07-12
      • 1970-01-01
      • 2018-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多