cplusplus / draft

C++ standards drafts
http://www.open-std.org/jtc1/sc22/wg21/
5.69k stars 749 forks source link

[range.split.outer,range.split.inner] "current" placeholder vs. current_ exposition-only member #3851

Open jensmaurer opened 4 years ago

jensmaurer commented 4 years ago

Some misuse was fixed in #3849, but having these two near-identical identifiers with different semantics is prone to cause further mix-ups.

Find a better name for one of them.

JohelEGP commented 4 years ago

How about renaming current to effective-current?

CaseyCarter commented 4 years ago

I'd like to avoid anything of the form "xxx-current"/"current-xxx" if we can. Now that all of the private variables have been kebab-cased, it's too easy to confuse the exposition only name foo-bar with an expression that calculates the difference of the two exposition-only names foo and bar.

JohelEGP commented 4 years ago

Ah, right. IIRC, the dash replaced underscores in exposition-only names to make that property more obvious. Now that they're kebab-cased, underscores should once again be viable.

jwakely commented 4 years ago

One option would be to define current() as a pair of exposition-only member functions (const and non-const), and we could specify them precisely:

constexpr auto& current() {
 if constexpr (forward_range<Base>)
  return current_;
else
  return parent_.current_;
}

The distinction between `current_ and _current()`_ still isn't huge, but the parentheses would help.

Or there's always CURRENT in the style of INVOKE, but we've moved away from that to kebab-case.