Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2006-05-26 04:23:13


Alexei Alexandrov ha escrito:

> 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
>

Hello Alexei,

Well, this looks like a bug in MSVC 7.1. I've checked with other compilers, as
you've also done, and everything works fine. Let's try a workaround and do
a little bug hunt, OK?

* The workaround: I cannot try it myself (I don't have MSVC 7.1) but
possibly the following will avoid the compiler error: try using the
following instead of the direct instantiation of
BOOST_MULTI_INDEX_CONST_MEM_FUN:

struct base_record_if_extractor:
  public BOOST_MULTI_INDEX_CONST_MEM_FUN(base_record, int, get_id)
{};

Does this improve things?

* As for why MSVC 7.1 is choking, the error trace seems to indicate that
boost::is_function is having a hard time with types involving virtual inheritance.

The following is an attempt at reducing the problem to its essentials. Could
you try whether MSVC 7.1 still fails at this? If so, can you try to reduce
the test case some more?

*********BEGIN CODE*********
#include <boost/type_traits/is_function.hpp>

struct foo{};

struct bar: virtual foo
{
  int f()const{return 0;}
};

template<typename C,typename T,T (C::*P)()const>
struct baz{};

template<typename T>
struct qux
{
  struct type1:boost::is_function<T>{};
  struct type2:boost::is_function<T>{};
};

int main()
{
  typedef qux<baz<bar,int,&bar::f> > type;
  type::type1 t1;
  type::type2 t2;

  return 0;
}

*********END CODE*********

Looking fwd to your feedback,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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