Date: Tue, 19 Dec 2023 10:09:35 -0500
The only parameters available to a concept are the template parameters.
The parameters to the requires expression, as in your example, are not
concept parameters. Note that a concept may be defined that does not use
a requires expression at all; or may use more than one.
Tom.
On 12/19/23 3:12 AM, JIMMY HU via Std-Proposals wrote:
> Hi,
>
> The meaning of *function overloading* is that two or more functions
> can have the same name but different parameters. In C++20, concept
> <https://en.cppreference.com/w/cpp/language/constraints> has been
> introduced. I think that the same logic should be applied to concepts
> in C++: *two or more concepts can have the same name but different
> number of parameters, and the usage of concept depends on the number
> of given parameters.*
>
> *Example*:
> template<typenameT>
> conceptis_summable = requires(T x) { x + x; }; // one
> parameter version
> // error: redefinition of concept 'is_summable' with different
> template parameters or requirements
> template<typenameT>
> conceptis_summable = requires(T x, T y) { x + y; }; // two
> parameter version
> template<is_summableT> // the
> usage of one parameter version
> voidfoo(Tinput)
> {
> }
> template<classT1, classT2>
> requires(is_summable<T1, T2>) // the
> usage of two parameter version
> {
> }
>
> --
> Jimmy Hu
>
> Dec. 19, 2023
>
> Email: s103360021_at_[hidden]
>
The parameters to the requires expression, as in your example, are not
concept parameters. Note that a concept may be defined that does not use
a requires expression at all; or may use more than one.
Tom.
On 12/19/23 3:12 AM, JIMMY HU via Std-Proposals wrote:
> Hi,
>
> The meaning of *function overloading* is that two or more functions
> can have the same name but different parameters. In C++20, concept
> <https://en.cppreference.com/w/cpp/language/constraints> has been
> introduced. I think that the same logic should be applied to concepts
> in C++: *two or more concepts can have the same name but different
> number of parameters, and the usage of concept depends on the number
> of given parameters.*
>
> *Example*:
> template<typenameT>
> conceptis_summable = requires(T x) { x + x; }; // one
> parameter version
> // error: redefinition of concept 'is_summable' with different
> template parameters or requirements
> template<typenameT>
> conceptis_summable = requires(T x, T y) { x + y; }; // two
> parameter version
> template<is_summableT> // the
> usage of one parameter version
> voidfoo(Tinput)
> {
> }
> template<classT1, classT2>
> requires(is_summable<T1, T2>) // the
> usage of two parameter version
> {
> }
>
> --
> Jimmy Hu
>
> Dec. 19, 2023
>
> Email: s103360021_at_[hidden]
>
Received on 2023-12-19 15:09:39