POV-Ray : Newsgroups : povray.off-topic : using namespace : Re: using namespace Server Time
4 Sep 2024 03:16:37 EDT (-0400)
  Re: using namespace  
From: scott
Date: 2 Jun 2010 04:17:52
Message: <4c0613b0$1@news.povray.org>
>  "using namespace" statements might in some cases be justifiable if the
> name of the namespace is very long and/or there are many nested namespaces
> (which is sometimes the case). However, a common recommendation in these
> cases is to use namespace aliases instead (which is possible in C++). It's
> a bit like a typedef, but for namespaces. For example:
>
>    namespace bid = boost::io::detail;
>
>  After that you can use 'bid::' instead of 'boost::io::detail::' as the
> prefix for names in that namespace.

In that case what is the benefit of using 'bid::' to qualify every type 
rather than simply putting "using namespace boost::io::detail" at the top?

The disadvantages are obvious - having to type bid:: before every type 
(annoying if almost every line contains several types from that namespace) 
and your code looks very "unoptimised" when the same string is repeated a 
huge number of times.


Post a reply to this message

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