mirror of https://github.com/kiwix/libkiwix.git
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<typename __base::iterator>') to 'std::map<std::string, unsigned int>::const_iterator' (aka '__map_const_iterator<typename __base::const_iterator>') std::map<std::string, unsigned int>::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<typename __base::iterator>') to 'const std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::__value_type<std::__1::basic_string<char>, unsigned int>, std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char>, 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.
This commit is contained in:
parent
2bcd43af98
commit
4f57e765e5
|
@ -128,7 +128,7 @@ namespace kiwix {
|
|||
if (counterMap.empty()) {
|
||||
counter = this->nsACount;
|
||||
} else {
|
||||
std::map<std::string, unsigned int>::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<std::string, unsigned int>::const_iterator it;
|
||||
|
||||
it = counterMap.find("image/jpeg");
|
||||
auto it = counterMap.find("image/jpeg");
|
||||
if (it != counterMap.end())
|
||||
counter += it->second;
|
||||
|
||||
|
|
Loading…
Reference in New Issue