StringUtils.h IStream and OStream not C++11 compliant
Posted: 26 Nov 2015, 14:21
Using Revision: 5133
I ran cmake with the following command:
It completed fine. I opened the MSVC project. Pretty much anything I try to build returns the following errors:
Looking at StringUtils.h, it seems that the call to `IStream::operator void *()` is supposed to return whatever `std::istringstream::operator void*()` would return. And according to [1], this operator is just a check for no errors that has been replaced since C++11 with `operator bool()`. Luckily, for preservation of backwards compatibility, both pre- and post-C++11 functions are just synonyms for !fail().
I changed the offending lines to something like the following:
That fixes many of the errors, but also creates new ones.
I don't understand how the return type is different and it can no longer implicitly convert the result to bool. This can be done explicitly by going into each function and wrapping the return with a (bool)(), but that's kind of annoying. I'm guessing I'm doing something wrong.
[1] http://en.cppreference.com/w/cpp/io/bas ... rator_bool
Probably unrelated, but I'm also getting errors related to min and max not being found.
I ran cmake with the following command:
Code: Select all
E:\SachsLab\Tools\Neurophys\BCI2000\cbuild>cmake ../build -G "Visual Studio 12 2013 Win64" -DUSE_EXTERNAL_QT=ON -DQT_QMAKE_EXECUTABLE=C:\Qt\5.5\msvc2013_64\bin\qmake.exe -DBUILD_BCPY2000=ON
Code: Select all
1>
e:\sachslab\tools\neurophys\bci2000\src\shared\utils\lib\StringUtils.h(56): error C2738: 'operator void *' : is ambiguous or is not a member of 'std::basic_istringstream<char,std::char_traits<char>,std::allocator<char>>'
1>e:\sachslab\tools\neurophys\bci2000\src\shared\utils\lib\StringUtils.h(69): error C2738: 'operator void *' : is ambiguous or is not a member of 'std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char>>'
I changed the offending lines to something like the following:
Code: Select all
operator void*() const { return iss ? reinterpret_cast<void*>(!iss->fail()) : 0; }
Code: Select all
error C2440: 'return' : cannot convert from 'std::basic_ostream<char,std::char_traits<char>>' to 'bool'
[1] http://en.cppreference.com/w/cpp/io/bas ... rator_bool
Probably unrelated, but I'm also getting errors related to min and max not being found.