This is codes snippet from our codes

void testSmartAssign()
{
  boost::shared_ptr<int> A;
  std::auto_ptr<int> B(new int(9));
  A = B;
}

Is this kind of assignment well defined?

Thanks

> Is this kind of assignment well defined?

yes; it is well-defined and well-behaved. Calls release() on the auto_ptr.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.