Eternal Eternal - 2 months ago 6x
C++ Question

Are using-declarations static?

I'm a bit confused about using-declarations. I understand that

using foo::bar;
imports the symbol
from namespace
into the current namespace, but does this happen statically or dynamically?

More specifically, do using-declarations lead to an overhead? Would it be possible to import different symbols with the same name depending on a condition? (that would be bad practice, but I'm curious all the same)

It feels like it should be static, but I can't find anything to confirm this...


Namespace resolution happens at compile time. You can not change them dynamically at run time.

One way to import different symbols depending on condition is to use preprocessor directives and macros:

#ifdef USEA
using a::f;
using b::f;