ํฐ์คํ ๋ฆฌ ๋ทฐ
์ ๋ฒ์ ์ ๋ฆฌํ๋ friend, explicit์ ์ด์ด noexcept๋ผ๋ ์๋ก์ด ํค์๋์ ๋ํด์ ์ ๋ฆฌํด๋ณด๋ ค ํฉ๋๋ค.
noexcept์ ์ด๋ค ์๋ฏธ๋ฅผ ๊ฐ์ง๊ณ ์๋,,, ๋ง ๊ทธ๋๋ก ํจ๊ป ์์ฑ๋ ํจ์์์ ์์ธ๋ฅผ ๋ฐ์์ํค์ง ์๊ฒ ๋ค๋ ๋ป์ ๊ฐ์ง๊ณ ์์ต๋๋ค.
ํด๋น ํค์๋๋ฅผ ์ฌ์ฉํ์ ๋ ์ด์ ์
1. ์ ์ ์ ์ปดํ์ผ๋ฌ์๊ฒ ํํธ๋ฅผ ์ค ์ ์์ต๋๋ค.
2. ์ฝ๋๋ฅผ ๊ฐ๊ฒฐํ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค.
3. ์ปดํ์ผ๋ฌ ์ต์ ํ๋ฅผ ๊ฐ๋ฅํ๊ฒ ๋ง๋ค์ด์ค๋๋ค.
์์ ์ ํจ๊ป ๋ณด๊ฒ ์ต๋๋ค.
#include <iostream>
#include <stdexcept>
using namespace std;
int funcA() noexcept {
// ...e
return 0;
}
int main() {
try {
funcA();
}catch (char c) {
std::cout << "Catch char!" << std::endl;
} catch (...) {
std::cout << "Default exception catch!" << std::endl;
}
std::cout << "Program ends without exception" << std::endl;
return 0;
}
funcA์์ ์๋ฌ๋ฅผ ๋์ง ์๋ ์์ง๋ง ์ ์์ ์ผ๋ก ์๋๋๋ ๋ชจ์ต์ ๋ณผ ์ ์์ต๋๋ค.
๊ทธ๋ฐ๋ฐ ๋ง์ฝ noexception ํค์๋๋ฅผ ์ฌ์ฉํ๋๋ฐ Exception์ throwํ๋ฉด ๋ฐ์ํ๋ฉด ์ด๋ป๊ฒ ๋ ๊น์
#include <iostream>
#include <stdexcept>
using namespace std;
int funcA() noexcept {
// ...
throw runtime_error("Exception!");
return 0;
}
int main() {
try {
funcA();
}catch (char c) {
std::cout << "Catch char!" << std::endl;
} catch (...) {
std::cout << "Default exception catch!" << std::endl;
}
std::cout << "Program ends without exception" << std::endl;
return 0;
}
libc++abi: terminating due to uncaught exception of type std::runtime_error: Exception!
ํด๋น ์ค๋ฅ๋ ์์ธ๊ฐ ์ฒ๋ฆฌ๋์ง ์๊ณ ํ๋ก๊ทธ๋จ์ด ๋น์ ์์ ์ผ๋ก ์ข ๋ฃ๋์๊ธฐ ๋๋ฌธ์ ๋ฌ๋ค๊ณ ํฉ๋๋ค.
noexception ๋๋ฌธ์ ์์ธ๊ฐ ์ ๋๋ก ์ฒ๋ฆฌ๋์ง ์์ ๊ฒ ๊ฐ๋ค์.
'๐พ CS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[html, JS] input์ ์ ํจ์ฑ ๊ฒ์ฌ (0) | 2023.11.09 |
---|---|
[์์นํ๋ก๊ทธ๋๋ฐ] ํฉ๊ธ๋ถํ ํ์๋ฒ (0) | 2023.10.28 |
์ต์ ํ ์ ์, ์์(๊ฐ๋จ) (0) | 2023.10.28 |
[C++] explicit Keyword (0) | 2023.10.07 |
[C++] friend Keyword (0) | 2023.10.07 |
- Total
- Today
- Yesterday
- GradientDescent
- convolution
- FirstOrderMethod
- code
- ๊ฒฝ๋ํ ๋ชจ๋ธ
- classimbalance
- depthwise
- GradientScaling
- Outlier์ฒ๋ฆฌ
- AutomaticAnnealing
- OptimizerStability
- separable
- LossFunction
- BiasCorrection
- logitadjustment
- Example
- EffectiveStepsize
- MobileNet
- AdamOptimizer
- imbalanceddata
- tensorflow
- OptimizationThory
- DeepLearning
- Focal loss
- ์๋ํ์ต๋ฅ ์กฐ์
- SignalToNoiseRatio
- DeepLearningOptimization
- HyperParametertuning
- fisherconsistency
- Optimizer
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |