Topic: Q: <cxxx> headers and namespace std
Author: Tanveer Gani <tanveerg@microware.com>
Date: 1997/04/04 Raw View
I'm currently building the draft standard C++ library for our
compiler/OS and am puzzled by the following in the 12/96 version of ANSI
C++ WP:
5.3.3 [expr.sizeof] says in para 6 that sizeof returns size_t which is
named in the standard header <cstddef>
But, in 18.4 [lib.support.dynamic] we have:
void* operator new(std::size_t size) throw(std::bad_alloc);
I have the following questions:
1. Should it be size_t or std::size_t?
2. Are both size_t and std::size_t to be provided?
3. In general, are the contents of <cxxxxx> headers (i.e C headers
accessed via the new naming scheme) to be wrapped in
namespace std { } ? For example, should we create a <cstdio> header as:
namespace std {
#include <stdio.h>
}
4. Could we then call std::printf() ?
5. Would printf() still be accessible from the global namespace?
I've been going through the WP (dated 12/96) but couldn't find a clear
answer. Maybe I'm missing something here...
Any help would be greatly appreciated.
Regards,
Tanveer
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1997/04/04 Raw View
Tanveer Gani <tanveerg@microware.com> writes:
>I'm currently building the draft standard C++ library for our
>compiler/OS and am puzzled by the following in the 12/96 version of ANSI
>C++ WP:
>
>5.3.3 [expr.sizeof] says in para 6 that sizeof returns size_t which is
>named in the standard header <cstddef>
>
>But, in 18.4 [lib.support.dynamic] we have:
>
>void* operator new(std::size_t size) throw(std::bad_alloc);
>
>I have the following questions:
>
>1. Should it be size_t or std::size_t?
It should be std::size_t. I'm sure 5.3.3 is an editorial error; it
said `size_t' before namespaces were added, and it has just never been
corrected.
>2. Are both size_t and std::size_t to be provided?
Just std::size_t.
>3. In general, are the contents of <cxxxxx> headers (i.e C headers
>accessed via the new naming scheme) to be wrapped in
>namespace std { } ?
Yes.
>For example, should we create a <cstdio> header as:
>
> namespace std {
> #include <stdio.h>
> }
I don't think so. I think the idea is that <cstdio> should have something
like this:
namespace std {
...
... body of old stdio.h goes here
...
}
Then <stdio.h> should have
#include <cstdio>
using std::printf;
using std::puts;
...
>4. Could we then call std::printf() ?
Yep.
>5. Would printf() still be accessible from the global namespace?
Only if there is an appropriate using declaration in scope (which there
would be if you have #included <stdio.h>).
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]