I have some C++11 code using the auto
inferred type that I have to convert to C++98. How would I go about converting the code, substituting in the actual type f
You could use typeid and std::type_info::name();
#include
#include
#include
int
main()
{
using namespace std::literals::complex_literals;
auto x = 3.1415F;
std::cout << typeid(x).name() << '\n';
auto z = 1.0 + 1.0i;
std::cout << typeid(z).name() << '\n';
}
$ /home/ed/bin_concepts/bin/g++ -std=c++14 typeid.cpp
$ ./a.out
f
St7complexIdE
The names aren't beautiful but you can at least translate them. These names are got from g++. The name is compiler dependent. There is some movement to standardize a pretty_name(). Here is a non-standard way to unmangle the names.