Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #70411
| From | "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: I'd like to have unusing |
| Date | 2019-12-12 13:51 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <qstd3m$dn$1@dont-email.me> (permalink) |
| References | <qst9g8$2d7$1@news.albasani.net> |
On 12.12.2019 12:49, Bonita Montero wrote:
> In a header I'm fixed to write the std::-prefixes since I can't use
> "using namespacee std" because this would be against the exepectations
> of those including the header.
> So I had a simple idea: with every "using namespace xxx" an counter for
> the namespace xxx would be incremented and at the end of block where the
> prefixes where used implicitly there would be a new "unusing"-directive
> that derements the counter and when it becomes zero, the implicit
> attachment to symbols is disabled.
A workaround until you get that feature proposed and adopted, is to use
a clean /exporting namespace/.
For example, you may want the stuff to be available in namespace `bonitas`.
Then do like this, first defining stuff in the /defining/ namespace
`bonitas::_`, or whatever, really, just not same as exporting ns:
// Here a stern admonition to not use namespace bonitas::_.
// Then:
namespace bonitas::_ {
using namespace std; // Oh joy
void stuff() { feclearexcept(FE_ALL_EXCEPT); }
}
namespace bonitas {
using _::stuff;
}
Regarding `_` a main difference from the usual `impl` or `detail`
namespace (e.g. Boost's `detail`) is that `_` here contains stuff meant
to be used directly by client code, not just implementation details.
However, client code is only meant to use the stuff via the exporting
namespace(s), here bonitas, which itself is/are clean.
There are countless variations and extensions of the scheme, and there
is a gotcha about templates that client code is meant to specialize.
- Alf (who's gradually started to adopt this scheme)
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
I'd like to have unusing Bonita Montero <Bonita.Montero@gmail.com> - 2019-12-12 12:49 +0100
Re: I'd like to have unusing "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-12 13:51 +0100
Re: I'd like to have unusing Öö Tiib <ootiib@hot.ee> - 2019-12-12 05:47 -0800
Re: I'd like to have unusing "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-12 17:58 +0100
Re: I'd like to have unusing Öö Tiib <ootiib@hot.ee> - 2019-12-12 09:40 -0800
Re: I'd like to have unusing "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-13 09:23 +0100
Re: I'd like to have unusing "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-12 17:58 +0100
Re: I'd like to have unusing boltar@nowhere.co.uk - 2019-12-12 16:23 +0000
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-12-25 13:19 -0500
Re: I'd like to have unusing "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-25 20:09 +0100
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-12-25 16:37 -0500
Re: I'd like to have unusing "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-25 22:56 +0100
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-12-25 17:06 -0500
Re: I'd like to have unusing Öö Tiib <ootiib@hot.ee> - 2019-12-25 14:14 -0800
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-12-25 17:28 -0500
Re: I'd like to have unusing "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-26 00:49 +0100
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-12-25 19:54 -0500
Re: I'd like to have unusing "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-26 03:53 +0100
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-12-25 22:32 -0500
Re: I'd like to have unusing Öö Tiib <ootiib@hot.ee> - 2019-12-26 03:01 -0800
Re: I'd like to have unusing Öö Tiib <ootiib@hot.ee> - 2019-12-26 03:20 -0800
Re: I'd like to have unusing Richard Damon <Richard@Damon-Family.org> - 2019-12-27 11:24 -0500
Re: I'd like to have unusing Öö Tiib <ootiib@hot.ee> - 2019-12-27 09:22 -0800
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2020-01-02 23:47 -0500
Re: I'd like to have unusing Öö Tiib <ootiib@hot.ee> - 2020-01-02 23:46 -0800
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2020-01-04 23:46 -0500
Re: I'd like to have unusing Richard Damon <Richard@Damon-Family.org> - 2020-01-04 18:43 -0500
Re: I'd like to have unusing Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2020-01-04 23:55 -0500
Re: I'd like to have unusing Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2019-12-12 18:29 +0000
Re: I'd like to have unusing Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2019-12-12 18:34 +0000
Re: I'd like to have unusing Daniel <danielaparker@gmail.com> - 2019-12-12 11:17 -0800
Re: I'd like to have unusing Bonita Montero <Bonita.Montero@gmail.com> - 2019-12-12 19:40 +0100
Re: I'd like to have unusing Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2019-12-12 19:56 +0000
Re: I'd like to have unusing Bonita Montero <Bonita.Montero@gmail.com> - 2019-12-13 06:35 +0100
csiph-web