C++ Logo

std-proposals

Advanced search

Re: Proposal: add support for template qualifiers

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Mon, 17 Feb 2020 23:53:17 -0500
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> {
>

This is very similar to `noexcept(bool)` [C++11] and `explicit(bool)`
[C++20], except that you're spelling it with angle brackets instead of
parentheses. What's your rationale for that? Does it have anything to do
with the formal grammar?
Also for `static` and `thread_local`. But not `extern`? `mutable`? `friend`?
If you're doing `const(bool)`, why aren't you doing `volatile(bool)`?
Heck, why not `long(bool)` or `unsigned(bool)`?

    template<bool B> long(B) int pi = 3;
    static_assert(std::is_same_v<decltype(pi<true>), long int>);
    static_assert(std::is_same_v<decltype(pi<false>), int>);

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.

HTH,
Arthur

Received on 2020-02-17 22:56:08