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 9230655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:52:42+00:00 2026-06-18T05:52:42+00:00

I want a multi-index-container in a class, that depends on a template-dependent class in

  • 0

I want a multi-index-container in a class, that depends on a template-dependent class in the class.
Sounds complicated, here is the code:

#include <boost/unordered_map.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/member.hpp>

template <typename Type>
class myDataContainer{
public:
    struct DataStruct{
        double t;
        std::vector<Type> data;
    };

    // indices structs
    struct TagTime{};
    struct TagOrdered{};

    typedef boost::multi_index::multi_index_container<
    DataStruct,
    boost::multi_index::indexed_by<
        boost::multi_index::hashed_unique<boost::multi_index::tag<TagTime>,     boost::multi_index::member<DataStruct, double, &DataStruct::t> >,
        boost::multi_index::ordered_unique<boost::multi_index::tag<TagOrdered>,     boost::multi_index::member<DataStruct, double, &DataStruct::t> > // this index represents     timestamp incremental order
        >
    > InnerDataContainer;
    typedef typename boost::multi_index::index<InnerDataContainer,TagTime>::type timestamp_view;
    typedef typename boost::multi_index::index<InnerDataContainer,TagOrdered>::type ordered_view;

    InnerDataContainer dataContainer;
    void begin(){
        ordered_view& ordView = dataContainer.get<TagOrdered>();
        ordView.begin();
    }

};

int main(int argc, char *argv[])
{
    myDataContainer<float> data;
    myDataContainer<float>::ordered_view& ordView = data.dataContainer.get<TagOrder>();
    ordView.begin();
}

Without the myDataContainer::begin() function this code compiles, but with the myDataContainer::begin() I get the following error:

main.cpp: In member function 'void myDataContainer<Type>::begin()':
main.cpp:134:66: error: expected primary-expression before '>' token
main.cpp:134:68: error: expected primary-expression before ')' token

Am I missing something? Is this a bug in boost or is it not possible?`

Thanks in advance
veio

  • 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-18T05:52:43+00:00Added an answer on June 18, 2026 at 5:52 am

    Because dataContainer is template parameter dependent, you need

    ordered_view& ordView = dataContainer.template get<TagOrdered>();
    

    In main() you use specific a specialization, so there are no dependent expressions any more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this application that I want to support multi languages. I thought the
I want to develop a multi-server clustered framework that will work similarly to the
I want to create a multi-tenant application that uses the hostname to determine the
i want to write a function that prints multi-dimensional objects which are text (or
I have a MultiIndex container of boost::shared_ptrs to members of class Host . These
There is a class in my code (not my code) which uses boost multi_index_container
In boost multi-index, can I verify whether a particular index type is ordered/not through
I have a dataset with multi-index columns in a pandas df that I would
I've just started to use boost multi_index and so far have a container that
I require a linear vector container to behave like a multi-dimensional vector container. That

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.