boost::intrusive::slist push_back() => error: static assertion failed: (cache_last)

Hi All! First post... Attempt switching to intrusive slist for efficiency, the following example is simply cut-paste from docs. Won't compile! g++ 4.9.1 complains as inlined in code below. #include <boost/intrusive/slist.hpp> using namespace boost::intrusive; struct point : slist_base_hook<> { int64_t x,y; }; using points = slist<point>; int main() { points plist; point p1,p2,p3; ACCEPT( 0U == plist.size() ); plist.push_back( p1 ); // => error: static assertion failed: (cache_last) ACCEPT( 1U == plist.size() ); } The code is from the docs of my version (1.55) and im pretty sure this or similar worked before. (1.54 i think) Please help, what am I missing?

El 09/05/2015 a las 12:12, Jonas Printzén escribió:
Hi All! First post...
Attempt switching to intrusive slist for efficiency, the following example is simply cut-paste from docs. Won't compile! g++ 4.9.1 complains as inlined in code below.
Which docs? I can't see int64_t anywhere in the docs. The issue is that you are using a singly linked list, which typically only can push at front. Only if you use the "cache_last" option the singly linked lists stores a pointer to the last element which allows push_back. From push_back comments: //! <b>Note</b>: Does not affect the validity of iterators and references. //! This function is only available is cache_last<> is true. Since cache_last option is not active the implementation static_asserts as push_back can't be implemented. Ion
participants (2)
-
Ion Gaztañaga
-
Jonas Printzén