std:: is_final
| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++14)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
헤더에 정의됨
<type_traits>
|
||
|
template
<
class
T
>
struct is_final ; |
(C++14부터) | |
std::is_final
는
UnaryTypeTrait
입니다.
만약
T
가
final
클래스인 경우, 멤버 상수
value
를
true
로 제공합니다. 다른 모든 타입에 대해서는
value
가
false
입니다.
만약
T
가 불완전한 클래스 타입이라면, 동작은 정의되지 않습니다.
프로그램이
std::is_final
또는
std::is_final_v
(C++17부터)
에 대한 특수화를 추가하는 경우, 그 동작은 정의되지 않습니다.
목차 |
템플릿 매개변수
| T | - | 확인할 타입 |
헬퍼 변수 템플릿
|
template
<
class
T
>
constexpr bool is_final_v = is_final < T > :: value ; |
(C++17부터) | |
std:: integral_constant 로부터 상속됨
멤버 상수
|
value
[static]
|
true
만약
T
가 final 클래스 타입이면,
false
그렇지 않으면
(public static member constant) |
멤버 함수
|
operator bool
|
객체를
bool
로 변환,
value
반환
(public member function) |
|
operator()
(C++14)
|
value
반환
(public member function) |
멤버 타입
| 타입 | 정의 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
참고 사항
std::is_final
는
LWG 이슈 2112
의 해결을 통해 도입되었습니다.
union
은
final
으로 선언될 수 있습니다(그리고
std::is_final
가 이를 감지할 수 있습니다). 비록 union이 어떤 경우에도 기반 클래스로 사용될 수 없음에도 불구하고 말입니다.
| 기능 테스트 매크로 | 값 | 표준 | 기능 |
|---|---|---|---|
__cpp_lib_is_final
|
201402L
|
(C++14) |
std::is_final
|
예제
#include <type_traits> class A {}; static_assert(std::is_final_v<A> == false); class B final {}; static_assert(std::is_final_v<B> == true); union U final { int x; double d; }; static_assert(std::is_final_v<U> == true); int main() { }
참고 항목
|
(C++11)
|
타입이 비-유니온 클래스 타입인지 검사합니다
(class template) |
|
(C++11)
|
타입이 다형 클래스 타입인지 검사합니다
(class template) |