Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issues with std::basic_ios and std::basic_stringstream usage #11308

Merged

Conversation

davidlt
Copy link
Contributor

@davidlt davidlt commented Sep 17, 2015

std::cout does not directly support std::basic_stringstream as
argument, but because std::basic_stringstream inherits std::basic_ios
and it supports operator void* (until C++11) one could have pushed it
to std::cout. That is wrong, because operator void*() const does not
provide string content of std::basic_stringstream. Instead use str()
method to get a string copy of std::basic_stringstream content.

Instead of using operator void*() const; to check if stream is
good/bad. You have to use explicit operator bool() const in C++11 or
above or directly use fail() method.

Signed-off-by: David Abdurachmanov [email protected]

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @davidlt for CMSSW_7_6_X.

Resolve issues with std::basic_ios and std::basic_stringstream usage

It involves the following packages:

SimCalorimetry/EcalElectronicsEmulation
SimCalorimetry/EcalTrigPrimProducers
SimG4CMS/FP420
SimG4CMS/Forward
SimMuon/CSCDigitizer

@cmsbuild, @civanch, @mulhearn, @mdhildreth can you please review it and eventually sign? Thanks.
@makortel, @jhgoh, @argiro this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
If you are a L2 or a release manager you can ask for tests by saying 'please test' in the first line of a comment.
@Degano you are the release manager for this.
You can merge this pull request by typing 'merge' in the first line of your comment.

@cmsbuild
Copy link
Contributor

@mulhearn
Copy link
Contributor

+1

@cmsbuild
Copy link
Contributor

@civanch
Copy link
Contributor

civanch commented Sep 17, 2015

@davidlt , in SimCalorimetry/EcalElectronicsEmulation/src/EcalSimRawData.cc there are similar constructions in lines 208, 286, 356 which are not yet changed.

@davidlt
Copy link
Contributor Author

davidlt commented Sep 17, 2015

@civanch I changed that particular line from operator! to fail(), because I believe fail() provides more details on what is checked. Other than that, both do exactly the same. I can revert that line back if needed for consistency.

@civanch
Copy link
Contributor

civanch commented Sep 17, 2015

@davidlt , I mean to do the same construction if(f.fail()) in lines 208, 286, 356

@cmsbuild
Copy link
Contributor

Pull request #11308 was updated. @civanch, @Dr15Jones, @cvuosalo, @emeschi, @ianna, @mdhildreth, @monttj, @cmsbuild, @ggovi, @diguida, @cerminar, @deguio, @slava77, @mommsen, @vadler, @mmusich, @mulhearn, @danduggan can you please check and sign again.

David Abdurachmanov added 2 commits September 17, 2015 14:58
`std::cout` does not directly support `std::basic_stringstream` as
argument, but because `std::basic_stringstream` inherits `std::basic_ios`
and it supports `operator void*` (until C++11) one could have pushed it
to `std::cout`. That is wrong, because `operator void*() const` does not
provide string content of `std::basic_stringstream`. Instead use `str()`
method to get a string copy of `std::basic_stringstream` content.

Instead of using `operator void*() const;` to check if stream is
good/bad. You have to use `explicit operator bool() const` in C++11 or
above or directly use `fail()` method.

Signed-off-by: David Abdurachmanov <[email protected]>
`fail()` and `operator!` work in the same way, but `fail()` provides more
details, i.e. makes code easier to understand.

Signed-off-by: David Abdurachmanov <[email protected]>
@davidlt davidlt force-pushed the fix-basic_ios-basic_stringstream-SIM branch from a610aae to bdcaf42 Compare September 17, 2015 12:59
@diguida
Copy link
Contributor

diguida commented Sep 17, 2015

please test

@davidlt
Copy link
Contributor Author

davidlt commented Sep 17, 2015

Done, but I had to rebase. Forgot there was other branches in work in the same work dir. Hopefully cms-bot resolves the labels.

@cmsbuild
Copy link
Contributor

The tests are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

Pull request #11308 was updated. @cmsbuild, @civanch, @mulhearn, @mdhildreth can you please check and sign again.

@cmsbuild
Copy link
Contributor

@civanch
Copy link
Contributor

civanch commented Sep 17, 2015

+1

davidlange6 added a commit that referenced this pull request Sep 18, 2015
…am-SIM

Resolve issues with std::basic_ios and std::basic_stringstream usage
@davidlange6 davidlange6 merged commit 0050854 into cms-sw:CMSSW_7_6_X Sep 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants