Public Group

# Boost.intrusive multiple containers

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

## 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 on other sites

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 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;

• 40
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631371
• Total Posts
2999611
×