Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:31:30+00:00 2026-06-02T20:31:30+00:00

When I try to compile template class, I got the following errors: C.cpp: In

  • 0

When I try to compile template class, I got the following errors:

C.cpp: In member function 'void PeriodContainerAdvanced<T>::add()':
C.cpp:133: error: type/value mismatch at argument 1 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
C.cpp:133: error:   expected a type, got 'std::map<int,T,std::less<int>,std::allocator<std::pair<const int, T> > >::iterator'
C.cpp:133: error: invalid type in declaration before ';' token

Class at C.h file: (Simplified)

template <class T>
class PeriodContainerAdvanced 
{
[skip]
    void add (); 
[skip]
}

C.cpp (Simplified):

template <class T>
void PeriodContainerAdvanced<T>::add()
{
[skip]
    std::pair<std::map< time_t, T >::iterator, bool> ret; // line 133 !
[skip]
}

And the similar error at other function when trying to define

std::map< time_t, T >::iterator it, it_start, it_end; // line 153

after this line compiler say:

C.cpp:153: error: expected `;' before 'it'
C.cpp:166: error: 'it_start' was not declared in this scope

How to fix it? thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:31:31+00:00Added an answer on June 2, 2026 at 8:31 pm

    That’s a dependent name, you’ll need to declare it as:

    std::pair<typename std::map< time_t, T >::iterator, bool> ret;
    

    Also, to avoid later linker errors, you should move template implementations to a file visible to all translation units that use that template – like the header where you define your template class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try and compile the following code... #include <vector> template <class T> void
If I try to compile the following C++0x code, I get an error: template<int
When I try to compile Gforth 0.7.0, I get the following error: $ ./configure
When I try to compile this: #include <map> #include <string> template <class T> class
When I try to compile an assembly in VS 2008, I got (occasionally, usually
When I try to compile this: import java.awt.* ; class obj { public static
I found this vector template class implementation, but it doesn't compile on XCode. Header
I have the following definitions: template<typename T1, typename T2> class Test2 { public: static
So given the following template functions with partial specialization template<typename T> void foo(vector<T> &in)
I have the following code in django.template: class Template(object): def __init__(self, template_string, origin=None, name='<Unknown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.