A function to handle multiple datatypes

Casting a template argument in a generic function to a void pointer is a bad practice. You've created a function that allegedly sends anything. It will work with the intrinsic types and it will work with some class types, but it will definitely not send anything (although it will always send something, whether it makes sense or not).

The question that begs asking is, what data type are you attempting to transmit that requires casting to a void pointer (and then to a byte pointer)?

Your template function should be relying on either an overloaded Serial.write() method for sending the passed in data, or the user passing in the data in a form that is compatible with the Serial.write() method. You're hiding a void cast inside a generic function. Just to reiterate, bad practice.

Your function would basically allow all sorts of nonsense code to compile. ie:

sendAnything(Serial);
sendAnything(someComplexList);
etc.

A more appropriate function name would be sendAnythingViaVoid_EvenIfItDoesntMakeSense().

Well sorry, but actually, I do want to break type checking in some cases. And I do. And that is precisely what void* is for, both in C and C++ -- to work with a pointer without a type.

The cases to break type safety are when there are no better options available. This is NOT one of those cases.

But if sharp objects make you nervous, you can always choose to use the safety scissors instead. Choices are good.

Choices are indeed good. Veiled petty insults... another story.