이 코드는 VS2010 SP1의 정지 :냉동 감정
// STC_14_1.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <exception>
#include <iostream>
#include <cstdlib>
using std::cerr;
using std::cout;
using std::cin;
void my_new_handler()
{
cerr << "Mem. alloc failed.";
std::exit(-1);
}
//std::unexpected_handler std::set_unexpected(std::unexpected_handler);
class STC
{
std::new_handler old;
public:
STC(std::new_handler n_h):old(std::set_new_handler(n_h))
{ }
~STC()
{
std::set_unexpected(old);
}
};
int main(int argc, char* argv[])
{
STC stc(&my_new_handler);
while (true)
{
auto tmp = new int[50000];
}
return 0;
}
그것이 내가 뭔가를 잘못하고 있어요하거나 VS의 문제라는 것이다을?
STC : : ~ STC'? 디폴트'unexpected_handler'를 디폴트'new_handler'로 대체하는 것이 이상하게 보입니다. –
@Charles 물론 아닙니다. 내 실수. –
컴파일 할 때 컴파일러에게주는 옵션은 무엇입니까? –