C++ Standard Question
Marc Glisse
marc.glisse@inria.fr
Thu Jan 22 21:44:00 GMT 2015
On Thu, 22 Jan 2015, Joel Sherrill wrote:
> I think this is a glibc issue but since this method is defined in the C++
> standards, I thought there were plenty of language lawyers here. :)
s/glibc/libstdc++/ and they have their own ML.
> <strstream>
That's deprecated, isn't it?
> class strstreambuf : public basic_streambuf<char, char_traits<char> >
> ISSUE ====> int pcount() const; <===== ISSUE
>
> My reading of the C++03 and draft C++14 says that the int pcount() method
> in this class is not const. glibc has it const in the glibc shipped with
> Fedora 20
> and CentOS 6.
>
> This is a simple test case:
>
> #include <strstream>
>
> int main() {
> int (std::strstreambuf::*dummy)() = &std::strstreambuf::pcount;
> /*-- pcount is conformant --*/
> return 0;
> }
>
> What's the consensus?
The exact signature of member functions is not mandated by the standard,
implementations are allowed to make the function const if that works (or
provide both a const and a non-const version). Your code is not guaranteed
to work. Lambdas usually provide a fine workaround.
--
Marc Glisse
More information about the Gcc
mailing list