Copy elision is a neat optimization technique and in some cases relying on copy elision can actually be faster than passing around references "by hand".
So, let's assume you have identified a critical code path where you rely on the fact that the copy elision is performed by your compiler for the code path for maximum performance.
But now you are relying on a compiler optimization.
Is there any (compiler specific, obviously) way to ensure that the copy elision is actually performed and have the compiler (or another tool) generate a warning/error if the copy elision cannot be performed?
(I'm thinking of something remotely similar to Visual C++'s __forceinline
than will generate a warning if the function marked thus isn't inlined by the compiler.)