In a project that still uses pre-C++11 I wanted to prepare the source for the switch by compiling with a C++11 compiler and fixing the errors. They consisted of
- instances of
std::auto_ptr<T>
replaced withstd::unique_ptr<T>
- where necessary, wrapped the smart pointer with
std::move()
- some
0
andNULL
replaced withnullptr
Now I want to switch back to a pre-C++ compiler and write a macro that can switch back the changes, so that, when the time for the final compiler switch is there, I simply remove the macro. I tried
#ifndef HAVE_CXX11
#define nullptr NULL
namespace std {
#define unique_ptr<exvector> auto_ptr<exvector>
}
#endif
(with exvector
an example type used with the smart pointer) This and similar attempts don't work because macros can't change template types. I also used typedef
with no better results.
Is this possible at all and, if so, how?
Aucun commentaire:
Enregistrer un commentaire