How to signify to the compiler that a function always throws?
c++, exception, visual-c++
Solution
With Visual C++, you can use `__declspec(noreturn)`.
Problem
When calling functions that always throw from a function returning a value, the compiler often warns that not all control paths return a value. Legitimately so. ``` void AlwaysThrows() { throw "something"; } bool foo() { if (cond) AlwaysThrows(); else return true; // Warning C4715 here } ``` Is there a way to tell the compiler that AlwaysThrows does what it says? I'm aware that I can add another `throw` after the function call: ``` { AlwaysThrows(); throw "dummy"; } ``` And I'm aware that I can disable the warning explicitly. But I was wondering if there is a more elegant solution.