C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Function only accepts parameter that will persist

From: Gašper Ažman <gasper.azman_at_[hidden]>
Date: Mon, 6 May 2024 02:26:26 -0600
P1690 - just use a different comparator. It already works.

On Mon, May 6, 2024, 04:43 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Mon, May 6, 2024 at 12:20 AM Frederick Virchanza Gotham wrote:
> >
> > Now obviously the following paper is way too simplistic and needs to
> > be beefed out considerably . . . but it's a start:
> >
> > http://www.virjacode.com/papers/consteval_template_instantiation.htm
>
>
> And it would make it possible to do a few other things too, such as
> having different return types depending upon the argument:
>
> consteval auto Monkey(std::initializer_list<std::string_view> const
> args)
> {
> if constexpr ( args.size() % 2u )
> {
> return 5; // returns int
> }
> else
> {
> return 2.5; // returns double
> }
> }
>
> And then 'decltype' could be used to get the return type without
> invoking the function:
>
> typedef decltype( Monkey("frog","cat","fish") ) MyType;
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-05-06 08:26:39