Boost logo

Boost :

Subject: Re: [boost] [move] problem with msvc and BOOST_MOVABLE_BUT_NOT_COPYABLE
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2010-05-29 04:49:21


On 29/05/2010 0:24, Ilya Sokolov wrote:
> Ion Gaztañaga wrote:
>> Adding a base class is not something I like because in some C++03
>> (Msvc I think, empty base classes are not optimized with multiple
>> inheritance),
>
> IIRC, compilers don't do SBO if the same class is used as a base
> multiple times. However, movable<> will be instantiated with different
> types most of the time.

Taken from:

http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/6502c2d3-7c06-472e-a35f-83056a2c51cf

#include <cstdio>

class E1
{
public:
  void ReportE1()
  {
     std::printf("In E1, this is %p\n", this);
  }
};

class E2
{
public:
  void ReportE2()
  {
     std::printf("In E2, this is %p\n", this);
  }
};

class E3
{
public:
  void ReportE3()
  {
     std::printf("In E3, this is %p\n", this);
  }
};

class D: public E1, public E2, public E3
{
};

int main()
{
     D d;
     d.ReportE1();
     d.ReportE2();
     d.ReportE3();
}

Reports the same this pointer values if compiled using G++;

However, when I compile it using visual C++ 2010 express, the values
reported increment by 1, say 10000,10001,10002.

Best,

Ion


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