Article View: comp.std.c++
Article #2452Re: global new/delete in a namespace ?
From: Fergus Henderson
Date: Tue, 07 Nov 1995 13:55
Date: Tue, 07 Nov 1995 13:55
44 lines
2650 bytes
2650 bytes
clamage@Eng.Sun.COM (Steve Clamage) writes: >In article bbl@voyager.Internex.NET, muzok@msn.com (muzo) writes: >> >>is global new/delete in any namespace ? Are there any discussions about such a >>thing ? > >Namespaces don't apply to the keywords "new" and "delete" that introduce >new-expressions and delete-expressions (any more than namespaces apply >to "if" or "while"). > >The entire standard C++ library, which includes the various standard versions >of operator new and operator delete, is in the "std" namespace. Although it is indeed stated in the April draft and the September working paper that all library entities are defined in the `std' namespace [17.3.1.1/2], it is elsewhere stated that the library defines `operator new' and `operator delete' in the global namespace [3.7.3/2], and indeed also that `operator new' and `operator delete' must be either static class members or global functions [3.7.3.1/2], and so cannot be defined inside a namespace. (3.3.4/2 makes it clear that "global" means in the global namespace, not in any other namespace.) In other words, the draft standard is inconsistent. I think the most likely resolution of this inconsistency is that 17.3.1.1/2 will be changed so that it is clear that the library definitions of `operator new' and `operator delete' are in the global namespace. It is possible that 3.7.3.1 could be changed to allow allocation and deallocation functions to be defined in a namespace, and this might well be a better solution, but this would require changes to the name lookup rules for allocation functions, and I think a change of that magnitude is less likely at this stage. -- Fergus Henderson WWW: http://www.cs.mu.oz.au/~fjh fjh@cs.mu.oz.au PGP: finger fjh@128.250.37.3 --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<9531200.20340@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backReferences:
<46tv9o$bbl@voyager.Internex.NET> <470vgc$it4@engnews1.eng.sun.com>Show Full Headers
Complete Article Headers
Approved: fjh@cs.mu.oz.au Date: 07 Nov 95 13:55:30 GMT From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson) Message-ID: <9531200.20340@mulga.cs.mu.OZ.AU> Newsgroups: comp.std.c++ Organization: Computer Science, University of Melbourne, Australia Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back References: <46tv9o$bbl@voyager.Internex.NET> <470vgc$it4@engnews1.eng.sun.com> Subject: Re: global new/delete in a namespace ? X-Original-Date: Wed, 8 Nov 1995 00:37:50 +1100 X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMJ9la+EDnX0m9pzZAQEB4AF/TkH8gxfedjmHBq94CCfgEWmoKmKcZINs bVzOFfAl2NQS9MOUQgVSVa8UqyxL1Vld =/3Mj