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 <boost/config.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/hashed_index.hpp>
#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<e.id;}
};

struct id{};
struct name{};
struct ssnumber{};


typedef multi_index_container<
  employee,
  indexed_by<
    // sort by employee::operator<
    ordered_unique<tag<id>,BOOST_MULTI_INDEX_MEMBER(employee,int,id) >,
   
    // sort by less<string> on name
    ordered_non_unique<tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,std::string,name) >,
   
    // hashed on ssnumber
    hashed_unique<tag<ssnumber>,BOOST_MULTI_INDEX_MEMBER(employee,int,ssnumber) >
  >
> employee_set;


void main()
{

        employee_set es;

        typedef employee_set::index<employee_set,ssnumber>::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<class boost::multi_index::multi_index_container<struct employee,struct boost::multi_index::indexed_by<struct boost::multi_index::ordered_unique<struct boost::multi_index::tag<

struct id,struct boost::mpl::na,struct boost::mpl::na>,struct boost::multi_index::member_offset<struct employee,int,0>,struct boost::mpl::na>,struct boost::multi_index::ordered_non_unique<struct boost::multi_index::tag<struct name,struct boost::mpl:

:na,struct boost::mpl::na>,struct boost::multi_index::member_offset<struct employee,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,4>,struct boost::mpl::na>,struct boost::multi_index::hashed_unique<struct boo

st::multi_index::tag<struct ssnumber,struct boost::mpl::na,struct boost::mpl::na>,struct boost::multi_index::member_offset<struct employee,int,20>,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 employee,struct boost::multi_index::indexed_by<struct boost::multi_index::ordered_unique<struct boost::multi_index::tag<struct id,struct boost::mpl::na,

struct boost::mpl::na>,struct boost::multi_index::member_offset<struct employee,int,0>,struct boost::mpl::na>,struct boost::multi_index::ordered_non_unique<struct boost::multi_index::tag<struct name,struct boost::mpl::na,struct boost::mpl::na>,struc

t boost::multi_index::member_offset<struct employee,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,4>,struct boost::mpl::na>,struct boost::multi_index::hashed_unique<struct boost::multi_index::tag<struct ssnu

mber,struct boost::mpl::na,struct boost::mpl::na>,struct boost::multi_index::member_offset<struct employee,int,20>,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 employee,struct boost::multi_index::indexed_by<struct boost::multi_index::ordered_unique<struct boost::multi_index::tag<struc

t id,struct boost::mpl::na,struct boost::mpl::na>,struct boost::multi_index::member_offset<struct employee,int,0>,struct boost::mpl::na>,struct boost::multi_index::ordered_non_unique<struct boost::multi_index::tag<struct name,struct boost::mpl::na,s

truct boost::mpl::na>,struct boost::multi_index::member_offset<struct employee,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,4>,struct boost::mpl::na>,struct boost::multi_index::hashed_unique<struct boost::m

ulti_index::tag<struct ssnumber,struct boost::mpl::na,struct boost::mpl::na>,struct boost::multi_index::member_offset<struct employee,int,20>,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