Date: Sat, 8 Oct 2022 22:52:34 +0100
On Sat, 8 Oct 2022 at 22:46, Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> This year I wrote a function something like as follows:
>
> long unsigned Func(long unsigned &arg)
> {
> return arg + 5u;
> }
>
> You can see that 'arg' isn't altered by this function, and so the
> function parameter type could be made a reference to const. I left it
> as non-const though, because I didn't want someone to be able to do
> the following:
>
> short unsigned k = 7u;
>
> Func(k);
>
> I didn't want the implicit conversion from rvalue to "reference to const".
>
> I think there should be a way of telling the compiler to disallow this
> implicit conversion when passing arguments to a function
long unsigned Func(std::same_as<long unsigned> auto const& arg);
(Also, "unsigned long", please.)
, for example
> using the caret symbol as follows:
>
> long unsigned Func(long unsigned const &^arg)
> {
> return arg + 5u;
> }
>
> With regard to parsing and globbing, the two symbols & and ^ side by
> side could be globbed together as one token, and could be also be used
> as follows:
>
> int main(void)
> {
> int n= 4;
>
> int const &^x = n; // This is fine, it compiles
>
> int const &^y = 7; // This fails to compile (no implicit
> rvalue conversion)
>
> int const &z = n;
>
> int const &^w = z; // This is allowed (because z is an
> lvalue)
>
> int const &b = 73;
>
> int const &^c = b; // This is allowed (even though it
> started out as an rvalue)
> }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
std-proposals_at_[hidden]> wrote:
> This year I wrote a function something like as follows:
>
> long unsigned Func(long unsigned &arg)
> {
> return arg + 5u;
> }
>
> You can see that 'arg' isn't altered by this function, and so the
> function parameter type could be made a reference to const. I left it
> as non-const though, because I didn't want someone to be able to do
> the following:
>
> short unsigned k = 7u;
>
> Func(k);
>
> I didn't want the implicit conversion from rvalue to "reference to const".
>
> I think there should be a way of telling the compiler to disallow this
> implicit conversion when passing arguments to a function
long unsigned Func(std::same_as<long unsigned> auto const& arg);
(Also, "unsigned long", please.)
, for example
> using the caret symbol as follows:
>
> long unsigned Func(long unsigned const &^arg)
> {
> return arg + 5u;
> }
>
> With regard to parsing and globbing, the two symbols & and ^ side by
> side could be globbed together as one token, and could be also be used
> as follows:
>
> int main(void)
> {
> int n= 4;
>
> int const &^x = n; // This is fine, it compiles
>
> int const &^y = 7; // This fails to compile (no implicit
> rvalue conversion)
>
> int const &z = n;
>
> int const &^w = z; // This is allowed (because z is an
> lvalue)
>
> int const &b = 73;
>
> int const &^c = b; // This is allowed (even though it
> started out as an rvalue)
> }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2022-10-08 21:52:47