Updated:

less than 1 minute read

개요

  • 중첩된 인라인 네임스페이스에 대한 정의


예제

  • 코드
     #include <iostream>
        
     using namespace std;
        
     // before C++20
     namespace A {
     inline namespace B {
     namespace C {
     void func1() { cout << __func__ << " call" << endl; }
     } // namespace C
     } // namespace B
     } // namespace A
        
     // C++20
     namespace A::inline B::C {
     void func2() { cout << __func__ << " call" << endl; }
     } // namespace A::inline B::C
        
     int main() {
     	A::B::C::func1();
     	A::B::C::func2();
        
     	return 0;
     }
    
  • 실행 결과
     func1 call
     func2 call