Date: Mon, 13 May 2024 11:05:52 +0200
Hi,
Il 13/05/24 09:45, Ahmed Elbadawy via Std-Proposals ha scritto:
> Currently, using |std::any| requires explicit casting using
> |std::any_cast |but adding a conversion function to |std::any| will
> allow users to convert the stored value to a specified type directly,
> without the need for |std::any_cast| which will
>
> 1. Improve Readability: The proposed conversion function makes code
> more readable by eliminating the need for explicit casts.
You need to bring more data to this discussion. Why are explicit casts
"bad"? Why do they hinder readability? Why does C.164 say to avoid
implicit casts?
> 2. Simplified Usage: Developers can use the conversion function
> directly, reducing the complexity of working with |std::any|.
Ditto.
> Considering the scenario where |std::any|is used as an argument to an
> overloaded function.
Why does the function need to be overloaded? What's in the overload set?
> With the proposed conversion function, we can use
> the builtin *static_cast*which is more convenient to be used than the
> template function *std::any_cast.*
Once more, [citation needed].
Are
* static_cast<type>(foo)
* std::any_cast<type>(foo)
really *that* different?
Besides, you're proposing to even avoid the static_cast entirely because
your conversion operator is *implicit*. Now you have an implicit
conversion operator which may throw an exception, that sounds very bad
to me.
My 2 c,
--
Giuseppe D'Angelo
Il 13/05/24 09:45, Ahmed Elbadawy via Std-Proposals ha scritto:
> Currently, using |std::any| requires explicit casting using
> |std::any_cast |but adding a conversion function to |std::any| will
> allow users to convert the stored value to a specified type directly,
> without the need for |std::any_cast| which will
>
> 1. Improve Readability: The proposed conversion function makes code
> more readable by eliminating the need for explicit casts.
You need to bring more data to this discussion. Why are explicit casts
"bad"? Why do they hinder readability? Why does C.164 say to avoid
implicit casts?
> 2. Simplified Usage: Developers can use the conversion function
> directly, reducing the complexity of working with |std::any|.
Ditto.
> Considering the scenario where |std::any|is used as an argument to an
> overloaded function.
Why does the function need to be overloaded? What's in the overload set?
> With the proposed conversion function, we can use
> the builtin *static_cast*which is more convenient to be used than the
> template function *std::any_cast.*
Once more, [citation needed].
Are
* static_cast<type>(foo)
* std::any_cast<type>(foo)
really *that* different?
Besides, you're proposing to even avoid the static_cast entirely because
your conversion operator is *implicit*. Now you have an implicit
conversion operator which may throw an exception, that sounds very bad
to me.
My 2 c,
--
Giuseppe D'Angelo
Received on 2024-05-13 09:05:57