I know that among other things (like auto_ptr), exception specifications have been deprecated in C++11.
Is there any way to get a warning from g++ 4.8 with the following code ?
struct F{
void foo() throw (int){}
};
int main()
{
}
I already tried with -Wall -pedantic -Wextra -Wdeprecated-declarations, but without any success.
You can use
class __attribute__((deprecated)) old_style_throw_specification;
class old_style_throw_specification {};
#define throw(...) throw(old_style_throw_specification, __VA_ARGS__)
or if you need to support empty throw specifications (thanks @John5342 for pointing this out), you can use
#define throw(...) throw(old_style_throw_specification, ##__VA_ARGS__)
for the macros but you'll need to compile with the GNU-extensions: -std=gnu++11
as the above is not strictly legal C++11.