Date: Thu, 27 Jun 2024 13:59:16 -0400
On Thu, Jun 27, 2024, 1:10 PM Ville Voutilainen via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Wed, 26 Jun 2024 at 23:17, Mateusz Pusz via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > During the discussion in the SG6 it was raised that that `30 *
> absolute<deg_C>` feels wrong, and I tend to agree with that. This was the
> only usage of `absolute` so, if multiply syntax should not use it, the
> `absolute` can be removed. After that, `30 * delta<deg_C>` looks like a
> hack and not a feature.
> >
> > I am looking for some other solutions that would help here. Maybe we
> should:
> > - disallow the multiply syntax for offset units (K, deg_C, deg_F),
> > - change `delta` to be a functor and call it as `delta<deg_C>(20)` which
> produces a `quantity`
> > - re-add `absolute` to create a `quantity_point` with the same syntax
> (e.g., `absolute<deg_C>`)
> >
> > With the above, we would end up with the following helpers:
> >
> > ```cpp
> > quantity q1 = 40 * m;
> > quantity q2 = delta<m>(40);
> > quantity_point q3 = absolute<m>(40);
> > quantity q4 = 40 * deg_C; // Compile-time error
> > quantity q5 = delta<deg_C>(40);
> > quantity_point q6 = absolute<deg_C>(40);
> > quantity q7 = 40 * isq::thermodynamic_temperature[deg_C]; //
> Compile-time error
> > quantity q8 = delta<isq::thermodynamic_temperature[deg_C]>(40);
> > quantity_point q9 = absolute<isq::thermodynamic_temperature[deg_C]>(40);
> > ```
> >
> > With the proposed change, I hope that is more evident what the following
> code does:
> >
> > ```cpp
> > quantity q = delta<K>(300);
> > quantity_point qp = absolute<K>(300);
>
> These look very clear to me.
>
> > static_cast(q.in(deg_C) != qp.in(deg_C).quantity_from_zero());
>
> This one less so. Also.. huh? static_cast to what?
>
Based on context, I'm guessing this was intended to mean `static_assert`.
> Why can't we just have a to_absolute<T>(U) ?
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
std-proposals_at_[hidden]> wrote:
> On Wed, 26 Jun 2024 at 23:17, Mateusz Pusz via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > During the discussion in the SG6 it was raised that that `30 *
> absolute<deg_C>` feels wrong, and I tend to agree with that. This was the
> only usage of `absolute` so, if multiply syntax should not use it, the
> `absolute` can be removed. After that, `30 * delta<deg_C>` looks like a
> hack and not a feature.
> >
> > I am looking for some other solutions that would help here. Maybe we
> should:
> > - disallow the multiply syntax for offset units (K, deg_C, deg_F),
> > - change `delta` to be a functor and call it as `delta<deg_C>(20)` which
> produces a `quantity`
> > - re-add `absolute` to create a `quantity_point` with the same syntax
> (e.g., `absolute<deg_C>`)
> >
> > With the above, we would end up with the following helpers:
> >
> > ```cpp
> > quantity q1 = 40 * m;
> > quantity q2 = delta<m>(40);
> > quantity_point q3 = absolute<m>(40);
> > quantity q4 = 40 * deg_C; // Compile-time error
> > quantity q5 = delta<deg_C>(40);
> > quantity_point q6 = absolute<deg_C>(40);
> > quantity q7 = 40 * isq::thermodynamic_temperature[deg_C]; //
> Compile-time error
> > quantity q8 = delta<isq::thermodynamic_temperature[deg_C]>(40);
> > quantity_point q9 = absolute<isq::thermodynamic_temperature[deg_C]>(40);
> > ```
> >
> > With the proposed change, I hope that is more evident what the following
> code does:
> >
> > ```cpp
> > quantity q = delta<K>(300);
> > quantity_point qp = absolute<K>(300);
>
> These look very clear to me.
>
> > static_cast(q.in(deg_C) != qp.in(deg_C).quantity_from_zero());
>
> This one less so. Also.. huh? static_cast to what?
>
Based on context, I'm guessing this was intended to mean `static_assert`.
> Why can't we just have a to_absolute<T>(U) ?
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2024-06-27 17:59:31