StringUtils.h IStream and OStream not C++11 compliant

Forum for software developers to discuss BCI2000 software development
Post Reply
Posts: 382
Joined: 25 Dec 2011, 21:14

StringUtils.h IStream and OStream not C++11 compliant

Post by boulay » 26 Nov 2015, 14:21

Using Revision: 5133

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
It completed fine. I opened the MSVC project. Pretty much anything I try to build returns the following errors:

Code: Select all

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>>'
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:

Code: Select all

operator void*() const { return iss ? reinterpret_cast<void*>(!iss->fail()) : 0; }
That fixes many of the errors, but also creates new ones.

Code: Select all

error C2440: 'return' : cannot convert from 'std::basic_ostream<char,std::char_traits<char>>' to 'bool'
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] ... rator_bool

Probably unrelated, but I'm also getting errors related to min and max not being found.

Posts: 344
Joined: 17 Sep 2010, 12:43

Re: StringUtils.h IStream and OStream not C++11 compliant

Post by pbrunner » 07 Dec 2015, 14:03


thanks for looking into the C++11 issue. The plan for Jürgen is to fix these error after the 3.6 release. In this process VS2013 and VS2015 should work, including the community version. If you have solved some these issues since your initial report, can you please paste the fixes as a comprehensive list. This would make it easier for Jürgen. Thanks!

Regards, Peter

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest