C++ Logo

std-proposals

Advanced search

Re: Proposal: add support for template qualifiers

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 20 Feb 2020 08:58:13 -0800
On Monday, 17 February 2020 20:53:17 PST Arthur O'Dwyer via Std-Proposals
wrote:
> On Mon, Feb 17, 2020 at 4:21 PM Oleksii Tarasiuk via Std-Proposals <
>
> std-proposals_at_[hidden]> wrote:
> > Hi all!
> >
> > template<bool b>
> > Bar const<b>* byName(string const& name) const<b> {
[snip]
> I think there's a big drop in usefulness between `const(bool)` and
> everything else you're proposing (or that I'm ironically 'proposing' above).
> And `const(bool)` seems to be already handled, better, by P0847 "Deducing
> this"
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0847r4.html>.
> Your proposal would have to explain why P0847 is comparatively undesirable
> and why your proposal doesn't have those same problems.

For anything that names types, you can also use std::conditional_t:

  template <bool b>
  std::conditional_t<b, const Bar *, Bar *> byName(const string &name);

But it wouldn't for the function-qualifying const. Nor, for that matter, for
tthe ref-qualifying of the member, which the paper above is more interesting
for.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2020-02-20 11:00:57