[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppVectorRemoveElementsTemplate
Prefer using an explicit declaration of T, see the warnings below.
This gives the warnings (in GCC compiler):
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppVectorRemoveElementsTemplate
Remove elements of a std::vector, templated function
template <class T>
void removeElements(std::vector<T>& myVector,
const T& myElement)
{
std::vector<T>::iterator i;
while (1)
{
i = find(myVector.begin(),myVector.end(),myElement);
if (i==myVector.end()) break;
myVector.erase(i);
}
}
This gives the warnings (in GCC compiler):
- implicit typename is deprecated, please see the documentation for details
- std::vector<T, std::allocator<_CharT> >::iterator' is implicitly a typename[/b]
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
