[Boost-bugs] [Boost C++ Libraries] #10328: is_linked is broken for linear slist

Subject: [Boost-bugs] [Boost C++ Libraries] #10328: is_linked is broken for linear slist
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-08-08 13:32:17


#10328: is_linked is broken for linear slist
-------------------------------------+------------------------
 Reporter: anonymous | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: intrusive
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
-------------------------------------+------------------------
 The following program should print "Ok" but it print "Arghhhh"

 This is do to is_linked checking the next pointer which is nullptr for the
 last element. The example works fine when omitting the ,bi::linear<true>
 line

 {{{#!cpp
 #include <boost/intrusive/slist.hpp>
 #include <iostream>

 namespace bi=boost::intrusive;
 struct my_tag {};
 typedef bi::slist_base_hook<bi::tag<my_tag>, bi::link_mode<bi::safe_link>
> my_hook;

 struct my_type: public my_hook {
   bool is_linked() const {
     return my_hook::is_linked();
   }
 };

 typedef bi::slist<my_type,
                   bi::base_hook<my_hook>
                   , bi::linear<true>
> my_list;

 int main() {
   my_type item;
   my_list list;
   list.push_front(item);
   std::cout << (item.is_linked() ? "Ok": "Arghhhhh") << std::endl;
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10328>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC