POV-Ray : Newsgroups : povray.beta-test : Beta 37 and C++0x : Re: Beta 37 and C++0x Server Time
7 Jul 2024 10:55:50 EDT (-0400)
  Re: Beta 37 and C++0x  
From: Warp
Date: 3 Jun 2010 15:05:33
Message: <4c07fcfd@news.povray.org>
Edouard <pov### [at] edouardinfo> wrote:
> Or you can leave them as bare shared_ptr's and instead having "using" statements
> to intelligently chose (based on compiler and version) whether a particular
> compilation of POV uses the version in std or the version in boost. Yes, the
> existing "using namespace boost; using namespace std;" causes a problem, but the
> solution is to change those two lines, not hundreds of other lines in the file.

  You are assuming that "shared_ptr" is the only thing that is being used
without a scope qualifier in the source code, and hence it's simply enough
to choose between either "using namespace std;" or "using namespace boost;"
to get the program to compile.

  If you change those two lines, you are going to break a lot more than
some "shared_ptr" uses. Thus you either have to keep those lines, or you
have to go through hunderds of lines of code and add namespace prefixes.

  Your argument did not, in fact, deal with whether it's a good idea to
use namespace prefixes or not. It dealt with abstraction. What you are
saying is "shared_ptr might refer to either the one in boost or the one
in the standard library, and it's thus bad to say explicitly at each
usage location which one it's using".

  The solution to such a problem is not to play with namespaces, but to
abstract away the type. Using the name "shared_ptr" may be a bad idea
because it's actually not abstracting away much, and it has the danger
of suffering from name collisions.

  In one post in this thread Thorsten suggested abstracting the smart
pointer away with a typedef. That's actually a good idea, and I concede that
that is a much better solution than the other things he suggested, or what
you are suggesting.

  (Of course that doesn't mean that the "using namespace" statements are
any more of a good idea. IMO they should be removed regardless of whether
"shared_ptr" is abstracted away or not.)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.