Vladimir Grigoriev
2009-11-17 14:06:27 UTC
There is a function template in the std namespace. And a function with the
same name is defined in a program. Is it correct that the compiler issues an
error about ambiguous call then the function is called without std:: prefix?
For example
#include <functional>
template <typename InputIterator, typename T>
inline const T accumulate( Input Iterator first, InputIterator last, const T
&val )
{
T result = val;
for ( ; first != last; ++first )
{
result = result + *first;
}
return ( result );
}
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> vi;
...
int sum = accumulate( vi.begin(), vi.end(), 0 ); // <== here is the
error
...
return 0;
}
Vladimir Grigoriev
same name is defined in a program. Is it correct that the compiler issues an
error about ambiguous call then the function is called without std:: prefix?
For example
#include <functional>
template <typename InputIterator, typename T>
inline const T accumulate( Input Iterator first, InputIterator last, const T
&val )
{
T result = val;
for ( ; first != last; ++first )
{
result = result + *first;
}
return ( result );
}
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> vi;
...
int sum = accumulate( vi.begin(), vi.end(), 0 ); // <== here is the
error
...
return 0;
}
Vladimir Grigoriev