Topic: Preventing access to classes/namespaces
Author: Lawrence Crowl <crowl@googlers.com>
Date: Tue, 20 Nov 2012 18:40:47 -0800
Raw View
On 11/7/12, LCID Fire <lcidfire@gmail.com> wrote:
> I was thinking of being able to prevent usage of certain
> classes/namespaces.
> For example in the upper part of your Compilation Unit you would write:
>
> #include <string>
> #include "mygreatstuff.hpp"
>
> using namespace my::great::namespace;
> block namespace std; // We have optimized implementations which should be
> used instead
> block namespace ::; // We don't want any global messing
> allow std::int8_t;
> namespace {
> std::string test_a; // ERROR: std namespace disabled in file ...
> std::int8_ test_b; // previously allowed
> }
> extern void test_c(); // ERROR: global namespace disabled in file ...
> Not only would that allow for enforcing code conventions, but also be
> handy, if one wants to use big precompiled headers but not allow for access
>
> to everything that is in there.
> Are there any drawbacks I have not yet thought about?
There is a proposal to use the protection labels at namespace
scope to achieve this effect. I expect something like that will come
with a modules proposal.
--
Lawrence Crowl
--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 20 Nov 2012 19:52:51 -0800 (PST)
Raw View
------=_Part_34_29679925.1353469971457
Content-Type: text/plain; charset=ISO-8859-1
On Tuesday, November 20, 2012 6:40:49 PM UTC-8, Lawrence Crowl wrote:
>
> On 11/7/12, LCID Fire <lcid...@gmail.com <javascript:>> wrote:
> > I was thinking of being able to prevent usage of certain
> > classes/namespaces.
> > For example in the upper part of your Compilation Unit you would write:
> >
> > #include <string>
> > #include "mygreatstuff.hpp"
> >
> > using namespace my::great::namespace;
> > block namespace std; // We have optimized implementations which should
> be
> > used instead
> > block namespace ::; // We don't want any global messing
> > allow std::int8_t;
> > namespace {
> > std::string test_a; // ERROR: std namespace disabled in file ...
> > std::int8_ test_b; // previously allowed
> > }
> > extern void test_c(); // ERROR: global namespace disabled in file ...
> > Not only would that allow for enforcing code conventions, but also be
> > handy, if one wants to use big precompiled headers but not allow for
> access
> >
> > to everything that is in there.
> > Are there any drawbacks I have not yet thought about?
>
> There is a proposal to use the protection labels at namespace
> scope to achieve this effect. I expect something like that will come
> with a modules proposal.
>
> --
> Lawrence Crowl
>
Is there a document for that proposal? I'm curious to see how it works.
--
------=_Part_34_29679925.1353469971457
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><br>On Tuesday, November 20, 2012 6:40:49 PM UTC-8, Lawrence Crowl wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;">On 11/7/12, LCID Fire <<a=
href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"mgdwuxOmtW=
MJ">lcid...@gmail.com</a>> wrote:
<br>> I was thinking of being able to prevent usage of certain
<br>> classes/namespaces.
<br>> For example in the upper part of your Compilation Unit you would w=
rite:
<br>>
<br>> #include <string>
<br>> #include "mygreatstuff.hpp"
<br>>
<br>> using namespace my::great::namespace;
<br>> block namespace std; // We have optimized implementations which sh=
ould be
<br>> used instead
<br>> block namespace ::; // We don't want any global messing
<br>> allow std::int8_t;
<br>> namespace {
<br>> std::string test_a; // ERROR: std namespace disabled in fil=
e ...
<br>> std::int8_ test_b; // previously allowed
<br>> }
<br>> extern void test_c(); // ERROR: global namespace disabled in file =
....
<br>> Not only would that allow for enforcing code conventions, but also=
be
<br>> handy, if one wants to use big precompiled headers but not allow f=
or access
<br>>
<br>> to everything that is in there.
<br>> Are there any drawbacks I have not yet thought about?
<br>
<br>There is a proposal to use the protection labels at namespace
<br>scope to achieve this effect. I expect something like that will c=
ome
<br>with a modules proposal.
<br>
<br>--=20
<br>Lawrence Crowl
<br></blockquote><div><br>Is there a document for that proposal? I'm curiou=
s to see how it works. <br></div>
<p></p>
-- <br />
<br />
<br />
<br />
------=_Part_34_29679925.1353469971457--
.
Author: Lawrence Crowl <crowl@googlers.com>
Date: Mon, 26 Nov 2012 18:46:58 -0800
Raw View
On 11/20/12, Nicol Bolas <jmckesson@gmail.com> wrote:
> On Tuesday, November 20, 2012 6:40:49 PM UTC-8, Lawrence Crowl wrote:
> > On 11/7/12, LCID Fire <lcid...@gmail.com <javascript:>> wrote:
> > > I was thinking of being able to prevent usage of certain
> > > classes/namespaces. For example in the upper part of your
> > > Compilation Unit you would write:
> > >
> > > #include <string>
> > > #include "mygreatstuff.hpp"
> > >
> > > using namespace my::great::namespace;
> > > block namespace std;
> > > // We have optimized implementations which should be used instead
> > > block namespace ::; // We don't want any global messing
> > > allow std::int8_t;
> > > namespace {
> > > > std::string test_a; // ERROR: std namespace disabled in file ...
> > > > std::int8_ test_b; // previously allowed
> > > }
> > > extern void test_c(); // ERROR: global namespace disabled in file ...
> > >
> > > Not only would that allow for enforcing code conventions, but
> > > also be handy, if one wants to use big precompiled headers
> > > but not allow for access to everything that is in there.
> > > Are there any drawbacks I have not yet thought about?
> >
> > There is a proposal to use the protection labels at namespace
> > scope to achieve this effect. I expect something like that
> > will come with a modules proposal.
>
> Is there a document for that proposal? I'm curious to see how it works.
See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2425.html.
Note that work on dynamic library support is "on hold".
--
Lawrence Crowl
--
.