
20 Jan
2025
20 Jan
'25
6:33 p.m.
>> one potential recipe on how>> to deal with this in generic>> code above. > I'm not sure I understand this.> How can you have "generic code"> with different suffixes where there> are compilation failures that> would not be there in non-generic> code? > From "one data table for a type T"> I imagine something like > `T table[] = {1.25_df, 3.2_df, 51_df}` > So while your table type is generic> the constants used are not. You are right and my rhetoricwas flawed. In fact, that is exactly what I meant.My description got all confusedand was not quite right. You mightcast each table menber to T viastatic_cast, but that is the generalidea. Now one thing I am not confused aboutis that I do not want compilationerrors nor warnings if the clientputs not-enough/too-many digitsin the string literals. That wasthe main issue I was attemptingto debate. Thank you and good catch. - Chris On Monday, January 20, 2025 at 11:17:15 AM GMT+1, Alexander Grund via Boostwrote: Am 18.01.25 um 12:48 schrieb Christopher Kormanyos via Boost: > > Could you illustrate such a use case? > > Concretely, what do you mean by > > several widths of types? Do you > > mean decimal32 vs decimal64? > Yes. Let's say you made a program > that uses one data table for a type T that could be decimal32, 64 or 128. > But you only wanted one table. > You would make the table entries with the highest width suffix and decoratee ach table entry with a static-cast to T in order to get all the table entries into type T. > To be fair, everyone already has todo something like this with normal float, double and long double. >> With the syntax you have today, >> you already have distinct suffixes >> for each type (i.e. _df always constructs >> decimal32, _dd always constructs decimal64, >> and so on). > Yes. And I gave one potential recipe on how to deal with this in generic code above. My judgement may have been hurried and might seem unfair. > But my intuition tells me, a whole bunch of clients would run into compilation failures. Until they come up with their own recipes for generic literal values. > And the result would be more frustration than had we simply done nothing. I'm not sure I understand this. How can you have "generic code" with different suffixes where there are compilation failures that would not be there in non-generic code? From "one data table for a type T" I imagine something like `T table[] = {1.25_df, 3.2_df, 51_df}` So while your table type is generic the constants used are not. If the above errors due to using `1.25352397826723672375_df` you ought to use `_dd` to be able to use it in `decimal64 table[]` anyway. I don't see a scenario where it would be ok to truncate a constant and then store them in a type that would have been able to store the nun-truncated value. The other way round is more reasonable to use rounding/truncation when really required by the target type. Can you explain which case you had in mind? _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost