Boost Unpredictable Strangeness

I have a class inheriting from boost::noncopyable; let's say with an excerpt of the header as follows:

class A : boost::noncopyable {
   ...
   blah
   ...
private:
   struct impl;
   boost::scoped_ptr<impl> m_impl;
};

Then in one of the projects of my solution I have a class (which is also inherited from boost::noncopyable), one whose private members in the implementation details are a reference to an object of type A, say, in the header excerpt:

class B : boost::noncopyable {
   ...
   blah
   ...
private:
   struct impl;
   boost::scoped_ptr<impl> m_impl;
};

and in the statement of implementation (cpp):

struct B::impl {
    impl(A& a) : m_a(a) {}
    set_A(A& a) {m_a = a;}
    A& m_a;
    ...
}

B(A& a) : m_impl(new impl(a)) {}
...

Then in another project of my solution, I have a class C inheriting from B, say, with a header excerpt:

class C : public B {
   ...
   blah;
   ...
private: 
   struct impl;
   boost::scoped_ptr<impl> m_impl;
};

and in the statement of implementation (cpp):

struct C::impl {
    impl(A& a) : m_a(a) {}
    void set_A(A& a) {m_a = a;}
    A& m_a;
};

C(A &a) : B(a), m_impl(new impl(a)) {}
...

But when I try to build in MSVC ++ 2008, I get the following error:

error C2248: 'boost::noncopyable_::noncopyable::operator =' : cannot access private member declared in class 'boost::noncopyable_::noncopyable'
see declaration of 'boost::noncopyable_::noncopyable::operator ='
error C2248: 'boost::scoped_ptr<T>::operator =' : cannot access private member declared in class 'boost::scoped_ptr<T>' with T = A::impl
This diagnostic occurred in the compiler generated function 'A& A::operator =(const A&)'

The compiler has only problem with the C function set_Ainstead Bed and set_A. Appreciate if anyone has any ideas on this and can shed some light? Thank you, as always, for your interest.

Edit:

, , , boost::noncopyable. set_A(..) C, . , , B. , . , - . , C - ? ?

+5
1

[EDIT]

, , , :

struct C::impl {
    impl(A& a) : m_a(&a) {}
    void set_A(A& a) {m_a = &a;}
    A* m_a;
};

A , :

void set_A(A& a) {m_a = a;}

:

:

C2248: 'boost:: scoped_ptr:: operator =': , "boost:: scoped_ptr" T = A::

, boost::scoped_ptr<T> , , A .

:

"A & A:: operator = (const A &) '

- XXX::set_A(A& a) { m_A = a; }. A::operator =(const A&) - , . - A boost::scoped_ptr<A::impl>.

- - XXX::set_A(A& a) { m_A = a; }?

g++ 4.5.x. - - set_A - . , A& operator = (const A&), . g++ :

../src/AnExample.cpp:24:32: note: synthesized method 'A& A::operator=(const A&)' first required here

:

class noncopyable {
private:
   noncopyable(const noncopyable&);
   noncopyable& operator = (const noncopyable&);
};

class A {
  noncopyable m;
};

class B {
  B(A& a) : a(a) {}
  void set_A(A& a) { this->a = a; } // line 24
  A& a;
};

class C {
  C(A& a) : a(a) {}
  void set_A(A& a) { this->a = a; }
  A& a;
};

make all 
Building file: ../src/AnExample.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/AnExample.d" -MT"src/AnExample.d" -o "src/AnExample.o" "../src/AnExample.cpp"
../src/AnExample.cpp: In member function 'A& A::operator=(const A&)':
../src/AnExample.cpp:15:17: error: 'noncopyable& noncopyable::operator=(const noncopyable&)' is private
../src/AnExample.cpp:18:9: error: within this context
../src/AnExample.cpp: In member function 'void B::set_A(A&)':
../src/AnExample.cpp:24:32: note: synthesized method 'A& A::operator=(const A&)' first required here 
make: *** [src/AnExample.o] Error 1
src/subdir.mk:18: recipe for target `src/AnExample.o' failed
+6

All Articles