Why would I want to write something like this and fill // STUFF with stuff?
// boost
namespace another_name {} namespace boost = another_name; namespace another_name {
// STUFF
}
Why would I want to write something like this and fill // STUFF with stuff?
// boost
namespace another_name {} namespace boost = another_name; namespace another_name {
// STUFF
}
Copyright © 2021 Jogjafile Inc.
This is just a regular namespace definition followed by a namespace alias definition aliasing the former.
Note however that defining an alias name
boostcould conflict with an actual namespaceboostsuch that as soon as you actually include a boost header you will run into a compiler error:
If you've seen this particular example in a code base, it could be an attempt at providing an internal what seems-to-be boost (subset) implementation of boost that could later be replaced by removing the alias and including the actual boost headers, but without having to change call sites that explicitly qualifies entities using
boost::.E.g., an early version of the code base (before using actual boost):
where later
internal_boost.his modified intoThis approach could arguably facilitate variants easier (say one product variant where 3rd party libs may not be used due to e.g. safety critical concerns) but it may also confuse developers, and an arguably better approach would be to provide a unique alias that is simply set to different values for different variants/versions (rather than providing an alias that is named as and later entirely replaced by an actual well-known namespace such as
boost).