This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ Standard Question


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]