boostorg / algorithm

Boost.org algorithm module
http://boost.org/libs/algorithm
Boost Software License 1.0
112 stars 105 forks source link

:sparkles: C++20 bit header #92

Closed jgopel closed 2 years ago

jgopel commented 2 years ago

As part of C++Now's Library in a Week effort.

Thanks to @fpikus for the help with this!

glenfe commented 2 years ago

We already have this in Boost.Core

glenfe commented 2 years ago

See https://github.com/boostorg/core/blob/develop/include/boost/core/bit.hpp

And https://www.boost.org/doc/libs/1_79_0/libs/core/doc/html/core/bit.html

We don't need a duplicate in Boost.Algorithm.

mclow commented 2 years ago

On May 5, 2022, at 2:51 PM, Glen Fernandes @.***> wrote:

We don't need a duplicate in Boost.Algorithm.

How do you feel about a PR adding constexpr, etc into the bit routines in Boost.core?

glenfe commented 2 years ago

Any improvements to the functionality in Core are always good.

On a related note, it seemed like a few C++Now's ago, everyone was excited about a future Boost that didn't replicate functionality available in the C++ standard library. Has that changed, or does the sentiment not apply to C++20 and above?

pdimov commented 2 years ago

constexpr when using non-constexpr intrinsics isn't possible without std::is_constant_evaluated, which is C++20. There's an issue already about this (https://github.com/boostorg/core/issues/109) and I'll probably end up adding separately named functions when constexpr is required. (The existing functions are best-effort constexpr, which doesn't allow their portable use in constant expressions.)