No matching function find in gcc 4.6

K

kuangye

Hi, all. I encountered a compiler error. But I don't know why??


#include <vector>
#include <iostream>
using namespace std;

template<typename Container>
auto findFirst(Container&& c, typename Container::value_type low,
typename Container::value_type high)->decltype(c.iterator){
//....
//try it
return c.begin();
}


int main(){
vector<int> vi={1,2,3,4};
auto it=findFirst(vi, 2, 4);
return 0;
}

//using gcc 4.6 here
~/shared/learn_code $ g++ -std=c++0x test_erro1.cpp
test_erro1.cpp: In function ‘int main()’:
test_erro1.cpp:18:29: error: no matching function for call to
‘findFirst(std::vector<int>&, int, int)’
test_erro1.cpp:18:29: note: candidate is:
test_erro1.cpp:7:124: note: template said:
iterator) findFirst(Container&&, typename Container::value_type,
typename Container::value_type)
test_erro1.cpp:18:29: error: unable to deduce ‘auto’ from ‘<expression
error>’
 
M

Marc

kuangye said:
#include <vector>
#include <iostream>
using namespace std;

template<typename Container>
auto findFirst(Container&& c, typename Container::value_type low,
typename Container::value_type high)->decltype(c.iterator){

c.iterator? What's that?
typename Container::value_type)
test_erro1.cpp:18:29: error: unable to deduce ‘auto’ from ‘<expression
error>’

Yup, compiler says the same thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top