I have a template function, that accepts a read-only parameter of the templated type. This is a library function for various platforms, from 8-bit (AVR8) to 32 bit (Cortex). How to pass this parameter?
template< typename T >
void f( const T p ){ ... }
template< typename T >
void f( const T & p ){ ... }
By value is (probably) more efficient for parameter types that are smaller than a pointer, by reference is (probably) more efficient for parameter types that are larger than a pointer, and/or expensive to copy.
Is there any standard way to abstract this choice, like
template< typename T >
void f( pass_efficiently< T > p ){ ... }
?