Boost logo

Boost Users :

Subject: Re: [Boost-users] Compile problems with instrusive::slist::push_back
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-05-16 01:36:07


AMDG

Johannes Gajdosik wrote:
> >From this piece of code
> ----------------------------------------
> #include <boost/intrusive/slist.hpp>
>
> class Node : public boost::intrusive::slist_base_hook<> {
> public:
> Node(int x) : x(x) {}
> int x;
> };
>
> typedef boost::intrusive::slist<Node> List;
>
> int main(int argc,char *argv[]) {
> List list;
> Node n1(1234);
> Node n2(5678);
> list.push_front(n1);
> list.push_back(n2);
> return 0;
> }
> ------------------------------------------
> I get the following error:
>
>
>
> false>boost_1_39_0/boost/intrusive/slist.hpp:382: error: invalid
> false>application of 'sizeof' to incomplete type
> false>'boost::STATIC_ASSERTION_FAILURE<false>' IntrusiveTest1.C:16:
>

The line that triggers the error is
      BOOST_STATIC_ASSERT((cache_last != 0));

slist does not support push_back by default.
To allow push_back, you need to add the option cache_last:
typedef boost::intrisive::slist<Node, cache_last<true> > List;

In Christ,
Steven Watanabe


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