This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

is it a g++ bug ?


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]