728x90
반응형
- c++17
#include <iostream>
using namespace std;
int func1() noexcept //
{
throw 1; // error, call terminate()
}
int func2() noexcept(false)
{
throw 1;
}
int main()
{
try
{
// func1(); // terminate()
func2();
}
catch(...)
{
cout << "error" << endl;
}
// noexcept 확인 가능
bool ch1 = noexcept(func1() ); // 1
bool ch2 = noexcept(func2() ); // 0
cout << ch1 << " , " << ch2 << endl;
}
728x90
반응형
'Programming > C&C++&C#' 카테고리의 다른 글
modern C++ 스마트포인터 unique_ptr (0) | 2019.12.26 |
---|---|
modern C++ begin/end (0) | 2019.12.15 |
modern C++ using 사용법 (0) | 2019.12.15 |
modern C++ static_assert (0) | 2019.12.15 |
modern C++ 11/14 iteral & type, auto & decltype (0) | 2019.12.15 |