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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:05:32+00:00 2026-05-22T00:05:32+00:00

§24.1.1/3 from C++03 Standard reads, For input iterators, a == b does not imply

  • 0

§24.1.1/3 from C++03 Standard reads,

For input iterators, a == b does not imply ++a == ++b. (Equality does not
guarantee the substitution property or
referential transparency.
) Algorithms
on input iterators should never
attempt to pass through the same
iterator twice. They should be single
pass algorithms. Value type T is not
required to be an Assignable type
(23.1). These algorithms can be used
with istreams as the source of the
input data through the
istream_iterator class.

I couldn’t understand the bold text in the above quotation. Can anyone help me understanding this?

Also, what does the following statement (italicized text in the above quotation) mean? How is it related to a==b and ++a==++b expressions?

Equality does not
guarantee the substitution property or
referential transparency.

  • 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-22T00:05:33+00:00Added an answer on May 22, 2026 at 12:05 am

    The properties referred to are:

    Substitution Property

    For any quantities a and b and any expression F(x), if a = b, then F(a) = F(b) (if either side makes sense, i.e. is well-formed).

    Referential Transparency

    Informally, it means that there is no difference between a value and a reference to this value (thus how the term was coined).

    In imperative programming it is a difficult concept to get, because we are used to modify our variables. Rick Hickey (behind Clojure) gives a nice talk about the distinction between Identity and State that may help you. The gist of it is that a variable is an Identity. At any point in time an Identity refers to a State. A State never changes, however an Identity may be altered to refer to another State.

    Input Iterators

    The substitution property violation is “obvious” here, if we define F(x) in the above to mean ++x, then we have that if input iterators verified the substitution property, the following would hold a == b => ++a == ++b.

    This is not true, however, because incrementing an input iterator may invalidate all other input iterators from the same source. From table 107 in n3290 (page 831, just above the paragraph you quoted):

    ++r

    pre: r is dereferenceable.

    post: r is dereferenceable or r is past-the-end.

    post: any copies of the previous value of r are no longer required either to be
    dereferenceable or to be in the domain of ==.

    That is, when we perform ++a, then b may become invalid, and therefore ++b itself will be undefined behavior.

    This is a direct violation of ++a == ++b, therefore the substitution property does not hold.

    The referential transparency is a bit more evident here. If Input Iterators were referentially transparent, it would mean that they would be indifferentiable from the value they point to. Clearly this is not the case, as applying ++ does not increment the value, but the iterator.

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

Sidebar

Related Questions

Jakob Østergaard presented this challenge: Write a program that reads text from standard-input, and
for these guidelines: Write a loop that reads positive integers from standard input and
I'm reading from the standard input using the read() system call but there's a
I need to read input from standard input until a space or a TAB
Command wc has an option --files0-from=F. According to the manual, it reads input from
I am basically trying to return from a method which reads user input from
Possible Duplicate: C/C++: Capture characters from standard input without waiting for enter to be
I want to be able to write bytes and read them from standard input/output
I want to read a word from standard input and then find out its
I'm trying to figure out how to read from the standard input stream of

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.