Hi all,
I am newbie to Boost library. I am trying to use multi_index_container
library in my project. The problem I have at my hands needs One Hash
index and one ordered indexed. I refer the Boost tutorial and Advance
topic and tried to write the following snippet. But when I compiled it
gives compilation error. I searched lot of different options and tried
to fix it but I could not able to do it so.
If you can guide me how to shut the compilation errors it will be great.
If anyone of you is having any decent example tried out for Hash having
ordered indexes please send it to me so I can go through and build my
logic on top of that....
Code Follows.
I am using MSVC SP6 on Win XP .
/*****************************************/
#define BOOST_MULTI_INDEX_CHECK_INVARIANT
#include
#include
#include
#include
#include
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
using boost::multi_index_container;
using namespace boost::multi_index;
struct employee
{
int id;
std::string name;
int ssnumber;
employee(int id,const std::string& name,int ssnumber):
id(id),name(name),ssnumber(ssnumber){}
bool operator<(const employee& e)const{return id,
// sort by less<string> on name
ordered_non_unique,
// hashed on ssnumber
hashed_unique
employee_set;
void main()
{
employee_set es;
typedef employee_set::index::type
employee_set_by_ssn;
es.insert(employee(1,"aashit",323));
es.insert(employee(3,"chetan",443));
employee_set_by_ssn& ssn_index=es.get<2>();
}
--------------------Configuration: MyHash - Win32
Debug--------------------
Compiling...
main.cpp
f:\practice\multiindex_examples\myhash\main.cpp(53) : error C2039:
'index,struct
boost::multi_index::member_offset,struct
boost::mpl::na>,struct boost::multi_index::ordered_non_unique,struct
boost::multi_index::member_offset,4>,struct boost::mpl::na>,struct
boost::multi_index::hashed_unique,struct boost::multi_index::member_offset,struct boost::mpl::na,struct boost::mpl::na>,struct
boost::mpl::na,struct boost::mpl::na>,class std::a
llocator<struct employee> >,struct ssnumber>' : is not a member of
'multi_index_container,struct boost::multi_index::member_offset,struct boost::mpl::na>,struct
boost::multi_index::ordered_non_unique,struc
t boost::multi_index::member_offset,4>,struct boost::mpl::na>,struct
boost::multi_index::hashed_unique,struct
boost::multi_index::member_offset,struct
boost::mpl::na,struct boost::mpl::na>,struct boost::mpl::na,struct
boost::mpl::na>,class std::allocator<struct employee> >'
f:\practice\multiindex_examples\myhash\main.cpp(53) : error C2146:
syntax error : missing ';' before identifier 'employee_set_by_ssn'
f:\practice\multiindex_examples\myhash\main.cpp(53) : error C2065:
'employee_set_by_ssn' : undeclared identifier
f:\practice\multiindex_examples\myhash\main.cpp(60) : error C2065:
'ssn_index' : undeclared identifier
f:\practice\multiindex_examples\myhash\main.cpp(60) : error C2039: 'get'
: is not a member of 'multi_index_container,struct
boost::multi_index::member_offset,struct
boost::mpl::na>,struct boost::multi_index::ordered_non_unique,struct boost::multi_index::member_offset,4>,struct
boost::mpl::na>,struct boost::multi_index::hashed_unique,struct boost::multi_index::member_offset,struct boost::mpl::na,struct boost::mpl::na>,struct
boost::mpl::na,struct boost::mpl::na>,class std::alloca
tor<struct employee> >'
f:\practice\multiindex_examples\myhash\main.cpp(60) : error C2059:
syntax error : ')'
Error executing cl.exe.
main.obj - 6 error(s), 0 warning(s)
A a s h i t