Problem with recursion using Boost intrusive list

Hi, I am a newbie to Boost libraries and I have the following problem with Boost intrusive list: I have a Page class and I need to put its instances into an intrusive set. There is no problem and it is working fine. Beside that, I need every instance of this class had a member intrusive list containing other Pages. The source is as follows: struct pageTag; typedef link_mode<normal_link> NormalLinkMode; typedef set_base_hook<tag<pageTag>, NormalLinkMode> SetPageHook; typedef list_base_hook<tag<pageTag>, NormalLinkMode> ListPageHook; class Page : public ListPageHook, public SetPageHook { public: typedef set<Page, base_hook<SetPageHook>> PageSet; typedef list<Page, base_hook<ListPageHook>> PageList; Page(); ... friend bool operator< (const Page &a, const Page &b) { return a.fullPath < b.fullPath; } friend bool operator> (const Page &a, const Page &b) { return a.fullPath > b.fullPath; } friend bool operator== (const Page &a, const Page &b) { return a.fullPath < b.fullPath; } private: // some stuff here PageList links; /****************** THIS IS THE PROBLEM ************************* }; As I add the last line with the list, I get: "Error 1 error C2248: 'boost::intrusive::list_impl<Config>::list_impl' : cannot access private member declared in class 'boost::intrusive::list_impl<Config>' c:\program files\boost\boost_1_35_0\boost\intrusive\list.hpp 1434". Is there any problem with recursion in Boost intrusive containers? Thank you. Tomas

Tomáš Šalamon wrote:
As I add the last line with the list, I get: "Error 1 error C2248: 'boost::intrusive::list_impl<Config>::list_impl' : cannot access private member declared in class 'boost::intrusive::list_impl<Config>' c:\program files\boost\boost_1_35_0\boost\intrusive\list.hpp 1434".
Is there any problem with recursion in Boost intrusive containers?
I don't think so. This works for Visual 2005 and gcc-4.3: #include <boost/intrusive/list.hpp> #include <boost/intrusive/set.hpp> #include <string> using namespace boost::intrusive; struct pageTag; typedef link_mode<normal_link> NormalLinkMode; typedef set_base_hook<tag<pageTag>, NormalLinkMode> SetPageHook; typedef list_base_hook<tag<pageTag>, NormalLinkMode> ListPageHook; class Page : public ListPageHook, public SetPageHook { public: typedef set<Page, base_hook<SetPageHook> > PageSet; typedef list<Page, base_hook<ListPageHook> > PageList; Page(){} friend bool operator< (const Page &a, const Page &b) { return a.fullPath < b.fullPath; } friend bool operator> (const Page &a, const Page &b) { return a.fullPath > b.fullPath; } friend bool operator== (const Page &a, const Page &b) { return a.fullPath < b.fullPath; } void add_to_pagelist(Page &p) { links.push_back(p); } private: // some stuff here PageList links; //THIS IS THE PROBLEM ?? std::string fullPath; }; int main() { Page parent_page, child_page; parent_page.add_to_pagelist(child_page); return 0; }
Thank you.
Tomas
Regards, Ion

Ion, you are right. I made a mess of some pointers in another class and it caused the problem. Sorry for the false alarm. Thanx a lot. Tomas
participants (2)
-
Ion Gaztañaga
-
Tomáš Šalamon