There's a class template that I would like to deprecate in my project.
template<typename T, size_t Size>
class X {};
I've come up with a following scheme to do that.
Stage 1
For next release - let's say version "5" - I'm going to provide the "new" class with different name (the replacement) and convert the old one to a deprecated alias:
template<size_t ElementSize, size_t Size>
class X2 {};
template<typename T, size_t Size>
using X __attribute__ ((deprecated)) = X2<sizeof(T), Size>;
This will cause a warning for all users of the "old" API, but the code will still work.
Stage 2
In the next version - "6" - I'm going to remove the "old" deprecated class, rename the "new" one to the old name and create a deprecated alias:
template<size_t ElementSize, size_t Size>
class X {};
template<size_t ElementSize, size_t Size>
using X2 __attribute__ ((deprecated)) = X<ElementSize, Size>;
This will again cause the warning for the users.
Stage 3
In this final step - done in version "7" - I'll remove the deprecated alias, leaving only the changed class.
template<size_t ElementSize, size_t Size>
class X {};
This whole scheme has some pros (at each stage the code compiles and works, only warning is issued for deprecated interface) and cons (the users are forced to change their code twice). However I did not come up with anything better - all other options I considered involve a compilation error at some point. The main problem I'm facing here is that I would like to keep the name of the class (in the final stage), but change the template "signature" from <type, value>
to <value, value>
, which (as I assume) precludes all other clever options...
Is there any better option? If not, does the above scheme seem "acceptable", or maybe I should just cause one single compilation failure and be done with that? The project is in an early stage of development, so I'm not very much concerned about backward compatibility, but I thought this is a very good opportunity to try out the whole process.