Garrett
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Был шаблон, которым я печатал сеты и ключи мультимапов. Код: template <typename T> inline void PRINT_ELEMENTS( FILE* fs, const T& coll, const char* szTitle = "" ) { int k = 0; fprintf( fs, szTitle ); typename T::const_iterator pos; for( pos = coll.begin(); pos != coll.end(); ++pos ) { if ( k > 10 ) { k = 0; fprintf( fs, "\n " ); } ++k; fprintf( fs, " %4u", *pos ); } fprintf( fs, "\n" ); } | Но с переходом на VS2017 и выставления стандарта с++17, компилятор дает предупреждения Код: warning C4477: 'fprintf' : format string '%4u' requires an argument of type 'unsigned int', but variadic argument 1 has type 'const std::pair<const _Kty,_Ty>' 1> with 1> [ 1> _Kty=int, 1> _Ty=int 1> ] note: see reference to function template instantiation 'void PRINT_ELEMENTS<std::multimap<int,int,std::less<int>,std::allocator<std::pair<const _Kty,_Ty>>>>(FILE *,const T &,const char *)' being compiled 1> with 1> [ 1> _Kty=int, 1> _Ty=int, 1> T=std::multimap<int,int,std::less<int>,std::allocator<std::pair<const int,int>>> 1> ] | как избавиться от предупреждений или правильней написать код функции? | Всего записей: 2740 | Зарегистр. 16-10-2003 | Отправлено: 11:16 15-01-2019 | Исправлено: Garrett, 11:20 15-01-2019 |
|