From 4f57e765e5a9839baac78bd3a77fd2986b0e484e Mon Sep 17 00:00:00 2001 From: Steve Wills Date: Thu, 15 Jun 2017 14:06:24 -0400 Subject: [PATCH] Fix type error in build Compilation fails on clang 3.4.1 (and presumably later, tho I haven't tested) with ``` src/reader.cpp:131:59: error: no viable conversion from 'iterator' (aka '__map_iterator') to 'std::map::const_iterator' (aka '__map_const_iterator') std::map::const_iterator it = counterMap.find("text/html"); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/v1/map:713:29: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'iterator' (aka '__map_iterator') to 'const std::__1::__map_const_iterator, unsigned int>, std::__1::__tree_node, unsigned int>, void *> *, long> > &' for 1st argument class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator ^ ``` because we are not using the right type for the map iterator. As we are using C++11, let's use `auto` and make compiler set the right type for us. --- src/reader.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index bfd3e78b8..d224bf6b3 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -128,7 +128,7 @@ namespace kiwix { if (counterMap.empty()) { counter = this->nsACount; } else { - std::map::const_iterator it = counterMap.find("text/html"); + auto it = counterMap.find("text/html"); if (it != counterMap.end()) counter = it->second; } @@ -144,9 +144,7 @@ namespace kiwix { if (counterMap.empty()) counter = this->nsICount; else { - std::map::const_iterator it; - - it = counterMap.find("image/jpeg"); + auto it = counterMap.find("image/jpeg"); if (it != counterMap.end()) counter += it->second;