缺少模板重载处的Boost MPL

  • 本文关键字:Boost MPL 重载 boost-mpl
  • 更新时间 :
  • 英文 :


我正在尝试使用boost mpl的map容器进行基于策略的设计的POC。(此处编码)

我使用mpl::map传递我的策略,它默认为空:

typedef boost::mpl::map<> DefaultPolicy;

为了获得策略,我尝试了以下操作:

typedef typename boost::mpl::at<TPolicy, LogPK, DefaultLogP>::type LoggingPolicy;

相反,我得到了以下g++4.81的错误(以及clang++3.3的等效错误):

main.cpp:49:61: error: wrong number of template arguments (3, should be 2)
    typedef typename boost::mpl::at<TPolicy, LogPK, DefaultLogP>::type LoggingPolicy;
                                                               ^

boost文档提到了at模板的三个参数重载。看起来它不在#include <boost/mpl/at.hpp>中。我甚至通过boost代码搜索了这个过载,但没有成功。我找到的唯一一个模板是有两个参数的模板。我在谷歌上搜索这个问题失败了("at"太常见了)。

这是一个boost文档错误,还是有人发现如何在重载时使用这个mpl::?

只有两种类型的版本。不幸的是,这份文件是错误的,而且一直都是错误的。但你总是可以推出自己的

template <typename Seq, typename Key, typename Def>
struct at_def
: mpl::eval_if<
    typename mpl::has_key<Seq, Key>::type,
    mpl::at<Seq, Key>,
    mpl::identity<Def>
    >
{ }

最新更新