Date: Mon, 22 Mar 2021 00:59:37 +0200
Please ignore this.
My case was too narrow, it just doesn't make sense in general.
Sorry if you wasted time reading this.
On Sat, Mar 20, 2021 at 7:41 PM Omer Rosler <omer.rosler_at_[hidden]> wrote:
> When deducing a templated CNTTP inside a deduction guide, shouldn't the
> context be unevaluated?
>
> Consider the following snippet:
>
> https://godbolt.org/z/5e4nTY
>
> ```c++
> template<typename T>
> constexpr T&& constexpr_declval() { return {};}
>
> /************************************************/
>
> template<auto V>
> struct nttp_tag {};
>
>
> /************************************************/
> template<bool is_type>
> struct use_ctad
> {
> template<auto V> requires (!is_type)
> constexpr use_ctad(nttp_tag<V>) {}
> };
>
> template<auto V>
> use_ctad(nttp_tag<V>) -> use_ctad<false>;
>
> /**********************************************/
> template<use_ctad t>
> struct wrapper
> {
> template<typename Tag>
> wrapper(Tag);
> };
>
> template<typename Tag>
> wrapper(Tag) -> wrapper<use_ctad{constexpr_declval<Tag>()}>;
>
> int main()
> {
> wrapper t{nttp_tag<42>{}};
> }
> ```
>
> [Note: gcc complains about a deduction failure, which is probably a
> compiler bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99683), clang
> accepts this].
>
> The deduction guide of `wrapper` uses a CTAD to deduce the NTTP, but in
> this context there is no need to evaluate `constexpr_declval` (only perform
> CTAD) as we only care about the deduction.
>
> So my questions/proposals:
>
> 1. Should this context be unevaluated (unless I'm missing something, we
> only deduce things and there is no need for evaluation), and we can remove
> the definition (not declaration) of `constexpr_declval` and it would still
> work?
>
> 2. If 1 is yes, shouldn't we make `std::declval` `constexpr` to support
> this construct?
>
>
My case was too narrow, it just doesn't make sense in general.
Sorry if you wasted time reading this.
On Sat, Mar 20, 2021 at 7:41 PM Omer Rosler <omer.rosler_at_[hidden]> wrote:
> When deducing a templated CNTTP inside a deduction guide, shouldn't the
> context be unevaluated?
>
> Consider the following snippet:
>
> https://godbolt.org/z/5e4nTY
>
> ```c++
> template<typename T>
> constexpr T&& constexpr_declval() { return {};}
>
> /************************************************/
>
> template<auto V>
> struct nttp_tag {};
>
>
> /************************************************/
> template<bool is_type>
> struct use_ctad
> {
> template<auto V> requires (!is_type)
> constexpr use_ctad(nttp_tag<V>) {}
> };
>
> template<auto V>
> use_ctad(nttp_tag<V>) -> use_ctad<false>;
>
> /**********************************************/
> template<use_ctad t>
> struct wrapper
> {
> template<typename Tag>
> wrapper(Tag);
> };
>
> template<typename Tag>
> wrapper(Tag) -> wrapper<use_ctad{constexpr_declval<Tag>()}>;
>
> int main()
> {
> wrapper t{nttp_tag<42>{}};
> }
> ```
>
> [Note: gcc complains about a deduction failure, which is probably a
> compiler bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99683), clang
> accepts this].
>
> The deduction guide of `wrapper` uses a CTAD to deduce the NTTP, but in
> this context there is no need to evaluate `constexpr_declval` (only perform
> CTAD) as we only care about the deduction.
>
> So my questions/proposals:
>
> 1. Should this context be unevaluated (unless I'm missing something, we
> only deduce things and there is no need for evaluation), and we can remove
> the definition (not declaration) of `constexpr_declval` and it would still
> work?
>
> 2. If 1 is yes, shouldn't we make `std::declval` `constexpr` to support
> this construct?
>
>
Received on 2021-03-21 17:59:50