When I compile the attached test case with mainline, I get this:

foo.cc: In function ‘void foo(const B&)’:
foo.cc:3: error: ‘B::B(const B&)’ is private
foo.cc:13: error: within this context

I don't understand why, as I don't see the copy constructor being used
anywhere.  It seems to me this code should create a temporary for the
duration of the statement, and pass the temporary as a reference to
b.fn.  This code compiles with icc with no errors.

What is wrong with this code?

Thanks.

Ian

class B {
 private:
  B(const B&);
  void operator=(const B&);

 public:
  B();
  void fn(const B &other) const;
};

void foo (const B& b)
{
  b.fn(B());
}

Reply via email to