0

The following repo compiles fine:

#include <tuple>
#include <vector>

class Foo
{
public:

    typedef std::tuple<int, int> foo_type;

    std::vector<foo_type>::iterator Find() {
        return Listeners.begin();
    }

    std::vector<foo_type> Listeners;
};

int main() 
{
    Foo foo;

    auto i = foo.Find();
}

But when I template the tuple on P, Q as in the following repo, I get this error:

syntax error : missing ';' before identifier 'Find'

#include <tuple>
#include <vector>

template<typename P, typename Q>
class Foo
{
public:

    typedef std::tuple<P, Q> foo_type;

    std::vector<foo_type>::iterator Find() {
        return Listeners.begin();
    }

    std::vector<foo_type> Listeners;
};

int main()
{
    Foo<int, int> foo;

    auto i = foo.Find();
}
Robinson
  • 9,666
  • 16
  • 71
  • 115

1 Answers1

2

You're missing a typename here:

typename std::vector<foo_type>::iterator Find() {
^^^^^^^^
    return Listeners.begin();
}

For a more detailed description, see Where and why do I have to put the "template" and "typename" keywords?

Community
  • 1
  • 1
Barry
  • 286,269
  • 29
  • 621
  • 977