I have this function to set a variable to some 'default':
template <class T> inline T Default() { return T(); }
Now, if T is a large type, I don't want it to be return by value. While the function is short, it might also be called a lot.
Can I be sure that the compiler will leave this as inline as it could be very bad if it isn't. (In case it matters, this function is declared and implemented in a header file.)
Ah yes, I forgot about RVO... it should be fine then.
As for why I have this function, it's this: I have a template class template <class resource, class loaddata, void (*loader)(resource&, const loaddata&)> class ResourceManager;
If the user loads a resource without providing loading data, the defaults must be generated. Suppose this is some type whose default constructor doesn't load the defaults the user wants (and is out of his/her control) then he/she can specialise this function for their type and the ResourceManager will get the right default value.