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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:37:40+00:00 2026-05-28T04:37:40+00:00

I would like to treat a database query as a standard C++ input iterator.

  • 0

I would like to treat a database query as a standard C++ input iterator.
On the other hand, one can view a database query as an input stream of query result items.
What do you think is a better model for a db query – an input iterator or an input stream?

Personally, I have an impression that C++ IO streams are supposed to operate on characters only, where I have never seen any example of a stream where characters would be something other than char or wchar_t. I understand, that the templated nature of the streams allows me to pass anything as a character, so theoretically, it seems that I can treat the query result item as a character for the sake of streaming, but I am not sure if it is a good idea.

Advices are welcome.

Thanks.

  • 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-28T04:37:41+00:00Added an answer on May 28, 2026 at 4:37 am

    Anything you use as a stream character type needs to have character traits, and maybe some stuff to do with locales, since someone might try to imbue a locale into your stream. Which might be nonsense, but it’s still there in the interface and even if you make it an error you probably need to make it a sensible error.

    I’d definitely use an input iterator, in C++ it’s the simple model for a sequence of objects.

    Streams do a lot of other stuff as well as merely presenting a sequence (formatting, control of the streambuf, the arcane error state model). Much of that probably isn’t applicable to your database items, although I suppose some of it could be. For example controlling the buffer size of a DB query result stream would make sense, but formatted reads from it wouldn’t.

    The fact that istream_iterator exists is proof that even if you offer someone a stream, they might well prefer/need the iterator interface.

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

Sidebar

Related Questions

I have several related database tables and I would like to treat their rows
Is it possible to use NIO with System.in? I would like to somehow treat
I would like to input a dataframe into paste and I would like paste
I would like to compare 2 date, which stored in database as String. When
I would like to treat my exceptions at a global level, but it seems
I would like to create a Javascript class that I can use like so:
I've started cocos2d game development and I would like to enable the flag treat
I inherited a mysql database that has a table with columns like this: object_id,
I would like findstr /m background *.vim | gvim to open all *.vim files
I am trying to organize my JavaScript. What I would like to do is

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.