I'm interested in what exactly happens "under the hood" when the following inline function is called in several translation units.
namespace some_name
{
inline const float& get_float()
{
static const float a = 5.0f;
return a;
}
}
My intention was to create an externally linked variable 'a', which can be used across the code (if the header with namespace is included), but also I wanted to prevent any change to this variable. From testing it seems I succeeded, but I'm interested in what exactly happens when I call this function the first time and then the next several times.
Additional question: Am I polluting global namespace with static variable declaration/definition?