boostorg / core

Boost Core Utilities
132 stars 86 forks source link

bit.hpp: Use C++17 if constexpr where possible #101

Closed Lastique closed 2 years ago

Lastique commented 2 years ago

@pdimov Ping?

pdimov commented 2 years ago

I'm not sure why would I want this change. It makes the source uglier and does effectively nothing else. At the same time, I don't have any good arguments against, either.

Lastique commented 2 years ago

It reduces the amount of code to compile. In each function, only one branch is enabled for a given call, the rest are just wasting compile time on overload resolution and DCE. if constexpr should allow to discard these branches earlier.

pdimov commented 2 years ago

All right, let's give it a go.