Subject: Re: [std-proposals] Meta types
From: Jake Arkinstall (jake.arkinstall_at_[hidden])
Date: 2020-02-05 17:14:37
On Wed, 5 Feb 2020, 00:27 Garrett May via Std-Proposals, <
> On Tue, 4 Feb 2020, 11:27 am Jake Arkinstall via Std-Proposals, <
> std-proposals_at_[hidden]> wrote:
> This proposal will likely also include a mechanism for switching on types.
> I'm also thinking of using template/concept syntax in place of var.
> I don't believe that template/concept syntax would be appropriate here
> unless changes were made to what templates/concepts can do. That's because
> what we have here is return types that are not dependent on templates, nor
> on concepts, but instead on *branches*.
The code for each branch is still generated at compile time, just as a call
to a template function within a branch generates the appropriate function.
As such, you can still place any requirement on the var type, and
compilation depends on every such branch satisfying that requirement -
exactly as if the equivalent callback struct had such a concept requirement
on the parameter passed to the operator() method.
As an example, in the halve method you expect to receive an Arithmetic
type. By prefixing var with Arithmetic, it provides useful error messages
if one of the potential yielded values was, for example, a std::string_view.
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups