• Advertisement
Sign in to follow this  

Boost.intrusive multiple containers

This topic is 2456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone,

In the boost.intrusive document, it mentions about using multiple containers to store in one object. However, there's no actual example, so I made my own. Is this the right way to do?


#include <boost/intrusive/list.hpp>
struct tag1;
class A:public list_member_hook<>, public list_member_hook<tag<tag1> >
{
}

typedef list_base_hook<tag<tag1> > TagHook;
typedef list<A> DefaultList;
typedef list<A, base_hook<TagHook> > TagList;

int main()
{
DefaultList dList;
agList tList;
A *a = new A();
dList.push_back(a);
tList.push_back(a);
}


If I add another container of the same type (such as adding another DefaultList), it will produce error. Is this intended? Why are we not allowed to use the second container of the same type?

Share this post


Link to post
Share on other sites
Advertisement

If I add another container of the same type (such as adding another DefaultList), it will produce error. Is this intended? Why are we not allowed to use the second container of the same type?

You can't define two different containers as the same type because it's already defined as a specific type. Is that what you were asking?

Share this post


Link to post
Share on other sites

[quote name='Rickert' timestamp='1306750991' post='4817451']
If I add another container of the same type (such as adding another DefaultList), it will produce error. Is this intended? Why are we not allowed to use the second container of the same type?

You can't define two different containers as the same type because it's already defined as a specific type. Is that what you were asking?
[/quote]
For example, we can have:

int a,b,c;

But why not:

DefaultList a,b,c;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement