Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2006-07-25 20:48:06

On Tue, 25 Jul 2006 19:25:04 -0500, "Hartmut Kaiser"
<hartmut.kaiser_at_[hidden]> wrote:

>> But what is the benefit? I think that's the key question. If
>> they don't have any they are just misleading. I'd say there
>> are very few exceptions to this (in truth the only one which
>> comes to mind is the nifty counter idiom).
>It's just an easy way to move a helper function 'out of the way'. But as
>always it's a matter of taste and personal style so I'm not going to argue
>with you :-P

Why not :-P Not sure what do you mean by 'out of the way' here. The
whole unnamed namespace is still subject to an implicit using

 namespace { void my_helper(); }

behaves the same as

 namespace name_unique_to_the_translation_unit

 using name_unique_to_the_translation_unit;
 namespace name_unique_to_the_translation_unit
 { void my_helper(); }


  // a.hpp
  namespace wave {
    namespace { void my_helper(); }

  // a.cpp
  #include "a.hpp"
  namespace wave {

    int my_helper();

    void f()
      my_helper(); // oops!

Comparing this with the version without unnamed namespace it seems to
me it only allows the error to go undetected longer (i.e. until you
attempt the function call)

>The mentioned problems are fixed now.

Thanks, but please only fix things if you are convinced that they need
to be fixed. There's no authority here :-)

[ Gennaro Prota, C++ developer for hire ]

Boost list run by bdawes at, gregod at, cpdaniel at, john at