Boost logo

Boost :

From: Alexei Alexandrov (alexei.alexandrov_at_[hidden])
Date: 2006-04-12 12:15:22


my multi_index use case:
  * The container contains not objects themselves, but pointers (shared_ptr-s).
  * The objects are noncopyable - they are created by a factory and only smart
pointers are copied between clients.
  * The container has 2 indexes. Indexes are built on const_mem_fn extractor.
One of the indexes uses a function from a base class.

It seems that in 1.34 problem with using member function from a base class is
supposed to be solved, but it causes a regression that you cannot have pointers
to noncopyable objects in the container. Is this a known issue?

My compiler is MSVC 7.1/Intel Compiler 9.0. Here is a code snippet to
demonstrate the problem. This code compiles well with boost 1.33.1, but fails
to compile with RC 1.34. If you uncomment the second index, it won't compile
neither with 1.33 nor with 1.34.

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <iostream>
#include <string>

using namespace boost::multi_index;

/* A name record consists of the given name (e.g. "Charlie")
 * and the family name (e.g. "Brown"). The full name, calculated
 * by name_record::name() is laid out in the "phonebook order"
 * family name + given_name.

class base_record : boost::noncopyable
    int get_id() const { return id_; }

    base_record() : id_(0) {}

    int id_;

class name_record : public base_record
  typedef boost::shared_ptr<name_record> Ptr;
  static Ptr create()
      return Ptr(new name_record());

  const std::string & name() const { return name_; }

  name_record() : name_("") {}

  std::string name_;

typedef multi_index_container<
      BOOST_MULTI_INDEX_CONST_MEM_FUN(name_record, const std::string &, name)
    // ,
    // ordered_unique<
    // BOOST_MULTI_INDEX_CONST_MEM_FUN(base_record, int, get_id)
    // >
/**/> name_record_set;

int main()
  name_record_set ns;


  return 0;

Boost list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at