mattkretz / wg21-papers

my papers to WG21 — the C++ committee
5 stars 7 forks source link

Integral power-of-2 operations #71

Open mattkretz opened 6 years ago

mattkretz commented 6 years ago

https://wg21.link/p0556r3

johnmcfarlane commented 6 years ago

I don't know what's changed recently but I added a rough implementation of this and Jens' other bit manipulation paper after Albuquerque. It's not just SIMD that needs to consider overloads of functions like this.

mattkretz commented 6 years ago

Thanks for the pointer. Do you have an idea how we could generalize the overloads? Can't we define some concept aka PowerOf2Manipulable? ;-) If we can, should we?

johnmcfarlane commented 6 years ago

We barely got around to opening that can of worms on Friday. I recall from the Jax discussion on two's complement signed integer that there are generally two approaches to specifying the behavior of integers: one involving hardware description (bits etc.) and the other being more purely mathematical. So I don't know if we want to exclude non-binary representations, e.g. who cares if BCD overloads are slower? Also, I don't know where that leaves fixed_point where bit#0 doesn't always have value 1.

As for composite types, I'm thinking that functions such as these should be a single overload which requires at least the concept Composite and recurses down into the wrapped type:

constexpr auto ispow2(Composite c) {
  auto rep = to_rep(c);  // unwraps the wrapped value
  return ispow2(rep);
}

But I'd much rather punt on it until someone requests it.

On Mon, Jun 11, 2018, 08:09 Matthias Kretz notifications@github.com wrote:

Thanks for the pointer. Do you have an idea how we could generalize the overloads? Can't we define some concept aka PowerOf2Manipulable? ;-) If we can, should we?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/mattkretz/wg21-papers/issues/71#issuecomment-396143766, or mute the thread https://github.com/notifications/unsubscribe-auth/AAszN_00giIiK518qeRalEcF_XsPA7q_ks5t7hfHgaJpZM4UhVyE .