Boost logo

Boost Users :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2008-07-13 06:50:38


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net