Skip to content
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

Open
sh1boot opened this issue Dec 23, 2023 · 1 comment
Open

How to use a class to wrap or derive from a sizeless vector type #305

sh1boot opened this issue Dec 23, 2023 · 1 comment

Comments

@sh1boot
Copy link

sh1boot commented Dec 23, 2023

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.

@sh1boot
Copy link
Author

sh1boot commented Dec 23, 2023

I guess the strong typedef concept has the advantage of working in C if used alongside _Generic().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant