summaryrefslogtreecommitdiffstats
path: root/lib/libcxx/include/fstream
diff options
context:
space:
mode:
authorrobert <robert@openbsd.org>2018-09-11 18:18:58 +0000
committerrobert <robert@openbsd.org>2018-09-11 18:18:58 +0000
commit820e1f31efc1d6ed04795ba2e79f3044e1907492 (patch)
tree815cebb3734784074b661935c33f00bd5eb4d862 /lib/libcxx/include/fstream
parentNuke unused LIST() ieee80211com_head. (diff)
downloadwireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.tar.xz
wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.zip
import of libc++ 6.0.0
Diffstat (limited to 'lib/libcxx/include/fstream')
-rw-r--r--lib/libcxx/include/fstream89
1 files changed, 42 insertions, 47 deletions
diff --git a/lib/libcxx/include/fstream b/lib/libcxx/include/fstream
index 3cb3b13bd10..f57908c8dfa 100644
--- a/lib/libcxx/include/fstream
+++ b/lib/libcxx/include/fstream
@@ -171,16 +171,18 @@ typedef basic_fstream<wchar_t> wfstream;
#include <__locale>
#include <cstdio>
-#include <__undef_min_max>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits>
-class _LIBCPP_TYPE_VIS_ONLY basic_filebuf
+class _LIBCPP_TEMPLATE_VIS basic_filebuf
: public basic_streambuf<_CharT, _Traits>
{
public:
@@ -193,13 +195,13 @@ public:
// 27.9.1.2 Constructors/destructor:
basic_filebuf();
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
basic_filebuf(basic_filebuf&& __rhs);
#endif
virtual ~basic_filebuf();
// 27.9.1.3 Assign/swap:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_filebuf& operator=(basic_filebuf&& __rhs);
#endif
@@ -276,7 +278,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
setbuf(0, 4096);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
@@ -313,7 +315,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
else
this->setp((char_type*)__extbuf_,
(char_type*)__extbuf_ + (__rhs. epptr() - __rhs.pbase()));
- this->pbump(__rhs. pptr() - __rhs.pbase());
+ this->__pbump(__rhs. pptr() - __rhs.pbase());
}
else if (__rhs.eback())
{
@@ -352,7 +354,7 @@ basic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs)
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>::~basic_filebuf()
@@ -432,7 +434,7 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
ptrdiff_t __e = this->epptr() - this->pbase();
this->setp((char_type*)__extbuf_min_,
(char_type*)__extbuf_min_ + __e);
- this->pbump(__n);
+ this->__pbump(__n);
}
if (__rhs.eback() == (char_type*)__extbuf_min_)
{
@@ -448,7 +450,7 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
ptrdiff_t __e = __rhs.epptr() - __rhs.pbase();
__rhs.setp((char_type*)__rhs.__extbuf_min_,
(char_type*)__rhs.__extbuf_min_ + __e);
- __rhs.pbump(__n);
+ __rhs.__pbump(__n);
}
}
@@ -615,13 +617,12 @@ basic_filebuf<_CharT, _Traits>::underflow()
static_cast<size_t>(__extbufend_ - __extbufnext_));
codecvt_base::result __r;
__st_last_ = __st_;
- size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_);
+ size_t __nr = fread((void*) const_cast<char *>(__extbufnext_), 1, __nmemb, __file_);
if (__nr != 0)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
if (!__cv_)
- throw bad_cast();
-#endif
+ __throw_bad_cast();
+
__extbufend_ = __extbufnext_ + __nr;
char_type* __inext;
__r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
@@ -629,7 +630,8 @@ basic_filebuf<_CharT, _Traits>::underflow()
this->eback() + __ibs_, __inext);
if (__r == codecvt_base::noconv)
{
- this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_);
+ this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
+ (char_type*)const_cast<char *>(__extbufend_));
__c = traits_type::to_int_type(*this->gptr());
}
else if (__inext != this->eback() + __unget_sz)
@@ -700,10 +702,9 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
codecvt_base::result __r;
do
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
if (!__cv_)
- throw bad_cast();
-#endif
+ __throw_bad_cast();
+
const char_type* __e;
__r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
__extbuf_, __extbuf_ + __ebs_, __extbe);
@@ -722,8 +723,8 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
return traits_type::eof();
if (__r == codecvt_base::partial)
{
- this->setp((char_type*)__e, this->pptr());
- this->pbump(this->epptr() - this->pbase());
+ this->setp(const_cast<char_type*>(__e), this->pptr());
+ this->__pbump(this->epptr() - this->pbase());
}
}
else
@@ -793,10 +794,9 @@ typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
if (!__cv_)
- throw bad_cast();
-#endif
+ __throw_bad_cast();
+
int __width = __cv_->encoding();
if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
return pos_type(off_type(-1));
@@ -816,7 +816,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
default:
return pos_type(off_type(-1));
}
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
return pos_type(off_type(-1));
pos_type __r = ftell(__file_);
@@ -835,7 +835,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
{
if (__file_ == 0 || sync())
return pos_type(off_type(-1));
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
if (fseek(__file_, __sp, SEEK_SET))
return pos_type(off_type(-1));
#else
@@ -852,10 +852,9 @@ basic_filebuf<_CharT, _Traits>::sync()
{
if (__file_ == 0)
return 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
if (!__cv_)
- throw bad_cast();
-#endif
+ __throw_bad_cast();
+
if (__cm_ & ios_base::out)
{
if (this->pptr() != this->pbase())
@@ -900,7 +899,7 @@ basic_filebuf<_CharT, _Traits>::sync()
}
}
}
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
if (fseek(__file_, -__c, SEEK_CUR))
return -1;
#else
@@ -1003,7 +1002,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode()
// basic_ifstream
template <class _CharT, class _Traits>
-class _LIBCPP_TYPE_VIS_ONLY basic_ifstream
+class _LIBCPP_TEMPLATE_VIS basic_ifstream
: public basic_istream<_CharT, _Traits>
{
public:
@@ -1021,12 +1020,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_ifstream(basic_ifstream&& __rhs);
-#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
basic_ifstream& operator=(basic_ifstream&& __rhs);
#endif
@@ -1075,7 +1072,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::ope
}
#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
inline
@@ -1096,7 +1093,7 @@ basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
inline
@@ -1165,7 +1162,7 @@ basic_ifstream<_CharT, _Traits>::close()
// basic_ofstream
template <class _CharT, class _Traits>
-class _LIBCPP_TYPE_VIS_ONLY basic_ofstream
+class _LIBCPP_TEMPLATE_VIS basic_ofstream
: public basic_ostream<_CharT, _Traits>
{
public:
@@ -1181,12 +1178,10 @@ public:
explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
_LIBCPP_INLINE_VISIBILITY
explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_ofstream(basic_ofstream&& __rhs);
-#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
basic_ofstream& operator=(basic_ofstream&& __rhs);
#endif
@@ -1235,7 +1230,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::ope
}
#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
inline
@@ -1256,7 +1251,7 @@ basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
inline
@@ -1325,7 +1320,7 @@ basic_ofstream<_CharT, _Traits>::close()
// basic_fstream
template <class _CharT, class _Traits>
-class _LIBCPP_TYPE_VIS_ONLY basic_fstream
+class _LIBCPP_TEMPLATE_VIS basic_fstream
: public basic_iostream<_CharT, _Traits>
{
public:
@@ -1343,12 +1338,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_fstream(basic_fstream&& __rhs);
-#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
basic_fstream& operator=(basic_fstream&& __rhs);
#endif
@@ -1397,7 +1390,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openm
}
#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
inline
@@ -1418,7 +1411,7 @@ basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
inline
@@ -1486,4 +1479,6 @@ basic_fstream<_CharT, _Traits>::close()
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP_FSTREAM