Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-10-24 06:59:53


Marc Duflot wrote:
>
> I extended your code with the following lines
>
> X x3 = f() ; cout << endl;
> X x4 = g() ; cout << endl;
>
> > }
>
> To my surprise, the results for (x3,x4) are not the same as the ones for
> (x1,x2) with some compilers :

Hm, interesting. As I said, I also added X( f() ); and X( g() ); which
gave some surprising results. Maybe we should re-run the tests with the
following code:

#include <iostream>
using namespace std;

struct X
{
   X() { cout << "X"; }
   X( const X& ) { cout << "C"; }
};

X f()
{
   return X();
}

X g()
{
   X x;
   return x;
}

#define TEST( code ) \
   cout << #code << "\t: "; code; cout << endl

int main()
{
   TEST( f() );
   TEST( g() );
   TEST( X( f() ) );
   TEST( X( g() ) );
   TEST( X x1( f() ); );
   TEST( X x2( g() ); );
   TEST( X x3 = f(); );
   TEST( X x4 = g(); );
}

Regards, Daniel

--
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

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