c++ - Returning ::iterator from function does not compile -


this question has answer here:

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 = foo.find(); } 

but when template tuple on p, q in following repo, 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 = foo.find(); } 

you're missing typename here:

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

for more detailed description, see where , why have put "template" , "typename" keywords?


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -