Q:

Is there a way to avoid constexpr function used in header file from entering global scope without extra namespace for it?

I have a header file with code simply looking like this:
constexpr uint32 GenTag(const char tag[5]) { ... }

class SomeClass
{
   static constexpr uint32 TAG1 = GenTag("smth");
   static constexpr uint32 TAG2 = GenTag("abcd");
};
//constexpr needed for switch-case statement

The problem is that function GenTag() belongs to global scope and I would like to avoid it if possible.
I wanted to declare it inside class but it is not possible with constexpr (explanation here: constexpr not working if the function is declared inside class scope).
Does c++ have anything like "undeclare" function at the end of the header (maybe some macro tricks)? Or any other options I missed? If no better ways exist I would probably go with extra (maybe excessive) namespace, but want to ask if there are any other ideas.

A:

There's no way to "undeclare" a function or variable in C++ (header file or not -- a header file is just included into the current translation unit). You'll need to use a namespace, or make GenTag into a macro. You can undefine macros with #undef MACRONAME.

