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: Should basic_*stream::is_open() be const?


Andreas Kohn wrote:

So, if I read this correctly, "Note that implementers can make this
change in a binary compatible way by providing both overloads; this
would be a conforming extension." overloads could be added to libstdc++
without violating the standard?

Is anything like that planned?


Ok, I'm going to apply the below to mainline (would be 3.5.0 or 4.0), not to
the release branch, however, since we want complete backward and forward
compatibility.

Tested x86-linux.

Paolo.

//////////////////
2004-08-13  Paolo Carlini  <pcarlini@suse.de>

	* include/std/std_fstream.h (class basic_ifstream,
	class basic_ofstream, class basic_fstream): Add const overloads
	of is_open, as per DR 365 [WP].
	* docs/html/ext/howto.html: Add an entry for DR 365.
diff -urN libstdc++-v3-orig/docs/html/ext/howto.html libstdc++-v3/docs/html/ext/howto.html
--- libstdc++-v3-orig/docs/html/ext/howto.html	2004-07-15 20:04:04.000000000 +0200
+++ libstdc++-v3/docs/html/ext/howto.html	2004-08-13 11:26:31.000000000 +0200
@@ -479,6 +479,12 @@
     <dd>Change the format string to &quot;%.0Lf&quot;.
     </dd>
 
+    <dt><a href="lwg-defects.html#365">365</a>:
+        <em>Lack of const-qualification in clause 27</em>
+    </dt>
+    <dd>Add const overloads of <code>is_open</code>.
+    </dd>
+
     <dt><a href="lwg-defects.html#389">389</a>:
         <em>Const overload of valarray::operator[] returns by value</em>
     </dt>
diff -urN libstdc++-v3-orig/include/std/std_fstream.h libstdc++-v3/include/std/std_fstream.h
--- libstdc++-v3-orig/include/std/std_fstream.h	2003-11-16 01:55:51.000000000 +0100
+++ libstdc++-v3/include/std/std_fstream.h	2004-08-13 11:33:51.000000000 +0200
@@ -1,6 +1,6 @@
 // File based streams -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -282,7 +282,8 @@
        *  @brief  Returns true if the external file is open.
       */
       bool
-      is_open() const throw() { return _M_file.is_open(); }
+      is_open() const throw()
+      { return _M_file.is_open(); }
 
       /**
        *  @brief  Opens an external file.
@@ -569,7 +570,14 @@
        *  @return  @c rdbuf()->is_open()
       */
       bool
-      is_open() { return _M_filebuf.is_open(); }
+      is_open()
+      { return _M_filebuf.is_open(); }
+
+      // _GLIBCXX_RESOLVE_LIB_DEFECTS
+      // 365. Lack of const-qualification in clause 27
+      bool
+      is_open() const
+      { return _M_filebuf.is_open(); }
 
       /**
        *  @brief  Opens an external file.
@@ -693,7 +701,14 @@
        *  @return  @c rdbuf()->is_open()
       */
       bool
-      is_open() { return _M_filebuf.is_open(); }
+      is_open()
+      { return _M_filebuf.is_open(); }
+
+      // _GLIBCXX_RESOLVE_LIB_DEFECTS
+      // 365. Lack of const-qualification in clause 27
+      bool
+      is_open() const
+      { return _M_filebuf.is_open(); }
 
       /**
        *  @brief  Opens an external file.
@@ -817,7 +832,14 @@
        *  @return  @c rdbuf()->is_open()
       */
       bool
-      is_open() { return _M_filebuf.is_open(); }
+      is_open()
+      { return _M_filebuf.is_open(); }
+
+      // _GLIBCXX_RESOLVE_LIB_DEFECTS
+      // 365. Lack of const-qualification in clause 27
+      bool
+      is_open() const
+      { return _M_filebuf.is_open(); }
 
       /**
        *  @brief  Opens an external file.

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