Conversation
|
|
I think |
include/iris/type_traits.hpp
Outdated
| // is_assignable_without_narrowing<Dest, Source> | ||
| // | ||
| // True when `Dest = Source` is valid AND does not involve a narrowing conversion. | ||
| // For non-arithmetic Dest types, narrowing is not checked — we trust that the |
There was a problem hiding this comment.
For non-arithmetic Dest types, narrowing is not checked
Why? This doesn't make sense at all.
"—" is a very bad sign for vibe coded slop. Please, please double check both the description and code itself.
Do you really think "not is arithmetic" can be the constituent part for being "assignable without narrowing"?
Arithmeric types are just arithmeric types. There should be absolutely no direct relationship to the concept of "assignable", whatever the condition is.
Am I missing something?
I'm really disappointed to see this level of low quality code.
There was a problem hiding this comment.
As noted in the clarification, is_assignable_without_narrowing itself was for detecting narrowing conversion, so it was just is_assignable for non-arithmetic types. The "mistake" was that the trait was used directly in X4 codebase, not the trait definition.
I admit that the clarification was missing, but before saying "vibe coded slop" or "low quality code", rethink about it.
|
I just realized that even the implementation for This mistake was not caught on my first review because I trusted your code initially. It seems like I have to be extra careful since you posted some AI coded crap! |
The former implementation DID work except for void to void "conversion" BTW. The differences from original were:
The first is just styling difference. The original reference implementation fails on void to void case too, so implementing the exact same trait is also wrong, yet the author already mentions about it. |
| template<class T> | ||
| auto operator()(Ti, T&&) -> aggregate_initialize_tag<I, Ti> | ||
| requires requires(T&& t) { { TiA{std::forward<T>(t)} }; } // emulate `Ti x[] = {std::forward<T>(t)};` | ||
| requires is_convertible_without_narrowing_v<T, Ti> |
There was a problem hiding this comment.
I think the first parameter Ti can be omitted, as it existed for checking is_convertible by passing-by-value
There was a problem hiding this comment.
No, the Ti parameter cannot be omitted, since we should consider overload resolution for Ti including implicit conversion sequence's priority.
For example, constructing rvariant<int, long> from int should be resolved to index() == 0 though both int and long are equally convertible from int without narrowing. This is because identity conversion should occur prior to integral promotion in standard conversion.
This reverts commit 1380b7e.
fixes #5
The array form
To[]is specifically chosen over the simplerTo{from}because the latter can accidentally select aggregate initialization ofToitself (ifTois an aggregate) or match a constructor takingstd::initializer_list, both ofwhich would mask the actual narrowing behavior. Since
To[]is always an aggregate regardless of whatTois, the braced initialization applies uniformly to the element type and tests exactly what we want: whetherFromcan becopy-initialized into a
Toslot without narrowing.