noexcept
noexcept can be used to any function, even any expression?
1 2 3
|
void fun(){}
void gun() noexcept(fun)
{}
| |
Yes, but there are two seperate uses of the keyword;
a) to specify whether a funciton may throw an exception or not
-
http://en.cppreference.com/w/cpp/language/noexcept_spec
b) as a compile-time operator to determine whether a function may throw
-
http://en.cppreference.com/w/cpp/language/noexcept
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
// noexcept as a specifier
void fun();
void gun() noexcept( /* Boolean expression */ true );
void run() noexcept;
int main() {
//noexcept as a compile-time operator
std::cout << noexcept(fun() ) << " " << noexcept(gun() ) << " " << noexcept(run() );
return 0;
}
| |
Output:
Last edited on
Topic archived. No new replies allowed.