Maybe a strange question, but is there any software available which, given a bunch of c++11 code, derives all types of the auto-typed variables and rewrites the code with those derived types? And also for initializer lists?
The reasoning is that we would like to provide a backwards compatible version of our code (non C++11), mainly for portability with osx. Auto-typing and initializer lists are the features we use most as they make the code a lot more readable, but removing them by hand is a no-go. As this is in fact what the compiler does with auto-typed variables, it does not seem too far-fetched?
Look at BOOST_AUTO and/or BOOST_TYPEOF
You could substitute
auto x = foo();
with
BOOS_AUTO(x, foo());
If you wanted to 'manage' a decltype you'd have to resort to BOOST_TYPEOF. Note that both macros have some variants that you will want to read more about
If you can use Boost, then you might look at boost::typeof. It won't do exactly what auto
does, but, in most cases, it can be automatically substituted via a regex-with-captures search.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With