A
Alexander Stippler
Hi,
I wonder about the behaviour of como and icc on some very simple program. I
thought initializing members of classes, which are of class type, would be
'direct initialized' (as the standard says). But in the example below the
copy
constructor of Vec is executed when initializing the Ref object. Is this
standard conform? Doesn't it result in bad performance?
#include <iostream>
using namespace std;
class Vec
{
public:
Vec() { cout << "constructor" << endl;}
Vec(const Vec &v) { cout << "copy constructor" << endl; }
};
class Ref
{
public:
Ref() : vec_(Vec()) { }
private:
Vec vec_;
};
int
main()
{
Ref ref;
return 0;
}
regards,
alex
I wonder about the behaviour of como and icc on some very simple program. I
thought initializing members of classes, which are of class type, would be
'direct initialized' (as the standard says). But in the example below the
copy
constructor of Vec is executed when initializing the Ref object. Is this
standard conform? Doesn't it result in bad performance?
#include <iostream>
using namespace std;
class Vec
{
public:
Vec() { cout << "constructor" << endl;}
Vec(const Vec &v) { cout << "copy constructor" << endl; }
};
class Ref
{
public:
Ref() : vec_(Vec()) { }
private:
Vec vec_;
};
int
main()
{
Ref ref;
return 0;
}
regards,
alex