-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use a class to wrap or derive from a sizeless vector type #305
Comments
I guess the strong typedef concept has the advantage of working in C if used alongside |
Hi @sh1boot I think there are fundamental issues with wrapping sizeless types in structs ( see for instance #238 (comment) ) which I understand are beyond the scope of this specification. While it may be possible to somehow wrap a buffer that allocates With some elbow grease it is possible to write some reasonable wrapper, but one has to be mindful of unnecessary allocations as this is not that different to a |
Hi @sh1boot , FWIW Highway has parallel types: one for the vector, which may be a builtin, and one plain/empty C++ class used only to describe the vector type. The latter can be used for overloading. Would that help your use-case? |
Well, I think the current RVV vector types demonstrate by their own existence how to answer each of these questions individually. You just forward all of the problems on to the derived class. That is to say, given something like Of course the trouble there is that the value of the type is stored at Alternatively
I think by the time you apply that much effort you might as well set intrinsics aside and lean right in to autovectorisation, though, right? |
Splitting out of my comment in #238.
Despite the fact that vector types are sizeless (unless you apply a type attribute (#176)), it's still useful to be able to abstract the types into something else, sharing the same limitations as the base vector type.
This would allow the addition of static data and utility functions which don't interfere with the sizeless property, and it would allow the type to be distinguished for function overloading (like Boost's strong typedef).
If it's really not possible to use a class, then I suppose an alternative would be the above 'strong typedef' concept as a type attribute; so it's at least possible to create the abstract type and then implement the utilities externally in template and function overloads.
I think in either case there's the problem of inheriting the ability to be passed to established intrinsic overloads without extra faff, while still being distinct types for new overloads.
This is not the first time I've had problems with attaching things to magic types. It's really a broader problem with the languages, but it would be nonsense to make a generic request for a language extension without reference to a specific problem case. So I'm starting here.
The text was updated successfully, but these errors were encountered: