Effective Modern C++ is a book I reviewed a while back. It described the limitations of auto type deduction. One area where this deduction issue may easily surface is in the use of strings you may want to convert to char*. While it may be ideal to totally exit from the use of const char*, well, that is not reality. I was in the midst of making a block of code more generic so I didn’t have to repeat myself and happened upon an issue with std::string. The code that resulted in the above message had the following form:
Auto type deduction does simplify many aspect of code but may not receive thorough treatment by compilers. More code like this is featured in my article, Building a Cross Platform C++ Program with SFML. In that article, I am creating a program that is defined in C++11 which is a great help in streamlining the program’s definition. Use of the auto keyword is one of those areas and as you see, it seems that unless you are satisfied with passing variables of type std::string to functions that accept just that type, you will undoubtedly be best served by declaring the type of std::string in C++11.