Consider this
void f(vector& p)
{
}
int main()
{
vector nonConstVec;
f(nonConstVec);
}
The followi
As others have said, conversions aren't applied to the template parameters. Put another way,
vector
...and:
vector
... are completely different types.
If you are trying to implement const-correctness in regard to f() not modifying the contents of the vector, this might be more along the lines of what you're looking for:
void f(vector::const_iterator begin, vector::const_iterator end)
{
for( ; begin != end; ++begin )
{
// do something with *begin
}
}
int main()
{
vector nonConstVec;
f(nonConstVec.begin(), nonConstVec.end());
}