Namespace aliases
From cppreference.net
C++
C++ language
| General topics | ||||||||||||||||
| Flow control | ||||||||||||||||
| Conditional execution statements | ||||||||||||||||
| Iteration statements (loops) | ||||||||||||||||
|
||||||||||||||||
| Jump statements | ||||||||||||||||
| Functions | ||||||||||||||||
| Function declaration | ||||||||||||||||
| Lambda function expression | ||||||||||||||||
inline
specifier
|
||||||||||||||||
| Dynamic exception specifications ( until C++17* ) | ||||||||||||||||
noexcept
specifier
(C++11)
|
||||||||||||||||
| Exceptions | ||||||||||||||||
| Namespaces | ||||||||||||||||
|
||||||||||||||||
| Types | ||||||||||||||||
| Specifiers | ||||||||||||||||
|
||||||||||||||||
| Storage duration specifiers | ||||||||||||||||
| Initialization | ||||||||||||||||
| Expressions | ||||||||||||||||
| Alternative representations | ||||||||||||||||
| Literals | ||||||||||||||||
| Boolean - Integer - Floating-point | ||||||||||||||||
| Character - String - nullptr (C++11) | ||||||||||||||||
| User-defined (C++11) | ||||||||||||||||
| Utilities | ||||||||||||||||
| Attributes (C++11) | ||||||||||||||||
| Types | ||||||||||||||||
typedef
declaration
|
||||||||||||||||
| Type alias declaration (C++11) | ||||||||||||||||
| Casts | ||||||||||||||||
| Memory allocation | ||||||||||||||||
| Classes | ||||||||||||||||
| Class-specific function properties | ||||||||||||||||
|
||||||||||||||||
| Special member functions | ||||||||||||||||
|
||||||||||||||||
| Templates | ||||||||||||||||
| Miscellaneous | ||||||||||||||||
Declarations
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
네임스페이스 별칭은 프로그래머가 네임스페이스에 대한 대체 이름을 정의할 수 있게 합니다.
이들은 일반적으로 길거나 깊게 중첩된 네임스페이스에 대한 편리한 단축키로 자주 사용됩니다.
목차 |
구문
namespace
alias_name
=
ns_name
;
|
(1) | ||||||||
namespace
alias_name
=
::
ns_name
;
|
(2) | ||||||||
namespace
alias_name
=
nested_name
::
ns_name
;
|
(3) | ||||||||
설명
새로운 별칭 alias_name 은 ns_name 에 접근하는 대체 방법을 제공합니다.
alias_name 는 이전에 사용되지 않은 이름이어야 합니다. alias_name 은 해당 별칭이 도입된 범위의 지속 기간 동안 유효합니다.
키워드
예제
이 코드 실행
#include <iostream> namespace foo { namespace bar { namespace baz { int qux = 42; } } } namespace fbz = foo::bar::baz; int main() { std::cout << fbz::qux << '\n'; }
출력:
42
참고 항목
| namespace declaration | 네임스페이스를 식별함 |
| type alias declaration (C++11) | 타입의 동의어를 생성함 |