Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 스프링 AOP
- c# scv
- b-tree index
- 그라나다
- 아펠가모
- 스페인
- 본식후기
- 아펠가모선릉
- HTTP #웹기술
- 코틀린 함수
- HTTP
- 바르셀로나
- elk
- 관심지향프로그래밍
- Kotlin
- 코틀린
- 코프링
- db index
- 스페인 준비물
- 마드리드
- http상태코드
- kopring
- 아펠가모 선릉
- git명령어
- kotiln
- sprintboot
- Srping AOP
- 세비야
- 400에러
- @Component
Archives
- Today
- Total
끄적이는 메모장
[C++11] static_assert 본문
반응형
# assertion
run time에 true-false를 판단하여 그 결과가 false인 경우 예외 처리를 하기 위해 사용됨
-> 프로그램이 실행중에 예외 감지를 위해 사용
# static_assert
compile time에 assertion을 수행할 수 있도록 제공되는 기능
보통은 type traits class에서 컴파일 타임에 템플릿 인자의 타입 특성을 확인하는데 사용됨
static_assert(bool_expr, message);
ex) static_assert(false, "not support");
컴파일 시 static_assert가 실패 했을때, message에 설정한 내용이 보여진다.
예시
#include <type_traits>
using namespace std;
template <typename T> void test (T p)
{
static_assert(function, "not support")
}
true 혹은 false를 반환 해주는 fuction이 어딘가 존재한다면 compile time에 에러 유무를 검출 하고,
에러가 발생하는 경우 메시지를 보여줄 것이다
반응형
'C, C++, C# > C++ 공부' 카테고리의 다른 글
[C++11] make_shared (0) | 2018.05.30 |
---|---|
[C++11] shared_ptr / weak_ptr (0) | 2018.05.30 |
[C++11] unique_ptr / smart pointer (0) | 2018.05.30 |
[C++11] nullptr (0) | 2018.05.30 |
[C++11] auto (0) | 2018.05.30 |