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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:23:34+00:00 2026-06-18T15:23:34+00:00

Is streaming a stringstream a libstdc++ extension? This program compiles with gcc-4.2 , gcc-4.7-2

  • 0

Is streaming a stringstream a libstdc++ extension? This program compiles with gcc-4.2, gcc-4.7-2 (using -std=c++03), and clang 3.2 using -std=c++11 and libstdc++ (thanks to Andy Prowl, see comments). It does not compile with clang 3.2 using -std=c++11 and -stdlib=libc++.

#include<iostream>
#include<sstream>
int main() {

  std::stringstream s; s << "b";

  std::cout << "ss: " << s << std::endl;

  return 0;
}

By looking at the constructor of ofstream it can take a std::basic_streambuf<CharT, Traits>* or a basic_ostream& st. A stringstream is a std::basic_istream, however both are std::basic_ios<CharT, Traits> so I would guess it should work.

The following change makes the code compile under clang:

  std::cout << "ss: " << s.str() << std::endl;

What is the right way to do it? cout << s; or cout << s.str(); ?

  • 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-18T15:23:35+00:00Added an answer on June 18, 2026 at 3:23 pm

    No, it’s a difference between C++03 and C++11. All streams have a conversion operator that enables code using if (s) and while (s). In C++03 this is usually operator void*() or something similar.

    In C++11 we have explicit operators, where an explicit operator bool() works for if (s), but not for cout << s.

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

Sidebar

Related Questions

Problem: I'm streaming my video from a php file with stream_get_contents(); using Flowplayer as
Jwplayer skips video streaming while it is buffering. I noticed this problem since a
I am using Twitter4j streaming API. I am using a geolocation constraint to get
I am streaming all events in my EventSTore with this: eventStore.Advanced.GetFrom(DateTime.MinValue).ToArray().SelectMany(its => its.Events).ToArray(); Keeping
I am using twitter streaming api to track terms. I knot that there is
When I create a streaming job with Amazon Elastic MapReduce (Amazon EMR), using the
I am using Hadoop streaming, I start the script as following: ../hadoop/bin/hadoop jar ../hadoop/contrib/streaming/hadoop-streaming-1.0.4.jar
Can I embed MP4-files streaming using a flash-player? I find several places it is
This streaming audio app will play in 3.2 simulator, but not in 4.x sim
I've several hadoop streaming api programs and produce output with this outputformat: org.apache.hadoop.mapred.SequenceFileOutputFormat And

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.