Hello Andrei,
BCS wrote:
so use ubyte, insert a cast, and call it a day. If you have too many
casts, the problem is most likely elsewhere
You might be correct, but I don't think any of us have enough info
right now to make that assertion.
Oh there is enough information. What's needed is:
const(ubyte)[] getRepresentation(T)(T[] data)
{
return cast(typeof(return)) data;
}
If you have many calls to getRepresentation(), then that
anticlimatically shows that you need to look at arrays'
representations often. If there are too many of those, maybe some of
the said arrays should be dealt with as ubyte[] in the first place.
Maybe in some cases but if the primary function of the code is processing
stuff between "raw data" and other data types than the above is irrelevant.
The OP sort of hinted somewhere that this is the kind of thing he is working
on. Without knowing what the OP is doing, I still don't think we can say
if his program is well designed.