Boost logo

Boost Users :

From: Carlo Wood (carlo_at_[hidden])
Date: 2006-05-05 12:40:41


On Fri, May 05, 2006 at 09:15:40AM -0400, james.jones_at_[hidden] wrote:
> From: Carlo Wood <carlo_at_[hidden]>
> >Also, the above is slightly dangerous, as the 'public' would
> >'leak' beyond the #ifdef when TESTING is defined. You'd have to make
> >sure that the test block at the end of the class.
>
> This is a very good point. A method defined as public in test might fail to compile as private in production.
>
> >Personally, I like the #define private public best, because it doesn't
> >polute the real code.
>
> But this contradicts your prior good point. This is even more dangerous than the conditional public: which you objected to, because now *every* method is public! At least with the other method, you can do it safely if you're careful.

Personally, I don't think it is that much of a problem to define private
as public - but since the #ifdef solution was given in order to avoid
access to other private members, I felt to point out that it didn't do
a perfect job in that.

Nevertheless, I believe that the solution that I gave at the end of my
previous post has the best of both solutions. What did you think of that
solution? It is totally safe in that you will not accidently access
variables that should be private (or protected: the derived class is
very simple and straight forward, you won't make a mistake in that).
And on top of that, there is no need to add test code to the header
under test.

-- 
Carlo Wood <carlo_at_[hidden]>

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net