私の C++ メソッドが奇妙なことに遭遇し、回復できない場合に、例外をスローしたいと考えています。std::string
ポインタを投げても大丈夫ですか?
私が楽しみにしていたことは次のとおりです。
void Foo::Bar() {
if(!QueryPerformanceTimer(&m_baz)) {
throw new std::string("it's the end of the world!");
}
}
void Foo::Caller() {
try {
this->Bar(); // should throw
}
catch(std::string *caught) { // not quite sure the syntax is OK here...
std::cout << "Got " << caught << std::endl;
}
}