C++ c++;访问boost fusion对中的字段类型时出错

C++ c++;访问boost fusion对中的字段类型时出错,c++,boost,template-meta-programming,C++,Boost,Template Meta Programming,我试图从fusion map创建一个filter_视图,但似乎无法使模板元函数正常工作 所以我有一个融合图,结构类似于这个 #include <boost/fusion/container/map.hpp> #include <boost/fusion/view/filter_view.hpp> template <typename> struct SetField { }; using IDType = int; using NameType = std:

我试图从fusion map创建一个filter_视图,但似乎无法使模板元函数正常工作

所以我有一个融合图,结构类似于这个

#include <boost/fusion/container/map.hpp>
#include <boost/fusion/view/filter_view.hpp>

template <typename> struct SetField { };
using IDType = int;
using NameType = std::string;
using TimeField = double;

using namespace boost::fusion;
typedef map<pair<struct ActId,  SetField<IDType> >,
            pair<struct ActName, SetField<NameType> >,
            pair<struct ActStart, TimeField>,
            pair<struct ActEnd,   TimeField> > ActivityMapType;
#包括
#包括
模板结构设置字段{};
使用IDType=int;
使用NameType=std::string;
使用TimeField=double;
使用名称空间boost::fusion;
类型定义映射活动映射类型;
我想创建一个过滤器视图,排除第二种类型为时间字段的字段

int main()
{
    ActivityMapType map_;
    filter_view<
            ActivityMapType const, 
            boost::mpl::not_<boost::is_same<result_of::second<boost::mpl::_>::type, TimeField>>
        > view(map_);
}
intmain()
{
ActivityMapType映射;
过滤视图<
ActivityMapType常量,
boost::mpl::not_
>视图(地图);
}
我得到的编译器错误是

 /home/mike/boost/boost/fusion/support/pair.hpp: In instantiation of
             'struct boost::fusion::result_of::second<mpl_::arg<-1> >':
 /home/mike/project/Filter/FusionActivityFilter.h:328:55:   required
 from here /home/mike/boost/boost/fusion/support/pair.hpp:68:48: error:
 no type named 'second_type' in 'struct mpl_::arg<-1>'
              typedef typename Pair::second_type type;
/home/mike/boost/boost/fusion/support/pair.hpp:在
'struct boost::fusion::result_of::second':
/home/mike/project/Filter/FusionActivityFilter.h:328:55:必需
从这里/home/mike/boost/boost/fusion/support/pair。hpp:68:48:错误:
“struct mpl::arg”中没有名为“second\u type”的类型
typedef typename对::第二种类型;

我想知道我是否只是错误地使用了boost::mpl::uu占位符,我对这种元编程的东西还不熟悉。

我找到了一个解决方案,基本上就是给出的答案

模板
结构获取秒
{
typedef typename FPair::second_type类型;
};
int main()
{
ActivityMapType映射;
typedef boost::fusion::result_of::filter_if<
boost::mpl::lambda<
boost::mpl::not_<
boost::是一样的吗<
时间场,
第二
>
>
>::类型
>::输入no_time_type;
无时间类型noTimes(映射);
}

我不太明白为什么我不能用boost::fusion::filter_视图做同样的事情。我以为我找到了一张提振票,这似乎是一个潜在的原因,但我现在找不到。“过滤器视图”似乎阻止了内部元函数看到占位符1的实际类型。

如果需要帮助,也许应该使示例代码自包含。如果人们甚至不能编译代码,他们就会跳过这个问题。啊,谢谢你,很高兴知道这可能只是
boost::mpl::not
?它至少编译了…(这里是MPL初学者),所以我想得更多一些。作为一个测试,我做了boost::mpl::not\ux。似乎这一对作为一个整体作为单个参数传递给了_1占位符。不过,我还没有弄清楚如何访问组成这对组合的各个类型。
template <typename FPair>
struct get_second 
{
   typedef typename FPair::second_type type;
};

int main()
{
    ActivityMapType map_;
    typedef boost::fusion::result_of::filter_if<
                       boost::mpl::lambda<
                               boost::mpl::not_<
                                        boost::is_same<
                                                  TimeField,
                                                  get_second<boost::mpl::_1>
                                        >
                               >
                       >::type
            >::type no_time_type;
    no_time_type noTimes(map_);
}