いやようするに、
#include <iostream>
#include <stdexcept>
using namespace std;
struct C {
operator runtime_error() {
return runtime_error("original description");
}
};
int main()
{
try {
throw C();
} catch(runtime_error &) { // (1)ここには来ないで……
cout << "catch std::runtime_error!" << endl;
} catch(...) { // (2)ここに来る
cout << "catch some type..." << endl;
}
}
てな感じで、変換関数が定義されたクラスをthrowしても、catchする時にはそれは適用されない。らしい。驚いた。
なんかあんまり直感的でないなー。なんでこうなっているんだろう。
ラベル:C++

