The problem has nothing to do with a map, which is a constant: this is a warning because the returned version type const std::map::at()
is equal to const mapped_type&
. This code also gives a warning:
typedef void *DuplicateFn(); typedef std::map< int, DuplicateFn > DuplicateMapTy; DuplicateMapTy DuplicateFns;
Type of map re-display at
here
const DuplicateFn&
Although this warning does occur (although I'm not sure about this particular situation, it is justified by the standard), in this case there should be no harm to localize it locally for the code using the map or if you do not like the pragma hassle, wrap the function pointer in simple structure.
change , as Gorpek points out in the comment below, it is actually generated in this particular place, although the function is not used. It seems that the VS compiler is aggressive when looking for warnings: it considers declarations.
template< class T > struct CheckMe { const T& at()
stijn source share