C++ std::map Error: 'template argument 2 is invalid' - How to Fix
The error message 'template argument 2 is invalid' typically occurs when you try to use an incorrect type as the second template argument in a std::map declaration.
The std::map template class in C++ requires two template arguments: the key type and the value type. For example, std::map<int, std::string> would create a map with integer keys and string values.
If you encounter the 'template argument 2 is invalid' error, it means that the type you are using as the second template argument is not valid for the std::map. To fix this error, you need to provide a valid type as the second template argument.
Here's an example of a correct std::map declaration:
std::map<int, std::string> myMap;
In this example, int is the key type, and std::string is the value type.
原文地址: https://www.cveoy.top/t/topic/huQ9 著作权归作者所有。请勿转载和采集!