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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:34:52+00:00 2026-05-31T02:34:52+00:00

All the standard implementations I have tried allow values to be assigned to the

  • 0

All the standard implementations I have tried allow values to be assigned to the std::ostream_iterator‘s without having them dereferenced before the assignment. Although the standard algorithms dereference the iterators before the assignment, I would like to know why there are implementations that don’t just forbid the assignment statically (with the help of a proxy class) so that the compilation would just fail, so that the user knows something wrong might happen if such assignment is ported to another implementation not allowing the assignment for some reasons.
In general, when implementing a standard functionality, is it a good practice to limit the implementation to only allow what is explicitly mentioned by the standard?

#include <iterator>
#include <string>
#include <iostream>

using namespace std;

int main() {
    ostream_iterator<string> o(cout);
    o = "Hello World\n"; // o is not dereferenced! It compiles with my GCC environment
    o++; // to make sure the implementation writes to cout
}
  • 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-31T02:34:53+00:00Added an answer on May 31, 2026 at 2:34 am

    The operator overload that allows this assignment is specified by the C++ language standard. Thus, a C++ Standard Library implementation must provide it.

    The overload is specified as follows (from C++11 §24.6.2.2/1):

    ostream_iterator& operator=(const T& value);
    

    Effects:

    *out_stream << value;
    if(delim != 0)
        *out_stream << delim;
    
    return (*this);
    

    (T is the T with which the ostream_iterator was instantiated. In your example, it is string.)

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

Sidebar

Related Questions

I know there is a standard behind all C compiler implementations, so there should
I have used all the Standard Network related code for Getting Images of about
Looking at the DateTimeFormatInfo documentation, it appears that all the standard formats have colons
I'm looking for all the current standard header values a web server would generally
Suppose I have a customer object that has all of the standard customer properties
I have never written a stateful IComparer<T> with a default constructor. All standard library
In all of the standard specifications for programming languages, why is it that you
Chapter 6 Language of the C Standard defines all the different concepts, conversions, lexical
In standard php or source code based projects we easily keep all of the
All I am trying to do is take a standard range on an excel

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.