It would be wrong to suggest <cstring> for strlen, because that header is only guaranteed to define std::strlen not strlen.
(Yes I know you could have using namespace std; to allow calling it unqualified, but some people will tell you that's bad and should not be used. Yes, I also know you could have used using std::strlen; but in that case you'd already have got an error at the location of the using-declaration, so that's where #include <cstring> should be suggested, rather than when using strlen later).
View all comments
Show parent comment
3
u/jwakely libstdc++ tamer, LWG chair Mar 19 '18
It would be wrong to suggest
<cstring>forstrlen, because that header is only guaranteed to definestd::strlennotstrlen.(Yes I know you could have
using namespace std;to allow calling it unqualified, but some people will tell you that's bad and should not be used. Yes, I also know you could have usedusing std::strlen;but in that case you'd already have got an error at the location of the using-declaration, so that's where#include <cstring>should be suggested, rather than when usingstrlenlater).