【发布时间】:2012-05-24 23:29:49
【问题描述】:
所以我有一个模板类,我想接受一个 std::map,其中数据类型是原始指针或 std::unique_ptr。然后在这个类中我想得到底层指针的类型:
typedef typename boost::mpl::if_<
boost::is_pointer<typename Container::mapped_type>,
typename Container::mapped_type,
typename Container::mapped_type::element_type*
>::type data_type
但是,在使用具有原始指针类型的映射实例化类时出现以下错误:
error: 'std::map<int, ValueType*>::mapped_type {aka ValueType*}' is not a class, struct, or union type
在我看来,它正在评估原始指针上的typename Container::mapped_type::element_type*,我认为使用模板元编程它不会在 if_ 成功时评估它。我应该以不同的方式解决这个问题吗?
【问题讨论】:
标签: c++ boost template-meta-programming boost-mpl