istream: Fix comments in the light of DR60 + N3168.
[gcc.git] / libstdc++-v3 / include / std / istream
index 521be7fd506936f3765c9506bf8c25710cfb2877..fb393921fd9a28ab2ee8a58e8caff3ece8df3023 100644 (file)
@@ -1,7 +1,7 @@
 // Input streams -*- C++ -*-
 
 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007, 2008, 2009
+// 2006, 2007, 2008, 2009, 2010, 2011
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -28,7 +28,7 @@
 // ISO C++ 14882: 27.6.1  Input streams
 //
 
-/** @file istream
+/** @file include/istream
  *  This is a Standard C++ Library header.
  */
 
@@ -40,7 +40,9 @@
 #include <ios>
 #include <ostream>
 
-_GLIBCXX_BEGIN_NAMESPACE(std)
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // [27.6.1.1] Template class basic_istream
   /**
@@ -112,8 +114,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  @brief  Interface for manipulators.
        *
        *  Manipulators such as @c std::ws and @c std::dec use these
-       *  functions in constructs like "std::cin >> std::ws".  For more
-       *  information, see the iomanip header.
+       *  functions in constructs like 
+       *  <code>std::cin >> std::ws</code>. 
+       *  For more information, see the iomanip header.
       */
       __istream_type&
       operator>>(__istream_type& (*__pf)(__istream_type&))
@@ -326,7 +329,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  @param  n  Maximum number of characters to store in @a s.
        *  @return  *this
        *
-       *  Returns @c get(s,n,widen('\n')).
+       *  Returns @c get(s,n,widen(&apos;\\n&apos;)).
       */
       __istream_type& 
       get(char_type* __s, streamsize __n)
@@ -359,7 +362,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  @param  sb  A streambuf in which to store data.
        *  @return  *this
        *
-       *  Returns @c get(sb,widen('\n')).
+       *  Returns @c get(sb,widen(&apos;\\n&apos;)).
       */
       __istream_type&
       get(__streambuf_type& __sb)
@@ -399,7 +402,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  @param  n  Maximum number of characters to extract.
        *  @return  *this
        *
-       *  Returns @c getline(s,n,widen('\n')).
+       *  Returns @c getline(s,n,widen(&apos;\\n&apos;)).
       */
       __istream_type& 
       getline(char_type* __s, streamsize __n)
@@ -492,8 +495,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
        *  the error state.
        *
-       *  @note  Since no characters are extracted, the next call to
-       *         @c gcount() will return 0, as required by DR 60.
+       *  @note  This function first clears eofbit.  Since no characters
+       *         are extracted, the next call to @c gcount() will return 0,
+       *         as required by DR 60.
       */
       __istream_type& 
       putback(char_type __c);
@@ -507,8 +511,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
        *  the error state.
        *
-       *  @note  Since no characters are extracted, the next call to
-       *         @c gcount() will return 0, as required by DR 60.
+       *  @note  This function first clears eofbit.  Since no characters
+       *         are extracted, the next call to @c gcount() will return 0,
+       *         as required by DR 60.
       */
       __istream_type& 
       unget();
@@ -540,9 +545,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *
        *  @note  This function does not count the number of characters
        *         extracted, if any, and therefore does not affect the next
-       *         call to @c gcount().
+       *         call to @c gcount().  At variance with putback, unget and
+       *         seekg, eofbit is not cleared first.
       */
-      pos_type 
+      pos_type
       tellg();
 
       /**
@@ -553,11 +559,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos).  If
        *  that function fails, sets failbit.
        *
-       *  @note  This function does not count the number of characters
-       *         extracted, if any, and therefore does not affect the next
-       *         call to @c gcount().
+       *  @note  This function first clears eofbit.  It does not count the
+       *         number of characters extracted, if any, and therefore does
+       *         not affect the next call to @c gcount().
       */
-      __istream_type& 
+      __istream_type&
       seekg(pos_type);
 
       /**
@@ -569,9 +575,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
        *  If that function fails, sets failbit.
        *
-       *  @note  This function does not count the number of characters
-       *         extracted, if any, and therefore does not affect the next
-       *         call to @c gcount().
+       *  @note  This function first clears eofbit.  It does not count the
+       *         number of characters extracted, if any, and therefore does
+       *         not affect the next call to @c gcount().
       */
       __istream_type& 
       seekg(off_type, ios_base::seekdir);
@@ -624,13 +630,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
    *  @brief  Performs setup work for input streams.
    *
    *  Objects of this class are created before all of the standard
-   *  extractors are run.  It is responsible for "exception-safe prefix and
-   *  suffix operations," although only prefix actions are currently required
-   *  by the standard. 
+   *  extractors are run.  It is responsible for <em>exception-safe
+   *  prefix and suffix operations,</em> although only prefix actions
+   *  are currently required by the standard.
   */
   template<typename _CharT, typename _Traits>
     class basic_istream<_CharT, _Traits>::sentry
     {
+      // Data Members.
+      bool _M_ok;
+
     public:
       /// Easy access to dependant types.
       typedef _Traits                                  traits_type;
@@ -645,8 +654,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  @param  noskipws  Whether to consume whitespace or not.
        *
        *  If the stream state is good (@a is.good() is true), then the
-       *  following actions are performed, otherwise the sentry state is
-       *  false ("not okay") and failbit is set in the stream state.
+       *  following actions are performed, otherwise the sentry state
+       *  is false (<em>not okay</em>) and failbit is set in the
+       *  stream state.
        *
        *  The sentry's preparatory actions are:
        *
@@ -658,7 +668,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *     used to determine whether each character is whitespace.
        *
        *  If the stream state is still good, then the sentry state becomes
-       *  true ("okay").
+       *  true (@a okay).
       */
       explicit
       sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
@@ -670,11 +680,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  For ease of use, sentries may be converted to booleans.  The
        *  return value is that of the sentry state (true == okay).
       */
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      explicit
+#endif
       operator bool() const
       { return _M_ok; }
-
-    private:
-      bool _M_ok;
     };
 
   // [27.6.1.2.3] character extraction templates
@@ -717,9 +727,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
    *  status, this function extracts up to @c n characters and stores them
    *  into the array starting at @a s.  @c n is defined as:
    *
-   *  - if @c width() is greater than zero, @c n is width()
-   *  - otherwise @c n is "the number of elements of the largest array of
-   *    @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6
+   *  - if @c width() is greater than zero, @c n is width() otherwise
+   *  - @c n is <em>the number of elements of the largest array of *
+   *  - @c char_type that can store a terminating @c eos.</em>
+   *  - [27.6.1.2.3]/6
    *
    *  Characters are extracted and stored until one of the following happens:
    *  - @c n-1 characters are stored
@@ -824,10 +835,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     basic_istream<_CharT, _Traits>& 
     ws(basic_istream<_CharT, _Traits>& __is);
 
-_GLIBCXX_END_NAMESPACE
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  // [27.7.1.6] Rvalue stream extraction
+  /**
+   *  @brief  Generic extractor for rvalue stream
+   *  @param  is  An input stream.
+   *  @param  x  A reference to the extraction target.
+   *  @return  is
+   *
+   *  This is just a forwarding function to allow extraction from
+   *  rvalue streams since they won't bind to the extractor functions
+   *  that take an lvalue reference.
+  */
+  template<typename _CharT, typename _Traits, typename _Tp>
+    inline basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
+    { return (__is >> __x); }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
 
-#ifndef _GLIBCXX_EXPORT_TEMPLATE
-# include <bits/istream.tcc>
-#endif
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#include <bits/istream.tcc>
 
 #endif /* _GLIBCXX_ISTREAM */