Gcc Error Non-template Used As Template
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to fix compile error: non-template 'iterator1' used as template [duplicate] up vote 2 down vote favorite This question already has an answer here: Where and why do I have to put the “template” and “typename” keywords? 5 answers i have some problem with a nested template class. The code compiles fine within VS2012, but fails in VS2013 and gcc 4.2.x: #include namespace utf { class klar{ //my test class public: template class iterator1 { int n; }; }; template< typename impl_t, typename utf_t > class tanga { int b; public: typedef typename utf_t::iterator1< typename impl_t::iterator > iterator2; tanga() { iterator2 i; } }; } typedef utf::tanga< std::string, utf::klar > Hugo; static const Hugo h; Any idea how to fix this problem? The error is: error: non-template 'iterator1' used as template typedef typename utf_t::iterator1< typename impl_t::iterator > iterator2; ^ c++ templates metaprogramming share|improve this question asked Jan 27 '14 at 10:15 muffmolch 164 marked as duplicate by juanchopanza, rene, Joseph Quinsey, Aurelius, sashoalm Mar 27 '14 at 15:34 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. add a comment| 1 Answer 1 active oldest votes up vote 4 down vote accepted You'll need to tell the compiler that iterator1 is a template with: typedef typename utf_t::template iterator1< typename impl_t::iterator > iterator2; share|improve this answer answered Jan 27 '14 at 10:17 Joseph Mansfield 74.1k9133228 works! thanks a lot! –muffmolch Jan 27 '14 at 10:22 add a comment| Not the answer you're looking for? Browse other questions tagged c++ templates metaprogramming or ask your own question. asked 2 years ago viewed 509 times active 2 years ago Linked 641 Where and why do I have
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why http://stackoverflow.com/questions/21378150/how-to-fix-compile-error-non-template-iterator1-used-as-template am I getting the error “non-template 'f' used as template” up vote 4 down vote favorite 1 I'm trying to understand where to use template and typename and I came across a problem I can't quite get around. I have a template-function f which uses the type passed to it (which will be a class) to call the template-member-function .f. I think my use http://stackoverflow.com/questions/12959250/why-am-i-getting-the-error-non-template-f-used-as-template of typename in the function body is correct, however, I keep getting the following error: source.cpp: In function 'void f()': source.cpp:11:19: error: non-template 'f' used as template source.cpp:11:19: note: use 'typename T::C::template f' to indicate that it is a template struct A { struct C { template void f() {} }; }; template void f() { typename T::C::f(); } int main() { f(); } Notice how on the last error it advises to use 'typename T::C::template f' instead. So I made the following change in accordance: // ... typename T::C::template f(); // ... I did as it said, but then I received the next line of error: error: no class template named 'f' in 'struct A::C' I believe this error is incorrect in that there is in fact a public template function named f in struct A::C. What could I be doing wrong here? c++ templates struct share|improve this question edited Oct 18 '12 at 16:31 Coding Mash 3,20451642 asked Oct 18 '12 at 16:23 template boy 4,0301956 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted Assuming we ma
Forgot Password Login: [x] User account creation filtered due to spam. Bug29469 - [DR 224] [4.2/4.3/4.4 Regression] error: non-template 'pair' used as template Summary: [DR https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29469 224] [4.2/4.3/4.4 Regression] error: non-template 'pair' used as template Status: RESOLVED FIXED Alias: None Product: gcc Classification: Unclassified Component: c++ (show other bugs) Version: 4.1.2 Importance: P2 normal Target Milestone: 4.3.4 Assignee: http://en.cppreference.com/w/cpp/language/member_template Jason Merrill URL: Keywords: rejects-valid Depends on: 9634 Blocks: 29607 Show dependency tree /graph Reported: 2006-10-14 17:37 UTC by Martin Michlmayr Modified: 2009-03-04 19:40 UTC (History) CC List: 6 gcc error users (show) debian-gcc fang gcc-bugs ismail jason mmitchel See Also: Host: Target: Build: Known to work: Known to fail: Last reconfirmed: 2009-03-04 16:54:14 Attachments testcase (410 bytes, text/plain) 2006-10-14 17:37 UTC, Martin Michlmayr Details View All Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description Martin Michlmayr 2006-10-14 gcc error non-template 17:37:12 UTC The following example code compiled fine with 4.1.2 20060901 (Debian 4.1.1-13) but fails with 4.1.2 20061007 (Debian 4.1.1-16). I'm wondering whether this change was intentional and whether there's a good reason for this change (in a stable branch). $ g++-4.1 -c pair.c x.c:32: error: non-template 'pair' used as template x.c:32: note: use 'avm_map::template pair' to indicate that it is a template Comment 1 Martin Michlmayr 2006-10-14 17:37:28 UTC Created attachment 12429 [details] testcase Comment 2 Andrew Pinski 2006-10-14 17:48:27 UTC The real question is avm_map dependent inside the nested class? I know there are C++ defect reports asking that question so ... Comment 3 Andrew Pinski 2006-10-14 18:11:30 UTC (In reply to comment #2) > The real question is avm_map dependent inside the nested class? > I know there are C++ defect reports asking that question so ... And that is DR 224 which is in WP. Comment 4 Andrew Pinski 2006-10-14 18:15:38 UTC I think this is more complicated than just DR 224. See PR 9634. Comment 5 Andrew Pinski 2006-10-14 18:25:16 UTC DR 224 says this is invalid code but GDR has ment
Strings library Containers library Algorithms library Iterators library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Filesystem library (C++17) Technical Specifications [edit] C++ language Templates parameters and arguments class templates function templates class member templates variable templates(C++14) template argument deduction class template deduction(C++17) explicit (full) specialization partial specialization dependent names parameter packs(C++11) sizeof...(C++11) fold-expressions(C++17) SFINAE Constraints and concepts(concepts TS) [edit] Template declarations (class, function, and variables (since C++14)) can appear inside a member specification of any class, struct, or union that aren't local classes. Run this code #include #include #include struct Printer { // generic functor std::ostream& os; Printer(std::ostream& os) : os(os) {} template void operator()(const T& obj) { os << obj << ' '; } // member template }; int main() { std::vector v = {1,2,3}; std::for_each(v.begin(), v.end(), Printer(std::cout)); std::string s = "abc"; std::for_each(s.begin(), s.end(), Printer(std::cout)); } Output: 1 2 3 a b c Partial specializations of member template may appear both at class scope and at enclosing namespace scope, but explicit specializations may only appear at enclosing namespace scope. struct A { template struct B; // primary member template template struct B { }; // OK: partial specialization // template<> struct B { }; // Error: full specialization }; template<> struct A::B { }; // OK template struct A::B { }; // OK If the enclosing class declaration is, in turn, a class template, when a member template is defined outside of the class body, it takes two sets of template parameters: one for the enclosing class, and another one for itself: template struct string { // member template function template int compare(const T2&); // constructors can be templates too template string(const std::basic_string& s) { /*...*/ } }; // out of class definition of string::compare template // for the enclosing class template template // for the member template int string::compare(const T2& s) { /* ... */ } Contents 1 Mem