Search code examples
c++c++11boostboost-graph

What's happened to slistS in BGL?


I'm using Boost 1.60 adjacency_list and would like to use slistS for the template parameter OutEdgeList:

using Graph = boost::adjacency_list<
                 boost::slistS, boost::listS, boost::bidirectionalS
              >;

This does not compile. Looking at adjacency_list.hpp it seems this type is explicitly removed in absence of the old STL std::slist:

#if !defined BOOST_NO_SLIST
#  ifdef BOOST_SLIST_HEADER
#    include BOOST_SLIST_HEADER
#  else
#    include <slist>
#  endif
#endif

#if !defined BOOST_NO_SLIST
   struct slistS {};
#endif

Is it not possible to use std::forward_list for boost::slistS? If not, are there any plans to include this in future releases of BGL?


Solution

  • This appears to me to be specific for Clang/Libc++ where <slist> is missing. It's not a part of the c++ standard.

    Compiling with GCC/libstdc++ is fine (tested with GCC 5.2 and c++14).

    So I'd just use boost::container::slist:

    Live On Coliru

    #include <boost/container/slist.hpp>
    #include <boost/graph/adjacency_list.hpp>
    
    #ifdef BOOST_NO_SLIST
    namespace boost {
        struct slistS;
    
        template <class ValueType> struct container_gen<slistS, ValueType> {
            typedef boost::container::slist<ValueType> type;
        };
    
        template <> struct parallel_edge_traits<slistS> { typedef allow_parallel_edge_tag type; };
    }
    #endif
    
    int main() {
        using namespace boost;
        adjacency_list<vecS, slistS> works_for_me;
    }