Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++CodeIDERAD Studio

Learn How to Use C++ Inline Namespaces For Windows Development In C++Builder

C++11 standard allows the inline keyword in a namespace-definition. An inline namespace is a namespace that uses the optional keyword inline in its original-namespace-definition.

We can see from above example that members of an inline namespace are treated as if they are members of the enclosing namespace in many situations (listed below). This property is transitive: if a namespace N contains an inline namespace M, which in turn contains an inline namespace O, then the members of O can be used as though they were members of M or N.

The inline specifier makes the declarations from the nested namespace appear exactly as if they had been declared in the enclosing namespace. This means it drags out the declaration (“var” in the above example) from a nested namespace to the containing namespace.

Advantages of using inline namespaces:

  • Avoid verbose :Consider the above code, if you want to print “var”, you write:

This looks good only if namespace’s names are short as in the above example. But by using inline with namespaces there is no need to type the entire namespace as given above or use the “using” directive.

  • Support of Library :The inline namespace mechanism is intended to support library evolution by providing a mechanism that supports a form of versioning. For example:

Head over and check out all of the modern C++ features available in Windows C++Builder development.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts
CodeDatabaseDelphiRAD Studio

Quickly Define Powerful Client-Side Aggregating Formulas With FireDAC Using TFDQuery In Delphi

CodeDatabaseDelphiRAD Studio

Quickly Learn How Easy It Is To Bind DataSets To Visual Controls In Delphi With LiveBindings

C++CodeRAD Studio

Learn How To Use C++ Incomplete Return Types In Windows Development

C++Delphi

Create Beautiful Windows Applications With Visually Stunning VCL Styles For Delphi And C++

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES