Declaring a namespace as a macro - C ++

In the standard library, I found that the namespace is stddeclared as a macro.

#define _STD_BEGIN  namespace std {
#define _STD_END        }
  • Is this best practice when using namespaces?
  • The macro is declared in Microsoft Visual Studio 9.0\VC\include\yvals.h. But I could not find the STL files, including this. If it is not turned on, how can it be used?

Any thoughts ..?

+5
source share
5 answers

This is probably not the best practice as it is difficult to read compared to the vanilla declaration namespace. However, remember that the rules are not always applied everywhere, and I am sure that there is some kind of scenario in which a macro can significantly improve the situation.

" STL, . , ?".

, , yvals.h -. , <vector> <memory>, <iterator>, <xutility>, <climits>, <yvals.h>. , - .

, ; .

+6
  • , , , .
  • . , , , STL.
+3

, - , /, .

+1

, , , :

BEGIN_NAMESPACE_XXX()

XXX - , :

BEGIN_NAMESPACE_3(ns1, ns1, ns3)

namespace ns1 {
    namespace ns2 {
        namespace ns2 {

END_NAMESPACE_3

        }
    }
}

( )

+1

C, ++ (, , C string.h ++ cstring). #ifdef _c_plus_plus.

. , , , , "" ++ ( , - 90- ). , , , . ; : " X, , , , ". , , , , ANSI C.

0

All Articles