They would have to write ::std:: all over the standard
headers.
That doesn't help. You can't use a qualified name in an
"elaborated type specifier" (something beginning with the key
words "class", "struct", "union" or "enum") unless it has been
previously declared. Which means the the first mention of the
type cannot have the ::std::.
This seems to me to be a meta-rule about the interpretation of
the text of the standard. It says nothing about the header
files.
It would have been nice if he'd have provided the reference, so
we could see the context. I suspect what the above is saying is
that when the standard defines the behavior, etc. of vector, it
means ::std::vector. But it's hard to say without knowing the
context where the statement was made.
Or to infirm it. It would be nice to find it.
There are two separate issues.
There is absolutely no requirement that an include must be at
global scope. In the past, I've even used #include in a
function body. (I find this bad practice, and today, I do not
do it. Even if the include file is machine generated code,
designed to be included in one, and only one location, I will
ensure that the generated code will open and close any
namespaces, classes or functions that it needs, and will include
it at global scope.)
There is a requirement that the standard headers be included
outside any definition or declaration, i.e. outside of any
namespace, class, enum, function or template. See §17.4.2.1.
But this only applies to standard headers.
Finally, it's worth remembering that most library authors
probably make the same requirements, even if they don't say so.
I can't find anything in Posix saying that you can't include its
headers in the middle of a struct or function (since Posix is C,
there's no issue of namespaces), but I wouldn't expect it to
work. A priori, I would assume that any library have the same
restrictions as the standard library with regards to using its
headers, unless it explicitly documented them otherwise. In
other words, unless there is contrary documentation:
1. the headers may be included in any order;
2. they may be included more than once, with no differing
effect than if they were included only once,
3. they must be included outside any other definition or
declaration (at global scope, if you prefer, but also
outside of any declaration or definition which doesn't
introduce a new scope, e.g. enum); and
4. they must be included before the first use of anything they
define.
There will usually also be requirements concerning names that
may or may not be defined; something like:
#define std 3.14159
#include <vector>
is forbidden by the standard, and I expect just about every
library in existance has similar restrictions. (It might not
care about std, but it will have other symbols which will cause
problems.)