Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8606163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:01:39+00:00 2026-06-12T03:01:39+00:00

I have a multi_index_container of struct Person : struct Person { std::string firstName; std::string

  • 0

I have a multi_index_container of struct Person:

struct Person {
    std::string firstName;
    std::string lastName;
    int id;
    bool operator <(const Person& rhs) const {return id < rhs.id;}
};

//index tags
struct BaseIndexTag {};
struct FirstName : BaseIndexTag {};
struct LastName : BaseIndexTag {};
struct ID : BaseIndexTag {};

namespace bmi = boost::multi_index;

typedef boost::multi_index_container<
    Person, 
    bmi::indexed_by<
    //PinsConnection operator < ordering
    bmi::ordered_unique<bmi::tag<ID>, bmi::identity<Person> >,
    //order by first name
    bmi::ordered_non_unique<bmi::tag<FirstName>, bmi::member<Person, std::string, &Person::firstName> >,
    //Order by last name
    bmi::ordered_non_unique<bmi::tag<LastName>, bmi::member<Person, std::string, &Person::lastName> >
    >
> PersonMultiSet; 

and a wrapper class for boost’s iterator_adaptor:

template <
typename I      //Internal iterator type
, typename C    //Container class
>   
class IteratorAdaptor : public boost::iterator_adaptor <
    IteratorAdaptor<I,C>,               //Derived
    I,                                  //Base      
    boost::use_default,                 //Value
    boost::forward_traversal_tag>       //Traversal
{
private:
    friend class boost::iterator_core_access;
    friend C;
public:
    IteratorAdaptor()
        : typename IteratorAdaptor<I,C>::iterator_adaptor_() {}
    explicit IteratorAdaptor(I& b)
        : typename IteratorAdaptor<I,C>::iterator_adaptor_(b) {}
};

Finally, I wrote a wrapper class for PersonMultiSet, in order to expose a clean interface to the users of this class and to avoid boost’s multi_index_container somewhat cumbersome interface:

class PersonContainer {
public:
    typedef IteratorAdaptor<PersonMultiSet::index<ID>::type::iterator, PersonContainer> IDIterator;
    typedef IteratorAdaptor<PersonMultiSet::index<ID>::type::const_iterator, PersonContainer> IDConstIterator;
    typedef IteratorAdaptor<PersonMultiSet::index<FirstName>::type::iterator, PersonContainer> FirstNameIterator;
    typedef IteratorAdaptor<PersonMultiSet::index<FirstName>::type::const_iterator, PersonContainer> FirstNameConstIterator;
    typedef IteratorAdaptor<PersonMultiSet::index<LastName>::type::iterator, PersonContainer> LastNameIterator;
    typedef IteratorAdaptor<PersonMultiSet::index<LastName>::type::const_iterator, PersonContainer> LastNameConstIterator;
    template <typename T> //tag
    void foo(IteratorAdaptor<PersonMultiSet::index<T>::type::iterator, PersonContainer> &it)
    {
        //...
    }
private:
    PersonMultiSet people;
};

Compiling this code under VS2010 produces the following error over the declaration of function foo:

1>  main.cpp
1>main.cpp(70): warning C4346: 'boost::multi_index::multi_index_container<Value,IndexSpecifierList>::index<T>::boost::multi_index::multi_index_container<Value1,IndexSpecifierList1,Allocator1>::index<Tag>::type::iterator' : dependent name is not a type
1>          with
1>          [
1>              Value=Person,
1>              IndexSpecifierList=boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::tag<ID>,boost::multi_index::identity<Person>>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<FirstName>,boost::multi_index::member<Person,std::string,pointer-to-member(0x0)>>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<LastName>,boost::multi_index::member<Person,std::string,pointer-to-member(0x20)>>>
1>          ]
1>          prefix with 'typename' to indicate a type
1>main.cpp(70): error C2923: 'IteratorAdaptor' : 'boost::multi_index::multi_index_container<Value,IndexSpecifierList>::index<T>::boost::multi_index::multi_index_container<Value1,IndexSpecifierList1,Allocator1>::index<Tag>::type::iterator' is not a valid template type argument for parameter 'I'
1>          with
1>          [
1>              Value=Person,
1>              IndexSpecifierList=boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::tag<ID>,boost::multi_index::identity<Person>>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<FirstName>,boost::multi_index::member<Person,std::string,pointer-to-member(0x0)>>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<LastName>,boost::multi_index::member<Person,std::string,pointer-to-member(0x20)>>>
1>          ]
1>
1>Build FAILED.

It seems that the compiler doesn’t allow the type IteratorAdaptor<PersonMultiSet::index<T>::type::iterator do be determined upon first use (I get this error before I even try and instantiate PersonContainer or call foo).
What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:01:40+00:00Added an answer on June 12, 2026 at 3:01 am

    The compiler gives you a hint what’s wrong:

    prefix with ‘typename’ to indicate a type

    So, you need to add typename before the “problematic” parameter.

    void foo(IteratorAdaptor<PersonMultiSet::index<T>::type::iterator, 
                             PersonContainer> &it)
    

    must be:

    //                         vvvvvvvv
    void foo( IteratorAdaptor< typename PersonMultiSet::index<T>::type::iterator,
                               PersonContainer> &it)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have an object like this: struct Bar { std::string const& property(); };
I have a problem getting boost::multi_index_container work with random-access and with orderd_unique at the
I have a struct to store info about persons and multi_index_contaider to store such
I have the following code: #include <iostream> #include boost/unordered_map.hpp using namespace std; using namespace
I have a problem in const manipulation of my variables. I have simplified the
I have a multi-dim string array something like this:- string[,] names = new string[2,
I have a multi_index_container with an index that is a composite_key . But I
Let's say I have a container (std::vector) of pointers used by a multi-threaded application.
So I have a boost::multi_index_container with multiple non-unique indexes. I would like to find
If you have a boost::multi_index_container< > with multiple indices, there are obviously multiple ways

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.