C++ Logo

std-proposals

Advanced search

Re: Pure value templates

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Mon, 21 Sep 2020 16:36:24 -0400
On Mon, Sep 21, 2020 at 3:29 PM Ramkumar Ramachandra via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I would like to propose:
>
> ```
> template <typename T = decltype(V), T V>
> constexpr auto Sz = std::extent_v(V);
> ```

That's a circular definition. The compiler can't know what `V` is
without knowing what `T` is and vice-versa.

Equally importantly, I'm pretty sure C++17 gives us similar
functionality as follows:

```
template<auto V>
constexpr auto Sz = std::extent_v<decltype(V)>;
```

Received on 2020-09-21 15:36:35