im confused your initial example was simple addition.
so maybe i should reword my question
can you provide a use case where something like this should be applied generically ?
as far as i understand numeric types have little quirks that make this annoying to deal with. so why should it be generic?
also it really doesn't take much effort to implement this yourself.
If you start making interfaces I'm worried about the performance.
when done right the performance hit due to interfaces should be neglible.
Then you have functions to process the image data, but they can work for any size of data and I'd like to just pass an array of any type and be done with it (using generics) but that doesn't work.
i feel like a better answer to this would be something like overloading.
Yeah I could do overloading, but then I'm literally copy pasting the same function five times with research and replace on types. That's really not ideal.
I just want "generic over any numeric type". Remove the need for overloading something that is trivial to do.
Well it can change them into shorts for the intermediate calculations then I can cast it back to a byte if I want. Or just make it return a byte anyway in this case.
I'd love to have compile time generics for that (with compile time reflection), but should I really have to use C++CLI for this?
2
u/AdministrationWaste7 Apr 16 '21
im confused your initial example was simple addition.
so maybe i should reword my question
can you provide a use case where something like this should be applied generically ?
as far as i understand numeric types have little quirks that make this annoying to deal with. so why should it be generic?
also it really doesn't take much effort to implement this yourself.
when done right the performance hit due to interfaces should be neglible.
i feel like a better answer to this would be something like overloading.