Usually, if you want to use the virtual template method, it means that something is wrong with the design of your class hierarchy. The following is a high level reason.
Template parameters must be known at compile time what their semantics are. They are used to guarantee the sound quality of your code.
Virtual functions are used for polymorphism, i.e. dynamic dispatch at runtime.
Thus, you cannot mix static properties with dispatch at runtime, it does not make sense if you look at the big picture.
Here, the fact that you are storing something somewhere somewhere should not be part of the type of your method, since it is just a behavioral attribute, it can change at runtime. Therefore, it is incorrect to include this information in the type of method.
This is why C ++ does not allow this: you must rely on polymorphism to achieve this behavior.
One simple way is to pass a pointer to the Storage object as an argument (singleton if you need only one object for each class), and work with this pointer in a virtual function.
Thus, your type signature does not depend on the specific behavior of your method. And you can change the retention policy (in this example) at runtime, which is really necessary for you to recommend as good practice.
Sometimes the behavior may be dictated by template parameters (for example, Alexandrescu template parameters), but it is at the level level, and not at the method level.
source share