Skip to content

fix: replace deprecated <strstream> with <sstream> in porthopper example - #1729

Closed
ghost wants to merge 1 commit into
masterfrom
unknown repository
Closed

ghost wants to merge 1 commit into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Mar 20, 2026

Copy link
Copy Markdown

Summary

Replaces the deprecated <strstream> header with <sstream> in the C++11 porthopper example. <strstream> has been deprecated since C++98 and is removed in C++26 per P2867R1.

Changes

src/examples/cpp11/porthopper/protocol.hpp:

  • #include <strstream> -> #include <sstream>
  • std::istrstream(data_, size) -> std::istringstream(std::string(data_, size))
  • std::ostrstream(data_, size) -> std::ostringstream + std::memcpy to copy the result back to the fixed buffer

The ostrstream -> ostringstream conversion requires an extra copy step since ostrstream writes directly to a provided char[] buffer while ostringstream manages its own internal string.

Fixes #1725

<strstream> is deprecated since C++98 and removed in C++26 (P2867R1).
Replace std::istrstream/std::ostrstream with std::istringstream/
std::ostringstream in the porthopper protocol example.

For writing, use std::ostringstream then memcpy to the fixed buffer
since ostringstream manages its own string storage unlike ostrstream.

Fixes #1725
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C++11 example using deprecated <strstream> replace with <sstream>?

1 participant