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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:17:45+00:00 2026-05-13T20:17:45+00:00

I have the following typedef’s in my code: typedef unsigned long int ulint; typedef

  • 0

I have the following typedef’s in my code:

typedef unsigned long int ulint;
typedef std::map<ulint, particle> mapType;
typedef std::vector< std::vector<mapType> > mapGridType;

particle is a custom class with no default constructor.

VS2008 gives me an error in this code:

std::set<ulint> gridOM::ids(int filter)
{
    std::set<ulint> result;
    ulint curId;
    for ( int i = 0; i < _dimx; ++i ) {
        for ( int j = 0; j < _dimy; ++j ) {
            // next line is reported to be erroneous
            for ( mapType::iterator cur = objectMap[i][j].begin(); cur != objectMap[i][j].end(); ++cur )
            {
                curId = (*cur).first;
                if ( (isStatic(curId) && filter != 2) || (!isStatic(curId) && filter != 1) )
                {
                    result.insert(curId);
                }
            }
        }
    }
    return result;
}

objectMap is an object of mapGridType. The error reads:

error C2512: 'gridOM::particle::particle' : no appropriate default constructor available
while compiling class template member function 'gridOM::particle &std::map<_Kty,_Ty>::operator [](const unsigned long &)'  
        with  
        [  
            _Kty=ulint,  
            _Ty=gridOM::particle  
        ]  
        .\gridOM.cpp(114) : see reference to class template   instantiation 'std::map<_Kty,_Ty>'   being compiled  
        with  
        [  
            _Kty=ulint,  
            _Ty=gridOM::particle  
        ]  

Correct me if I’m wrong, but the above code should not be making calls to map::operator[] at all. The first operator[] call is made to vector< vector<mapType> > and returns a vector<mapType>, the second is made to vector<mapType> and returns a mapType aka a map<ulint, particle>, and I only call begin() and end on that map. So why do I get an error trying to compile the operator[] for map?

  • 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-13T20:17:45+00:00Added an answer on May 13, 2026 at 8:17 pm

    Case closed. It turns out that I did in fact make the coding mistake of writing a call to operator[], but it was hundreds of lines further down in the source file from where the error was reported. Apparently VS just pointed me to the first usage of a variable of mapType instead of the actual point where it tried to instantiate the method.

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

Sidebar

Related Questions

I have the following c++ method: typedef unsigned long p3tOffsetType; p3tOffsetType buildString(std::string string) {
I have the following code: typedef unsigned char some_type[6]; int main() { some_type some_var1;
I have the following code: typedef vector<int> Vec; typedef vector<Vec> VecOfVec; template<typename Vec> Vec
I have the following C++ code: typedef istream_iterator<string> isi; // (1) vector<string> lineas(isi(cin), isi());
I have the following code: typedef Coord2d<double> dCoord; typedef std::pair<dCoord, Color<double> > cdpair; CircularBuffer<cdpair>
I have the following C++ code: typedef int* IntPtr; const int* cip = new
Let's say I have the following code: typedef std::function<void ()> func_type; void some_func() {
At the moment I have the following code: typedef struct _hexagon { int *vertice[6];
I have following code: typedef int (*t_Function) (int x); t_Function Functions[MAX_FUNCTIONS]; int f(int x)
I have following struct defination: typedef union U08_16_t { unsigned long s32;//message32 unsigned char

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.