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

  • Home
  • SEARCH
  • 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 158103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:37:21+00:00 2026-05-11T10:37:21+00:00

With reference to this question StackoVerflow 529831 , this was one of the suggested

  • 0

With reference to this question StackoVerflow 529831, this was one of the suggested approaches

template<typename Map> typename Map::const_iterator  greatest_less(Map const& m, typename Map::key_type const& k) {     //How to print K and Map m     typename Map::const_iterator it = m.lower_bound(k);     if(it != m.begin()) {       return --it;     }     return m.end(); } 

I would be interested in printing key K and Map m, How would go about this.

  • 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-11T10:37:21+00:00Added an answer on May 11, 2026 at 10:37 am

    Use the << operator, making sure that << is defined for both your Map::key_type and Map::data_type types (you will know if that is not the case as the code will not compile.)

    cout << k << endl; for (typename Map::const_iterator it = m.begin(); it != m.end(); ++i) {   cout << it->first << ' -> ' << it->second << endl; } 

    e.g. if your Map::data_type is a struct fraction with members float numerator and float denominator,

    ostream& operator<<(ostream& os, const fraction& obj) {    return os << obj.numerator << '/' << obj.denominator; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related to this one: https://stackoverflow.com/questions/7906356/how-to-solve-a-a-reference-tracked-object-changed-reference-during-deserializat Since the above post has been
Reference: This is a self-answered question. It was meant to share the knowledge, Q&A
This is with reference to the StackOverflow question Managing multiple asynchronous NSURLConnection connections I
I'm writing this question with reference to this one which I wrote yesterday. After
In reference to this answer to a Stack Overflow question : what is bench-testing
In reference with this question We have a header with a date picked component
With the reference to this question:- JavaScript -Change CSS color for 5 seconds Working
EDIT: This question is about finding definitive reference to MySQL syntax on SELECT modifying
Somebody ask me this question today . What is the need of reference in
I'm using Alberto Santini's solution to this question to get a spiral grid reference

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.