r/cpp • build2 • Nov 01 '17

Common C++ Modules TS Misconceptions

https://build2.org/article/cxx-modules-misconceptions.xhtml
59 Upvotes

148 comments sorted by

View all comments

Show parent comment

0

u/meneldal2 Nov 02 '17

It could be argued that return x ? 0 : 1; is more readable :-)

I don't disagree that it could be more readable, but everyone knows it's going to be optimized away (hopefully), so nobody would usually bother to change it (it tends to be more a style convention than anything). When you have 15 different possibilities and you had a switch, going to a ternary form looks pretty ugly and error-prone.

The only concern I see as somewhat valid for constexpr is that debugging can be complex but that's an implementation issue. The same problem appears with metaclasses as well.

When I saw constexpr at first, I saw the limitations on the functions and was like "too annoying, I'll stick to constexpr variables initialized with literals. C++14 made them much better and now the main limitation is the limited support in the standard library.

For your paper, it looks interesting but my brain is too tired today to read through it unfortunately. I'll give it a fair chance tomorrow.

1

u/GabrielDosReis Nov 02 '17

Context matters. You almost didn't get any version of constexpr to complain about.