Boost logo

Boost :

From: Alexei Alexandrov (alexei.alexandrov_at_[hidden])
Date: 2006-05-25 13:05:53


Hi,

I have a problem compiling the code snippet below with MSVC 7.1 (Intel
Compiler 9.0 and GCC compile it just fine). The problem trigger is
keyword "virtual" in class base inheritance - if you remove it it will
compile OK. The error message is very weird:

boost\type_traits\is_function.hpp(65) : error C2371:
'boost::detail::t' : redefinition; different basic types
        boost\type_traits\is_function.hpp(65) : see declaration of
'boost::detail::t'
        boost\type_traits\is_function.hpp(82) : see reference to class
template instantiation '<Unknown>' being compiled
        boost\tuple\detail\tuple_basic.hpp(310) : see reference to
class template instantiation '<Unknown>' being compiled
        boost\tuple\detail\tuple_basic.hpp(418) : see reference to
class template instantiation '<Unknown>' being compiled
        boost\multi_index\detail\def_ctor_tuple_cons.hpp(33) : see
reference to class template instantiation '<Unknown>' being compiled
        boost\multi_index_container.hpp(140) : see reference to class
template instantiation '<Unknown>' being compiled

Also, it is critical for reproducing to have 2 independent inheritance
chains - if I remove name_record_set2 class and variable it also
compiles just fine.

Here is the code itself:

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/ordered_index.hpp>

using namespace boost::multi_index;

class base {};

class base_record : virtual public base
{
public:
    base_record() : id_(0) {}
    int get_id() const { return id_; }

private:
    int id_;
};

class name_record : public base_record {};

class name_record2 : public base_record {};

typedef multi_index_container<
  name_record,
  indexed_by<
    ordered_unique<
      BOOST_MULTI_INDEX_CONST_MEM_FUN(base_record, int, get_id)
>
>
> name_record_set;

typedef multi_index_container<
  name_record2,
  indexed_by<
    ordered_unique<
      BOOST_MULTI_INDEX_CONST_MEM_FUN(base_record, int, get_id)
>
>
> name_record_set2;

int main()
{
    name_record_set ns;
    name_record_set2 ns2;

    ns.insert(name_record());
    ns2.insert(name_record2());

    return 0;
}

P.S. I use boost from RC_1_34 tag.

-- 
Alexei Alexandrov

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk