我玩弄一些提升容器,但最近,我封锁,因为我似乎无法multi_index_container的正确定义。我下面的一个例子,我下线抓住,但它仍然给了我和错误消息:故障定义的multi_index_container ordered_non_unique
struct boost::multi_index::global_fun<const node&, int, <error-constant>>
Error: Expression must have a constant value
这里是我的声明:
#define _CRT_SECURE_NO_DEPRECATE
#define _SCL_SECURE_NO_DEPRECATE
#include <boost/config.hpp>
#include <string>
#include <iostream>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/key_extractors.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/global_fun.hpp>
#include <boost/multi_index/ordered_index.hpp>
using namespace boost::multi_index;
struct node
{
node(std::string da, int in) {
data = da;
numerical = in;
};
std::string data;
int numerical;
};
int main()
{
typedef multi_index_container<
node,
indexed_by<
hashed_unique<
member<node,std::string, &node::data>>,
ordered_non_unique<
global_fun<const node&, int, node::numerical>> //right here, the value numerical errors
>
> node_type;
}
我有一种预感,我不包括文件这,但我找不到解决方案。
'node :: numerical'显然不是一个全局函数,而是一个成员。你在想什么? – pmr 2013-05-14 14:14:44