No matching function find in gcc 4.6

Discussion in 'C++' started by kuangye, May 23, 2011.

  1. kuangye

    kuangye Guest

    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<class Container> decltype (c-
    >iterator) findFirst(Container&&, typename Container::value_type,

    typename Container::value_type)
    test_erro1.cpp:18:29: error: unable to deduce ‘auto’ from ‘<expression
    error>’
     
    kuangye, May 23, 2011
    #1
    1. Advertising

  2. kuangye

    Marc Guest

    kuangye wrote:

    > #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?

    > test_erro1.cpp:7:124: note: template<class Container> decltype (c-
    >>iterator) findFirst(Container&&, typename Container::value_type,

    > typename Container::value_type)
    > test_erro1.cpp:18:29: error: unable to deduce ‘auto’ from ‘<expression
    > error>’


    Yup, compiler says the same thing.
     
    Marc, May 23, 2011
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    437
  2. Kevin P. Fleming

    C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1

    Kevin P. Fleming, Nov 6, 2003, in forum: C Programming
    Replies:
    2
    Views:
    649
    Kevin P. Fleming
    Nov 6, 2003
  3. Replies:
    5
    Views:
    365
    Nathan Addy
    Sep 17, 2005
  4. ashnin

    GCC 3.4.3 and GCC 4.1.2

    ashnin, Jul 7, 2008, in forum: C++
    Replies:
    1
    Views:
    529
    Michael DOUBEZ
    Jul 7, 2008
  5. nani
    Replies:
    2
    Views:
    170
    comp.llang.perl.moderated
    Mar 14, 2008
Loading...

Share This Page