Retrieving the type of auto in C++11 without executing the program

后端 未结 5 1510
悲&欢浪女
悲&欢浪女 2021-01-11 10:10

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

5条回答
  •  不知归路
    2021-01-11 10:43

    As auto is known at compile-time, you need to interoperate with the compiler.

    One option would be the Clang compiler's LibTooling library that provides infrastructure that you can base static analysis tools on. For example, look at their refactoring example code that removes superfluous .c_str() calls from the code. I think you could write a similar tool that converts auto into the inferred type.

提交回复
热议问题