Boost logo

Boost Users :

From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2007-01-23 03:34:40


Joaquín Mª López Muñoz <joaquin <at> tid.es> writes:

> [solution]

Unfortunately your solution does not work for tuples.
The following code fails with a 10-page error message with gcc:

#include <boost/tuple/tuple.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/key_extractors.hpp>

namespace bm = ::boost::multi_index;

template <int I>
struct tuple_t_extractor
{
        typedef std::string const & result_type;

        template <typename Tuple>
        result_type operator()(Tuple const & t) const
        {
                return boost::get<I>(t);
                // return t.get<I>(); // fails, too
        }
};

class C
{
    typedef boost::tuple<std::string, std::string> data_t;

    typedef bm::multi_index_container
    <data_t,
     bm::indexed_by
     <bm::sequenced<>,
      bm::ordered_unique<tuple_t_extractor<0> > > >
          storage_t;

    storage_t storage_;
};

int main()
{
    C c;
}


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