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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:53:46+00:00 2026-06-16T00:53:46+00:00

For debugging, I need to see the content of a map ( std::unordered_map or

  • 0

For debugging, I need to see the content of a map (std::unordered_map or std::map), which the Eclipse CDT debugger does not give me in a readable form, e.g. {1: 2, 3:4, ...}

What is the best way to inspect the content of a map while debugging?

Do I have to go back to debugging with print-statements? If yes, how would a concise macro or function look like that prints the content of any map as a string?

  • 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-16T00:53:47+00:00Added an answer on June 16, 2026 at 12:53 am

    Do I have to go back to debugging with print-statements? If yes, how would a concise macro or function look like that prints the content of any map as a string?

    I don’t know if you do or not – I don’t use Eclipse, but printing a map is very easy:

    template <typename K, typename V>
    std::ostream& operator<<(std::ostream& os, const std::map<K, V>& m)
    {
        os << "{ ";
        for (typename std::map<K, V>::const_iterator i = m.begin(); i != m.end(); ++i)
        {
            if (i != m.begin()) os << ", ";
            os << i->first << ": " << i->second;
        }
        return os << " }";
    }
    

    Then you can just use << my_map. Note though that in a large code base there’s a chance that someone else will have had the same “bright” idea, so you might want to put your helper function in your own namespace, or give it a more localised name. Things like the choice of surrounding "{ " and " }" and ", " separators are arbitrary and may not suit all users – some may want automatic string quoting/escaping etc., so putting this in a global namespace would be dubious at the best of times, and in this case it might even be reserved for possible inclusion in a future C++ Standard or something – after all, it’s kind of liking adding your own names into the std:: namespace. Check the Standard if you care.

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

Sidebar

Related Questions

I need to see the contents of a std::map variable while debugging. However, if
I have some very big DataTable s, which I need to see their content
While debugging jQuery apps that use AJAX, I often have the need to see
I'm currently debugging a 3rd party component and I need to monitor to see
I was debugging a defect which occurs, when clipboard is empty (could see popup
Hi I am debugging and need to be able to check what the values
I need help debugging some odd file behavior in Python. Take the following script
I need a proxy for web development debugging. Preferably something standalone so I can
I sometimes find that I need to re-enable alerting for debugging. Of course I
I'm doing some design/debugging in IRB and need to login a user and then

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.