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 6658561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:55:41+00:00 2026-05-26T01:55:41+00:00

trying to make a template, but I have an error in gcc4 but not

  • 0

trying to make a template, but I have an error in gcc4 but not in VS2008. This is the code that fails:

#pragma once
#ifndef _ZELESTE_ZEL_GPX_GENERALMANAGER_H_
#define _ZELESTE_ZEL_GPX_GENERALMANAGER_H_

#include "../internal/cuCoreLib.h"
#include "boost/functional/hash.hpp"
#include "boost/ptr_container/ptr_map.hpp"

namespace z3d{
    namespace core{
        template<class Key, class Value>
        class cuManager
        {
            boost::ptr_map<Key, Value> m_ItemMap;

        public:
            /**
            * Default constructor
            */
            cuManager(void){}

            /**
            * Get a vector that contain the keys of the elements contained in the manager.
            * @return an const std::vector of type Key 
            */
            const std::vector<Key> getKeys()
            {
                    boost::ptr_map<Key,Value>::iterator itr = m_ItemMap.begin();
                    std::vector<Key> v;
                    while(itr != m_ItemMap.end())
                    {
                            v.push_back(itr->first);
                            ++itr;
                    }
                    return v;
            }

          }
        };
    };

This is one of the methods that fails to compile (all methods of the class fail in the same iterator). This code works fine into visual studio but compilation in GCC return this error:

/home/dev001/desarrollo/code/lpgameengine/LPGameEngine/src/core/datatypes/cuManager.h: In member function ‘const std::vector<_Tp, std::allocator<_CharT> > z3d::core::cuManager<Key, Value>::getKeys()’:
/home/dev001/desarrollo/code/lpgameengine/LPGameEngine/src/core/datatypes/cuManager.h:28: error: expected ‘;’ before ‘itr’
/home/dev001/desarrollo/code/lpgameengine/LPGameEngine/src/core/datatypes/cuManager.h:30: error: ‘itr’ was not declared in this scope

Any help will be welcome

  • 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-05-26T01:55:42+00:00Added an answer on May 26, 2026 at 1:55 am

    Declare it like this:

    typename boost::ptr_map<Key,Value>::iterator itr = m_ItemMap.begin();
    ^^^^^^^^
    

    The point is that boost::ptr_map<Key,Value>::iterator is a dependent name, so you have to specify that it’s a type name (and not a variable name or a template name).

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

Sidebar

Related Questions

I have a template class in a header that fails to compile, but when
I'm trying to make a class that takes a map as a template parameter.
I have looked everywhere but have not found a problem similar to this. I
I'm trying to use the function atan2 in my class template but it's not
I have been trying to make this work for a long time now. In
Trying to make a make generic select control that I can dynamically add elements
Trying to make a custom :confirm message for a rails form that returns data
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:
I'm trying to make an SDL application in Xcode, but I'm having trouble loading

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.