Let's say I have a class that is just a thin wrapper over a pointer and the only thing the class does is call delete in the destructor like an auto pointer.However, it also has an operator that automatically dereferences, so I can pass it around in functions that take const references and then I make as much as my functions as possible to take in const references.I have 3 questions about this scenario:
1.Is it certain that the compiler(MSVC in release mode with all possible optimizations enabled) will inline every wrapper method and allow the pointer to have the same performance as a raw pointer?(It's hard to benchmark pointers since I get a lot of memory fragmentation when I test different types, so I'm not sure how to test them, but I've seen 100% identical performance between my array container and raw arrays, so I assume this should happen to the pointer wrapper too with exception to the part where it gets deleted when it goes out of scope)
2.Will the compiler optimize away the useless dereferencing from the wrapper's opereator if/when it realizes they're passed by references(which are basically pointers again)
3.Will passing everything around as const references improve performance?A lot of sources, like this for instance ftp://ftp.sgi.com/sgi/audio/audio.apps/dev/aliasing.html talk about how you can make the compiler's job easier by pretty much restricting and/or constifying inputs everywhere.(maybe I'm not getting it right).
Also it's extremely convenient not to have to manually delete every member in the destructor when you use the auto pointer for class members.I'm just worried about the performance impact.