https://www.learncpp.com/cpp-tutorial/unnamed-and-inline-namespaces/
말그대로 namespace가 이름없이 정의된 경우이다
매우 쓸모없어 보이지만
internal linkage와 같이 사용할 수 있다
이는 모든 function을 static function으로 선언하는 것과 같은 효과를 가진다
#include <iostream>
inline namespace v1 // declare an inline namespace named v1
{
void doSomething()
{
std::cout << "v1\n";
}
}
namespace v2 // declare a normal namespace named v2
{
void doSomething()
{
std::cout << "v2\n";
}
}
int main()
{
v1::doSomething(); // calls the v1 version of doSomething()
v2::doSomething(); // calls the v2 version of doSomething()
doSomething(); // calls the inline version of doSomething() (which is v1)
return 0;
}
위와 같은 경우
출력은
v1
v2
v1
이다 그냥 doSomethin();의 경우 inline namespace가 있어서 v1이 실행된다
위와 같은 활용법이 있으나 제한적인 활용법으로 자세히 다루지는 않겠다