c++ - call of overloaded *** <unresolved overloaded function type>)' is ambiguous -


please me how resolve error

template <typename inputlterator, typename outputlterator, typename predicate> outputlterator copy_if( inputlterator begin, inputlterator end, outputlterator destbegin, predicate p)  {     return remove_copy_if(begin, end,destbegin, not1( ptr_fun( p ) ) ); } template <class t> bool is_not_3( t val ) {     return val != 3; } void foo( ) {     vector<int> v;     v.push_back( 1 );     v.push_back( 2 );     v.push_back( 3 );     copy_if( v.begin( ), v.end( ), ostream_iterator<int>( cout, " " ), is_not_3<int> ); } 

and error saying : error: call of overloaded 'copy_if(std::vector::iterator, std::vector::iterator, std::ostream_iterator, )' ambiguous

rewrite statement

copy_if( v.begin( ), v.end( ), ostream_iterator<int>( cout, " " ), //...); 

like

::copy_if( v.begin( ), v.end( ), ostream_iterator<int>( cout, " " ), //...); ^^^ 

otherwise function conflicts standard algorithm std::copy_if

the problem arised due using derictive

using namespace std; 

pay attention function call in code snippet not syntaxically finished. forgot specify last argument.


Comments

Popular posts from this blog

Combining PHP Registration and Login into one class with multiple functions in one PHP file -

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -