몇 가지 부스트 컨테이너를 가지고 놀고 있습니다.하지만 최근에는 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 :: numeric'은 명백히 전역 함수가 아니라 멤버입니다. 너 뭐하니? – pmr