I am using std::count() in my code. My code is successfully build in windows but I am unable to compile this under Solaris,
Complete function is given below,
unsigned int
BBGENTVerify::tokenizeTickerEID(const std::string p_czTickerEIDs,\
std::vector<int>& p_rTickerEIDsVector){
int l_iStartPos = -1;
int l_iEndPos = -1;
unsigned int l_iEIDsPresent = std::count(p_czTickerEIDs.c_str(), \
p_czTickerEIDs.c_str() + p_czTickerEIDs.size(), ',') + 1;
do{
l_iEndPos = p_czTickerEIDs.find(",", l_iStartPos + 1);
if (l_iEndPos == -1){
l_iEndPos = p_czTickerEIDs.size() - l_iStartPos;
}
p_rTickerEIDsVector.push_back(atoi\
(p_czTickerEIDs.substr(l_iStartPos +1, l_iEndPos).c_str()));
l_iStartPos = l_iEndPos;
}while(p_rTickerEIDsVector.size() < l_iEIDsPresent);
return p_rTickerEIDsVector.size();
}
I am getting error,
"src/fileENTForP.cpp", line 136: Error: Could not find a match for std::count<std::InputIterator, std::T, std::Size>(const char*, const char*, char) needed in BBGENTVerify::tokenizeTickerEID(const std::string, std::vector<int>&).
1 Error(s) detected.
clearmake: Error: Build script failed for "release/sun_solaris64/BBGENTVerify.o"\
This code is successfully compiled in windows platform. I did some investigation and found that Solaris complier is somehow taking some other template signature, with one extra parameter.
Error: Could not find a match for std::count<std::InputIterator, std::T, std::Size>
(const char*, const char*, char)
whereas standard says the signature,
template <class InputIterator, class T>
typename iterator_traits<InputIterator>::difference_type
count (InputIterator first, InputIterator last, const T& val);
Code is expecting this signature
std::count<std::InputIterator, std::T, std::Size>
where as I am using/also what standard C++ supports,
template <class InputIterator, class T>
std::count(InputIterator first, InputIterator last, const T& val);
Please help me with this code.
It seems you are using a version of the RogueWave standard C++ library (this library is still the default although the STLport version is the recommended one). This implementation demands an initial value for the count:
The background is that the idea of
std::iterator_traits
wasn't around when this implementation first shipped!When I encountered this problem I have created an auxiliary header which just forwarded the algorithm call in a consistent way:
(the code is typed on a mobile device and probably contains some errors; I'm especially not sure about the proper macro to test).
In the actual code I would the consistently use
aux::count()
.