-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Resolve issues with std::basic_ios and std::basic_stringstream usage #11308
Conversation
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 @cmsbuild, @civanch, @mulhearn, @mdhildreth can you please review it and eventually sign? Thanks. |
+1 |
@davidlt , in SimCalorimetry/EcalElectronicsEmulation/src/EcalSimRawData.cc there are similar constructions in lines 208, 286, 356 which are not yet changed. |
@civanch I changed that particular line from |
@davidlt , I mean to do the same construction if(f.fail()) in lines 208, 286, 356 |
`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]>
a610aae
to
bdcaf42
Compare
please test |
Done, but I had to rebase. Forgot there was other branches in work in the same work dir. Hopefully cms-bot resolves the labels. |
The tests are being triggered in jenkins. |
Pull request #11308 was updated. @cmsbuild, @civanch, @mulhearn, @mdhildreth can you please check and sign again. |
+1 The following merge commits were also included on top of IB + this PR after doing git cms-merge-topic: |
+1 |
…am-SIM Resolve issues with std::basic_ios and std::basic_stringstream usage
std::cout
does not directly supportstd::basic_stringstream
asargument, but because
std::basic_stringstream
inheritsstd::basic_ios
and it supports
operator void*
(until C++11) one could have pushed itto
std::cout
. That is wrong, becauseoperator void*() const
does notprovide string content of
std::basic_stringstream
. Instead usestr()
method to get a string copy of
std::basic_stringstream
content.Instead of using
operator void*() const;
to check if stream isgood/bad. You have to use
explicit operator bool() const
in C++11 orabove or directly use
fail()
method.Signed-off-by: David Abdurachmanov [email protected]