c++ - Trouble defining multi_index_container ordered_non_unique -


i'm playing around boost containers, came blockade can't seem define multi_index_container correctly. i'm following example grabbed offline still gives me , error message:

struct boost::multi_index::global_fun<const node&, int, <error-constant>>  error: expression must have constant value 

here declaration:

#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, value numerical errors             >         > node_type;    } 

i have hunch i'm not including file this, can't find solution.

this should it:

typedef multi_index_container<   node,   indexed_by<  hashed_unique< member<node,std::string, &node::data> >              , ordered_non_unique< member<node, int, &node::numerical> >             >   > node_type; 

global_fun expects, well, gloabl function. &node::numerical member &node::data. can of course write function accepts node , extracts it, why you?

you missing member.hpp include.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -