@deezo

4 Followers
25 Following
144 Posts
@crazyeddie keep going, C++26 is awesome 😎
@crazyeddie you might still need to extract the function that creates the span to use it it a constexpr context, but the need for constexpr variables is significantly reduced by `meta::substitute` and `meta::extract`.
In my personal experience, it takes some time to get used to the new ways, even if you have a significant experience in the pre-C++26 metaprogramming.
@crazyeddie `std::span` returned by `std::define_static_array` doesn't refer to the original vector. You can pass almost arbitrary range into it, and you still get a span.
The retuned span is a span over static array (just as the title suggests 😂). The main limitation is that the element type must be something that can be used as constant template parameter.
You might benefit from watching some practical examples (https://youtu.be/ZX_z6wzEOG0?si=YlWb7RCh0UCrjKLA this is a cppcon talk by Barry Revzin)
Practical Reflection With C++26 - Barry Revzin - CppCon 2025

YouTube
@crazyeddie the most easy way at the moment is probably `std::define_static_array` and `std::define_static_string`

@kimapr
> cast random pointers left and right

TBH that's how I see C programming in a nutshell 😂

@kimapr I think another factor is that C might be more forgiving when casting stuff.
@kimapr Reading into it more carefully, I still think it's UB, but my initial reasoning was incorrect.
An object can be treated as an array of size 1.
But adding any integral value j to the pointer to i'th element that will result in (i+j) outside of array bounds of the array is UB (even without access).
So you can only create span<sigma> of size 1 from ligma.
@kimapr
I misunderstood the initial question, sorry about that.
I do think it's technically UB for the case with arrays. I think the relevant part is 7.6.6 Additive operators. Pointer addition is defined for pointer P if it is a pointer to an array element. Since there's no array of sigmas, it's UB.
I'm not a standard expert, I am studying it myself, please verify :)
Do you need the `std::span` specifically? Some range adaptor would be legal and likely as performant with optimizations enabled.
@kimapr you can reinterpret_cast between pointers to `pointer-interconvertible` types.
If ligma is a standard-layout class, you can cast a pointer to ligma object to pointer to it's first member's type.
[basic.compound] in standard spec
You should check the requirements for standard layout and see if you can satisfy them
@mkretz
Not using, just curious. Do You know which tool that Codacy runs gives the most false positives?
Emulating simd seems to be a pretty low level code with raw pointers, the most memory-dangerous kind.
Might be the reason for amount of warnings for this project.