Opened 14 years ago
Closed 13 years ago
#2864 closed Bugs (worksforme)
Compilation error if container definition is inside of linked class
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | Boost 1.39.0 | Component: | intrusive |
Version: | Boost 1.38.0 | Severity: | Problem |
Keywords: | Cc: | d_rider@… |
Description
Following code will fail to compile (at least under MSVC2005 SP1)
#include <boost/intrusive/list.hpp> using namespace boost::intrusive; struct Linked { list_member_hook<> _myhook; // list is defined inside of linked class list<Linked, member_hook<Linked, list_member_hook<>, &Linked::_myhook> > mylist; };
If it's impossible to resolve this problem, I think that nuance have to be highlighted in documentation.
Thanks in advance, Yuriy
Change History (4)
follow-up: 2 comment:1 by , 14 years ago
comment:2 by , 14 years ago
Cc: | added |
---|
Replying to andysem:
You can try using list_base_hook instead of list_member_hook.
Ok, thank you. It helped partly. Now I can use following
struct Linked : public list_base_hook<> { list<Linked> m_children; };
with one limitation - it's impossible to use tags. Also I've reproduced this issue on mingw ((GCC) 3.4.5 (mingw-vista special r3))
Regards, Yuriy
comment:3 by , 13 years ago
Your report is not a bug, it's standard C++, since you can't define a pointer to member "&Linked::_myhook" to the class inside the class (the compiler can't deduce the offset of the element). That's an inherent limitation of member hooks.
Why do you say is impossible to use tags when using base hooks?
comment:4 by , 13 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
You can try using list_base_hook instead of list_member_hook.