* Christopher Dearlove:
Roughly speaking, I
think an implementation can take three approaches:
<snipped other two>
-- Some of the functions (most of those directly inherited from
C) are in both :: and std::, others (typically the overloads
introduced by C++) are only in std::. This seems to be the
most frequent implementation, even if it results in some
incoherence.
What does/will be allowed to do an implementation taking this
route for the overloads introduced by C++ when including the
*.h form of the headers (which I believe you recently recommended)?
It's allowed in C++0x, that's the whole point of the change: to allow the
existing practice.
Specifically, the C++0x draft language regarding [xxx.h] in §D.5 is
<quote>
2 Every C header, each of which has a name of the form name.h, behaves as if
each name placed in the standard library namespace by the corresponding cname
header is placed within the global namespace scope. It is unspecified whether
these names are first declared or defined within namespace scope (3.3.5) of the
namespace std and are then injected into the global namespace scope by explicit
using-declarations (7.3.3).
3 [Example: The header <cstdlib> assuredly provides its declarations and
definitions within the namespace std. It may also provide these names within the
global namespace. The header <stdlib.h> assuredly provides the same declarations
and definitions within the global namespace, much as in the C Standard. It may
also provide these names within the namespace std. —endexample]
</quote>
I think it's a bit unclear what the "library namespace" is.
As with C++98, the non-normative example is more clear than the normative text!
I'm struggling to see how it could include the overloads in the *.h
file - where they should be in :: - but leaves them only in std:: in the
c* header, without going out of its way to do that, meaning that
someone sees an advantage in the above approach for other than
ease of implementation.
You're talking about an implementation conforming to C++98?
One approach I can think of is to use two helper headers [basic_c_xxx.h] and
[basic_cpp_xxx.h]. Then [cxxx] includes both those. [xxx.h] includes
[basic_c_xxx.h], and also includes [basic_cpp_xxx.h] if this is C++. It may play
around with macro definitions to remove [basic_c_xxx.h] namespace'ing when the
language is C. When the language is C++ it uses 'using' directives to bring the
names from some internal namespace and into the global namespace.
Assuming that works nicely, and I can't see why not, it isn't difficult. As is
oft stated, the solution to every computer science problem is indirection.
Or I'm missing something.
Dunno, dunno even if I understood your question, but
Cheers, & hth.,
- Alf