In C++, static assert that a declaration at current position would not be enclosed in any namespace?
<p>In C++ one sometimes has annoying bugs where someone forgot to close out a namespace which was opened in a header file, and it can sometimes be difficult to track down exactly which one.</p>

<p>Somewhat less banally, sometimes there are macros which for technical reasons cannot appear enclosed within any namespace, or cryptic error messages may occur. In the boost fusion library, <code>BOOST_FUSION_DEFINE_STRUCT</code> requires this, for example. Instead you are supposed to use the macro at filescope, and pass it the namespace that you want the declaration to be within.</p>

<p>For that matter, you get undefined behavior if you include any standard library header within a namespace.</p>

<p>Is it possible to do something like, write a macro e.g. <code>ASSERT_FILESCOPE</code> so that I can put a line <code>ASSERT_FILESCOPE;</code> at the end of a C++ header file, or at the start of a macro like <code>BOOST_FUSION_DEFINE_STRUCT</code>, which will cause a <code>static_assert</code> failure with a nice error message if that expression is <em>not</em> at filescope?</p>