C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Callsite passed as template parameter

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 16 Nov 2023 18:12:46 +0000
On Thursday, November 16, 2023, Sebastian Wittmeier via Std-Proposals wrote:

> And it is not very obvious to the caller.
>


If I decide to use this tactic in my Arduino microcontroller code, then
I'll probably do:

    template<typename T>
    void Func(void)
    {
        // stuff in here
    }

    #define CALLSITE decltype([]{})

    int main(void)
    {
        Func<CALLSITE>();
    }

It would be nice though if this could be standardised to:

    template<_Callsite>
    void Func(void)
    {
        // stuff in here
    }

    int main(void)
    {
        Func<_Callsite>();
    }

but I don't think the committee guys care.

Also, in the first example I gave above, it would be nice to be able to
constrain a template so that the parameter type must be a lambda, for
example

    template<typename T> requires is_lambda_v< remove_cvref_t<T> >
    void Func(void)
    {
        // stuff in here
    }

but for some reason lots of people here don't want to have an "is_lambda_v"
in the standard. (Actually I'd constrain in to be an Rvalue reference to a
lambda).

Received on 2023-11-16 18:12:49