This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
is it a g++ bug ?
- To: STDC++ <libstdc++ at sources dot redhat dot com>
- Subject: is it a g++ bug ?
- From: Levente Farkas <lfarkas at mindmaker dot hu>
- Date: Wed, 22 Nov 2000 12:04:16 +0100
- Organization: Mindmaker Ltd.
- Reply-To: lfarkas at mindmaker dot hu
hi,
why the following code not compile ?:
so why the compiler can't find the placement new and how can I force it ?
thanks.
---------------------------
template<typename T>
class A
{
public:
explicit A(T t = 0) : data(t) {}
template<typename T1>
A(const A<T1>& that) : data(T(that.data)) {}
template<typename T1>
A& operator=(const A<T1>& that)
{
if (this != (void*)&that)
{
this->~A();
new(this) A(that);
}
return *this;
}
T data;
};
int main()
{
A<double> x(2.0);
A<int> y(x);
x = y;
return 0;
}
---------------------------
-- Levente
"The only thing worse than not knowing the truth is
ruining the bliss of ignorance."