What are inline namespaces for?

Inline namespaces are a library versioning feature akin to symbol versioning, but implemented purely at the C++11 level (ie. cross-platform) instead of being a feature of a specific binary executable format (ie. platform-specific). It is a mechanism by which a library author can make a nested namespace look and act as if all its declarations … Read more

What are namespaces?

Namespacing does for functions and classes what scope does for variables. It allows you to use the same function or class name in different parts of the same program without causing a name collision. In simple terms, think of a namespace as a person’s surname. If there are two people named “John” you can use … Read more

What is the best way to solve an Objective-C namespace collision?

Prefixing your classes with a unique prefix is fundamentally the only option but there are several ways to make this less onerous and ugly. There is a long discussion of options here. My favorite is the @compatibility_alias Objective-C compiler directive (described here). You can use @compatibility_alias to “rename” a class, allowing you to name your … Read more

What are XML namespaces for?

They’re for allowing multiple markup languages to be combined, without having to worry about conflicts of element and attribute names. For example, look at any bit of XSLT code, and then think what would happen if you didn’t use namespaces and were trying to write an XSLT where the output has to contain “template”, “for-each”, … Read more

printf with std::string?

It’s compiling because printf isn’t type safe, since it uses variable arguments in the C sense1. printf has no option for std::string, only a C-style string. Using something else in place of what it expects definitely won’t give you the results you want. It’s actually undefined behaviour, so anything at all could happen. The easiest … Read more

Superiority of unnamed namespace over static?

You’re basically referring to the section ยง7.3.1.1/2 from the C++03 Standard, The use of the static keyword is deprecated when declaring objects in a namespace scope; the unnamed-namespace provides a superior alternative. Note that this paragraph was already removed in C++11. static functions are per standard no longer deprecated! Nonetheless, unnamed namespace‘s are superior to … Read more

Python ElementTree module: How to ignore the namespace of XML files to locate matching element when using the method “find”, “findall”

Instead of modifying the XML document itself, it’s best to parse it and then modify the tags in the result. This way you can handle multiple namespaces and namespace aliases: from io import StringIO # for Python 2 import from StringIO instead import xml.etree.ElementTree as ET # instead of ET.fromstring(xml) it = ET.iterparse(StringIO(xml)) for _, … Read more