y3c-stl 0.3.3
Friendly C++ STL wrapper with automatic stacktrace
Loading...
Searching...
No Matches
catch.cc

‍example output:

catch as std::out_of_range, what(): attempted to access index 100, that is outside the bounds of size 1.
catch as std::logic_error, what(): attempted to access index 100, that is outside the bounds of size 1.
catch as std::exception, what(): attempted to access index 100, that is outside the bounds of size 1.
catch anything
#include <y3c/array>
#include <iostream>
int main() {
try {
a.at(100) = 0;
} catch (const std::out_of_range &e) {
std::cout << "catch as std::out_of_range, what(): " << e.what()
<< std::endl;
}
try {
a.at(100) = 0;
} catch (const std::logic_error &e) {
std::cout << "catch as std::logic_error, what(): " << e.what()
<< std::endl;
}
try {
a.at(100) = 0;
} catch (const std::exception &e) {
std::cout << "catch as std::exception, what(): " << e.what()
<< std::endl;
}
try {
a.at(100) = 0;
} catch (...) {
std::cout << "catch anything" << std::endl;
}
}
固定長配列 (std::array)
Definition array.h:20
reference at(size_type n, internal::skip_trace_tag={})
要素アクセス
Definition array.h:133