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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:49:31+00:00 2026-05-10T17:49:31+00:00

I need help understanding some C++ operator overload statements. The class is declared like

  • 0

I need help understanding some C++ operator overload statements. The class is declared like this:

template <class key_t, class ipdc_t> class ipdc_map_template_t : public ipdc_lockable_t {     ...     typedef map<key_t,             ipdc_t*,             less<key_t>> map_t;     ... 

The creator of the class has created an iterator for the internal map structure:

struct iterator : public map_t::iterator {     iterator() {}     iterator(const map_t::iterator & it)         : map_t::iterator(it) {}     iterator(const iterator & it)         : map_t::iterator(             *static_cast<const map_t::iterator *>(&it)) {}     operator key_t() {return ((this->operator*()).first);}           // I don't understand this.     operator ipdc_t*() const {return ((this->operator*()).second);}  // or this.  }; 

And begin() and end() return the begin() and end() of the map:

iterator begin() {IT_ASSERT(is_owner()); return map.begin();} iterator end() {return map.end();} 

My question is, if I have an iterator, how do I use those overloads to get the key and the value?

ipdc_map_template_t::iterator iter;     for( iter = my_instance.begin();              iter != my_instance.end();          ++iter )     {         key_t my_key = ??????;         ipdc_t *my_value = ??????;      } 
  • 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. 2026-05-10T17:49:32+00:00Added an answer on May 10, 2026 at 5:49 pm

    These are typecast operators, so you can do this:

    {     key_t   key = iter;     ipdc_t *val = iter; } 

    Or, since ipdc_map_template::iterator is a subclass of std::map::iterator, you can still use the original accessors (which I find more readable):

    {     key_t   key = (*iter).first;     ipdc_t *val = (*iter).second;      // or, equivalently     key_t   key = iter->first;     ipdc_t *val = iter->second;  } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 131k
  • Answers 131k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just to make sure, you're using strings for primary keys… May 12, 2026 at 6:19 am
  • Editorial Team
    Editorial Team added an answer Try with this Regex: "[^"\r\n]*"|'[^'\r\n]*'|[^,\r\n]* Regex regexObj = new Regex(@"""[^""\r\n]*""|'[^'\r\n]*'|[^,\r\n]*");… May 12, 2026 at 6:19 am
  • Editorial Team
    Editorial Team added an answer Do you happen to use Visual Basic? T4 Toolbox only… May 12, 2026 at 6:19 am

Related Questions

I am just starting with C++ and got some problems in understanding how the
I'm working on an RTS game in C++ targeted at handheld hardware (Pandora). For
I'm having a hard time wrapping my head around this and need some help
I am trying to teach myself Python by working through some problems I came

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.