Is there a simple way to check if my template has been optimized out? After using #define HIDE_IT the code in play is below. I’m sure this code is optimized out so i get 0 overhead from defining Property<SomeType> but i like to check if possible (without going into assembly. Trivial code is hard enough to read after the optimizer passes through it)
template <class T>
class Property {
T v;
Property(Property&p) { }
public:
Property() {}
T operator=(T src) {
v = src; return v;
}
operator T() const {
return v;
}
T operator->() { return v; }
T operator++() { return ++v; }
template<class U>
T operator+=(U u) { return v+=u; }
T get() { return v; }
}
There’s no other way other than looking at the assembly. The only way it can be “optimised out” is by inlining those functions, and you can only check that by looking at the source.
That being said, on any modern compiler you can be pretty sure that those functions will be inlined in optimised code.