Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why when I write noexcept before const i get an error

Tags:

c++

c++17

Why when I write definition of a class member function such as

int returnSize() const noexcept

the code compiles, but when I write

int returnSize() noexcept const

it doesn't compile

like image 343
Eoan Ermine Avatar asked Sep 01 '26 06:09

Eoan Ermine


1 Answers

That's just the way the language is defined.

Exception specifiers need to come after const/volatile qualification: https://en.cppreference.com/w/cpp/language/function

function

like image 149
DeducibleSteak Avatar answered Sep 02 '26 22:09

DeducibleSteak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!