c++ - Boost Multiindex: Example compiles in cpp files but not in header -
i trying compile boost multiindex example
i have project consisting of multiple header , source files. when put following code source file works well, give me errors below, when code header file. both header , cpp include required boost header files , boost works fine otherwise.
i have never encountered such problem , quite confused reason be.
// define multiply indexed set indices id , name typedef multi_index_container< employee, indexed_by< // sort employee::operator< ordered_unique<identity<employee> >, // sort less<string> on name ordered_non_unique<member<employee,std::string,&employee::name> > > > employee_set; where employee simple struct.
void print_out_by_name(const employee_set& es) { // view index #1 (name) const employee_set::nth_index<1>::type& name_index=es.get<1>(); // use name_index regular std::set } missing 'typename' prior dependent type name 'employee_set::nth_index' const employee_set::nth_index<1>::type& name_index=es.get<1>();
expected unqualified-id const employee_set::nth_index<1>::type& name_index=es.get<1>();
try
const typename employee_set::nth_index<1>::type& name_index=es.get<1>(); nth_index<1>::type called depended type. compiler doesn't know whether type of value or whatever. , writing typename tells him indeed type.
Comments
Post a Comment