Originally posted by Mangix
View Post
Announcement
Collapse
No announcement yet.
GCC 11 Now Defaults To C++17 Dialect By Default
Collapse
X
-
Last edited by klapaucius; 29 June 2020, 06:00 AM.
-
Originally posted by Mangix View PostI was under the impression that constexpr enables compile time evaluation.
- Likes 1
Comment
-
Originally posted by archibald View Post
I'm sorry to say but you're mistaken here - constexpr is a keyword that allows compile-time evaluation: https://en.cppreference.com/w/cpp/language/constexpr. It can indeed slow down compilation time, but it results in runtime speedups and compile-time checking of results, so the tradeoff is generally considered worth it.
- Likes 1
Comment
-
Originally posted by archibald View Post
I'm sorry to say but you're mistaken here - constexpr is a keyword that allows compile-time evaluation: https://en.cppreference.com/w/cpp/language/constexpr. It can indeed slow down compilation time, but it results in runtime speedups and compile-time checking of results, so the tradeoff is generally considered worth it.
And c++14/17 greatly improved writing such code, with C11 you were limited and often had to resort to recursion. So easier, faster to evaluate and optimize code with higher standards
- Likes 1
Comment
-
Originally posted by carewolf View PostNope.. Try it Play round here on godbolt.org, and try to get const and constexpr to produce different code with optimizing compilers
Originally posted by discordian View PostEverything can slow down compilation, but constexpr often does the opposite. Evaluation is usually alot faster than multiple optimization passes and heuristics.
Last edited by archibald; 30 June 2020, 09:47 AM.
- Likes 1
Comment
-
Originally posted by pal666 View Postold code will use newer standard library, which will use newer language features which usually speed up compiling
Compiling as a new standard definitely CAN make compilation slower, and it DOES. C++11 added dozens of new constructors to containers and tuple, and that makes overload resolution noticably slower even if you don't use any of those new constructors. C++17 adds even more new things to headers, which takes longer to parse even if you don't use them.
Comment
Comment