Index: head/contrib/llvm-project/libcxx/include/codecvt =================================================================== --- head/contrib/llvm-project/libcxx/include/codecvt (revision 359086) +++ head/contrib/llvm-project/libcxx/include/codecvt (revision 359087) @@ -1,549 +1,549 @@ // -*- C++ -*- //===-------------------------- codecvt -----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_CODECVT #define _LIBCPP_CODECVT /* codecvt synopsis namespace std { enum codecvt_mode { consume_header = 4, generate_header = 2, little_endian = 1 }; template class codecvt_utf8 : public codecvt { explicit codecvt_utf8(size_t refs = 0); ~codecvt_utf8(); }; template class codecvt_utf16 : public codecvt { explicit codecvt_utf16(size_t refs = 0); ~codecvt_utf16(); }; template class codecvt_utf8_utf16 : public codecvt { explicit codecvt_utf8_utf16(size_t refs = 0); ~codecvt_utf8_utf16(); }; } // std */ #include <__config> #include <__locale> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD enum codecvt_mode { consume_header = 4, generate_header = 2, little_endian = 1 }; // codecvt_utf8 template class __codecvt_utf8; template <> class _LIBCPP_TYPE_VIS __codecvt_utf8 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf8 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef char16_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf8 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef char32_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template class _LIBCPP_TEMPLATE_VIS codecvt_utf8 : public __codecvt_utf8<_Elem> { public: _LIBCPP_INLINE_VISIBILITY explicit codecvt_utf8(size_t __refs = 0) : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {} _LIBCPP_INLINE_VISIBILITY ~codecvt_utf8() {} }; // codecvt_utf16 template class __codecvt_utf16; template <> class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef char16_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef char16_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef char32_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef char32_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template class _LIBCPP_TEMPLATE_VIS codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> { public: _LIBCPP_INLINE_VISIBILITY explicit codecvt_utf16(size_t __refs = 0) : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} _LIBCPP_INLINE_VISIBILITY ~codecvt_utf16() {} }; // codecvt_utf8_utf16 template class __codecvt_utf8_utf16; template <> class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef char32_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template <> class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16 : public codecvt { unsigned long _Maxcode_; codecvt_mode _Mode_; public: typedef char16_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} protected: virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const throw(); - virtual bool do_always_noconv() const throw(); + virtual int do_encoding() const _NOEXCEPT; + virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const throw(); + virtual int do_max_length() const _NOEXCEPT; }; template class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> { public: _LIBCPP_INLINE_VISIBILITY explicit codecvt_utf8_utf16(size_t __refs = 0) : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {} _LIBCPP_INLINE_VISIBILITY ~codecvt_utf8_utf16() {} }; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CODECVT Index: head/contrib/llvm-project/libcxx/include/exception =================================================================== --- head/contrib/llvm-project/libcxx/include/exception (revision 359086) +++ head/contrib/llvm-project/libcxx/include/exception (revision 359087) @@ -1,329 +1,331 @@ // -*- C++ -*- //===-------------------------- exception ---------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_EXCEPTION #define _LIBCPP_EXCEPTION /* exception synopsis namespace std { class exception { public: exception() noexcept; exception(const exception&) noexcept; exception& operator=(const exception&) noexcept; virtual ~exception() noexcept; virtual const char* what() const noexcept; }; class bad_exception : public exception { public: bad_exception() noexcept; bad_exception(const bad_exception&) noexcept; bad_exception& operator=(const bad_exception&) noexcept; virtual ~bad_exception() noexcept; virtual const char* what() const noexcept; }; typedef void (*unexpected_handler)(); unexpected_handler set_unexpected(unexpected_handler f ) noexcept; unexpected_handler get_unexpected() noexcept; [[noreturn]] void unexpected(); typedef void (*terminate_handler)(); terminate_handler set_terminate(terminate_handler f ) noexcept; terminate_handler get_terminate() noexcept; [[noreturn]] void terminate() noexcept; bool uncaught_exception() noexcept; int uncaught_exceptions() noexcept; // C++17 typedef unspecified exception_ptr; exception_ptr current_exception() noexcept; void rethrow_exception [[noreturn]] (exception_ptr p); template exception_ptr make_exception_ptr(E e) noexcept; class nested_exception { public: nested_exception() noexcept; nested_exception(const nested_exception&) noexcept = default; nested_exception& operator=(const nested_exception&) noexcept = default; virtual ~nested_exception() = default; // access functions [[noreturn]] void rethrow_nested() const; exception_ptr nested_ptr() const noexcept; }; template [[noreturn]] void throw_with_nested(T&& t); template void rethrow_if_nested(const E& e); } // std */ #include <__config> #include #include #include #include #if defined(_LIBCPP_ABI_VCRUNTIME) #include #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif namespace std // purposefully not using versioning namespace { #if !defined(_LIBCPP_ABI_VCRUNTIME) class _LIBCPP_EXCEPTION_ABI exception { public: _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default; + virtual ~exception() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; }; class _LIBCPP_EXCEPTION_ABI bad_exception : public exception { public: _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {} virtual ~bad_exception() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; }; #endif // !_LIBCPP_ABI_VCRUNTIME #if _LIBCPP_STD_VER <= 14 \ || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) \ || defined(_LIBCPP_BUILDING_LIBRARY) typedef void (*unexpected_handler)(); _LIBCPP_FUNC_VIS unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT; _LIBCPP_FUNC_VIS unexpected_handler get_unexpected() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void unexpected(); #endif typedef void (*terminate_handler)(); _LIBCPP_FUNC_VIS terminate_handler set_terminate(terminate_handler) _NOEXCEPT; _LIBCPP_FUNC_VIS terminate_handler get_terminate() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void terminate() _NOEXCEPT; _LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT; _LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_exceptions() _NOEXCEPT; class _LIBCPP_TYPE_VIS exception_ptr; _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); #ifndef _LIBCPP_ABI_MICROSOFT class _LIBCPP_TYPE_VIS exception_ptr { void* __ptr_; public: _LIBCPP_INLINE_VISIBILITY exception_ptr() _NOEXCEPT : __ptr_() {} _LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} exception_ptr(const exception_ptr&) _NOEXCEPT; exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; ~exception_ptr() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __ptr_ != nullptr;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {return __x.__ptr_ == __y.__ptr_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {return !(__x == __y);} friend _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; friend _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); }; template _LIBCPP_INLINE_VISIBILITY exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { #ifndef _LIBCPP_NO_EXCEPTIONS try { throw __e; } catch (...) { return current_exception(); } #else ((void)__e); _VSTD::abort(); #endif } #else // _LIBCPP_ABI_MICROSOFT class _LIBCPP_TYPE_VIS exception_ptr { #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-private-field" #endif void* __ptr1_; void* __ptr2_; #if defined(__clang__) #pragma clang diagnostic pop #endif public: exception_ptr() _NOEXCEPT; exception_ptr(nullptr_t) _NOEXCEPT; exception_ptr(const exception_ptr& __other) _NOEXCEPT; exception_ptr& operator=(const exception_ptr& __other) _NOEXCEPT; exception_ptr& operator=(nullptr_t) _NOEXCEPT; ~exception_ptr() _NOEXCEPT; _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT; }; _LIBCPP_FUNC_VIS bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT; inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {return !(__x == __y);} _LIBCPP_FUNC_VIS void swap(exception_ptr&, exception_ptr&) _NOEXCEPT; _LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__except, const void* __ptr); _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr p); // This is a built-in template function which automagically extracts the required // information. template void *__GetExceptionInfo(_E); template _LIBCPP_INLINE_VISIBILITY exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { return __copy_exception_ptr(_VSTD::addressof(__e), __GetExceptionInfo(__e)); } #endif // _LIBCPP_ABI_MICROSOFT // nested_exception class _LIBCPP_EXCEPTION_ABI nested_exception { exception_ptr __ptr_; public: nested_exception() _NOEXCEPT; // nested_exception(const nested_exception&) noexcept = default; // nested_exception& operator=(const nested_exception&) noexcept = default; virtual ~nested_exception() _NOEXCEPT; // access functions _LIBCPP_NORETURN void rethrow_nested() const; _LIBCPP_INLINE_VISIBILITY exception_ptr nested_ptr() const _NOEXCEPT {return __ptr_;} }; template struct __nested : public _Tp, public nested_exception { _LIBCPP_INLINE_VISIBILITY explicit __nested(const _Tp& __t) : _Tp(__t) {} }; #ifndef _LIBCPP_NO_EXCEPTIONS template struct __throw_with_nested; template struct __throw_with_nested<_Tp, _Up, true> { _LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void __do_throw(_Tp&& __t) { throw __nested<_Up>(_VSTD::forward<_Tp>(__t)); } }; template struct __throw_with_nested<_Tp, _Up, false> { _LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void #ifndef _LIBCPP_CXX03_LANG __do_throw(_Tp&& __t) #else __do_throw (_Tp& __t) #endif // _LIBCPP_CXX03_LANG { throw _VSTD::forward<_Tp>(__t); } }; #endif template _LIBCPP_NORETURN void throw_with_nested(_Tp&& __t) { #ifndef _LIBCPP_NO_EXCEPTIONS typedef typename decay<_Tp>::type _Up; static_assert( is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible"); __throw_with_nested<_Tp, _Up, is_class<_Up>::value && !is_base_of::value && !__libcpp_is_final<_Up>::value>:: __do_throw(_VSTD::forward<_Tp>(__t)); #else ((void)__t); // FIXME: Make this abort #endif } template struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT( is_polymorphic<_From>::value && (!is_base_of<_To, _From>::value || is_convertible::value)) {}; template inline _LIBCPP_INLINE_VISIBILITY void rethrow_if_nested(const _Ep& __e, typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0) { const nested_exception* __nep = dynamic_cast(_VSTD::addressof(__e)); if (__nep) __nep->rethrow_nested(); } template inline _LIBCPP_INLINE_VISIBILITY void rethrow_if_nested(const _Ep&, typename enable_if::value>::type* = 0) { } } // std #endif // _LIBCPP_EXCEPTION Index: head/contrib/llvm-project/libcxx/include/filesystem =================================================================== --- head/contrib/llvm-project/libcxx/include/filesystem (revision 359086) +++ head/contrib/llvm-project/libcxx/include/filesystem (revision 359087) @@ -1,2644 +1,2645 @@ // -*- C++ -*- //===--------------------------- filesystem -------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_FILESYSTEM #define _LIBCPP_FILESYSTEM /* filesystem synopsis namespace std { namespace filesystem { class path; void swap(path& lhs, path& rhs) noexcept; size_t hash_value(const path& p) noexcept; bool operator==(const path& lhs, const path& rhs) noexcept; bool operator!=(const path& lhs, const path& rhs) noexcept; bool operator< (const path& lhs, const path& rhs) noexcept; bool operator<=(const path& lhs, const path& rhs) noexcept; bool operator> (const path& lhs, const path& rhs) noexcept; bool operator>=(const path& lhs, const path& rhs) noexcept; path operator/ (const path& lhs, const path& rhs); // fs.path.io operators are friends of path. template friend basic_ostream& operator<<(basic_ostream& os, const path& p); template friend basic_istream& operator>>(basic_istream& is, path& p); template path u8path(const Source& source); template path u8path(InputIterator first, InputIterator last); class filesystem_error; class directory_entry; class directory_iterator; // enable directory_iterator range-based for statements directory_iterator begin(directory_iterator iter) noexcept; directory_iterator end(const directory_iterator&) noexcept; class recursive_directory_iterator; // enable recursive_directory_iterator range-based for statements recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; class file_status; struct space_info { uintmax_t capacity; uintmax_t free; uintmax_t available; }; enum class file_type; enum class perms; enum class perm_options; enum class copy_options; enum class directory_options; typedef chrono::time_point file_time_type; // operational functions path absolute(const path& p); path absolute(const path& p, error_code &ec); path canonical(const path& p); path canonical(const path& p, error_code& ec); void copy(const path& from, const path& to); void copy(const path& from, const path& to, error_code& ec); void copy(const path& from, const path& to, copy_options options); void copy(const path& from, const path& to, copy_options options, error_code& ec); bool copy_file(const path& from, const path& to); bool copy_file(const path& from, const path& to, error_code& ec); bool copy_file(const path& from, const path& to, copy_options option); bool copy_file(const path& from, const path& to, copy_options option, error_code& ec); void copy_symlink(const path& existing_symlink, const path& new_symlink); void copy_symlink(const path& existing_symlink, const path& new_symlink, error_code& ec) noexcept; bool create_directories(const path& p); bool create_directories(const path& p, error_code& ec); bool create_directory(const path& p); bool create_directory(const path& p, error_code& ec) noexcept; bool create_directory(const path& p, const path& attributes); bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept; void create_directory_symlink(const path& to, const path& new_symlink); void create_directory_symlink(const path& to, const path& new_symlink, error_code& ec) noexcept; void create_hard_link(const path& to, const path& new_hard_link); void create_hard_link(const path& to, const path& new_hard_link, error_code& ec) noexcept; void create_symlink(const path& to, const path& new_symlink); void create_symlink(const path& to, const path& new_symlink, error_code& ec) noexcept; path current_path(); path current_path(error_code& ec); void current_path(const path& p); void current_path(const path& p, error_code& ec) noexcept; bool exists(file_status s) noexcept; bool exists(const path& p); bool exists(const path& p, error_code& ec) noexcept; bool equivalent(const path& p1, const path& p2); bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; uintmax_t file_size(const path& p); uintmax_t file_size(const path& p, error_code& ec) noexcept; uintmax_t hard_link_count(const path& p); uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; bool is_block_file(file_status s) noexcept; bool is_block_file(const path& p); bool is_block_file(const path& p, error_code& ec) noexcept; bool is_character_file(file_status s) noexcept; bool is_character_file(const path& p); bool is_character_file(const path& p, error_code& ec) noexcept; bool is_directory(file_status s) noexcept; bool is_directory(const path& p); bool is_directory(const path& p, error_code& ec) noexcept; bool is_empty(const path& p); bool is_empty(const path& p, error_code& ec) noexcept; bool is_fifo(file_status s) noexcept; bool is_fifo(const path& p); bool is_fifo(const path& p, error_code& ec) noexcept; bool is_other(file_status s) noexcept; bool is_other(const path& p); bool is_other(const path& p, error_code& ec) noexcept; bool is_regular_file(file_status s) noexcept; bool is_regular_file(const path& p); bool is_regular_file(const path& p, error_code& ec) noexcept; bool is_socket(file_status s) noexcept; bool is_socket(const path& p); bool is_socket(const path& p, error_code& ec) noexcept; bool is_symlink(file_status s) noexcept; bool is_symlink(const path& p); bool is_symlink(const path& p, error_code& ec) noexcept; file_time_type last_write_time(const path& p); file_time_type last_write_time(const path& p, error_code& ec) noexcept; void last_write_time(const path& p, file_time_type new_time); void last_write_time(const path& p, file_time_type new_time, error_code& ec) noexcept; void permissions(const path& p, perms prms, perm_options opts=perm_options::replace); void permissions(const path& p, perms prms, error_code& ec) noexcept; void permissions(const path& p, perms prms, perm_options opts, error_code& ec); path proximate(const path& p, error_code& ec); path proximate(const path& p, const path& base = current_path()); path proximate(const path& p, const path& base, error_code &ec); path read_symlink(const path& p); path read_symlink(const path& p, error_code& ec); path relative(const path& p, error_code& ec); path relative(const path& p, const path& base=current_path()); path relative(const path& p, const path& base, error_code& ec); bool remove(const path& p); bool remove(const path& p, error_code& ec) noexcept; uintmax_t remove_all(const path& p); uintmax_t remove_all(const path& p, error_code& ec); void rename(const path& from, const path& to); void rename(const path& from, const path& to, error_code& ec) noexcept; void resize_file(const path& p, uintmax_t size); void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; space_info space(const path& p); space_info space(const path& p, error_code& ec) noexcept; file_status status(const path& p); file_status status(const path& p, error_code& ec) noexcept; bool status_known(file_status s) noexcept; file_status symlink_status(const path& p); file_status symlink_status(const path& p, error_code& ec) noexcept; path temp_directory_path(); path temp_directory_path(error_code& ec); path weakly_canonical(path const& p); path weakly_canonical(path const& p, error_code& ec); } } // namespaces std::filesystem */ #include <__config> #include #include #include #include #include #include #include #include #include #include #include #include // for quoted #include #include #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_PUSH_MACROS #include <__undef_macros> #ifndef _LIBCPP_CXX03_LANG _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH typedef chrono::time_point<_FilesystemClock> file_time_type; struct _LIBCPP_TYPE_VIS space_info { uintmax_t capacity; uintmax_t free; uintmax_t available; }; enum class _LIBCPP_ENUM_VIS file_type : signed char { none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3, block = 4, character = 5, fifo = 6, socket = 7, unknown = 8 }; enum class _LIBCPP_ENUM_VIS perms : unsigned { none = 0, owner_read = 0400, owner_write = 0200, owner_exec = 0100, owner_all = 0700, group_read = 040, group_write = 020, group_exec = 010, group_all = 070, others_read = 04, others_write = 02, others_exec = 01, others_all = 07, all = 0777, set_uid = 04000, set_gid = 02000, sticky_bit = 01000, mask = 07777, unknown = 0xFFFF, }; _LIBCPP_INLINE_VISIBILITY inline constexpr perms operator&(perms _LHS, perms _RHS) { return static_cast(static_cast(_LHS) & static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr perms operator|(perms _LHS, perms _RHS) { return static_cast(static_cast(_LHS) | static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr perms operator^(perms _LHS, perms _RHS) { return static_cast(static_cast(_LHS) ^ static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr perms operator~(perms _LHS) { return static_cast(~static_cast(_LHS)); } _LIBCPP_INLINE_VISIBILITY inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; } _LIBCPP_INLINE_VISIBILITY inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; } _LIBCPP_INLINE_VISIBILITY inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; } enum class _LIBCPP_ENUM_VIS perm_options : unsigned char { replace = 1, add = 2, remove = 4, nofollow = 8 }; _LIBCPP_INLINE_VISIBILITY inline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) { return static_cast(static_cast(_LHS) & static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) { return static_cast(static_cast(_LHS) | static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) { return static_cast(static_cast(_LHS) ^ static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr perm_options operator~(perm_options _LHS) { return static_cast(~static_cast(_LHS)); } _LIBCPP_INLINE_VISIBILITY inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) { return _LHS = _LHS & _RHS; } _LIBCPP_INLINE_VISIBILITY inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) { return _LHS = _LHS | _RHS; } _LIBCPP_INLINE_VISIBILITY inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) { return _LHS = _LHS ^ _RHS; } enum class _LIBCPP_ENUM_VIS copy_options : unsigned short { none = 0, skip_existing = 1, overwrite_existing = 2, update_existing = 4, recursive = 8, copy_symlinks = 16, skip_symlinks = 32, directories_only = 64, create_symlinks = 128, create_hard_links = 256, __in_recursive_copy = 512, }; _LIBCPP_INLINE_VISIBILITY inline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) { return static_cast(static_cast(_LHS) & static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) { return static_cast(static_cast(_LHS) | static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) { return static_cast(static_cast(_LHS) ^ static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr copy_options operator~(copy_options _LHS) { return static_cast(~static_cast(_LHS)); } _LIBCPP_INLINE_VISIBILITY inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) { return _LHS = _LHS & _RHS; } _LIBCPP_INLINE_VISIBILITY inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) { return _LHS = _LHS | _RHS; } _LIBCPP_INLINE_VISIBILITY inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) { return _LHS = _LHS ^ _RHS; } enum class _LIBCPP_ENUM_VIS directory_options : unsigned char { none = 0, follow_directory_symlink = 1, skip_permission_denied = 2 }; _LIBCPP_INLINE_VISIBILITY inline constexpr directory_options operator&(directory_options _LHS, directory_options _RHS) { return static_cast(static_cast(_LHS) & static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr directory_options operator|(directory_options _LHS, directory_options _RHS) { return static_cast(static_cast(_LHS) | static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr directory_options operator^(directory_options _LHS, directory_options _RHS) { return static_cast(static_cast(_LHS) ^ static_cast(_RHS)); } _LIBCPP_INLINE_VISIBILITY inline constexpr directory_options operator~(directory_options _LHS) { return static_cast(~static_cast(_LHS)); } _LIBCPP_INLINE_VISIBILITY inline directory_options& operator&=(directory_options& _LHS, directory_options _RHS) { return _LHS = _LHS & _RHS; } _LIBCPP_INLINE_VISIBILITY inline directory_options& operator|=(directory_options& _LHS, directory_options _RHS) { return _LHS = _LHS | _RHS; } _LIBCPP_INLINE_VISIBILITY inline directory_options& operator^=(directory_options& _LHS, directory_options _RHS) { return _LHS = _LHS ^ _RHS; } class _LIBCPP_TYPE_VIS file_status { public: // constructors _LIBCPP_INLINE_VISIBILITY file_status() noexcept : file_status(file_type::none) {} _LIBCPP_INLINE_VISIBILITY explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept : __ft_(__ft), __prms_(__prms) {} file_status(const file_status&) noexcept = default; file_status(file_status&&) noexcept = default; _LIBCPP_INLINE_VISIBILITY ~file_status() {} file_status& operator=(const file_status&) noexcept = default; file_status& operator=(file_status&&) noexcept = default; // observers _LIBCPP_INLINE_VISIBILITY file_type type() const noexcept { return __ft_; } _LIBCPP_INLINE_VISIBILITY perms permissions() const noexcept { return __prms_; } // modifiers _LIBCPP_INLINE_VISIBILITY void type(file_type __ft) noexcept { __ft_ = __ft; } _LIBCPP_INLINE_VISIBILITY void permissions(perms __p) noexcept { __prms_ = __p; } private: file_type __ft_; perms __prms_; }; class _LIBCPP_TYPE_VIS directory_entry; template struct __can_convert_char { static const bool value = false; }; template struct __can_convert_char : public __can_convert_char<_Tp> {}; template <> struct __can_convert_char { static const bool value = true; using __char_type = char; }; template <> struct __can_convert_char { static const bool value = true; using __char_type = wchar_t; }; template <> struct __can_convert_char { static const bool value = true; using __char_type = char16_t; }; template <> struct __can_convert_char { static const bool value = true; using __char_type = char32_t; }; template typename enable_if<__can_convert_char<_ECharT>::value, bool>::type __is_separator(_ECharT __e) { return __e == _ECharT('/'); } struct _NullSentinal {}; template using _Void = void; template struct __is_pathable_string : public false_type {}; template struct __is_pathable_string< basic_string<_ECharT, _Traits, _Alloc>, _Void::__char_type> > : public __can_convert_char<_ECharT> { using _Str = basic_string<_ECharT, _Traits, _Alloc>; using _Base = __can_convert_char<_ECharT>; static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } static _ECharT const* __range_end(_Str const& __s) { return __s.data() + __s.length(); } static _ECharT __first_or_null(_Str const& __s) { return __s.empty() ? _ECharT{} : __s[0]; } }; template struct __is_pathable_string< basic_string_view<_ECharT, _Traits>, _Void::__char_type> > : public __can_convert_char<_ECharT> { using _Str = basic_string_view<_ECharT, _Traits>; using _Base = __can_convert_char<_ECharT>; static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } static _ECharT const* __range_end(_Str const& __s) { return __s.data() + __s.length(); } static _ECharT __first_or_null(_Str const& __s) { return __s.empty() ? _ECharT{} : __s[0]; } }; template ::type, class _UnqualPtrType = typename remove_const::type>::type, bool _IsCharPtr = is_pointer<_DS>::value&& __can_convert_char<_UnqualPtrType>::value> struct __is_pathable_char_array : false_type {}; template struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> : __can_convert_char::type> { using _Base = __can_convert_char::type>; static _ECharT const* __range_begin(const _ECharT* __b) { return __b; } static _ECharT const* __range_end(const _ECharT* __b) { using _Iter = const _ECharT*; const _ECharT __sentinal = _ECharT{}; _Iter __e = __b; for (; *__e != __sentinal; ++__e) ; return __e; } static _ECharT __first_or_null(const _ECharT* __b) { return *__b; } }; template ::value, class = void> struct __is_pathable_iter : false_type {}; template struct __is_pathable_iter< _Iter, true, _Void::value_type>::__char_type> > : __can_convert_char::value_type> { using _ECharT = typename iterator_traits<_Iter>::value_type; using _Base = __can_convert_char<_ECharT>; static _Iter __range_begin(_Iter __b) { return __b; } static _NullSentinal __range_end(_Iter) { return _NullSentinal{}; } static _ECharT __first_or_null(_Iter __b) { return *__b; } }; template ::value, bool _IsCharIterT = __is_pathable_char_array<_Tp>::value, bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value> struct __is_pathable : false_type { static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false"); }; template struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {}; template struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> { }; template struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {}; template struct _PathCVT { static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible"); typedef __narrow_to_utf8 _Narrower; static void __append_range(string& __dest, _ECharT const* __b, _ECharT const* __e) { _Narrower()(back_inserter(__dest), __b, __e); } template static void __append_range(string& __dest, _Iter __b, _Iter __e) { static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); if (__b == __e) return; basic_string<_ECharT> __tmp(__b, __e); _Narrower()(back_inserter(__dest), __tmp.data(), __tmp.data() + __tmp.length()); } template static void __append_range(string& __dest, _Iter __b, _NullSentinal) { static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); const _ECharT __sentinal = _ECharT{}; if (*__b == __sentinal) return; basic_string<_ECharT> __tmp; for (; *__b != __sentinal; ++__b) __tmp.push_back(*__b); _Narrower()(back_inserter(__dest), __tmp.data(), __tmp.data() + __tmp.length()); } template static void __append_source(string& __dest, _Source const& __s) { using _Traits = __is_pathable<_Source>; __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s)); } }; template <> struct _PathCVT { template static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type __append_range(string& __dest, _Iter __b, _Iter __e) { for (; __b != __e; ++__b) __dest.push_back(*__b); } template static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type __append_range(string& __dest, _Iter __b, _Iter __e) { __dest.__append_forward_unsafe(__b, __e); } template static void __append_range(string& __dest, _Iter __b, _NullSentinal) { const char __sentinal = char{}; for (; *__b != __sentinal; ++__b) __dest.push_back(*__b); } template static void __append_source(string& __dest, _Source const& __s) { using _Traits = __is_pathable<_Source>; __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s)); } }; class _LIBCPP_TYPE_VIS path { template using _EnableIfPathable = typename enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type; template using _SourceChar = typename __is_pathable<_Tp>::__char_type; template using _SourceCVT = _PathCVT<_SourceChar<_Tp> >; public: typedef char value_type; typedef basic_string string_type; typedef _VSTD::string_view __string_view; static constexpr value_type preferred_separator = '/'; enum class _LIBCPP_ENUM_VIS format : unsigned char { auto_format, native_format, generic_format }; // constructors and destructor _LIBCPP_INLINE_VISIBILITY path() noexcept {} _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {} _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept : __pn_(_VSTD::move(__p.__pn_)) {} _LIBCPP_INLINE_VISIBILITY path(string_type&& __s, format = format::auto_format) noexcept : __pn_(_VSTD::move(__s)) {} template > path(const _Source& __src, format = format::auto_format) { _SourceCVT<_Source>::__append_source(__pn_, __src); } template path(_InputIt __first, _InputIt __last, format = format::auto_format) { typedef typename iterator_traits<_InputIt>::value_type _ItVal; _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); } // TODO Implement locale conversions. template > path(const _Source& __src, const locale& __loc, format = format::auto_format); template path(_InputIt __first, _InputIt _last, const locale& __loc, format = format::auto_format); _LIBCPP_INLINE_VISIBILITY ~path() = default; // assignments _LIBCPP_INLINE_VISIBILITY path& operator=(const path& __p) { __pn_ = __p.__pn_; return *this; } _LIBCPP_INLINE_VISIBILITY path& operator=(path&& __p) noexcept { __pn_ = _VSTD::move(__p.__pn_); return *this; } template _LIBCPP_INLINE_VISIBILITY path& operator=(string_type&& __s) noexcept { __pn_ = _VSTD::move(__s); return *this; } _LIBCPP_INLINE_VISIBILITY path& assign(string_type&& __s) noexcept { __pn_ = _VSTD::move(__s); return *this; } template _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> operator=(const _Source& __src) { return this->assign(__src); } template _EnableIfPathable<_Source> assign(const _Source& __src) { __pn_.clear(); _SourceCVT<_Source>::__append_source(__pn_, __src); return *this; } template path& assign(_InputIt __first, _InputIt __last) { typedef typename iterator_traits<_InputIt>::value_type _ItVal; __pn_.clear(); _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); return *this; } private: template static bool __source_is_absolute(_ECharT __first_or_null) { return __is_separator(__first_or_null); } public: // appends path& operator/=(const path& __p) { if (__p.is_absolute()) { __pn_ = __p.__pn_; return *this; } if (has_filename()) __pn_ += preferred_separator; __pn_ += __p.native(); return *this; } // FIXME: Use _LIBCPP_DIAGNOSE_WARNING to produce a diagnostic when __src // is known at compile time to be "/' since the user almost certainly intended // to append a separator instead of overwriting the path with "/" template _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> operator/=(const _Source& __src) { return this->append(__src); } template _EnableIfPathable<_Source> append(const _Source& __src) { using _Traits = __is_pathable<_Source>; using _CVT = _PathCVT<_SourceChar<_Source> >; if (__source_is_absolute(_Traits::__first_or_null(__src))) __pn_.clear(); else if (has_filename()) __pn_ += preferred_separator; _CVT::__append_source(__pn_, __src); return *this; } template path& append(_InputIt __first, _InputIt __last) { typedef typename iterator_traits<_InputIt>::value_type _ItVal; static_assert(__can_convert_char<_ItVal>::value, "Must convertible"); using _CVT = _PathCVT<_ItVal>; if (__first != __last && __source_is_absolute(*__first)) __pn_.clear(); else if (has_filename()) __pn_ += preferred_separator; _CVT::__append_range(__pn_, __first, __last); return *this; } // concatenation _LIBCPP_INLINE_VISIBILITY path& operator+=(const path& __x) { __pn_ += __x.__pn_; return *this; } _LIBCPP_INLINE_VISIBILITY path& operator+=(const string_type& __x) { __pn_ += __x; return *this; } _LIBCPP_INLINE_VISIBILITY path& operator+=(__string_view __x) { __pn_ += __x; return *this; } _LIBCPP_INLINE_VISIBILITY path& operator+=(const value_type* __x) { __pn_ += __x; return *this; } _LIBCPP_INLINE_VISIBILITY path& operator+=(value_type __x) { __pn_ += __x; return *this; } template typename enable_if<__can_convert_char<_ECharT>::value, path&>::type operator+=(_ECharT __x) { basic_string<_ECharT> __tmp; __tmp += __x; _PathCVT<_ECharT>::__append_source(__pn_, __tmp); return *this; } template _EnableIfPathable<_Source> operator+=(const _Source& __x) { return this->concat(__x); } template _EnableIfPathable<_Source> concat(const _Source& __x) { _SourceCVT<_Source>::__append_source(__pn_, __x); return *this; } template path& concat(_InputIt __first, _InputIt __last) { typedef typename iterator_traits<_InputIt>::value_type _ItVal; _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); return *this; } // modifiers _LIBCPP_INLINE_VISIBILITY void clear() noexcept { __pn_.clear(); } path& make_preferred() { return *this; } _LIBCPP_INLINE_VISIBILITY path& remove_filename() { auto __fname = __filename(); if (!__fname.empty()) __pn_.erase(__fname.data() - __pn_.data()); return *this; } path& replace_filename(const path& __replacement) { remove_filename(); return (*this /= __replacement); } path& replace_extension(const path& __replacement = path()); _LIBCPP_INLINE_VISIBILITY void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); } // private helper to allow reserving memory in the path _LIBCPP_INLINE_VISIBILITY void __reserve(size_t __s) { __pn_.reserve(__s); } // native format observers _LIBCPP_INLINE_VISIBILITY const string_type& native() const noexcept { return __pn_; } _LIBCPP_INLINE_VISIBILITY const value_type* c_str() const noexcept { return __pn_.c_str(); } _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; } template , class _Allocator = allocator<_ECharT> > basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const { using _CVT = __widen_from_utf8; using _Str = basic_string<_ECharT, _Traits, _Allocator>; _Str __s(__a); __s.reserve(__pn_.size()); _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); return __s; } _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; } _LIBCPP_INLINE_VISIBILITY std::wstring wstring() const { return string(); } _LIBCPP_INLINE_VISIBILITY std::string u8string() const { return __pn_; } _LIBCPP_INLINE_VISIBILITY std::u16string u16string() const { return string(); } _LIBCPP_INLINE_VISIBILITY std::u32string u32string() const { return string(); } // generic format observers template , class _Allocator = allocator<_ECharT> > basic_string<_ECharT, _Traits, _Allocator> generic_string(const _Allocator& __a = _Allocator()) const { return string<_ECharT, _Traits, _Allocator>(__a); } std::string generic_string() const { return __pn_; } std::wstring generic_wstring() const { return string(); } std::string generic_u8string() const { return __pn_; } std::u16string generic_u16string() const { return string(); } std::u32string generic_u32string() const { return string(); } private: int __compare(__string_view) const; __string_view __root_name() const; __string_view __root_directory() const; __string_view __root_path_raw() const; __string_view __relative_path() const; __string_view __parent_path() const; __string_view __filename() const; __string_view __stem() const; __string_view __extension() const; public: // compare _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept { return __compare(__p.__pn_); } _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { return __compare(__s); } _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const { return __compare(__s); } _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const { return __compare(__s); } // decomposition _LIBCPP_INLINE_VISIBILITY path root_name() const { return string_type(__root_name()); } _LIBCPP_INLINE_VISIBILITY path root_directory() const { return string_type(__root_directory()); } _LIBCPP_INLINE_VISIBILITY path root_path() const { return root_name().append(string_type(__root_directory())); } _LIBCPP_INLINE_VISIBILITY path relative_path() const { return string_type(__relative_path()); } _LIBCPP_INLINE_VISIBILITY path parent_path() const { return string_type(__parent_path()); } _LIBCPP_INLINE_VISIBILITY path filename() const { return string_type(__filename()); } _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); } _LIBCPP_INLINE_VISIBILITY path extension() const { return string_type(__extension()); } // query _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const noexcept { return __pn_.empty(); } _LIBCPP_INLINE_VISIBILITY bool has_root_name() const { return !__root_name().empty(); } _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { return !__root_directory().empty(); } _LIBCPP_INLINE_VISIBILITY bool has_root_path() const { return !__root_path_raw().empty(); } _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const { return !__relative_path().empty(); } _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const { return !__parent_path().empty(); } _LIBCPP_INLINE_VISIBILITY bool has_filename() const { return !__filename().empty(); } _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); } _LIBCPP_INLINE_VISIBILITY bool has_extension() const { return !__extension().empty(); } _LIBCPP_INLINE_VISIBILITY bool is_absolute() const { return has_root_directory(); } _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); } // relative paths path lexically_normal() const; path lexically_relative(const path& __base) const; _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const { path __result = this->lexically_relative(__base); if (__result.native().empty()) return *this; return __result; } // iterators class _LIBCPP_TYPE_VIS iterator; typedef iterator const_iterator; iterator begin() const; iterator end() const; template _LIBCPP_INLINE_VISIBILITY friend typename enable_if::value && is_same<_Traits, char_traits >::value, basic_ostream<_CharT, _Traits>&>::type operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { __os << std::__quoted(__p.native()); return __os; } template _LIBCPP_INLINE_VISIBILITY friend typename enable_if::value || !is_same<_Traits, char_traits >::value, basic_ostream<_CharT, _Traits>&>::type operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { __os << std::__quoted(__p.string<_CharT, _Traits>()); return __os; } template _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) { basic_string<_CharT, _Traits> __tmp; __is >> __quoted(__tmp); __p = __tmp; return __is; } friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept { return __lhs.compare(__rhs) == 0; } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept { return __lhs.compare(__rhs) != 0; } friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept { return __lhs.compare(__rhs) < 0; } friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept { return __lhs.compare(__rhs) <= 0; } friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept { return __lhs.compare(__rhs) > 0; } friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept { return __lhs.compare(__rhs) >= 0; } friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs, const path& __rhs) { path __result(__lhs); __result /= __rhs; return __result; } private: inline _LIBCPP_INLINE_VISIBILITY path& __assign_view(__string_view const& __s) noexcept { __pn_ = string_type(__s); return *this; } string_type __pn_; }; inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); } _LIBCPP_FUNC_VIS size_t hash_value(const path& __p) noexcept; template _LIBCPP_INLINE_VISIBILITY typename enable_if<__is_pathable<_Source>::value, path>::type u8path(const _Source& __s) { static_assert( is_same::__char_type, char>::value, "u8path(Source const&) requires Source have a character type of type " "'char'"); return path(__s); } template _LIBCPP_INLINE_VISIBILITY typename enable_if<__is_pathable<_InputIt>::value, path>::type u8path(_InputIt __f, _InputIt __l) { static_assert( is_same::__char_type, char>::value, "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"); return path(__f, __l); } class _LIBCPP_TYPE_VIS path::iterator { public: enum _ParserState : unsigned char { _Singular, _BeforeBegin, _InRootName, _InRootDir, _InFilenames, _InTrailingSep, _AtEnd }; public: typedef bidirectional_iterator_tag iterator_category; typedef path value_type; typedef std::ptrdiff_t difference_type; typedef const path* pointer; typedef const path& reference; typedef void __stashing_iterator_tag; // See reverse_iterator and __is_stashing_iterator public: _LIBCPP_INLINE_VISIBILITY iterator() : __stashed_elem_(), __path_ptr_(nullptr), __entry_(), __state_(_Singular) {} iterator(const iterator&) = default; ~iterator() = default; iterator& operator=(const iterator&) = default; _LIBCPP_INLINE_VISIBILITY reference operator*() const { return __stashed_elem_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { return &__stashed_elem_; } _LIBCPP_INLINE_VISIBILITY iterator& operator++() { _LIBCPP_ASSERT(__state_ != _Singular, "attempting to increment a singular iterator"); _LIBCPP_ASSERT(__state_ != _AtEnd, "attempting to increment the end iterator"); return __increment(); } _LIBCPP_INLINE_VISIBILITY iterator operator++(int) { iterator __it(*this); this->operator++(); return __it; } _LIBCPP_INLINE_VISIBILITY iterator& operator--() { _LIBCPP_ASSERT(__state_ != _Singular, "attempting to decrement a singular iterator"); _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(), "attempting to decrement the begin iterator"); return __decrement(); } _LIBCPP_INLINE_VISIBILITY iterator operator--(int) { iterator __it(*this); this->operator--(); return __it; } private: friend class path; inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&, const iterator&); iterator& __increment(); iterator& __decrement(); path __stashed_elem_; const path* __path_ptr_; path::__string_view __entry_; _ParserState __state_; }; inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path::iterator& __lhs, const path::iterator& __rhs) { return __lhs.__path_ptr_ == __rhs.__path_ptr_ && __lhs.__entry_.data() == __rhs.__entry_.data(); } inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs, const path::iterator& __rhs) { return !(__lhs == __rhs); } // TODO(ldionne): We need to pop the pragma and push it again after // filesystem_error to work around PR41078. _LIBCPP_AVAILABILITY_FILESYSTEM_POP class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error { public: _LIBCPP_INLINE_VISIBILITY filesystem_error(const string& __what, error_code __ec) : system_error(__ec, __what), __storage_(make_shared<_Storage>(path(), path())) { __create_what(0); } _LIBCPP_INLINE_VISIBILITY filesystem_error(const string& __what, const path& __p1, error_code __ec) : system_error(__ec, __what), __storage_(make_shared<_Storage>(__p1, path())) { __create_what(1); } _LIBCPP_INLINE_VISIBILITY filesystem_error(const string& __what, const path& __p1, const path& __p2, error_code __ec) : system_error(__ec, __what), __storage_(make_shared<_Storage>(__p1, __p2)) { __create_what(2); } _LIBCPP_INLINE_VISIBILITY const path& path1() const noexcept { return __storage_->__p1_; } _LIBCPP_INLINE_VISIBILITY const path& path2() const noexcept { return __storage_->__p2_; } + filesystem_error(const filesystem_error&) = default; ~filesystem_error() override; // key function _LIBCPP_INLINE_VISIBILITY const char* what() const noexcept override { return __storage_->__what_.c_str(); } void __create_what(int __num_paths); private: struct _LIBCPP_HIDDEN _Storage { _LIBCPP_INLINE_VISIBILITY _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {} path __p1_; path __p2_; string __what_; }; shared_ptr<_Storage> __storage_; }; _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH template _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_NO_EXCEPTIONS void __throw_filesystem_error(_Args&&... __args) { throw filesystem_error(std::forward<_Args>(__args)...); } #else void __throw_filesystem_error(_Args&&...) { _VSTD::abort(); } #endif // operational functions _LIBCPP_FUNC_VIS path __absolute(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS path __canonical(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS void __copy(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS bool __copy_file(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS bool __create_directories(const path& p, error_code* ec = nullptr); _LIBCPP_FUNC_VIS bool __create_directory(const path& p, error_code* ec = nullptr); _LIBCPP_FUNC_VIS bool __create_directory(const path& p, const path& attributes, error_code* ec = nullptr); _LIBCPP_FUNC_VIS void __create_directory_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS void __create_hard_link(const path& __to, const path& __new_hard_link, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS void __create_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS path __current_path(error_code* __ec = nullptr); _LIBCPP_FUNC_VIS void __current_path(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS bool __equivalent(const path&, const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS uintmax_t __file_size(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS bool __fs_is_empty(const path& p, error_code* ec = nullptr); _LIBCPP_FUNC_VIS file_time_type __last_write_time(const path& p, error_code* ec = nullptr); _LIBCPP_FUNC_VIS void __last_write_time(const path& p, file_time_type new_time, error_code* ec = nullptr); _LIBCPP_FUNC_VIS void __permissions(const path&, perms, perm_options, error_code* = nullptr); _LIBCPP_FUNC_VIS path __read_symlink(const path& p, error_code* ec = nullptr); _LIBCPP_FUNC_VIS bool __remove(const path& p, error_code* ec = nullptr); _LIBCPP_FUNC_VIS uintmax_t __remove_all(const path& p, error_code* ec = nullptr); _LIBCPP_FUNC_VIS void __rename(const path& from, const path& to, error_code* ec = nullptr); _LIBCPP_FUNC_VIS void __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr); _LIBCPP_FUNC_VIS space_info __space(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS file_status __status(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS file_status __symlink_status(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS path __system_complete(const path&, error_code* __ec = nullptr); _LIBCPP_FUNC_VIS path __temp_directory_path(error_code* __ec = nullptr); _LIBCPP_FUNC_VIS path __weakly_canonical(path const& __p, error_code* __ec = nullptr); inline _LIBCPP_INLINE_VISIBILITY path current_path() { return __current_path(); } inline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) { return __current_path(&__ec); } inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) { __current_path(__p); } inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) { return __absolute(__p); } inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) { return __canonical(__p); } inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); } inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); } inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); } inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); } inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); } inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); } inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { return __copy_file(__from, __to, __opt, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __existing, const path& __new) { __copy_symlink(__existing, __new); } inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __ext, const path& __new, error_code& __ec) noexcept { __copy_symlink(__ext, __new, &__ec); } inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) { return __create_directories(__p); } inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) { return __create_directory(__p); } inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); } inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __to, const path& __new) { __create_directory_symlink(__to, __new); } inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __to, const path& __new, error_code& __ec) noexcept { __create_directory_symlink(__to, __new, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __to, const path& __new) { __create_hard_link(__to, __new); } inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __to, const path& __new, error_code& __ec) noexcept { __create_hard_link(__to, __new, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __to, const path& __new) { __create_symlink(__to, __new); } inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __to, const path& __new, error_code& __ec) noexcept { return __create_symlink(__to, __new, &__ec); } inline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; } inline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; } inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) { return exists(__status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) noexcept { auto __s = __status(__p, &__ec); if (status_known(__s)) __ec.clear(); return exists(__s); } inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); } inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); } inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) { return __file_size(__p); } inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); } inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; } inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) { return is_block_file(__status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); } inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; } inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) { return is_character_file(__status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); } inline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; } inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) { return is_directory(__status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p, error_code& __ec) noexcept { return is_directory(__status(__p, &__ec)); } inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) { return __fs_is_empty(__p); } inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; } inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) { return is_fifo(__status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); } inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; } inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); } inline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; } inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) { return is_socket(__status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); } inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; } inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); } inline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); } inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) { return is_other(__status(__p)); } inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); } inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p) { return __last_write_time(__p); } inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); } inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { __last_write_time(__p, __t, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); } inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); } inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base, error_code& __ec) { path __tmp = __weakly_canonical(__p, &__ec); if (__ec) return {}; path __tmp_base = __weakly_canonical(__base, &__ec); if (__ec) return {}; return __tmp.lexically_proximate(__tmp_base); } inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); } inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate( __weakly_canonical(__base)); } inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) { return __read_symlink(__p); } inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base, error_code& __ec) { path __tmp = __weakly_canonical(__p, &__ec); if (__ec) return path(); path __tmpbase = __weakly_canonical(__base, &__ec); if (__ec) return path(); return __tmp.lexically_relative(__tmpbase); } inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); } inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); } inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) { return __remove(__p); } inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) { return __remove_all(__p); } inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to) { return __rename(__from, __to); } inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); } inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); } inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { return __resize_file(__p, __ns, &__ec); } inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) { return __space(__p); } inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) { return __status(__p); } inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) { return __symlink_status(__p); } inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); } inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() { return __temp_directory_path(); } inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); } inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) { return __weakly_canonical(__p); } inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); } class directory_iterator; class recursive_directory_iterator; class _LIBCPP_HIDDEN __dir_stream; class directory_entry { typedef _VSTD_FS::path _Path; public: // constructors and destructors directory_entry() noexcept = default; directory_entry(directory_entry const&) = default; directory_entry(directory_entry&&) noexcept = default; _LIBCPP_INLINE_VISIBILITY explicit directory_entry(_Path const& __p) : __p_(__p) { error_code __ec; __refresh(&__ec); } _LIBCPP_INLINE_VISIBILITY directory_entry(_Path const& __p, error_code& __ec) : __p_(__p) { __refresh(&__ec); } ~directory_entry() {} directory_entry& operator=(directory_entry const&) = default; directory_entry& operator=(directory_entry&&) noexcept = default; _LIBCPP_INLINE_VISIBILITY void assign(_Path const& __p) { __p_ = __p; error_code __ec; __refresh(&__ec); } _LIBCPP_INLINE_VISIBILITY void assign(_Path const& __p, error_code& __ec) { __p_ = __p; __refresh(&__ec); } _LIBCPP_INLINE_VISIBILITY void replace_filename(_Path const& __p) { __p_.replace_filename(__p); error_code __ec; __refresh(&__ec); } _LIBCPP_INLINE_VISIBILITY void replace_filename(_Path const& __p, error_code& __ec) { __p_ = __p_.parent_path() / __p; __refresh(&__ec); } _LIBCPP_INLINE_VISIBILITY void refresh() { __refresh(); } _LIBCPP_INLINE_VISIBILITY void refresh(error_code& __ec) noexcept { __refresh(&__ec); } _LIBCPP_INLINE_VISIBILITY _Path const& path() const noexcept { return __p_; } _LIBCPP_INLINE_VISIBILITY operator const _Path&() const noexcept { return __p_; } _LIBCPP_INLINE_VISIBILITY bool exists() const { return _VSTD_FS::exists(file_status{__get_ft()}); } _LIBCPP_INLINE_VISIBILITY bool exists(error_code& __ec) const noexcept { return _VSTD_FS::exists(file_status{__get_ft(&__ec)}); } _LIBCPP_INLINE_VISIBILITY bool is_block_file() const { return __get_ft() == file_type::block; } _LIBCPP_INLINE_VISIBILITY bool is_block_file(error_code& __ec) const noexcept { return __get_ft(&__ec) == file_type::block; } _LIBCPP_INLINE_VISIBILITY bool is_character_file() const { return __get_ft() == file_type::character; } _LIBCPP_INLINE_VISIBILITY bool is_character_file(error_code& __ec) const noexcept { return __get_ft(&__ec) == file_type::character; } _LIBCPP_INLINE_VISIBILITY bool is_directory() const { return __get_ft() == file_type::directory; } _LIBCPP_INLINE_VISIBILITY bool is_directory(error_code& __ec) const noexcept { return __get_ft(&__ec) == file_type::directory; } _LIBCPP_INLINE_VISIBILITY bool is_fifo() const { return __get_ft() == file_type::fifo; } _LIBCPP_INLINE_VISIBILITY bool is_fifo(error_code& __ec) const noexcept { return __get_ft(&__ec) == file_type::fifo; } _LIBCPP_INLINE_VISIBILITY bool is_other() const { return _VSTD_FS::is_other(file_status{__get_ft()}); } _LIBCPP_INLINE_VISIBILITY bool is_other(error_code& __ec) const noexcept { return _VSTD_FS::is_other(file_status{__get_ft(&__ec)}); } _LIBCPP_INLINE_VISIBILITY bool is_regular_file() const { return __get_ft() == file_type::regular; } _LIBCPP_INLINE_VISIBILITY bool is_regular_file(error_code& __ec) const noexcept { return __get_ft(&__ec) == file_type::regular; } _LIBCPP_INLINE_VISIBILITY bool is_socket() const { return __get_ft() == file_type::socket; } _LIBCPP_INLINE_VISIBILITY bool is_socket(error_code& __ec) const noexcept { return __get_ft(&__ec) == file_type::socket; } _LIBCPP_INLINE_VISIBILITY bool is_symlink() const { return __get_sym_ft() == file_type::symlink; } _LIBCPP_INLINE_VISIBILITY bool is_symlink(error_code& __ec) const noexcept { return __get_sym_ft(&__ec) == file_type::symlink; } _LIBCPP_INLINE_VISIBILITY uintmax_t file_size() const { return __get_size(); } _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(error_code& __ec) const noexcept { return __get_size(&__ec); } _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count() const { return __get_nlink(); } _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(error_code& __ec) const noexcept { return __get_nlink(&__ec); } _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time() const { return __get_write_time(); } _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(error_code& __ec) const noexcept { return __get_write_time(&__ec); } _LIBCPP_INLINE_VISIBILITY file_status status() const { return __get_status(); } _LIBCPP_INLINE_VISIBILITY file_status status(error_code& __ec) const noexcept { return __get_status(&__ec); } _LIBCPP_INLINE_VISIBILITY file_status symlink_status() const { return __get_symlink_status(); } _LIBCPP_INLINE_VISIBILITY file_status symlink_status(error_code& __ec) const noexcept { return __get_symlink_status(&__ec); } _LIBCPP_INLINE_VISIBILITY bool operator<(directory_entry const& __rhs) const noexcept { return __p_ < __rhs.__p_; } _LIBCPP_INLINE_VISIBILITY bool operator==(directory_entry const& __rhs) const noexcept { return __p_ == __rhs.__p_; } _LIBCPP_INLINE_VISIBILITY bool operator!=(directory_entry const& __rhs) const noexcept { return __p_ != __rhs.__p_; } _LIBCPP_INLINE_VISIBILITY bool operator<=(directory_entry const& __rhs) const noexcept { return __p_ <= __rhs.__p_; } _LIBCPP_INLINE_VISIBILITY bool operator>(directory_entry const& __rhs) const noexcept { return __p_ > __rhs.__p_; } _LIBCPP_INLINE_VISIBILITY bool operator>=(directory_entry const& __rhs) const noexcept { return __p_ >= __rhs.__p_; } private: friend class directory_iterator; friend class recursive_directory_iterator; friend class __dir_stream; enum _CacheType : unsigned char { _Empty, _IterSymlink, _IterNonSymlink, _RefreshSymlink, _RefreshSymlinkUnresolved, _RefreshNonSymlink }; struct __cached_data { uintmax_t __size_; uintmax_t __nlink_; file_time_type __write_time_; perms __sym_perms_; perms __non_sym_perms_; file_type __type_; _CacheType __cache_type_; _LIBCPP_INLINE_VISIBILITY __cached_data() noexcept { __reset(); } _LIBCPP_INLINE_VISIBILITY void __reset() { __cache_type_ = _Empty; __type_ = file_type::none; __sym_perms_ = __non_sym_perms_ = perms::unknown; __size_ = __nlink_ = uintmax_t(-1); __write_time_ = file_time_type::min(); } }; _LIBCPP_INLINE_VISIBILITY static __cached_data __create_iter_result(file_type __ft) { __cached_data __data; __data.__type_ = __ft; __data.__cache_type_ = [&]() { switch (__ft) { case file_type::none: return _Empty; case file_type::symlink: return _IterSymlink; default: return _IterNonSymlink; } }(); return __data; } _LIBCPP_INLINE_VISIBILITY void __assign_iter_entry(_Path&& __p, __cached_data __dt) { __p_ = std::move(__p); __data_ = __dt; } _LIBCPP_FUNC_VIS error_code __do_refresh() noexcept; _LIBCPP_INLINE_VISIBILITY static bool __is_dne_error(error_code const& __ec) { if (!__ec) return true; switch (static_cast(__ec.value())) { case errc::no_such_file_or_directory: case errc::not_a_directory: return true; default: return false; } } _LIBCPP_INLINE_VISIBILITY void __handle_error(const char* __msg, error_code* __dest_ec, error_code const& __ec, bool __allow_dne = false) const { if (__dest_ec) { *__dest_ec = __ec; return; } if (__ec && (!__allow_dne || !__is_dne_error(__ec))) __throw_filesystem_error(__msg, __p_, __ec); } _LIBCPP_INLINE_VISIBILITY void __refresh(error_code* __ec = nullptr) { __handle_error("in directory_entry::refresh", __ec, __do_refresh(), /*allow_dne*/ true); } _LIBCPP_INLINE_VISIBILITY file_type __get_sym_ft(error_code* __ec = nullptr) const { switch (__data_.__cache_type_) { case _Empty: return __symlink_status(__p_, __ec).type(); case _IterSymlink: case _RefreshSymlink: case _RefreshSymlinkUnresolved: if (__ec) __ec->clear(); return file_type::symlink; case _IterNonSymlink: case _RefreshNonSymlink: file_status __st(__data_.__type_); if (__ec && !_VSTD_FS::exists(__st)) *__ec = make_error_code(errc::no_such_file_or_directory); else if (__ec) __ec->clear(); return __data_.__type_; } _LIBCPP_UNREACHABLE(); } _LIBCPP_INLINE_VISIBILITY file_type __get_ft(error_code* __ec = nullptr) const { switch (__data_.__cache_type_) { case _Empty: case _IterSymlink: case _RefreshSymlinkUnresolved: return __status(__p_, __ec).type(); case _IterNonSymlink: case _RefreshNonSymlink: case _RefreshSymlink: { file_status __st(__data_.__type_); if (__ec && !_VSTD_FS::exists(__st)) *__ec = make_error_code(errc::no_such_file_or_directory); else if (__ec) __ec->clear(); return __data_.__type_; } } _LIBCPP_UNREACHABLE(); } _LIBCPP_INLINE_VISIBILITY file_status __get_status(error_code* __ec = nullptr) const { switch (__data_.__cache_type_) { case _Empty: case _IterNonSymlink: case _IterSymlink: case _RefreshSymlinkUnresolved: return __status(__p_, __ec); case _RefreshNonSymlink: case _RefreshSymlink: return file_status(__get_ft(__ec), __data_.__non_sym_perms_); } _LIBCPP_UNREACHABLE(); } _LIBCPP_INLINE_VISIBILITY file_status __get_symlink_status(error_code* __ec = nullptr) const { switch (__data_.__cache_type_) { case _Empty: case _IterNonSymlink: case _IterSymlink: return __symlink_status(__p_, __ec); case _RefreshNonSymlink: return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_); case _RefreshSymlink: case _RefreshSymlinkUnresolved: return file_status(__get_sym_ft(__ec), __data_.__sym_perms_); } _LIBCPP_UNREACHABLE(); } _LIBCPP_INLINE_VISIBILITY uintmax_t __get_size(error_code* __ec = nullptr) const { switch (__data_.__cache_type_) { case _Empty: case _IterNonSymlink: case _IterSymlink: case _RefreshSymlinkUnresolved: return _VSTD_FS::__file_size(__p_, __ec); case _RefreshSymlink: case _RefreshNonSymlink: { error_code __m_ec; file_status __st(__get_ft(&__m_ec)); __handle_error("in directory_entry::file_size", __ec, __m_ec); if (_VSTD_FS::exists(__st) && !_VSTD_FS::is_regular_file(__st)) { errc __err_kind = _VSTD_FS::is_directory(__st) ? errc::is_a_directory : errc::not_supported; __handle_error("in directory_entry::file_size", __ec, make_error_code(__err_kind)); } return __data_.__size_; } } _LIBCPP_UNREACHABLE(); } _LIBCPP_INLINE_VISIBILITY uintmax_t __get_nlink(error_code* __ec = nullptr) const { switch (__data_.__cache_type_) { case _Empty: case _IterNonSymlink: case _IterSymlink: case _RefreshSymlinkUnresolved: return _VSTD_FS::__hard_link_count(__p_, __ec); case _RefreshSymlink: case _RefreshNonSymlink: { error_code __m_ec; (void)__get_ft(&__m_ec); __handle_error("in directory_entry::hard_link_count", __ec, __m_ec); return __data_.__nlink_; } } _LIBCPP_UNREACHABLE(); } _LIBCPP_INLINE_VISIBILITY file_time_type __get_write_time(error_code* __ec = nullptr) const { switch (__data_.__cache_type_) { case _Empty: case _IterNonSymlink: case _IterSymlink: case _RefreshSymlinkUnresolved: return _VSTD_FS::__last_write_time(__p_, __ec); case _RefreshSymlink: case _RefreshNonSymlink: { error_code __m_ec; file_status __st(__get_ft(&__m_ec)); __handle_error("in directory_entry::last_write_time", __ec, __m_ec); if (_VSTD_FS::exists(__st) && __data_.__write_time_ == file_time_type::min()) __handle_error("in directory_entry::last_write_time", __ec, make_error_code(errc::value_too_large)); return __data_.__write_time_; } } _LIBCPP_UNREACHABLE(); } private: _Path __p_; __cached_data __data_; }; class __dir_element_proxy { public: inline _LIBCPP_INLINE_VISIBILITY directory_entry operator*() { return _VSTD::move(__elem_); } private: friend class directory_iterator; friend class recursive_directory_iterator; explicit __dir_element_proxy(directory_entry const& __e) : __elem_(__e) {} __dir_element_proxy(__dir_element_proxy&& __o) : __elem_(_VSTD::move(__o.__elem_)) {} directory_entry __elem_; }; class directory_iterator { public: typedef directory_entry value_type; typedef ptrdiff_t difference_type; typedef value_type const* pointer; typedef value_type const& reference; typedef input_iterator_tag iterator_category; public: //ctor & dtor directory_iterator() noexcept {} explicit directory_iterator(const path& __p) : directory_iterator(__p, nullptr) {} directory_iterator(const path& __p, directory_options __opts) : directory_iterator(__p, nullptr, __opts) {} directory_iterator(const path& __p, error_code& __ec) : directory_iterator(__p, &__ec) {} directory_iterator(const path& __p, directory_options __opts, error_code& __ec) : directory_iterator(__p, &__ec, __opts) {} directory_iterator(const directory_iterator&) = default; directory_iterator(directory_iterator&&) = default; directory_iterator& operator=(const directory_iterator&) = default; directory_iterator& operator=(directory_iterator&& __o) noexcept { // non-default implementation provided to support self-move assign. if (this != &__o) { __imp_ = _VSTD::move(__o.__imp_); } return *this; } ~directory_iterator() = default; const directory_entry& operator*() const { _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced"); return __dereference(); } const directory_entry* operator->() const { return &**this; } directory_iterator& operator++() { return __increment(); } __dir_element_proxy operator++(int) { __dir_element_proxy __p(**this); __increment(); return __p; } directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } private: inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const directory_iterator& __lhs, const directory_iterator& __rhs) noexcept; // construct the dir_stream _LIBCPP_FUNC_VIS directory_iterator(const path&, error_code*, directory_options = directory_options::none); _LIBCPP_FUNC_VIS directory_iterator& __increment(error_code* __ec = nullptr); _LIBCPP_FUNC_VIS const directory_entry& __dereference() const; private: shared_ptr<__dir_stream> __imp_; }; inline _LIBCPP_INLINE_VISIBILITY bool operator==(const directory_iterator& __lhs, const directory_iterator& __rhs) noexcept { return __lhs.__imp_ == __rhs.__imp_; } inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const directory_iterator& __lhs, const directory_iterator& __rhs) noexcept { return !(__lhs == __rhs); } // enable directory_iterator range-based for statements inline _LIBCPP_INLINE_VISIBILITY directory_iterator begin(directory_iterator __iter) noexcept { return __iter; } inline _LIBCPP_INLINE_VISIBILITY directory_iterator end(const directory_iterator&) noexcept { return directory_iterator(); } class recursive_directory_iterator { public: using value_type = directory_entry; using difference_type = std::ptrdiff_t; using pointer = directory_entry const*; using reference = directory_entry const&; using iterator_category = std::input_iterator_tag; public: // constructors and destructor _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator() noexcept : __rec_(false) {} _LIBCPP_INLINE_VISIBILITY explicit recursive_directory_iterator( const path& __p, directory_options __xoptions = directory_options::none) : recursive_directory_iterator(__p, __xoptions, nullptr) {} _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator(const path& __p, directory_options __xoptions, error_code& __ec) : recursive_directory_iterator(__p, __xoptions, &__ec) {} _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator(const path& __p, error_code& __ec) : recursive_directory_iterator(__p, directory_options::none, &__ec) {} recursive_directory_iterator(const recursive_directory_iterator&) = default; recursive_directory_iterator(recursive_directory_iterator&&) = default; recursive_directory_iterator& operator=(const recursive_directory_iterator&) = default; _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator& operator=(recursive_directory_iterator&& __o) noexcept { // non-default implementation provided to support self-move assign. if (this != &__o) { __imp_ = _VSTD::move(__o.__imp_); __rec_ = __o.__rec_; } return *this; } ~recursive_directory_iterator() = default; _LIBCPP_INLINE_VISIBILITY const directory_entry& operator*() const { return __dereference(); } _LIBCPP_INLINE_VISIBILITY const directory_entry* operator->() const { return &__dereference(); } recursive_directory_iterator& operator++() { return __increment(); } _LIBCPP_INLINE_VISIBILITY __dir_element_proxy operator++(int) { __dir_element_proxy __p(**this); __increment(); return __p; } _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } _LIBCPP_FUNC_VIS directory_options options() const; _LIBCPP_FUNC_VIS int depth() const; _LIBCPP_INLINE_VISIBILITY void pop() { __pop(); } _LIBCPP_INLINE_VISIBILITY void pop(error_code& __ec) { __pop(&__ec); } _LIBCPP_INLINE_VISIBILITY bool recursion_pending() const { return __rec_; } _LIBCPP_INLINE_VISIBILITY void disable_recursion_pending() { __rec_ = false; } private: _LIBCPP_FUNC_VIS recursive_directory_iterator(const path& __p, directory_options __opt, error_code* __ec); _LIBCPP_FUNC_VIS const directory_entry& __dereference() const; _LIBCPP_FUNC_VIS bool __try_recursion(error_code* __ec); _LIBCPP_FUNC_VIS void __advance(error_code* __ec = nullptr); _LIBCPP_FUNC_VIS recursive_directory_iterator& __increment(error_code* __ec = nullptr); _LIBCPP_FUNC_VIS void __pop(error_code* __ec = nullptr); inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const recursive_directory_iterator&, const recursive_directory_iterator&) noexcept; struct _LIBCPP_HIDDEN __shared_imp; shared_ptr<__shared_imp> __imp_; bool __rec_; }; // class recursive_directory_iterator inline _LIBCPP_INLINE_VISIBILITY bool operator==(const recursive_directory_iterator& __lhs, const recursive_directory_iterator& __rhs) noexcept { return __lhs.__imp_ == __rhs.__imp_; } _LIBCPP_INLINE_VISIBILITY inline bool operator!=(const recursive_directory_iterator& __lhs, const recursive_directory_iterator& __rhs) noexcept { return !(__lhs == __rhs); } // enable recursive_directory_iterator range-based for statements inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator begin(recursive_directory_iterator __iter) noexcept { return __iter; } inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator end(const recursive_directory_iterator&) noexcept { return recursive_directory_iterator(); } _LIBCPP_AVAILABILITY_FILESYSTEM_POP _LIBCPP_END_NAMESPACE_FILESYSTEM #endif // !_LIBCPP_CXX03_LANG _LIBCPP_POP_MACROS #endif // _LIBCPP_FILESYSTEM Index: head/contrib/llvm-project/libcxx/include/future =================================================================== --- head/contrib/llvm-project/libcxx/include/future (revision 359086) +++ head/contrib/llvm-project/libcxx/include/future (revision 359087) @@ -1,2608 +1,2609 @@ // -*- C++ -*- //===--------------------------- future -----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_FUTURE #define _LIBCPP_FUTURE /* future synopsis namespace std { enum class future_errc { future_already_retrieved = 1, promise_already_satisfied, no_state, broken_promise }; enum class launch { async = 1, deferred = 2, any = async | deferred }; enum class future_status { ready, timeout, deferred }; template <> struct is_error_code_enum : public true_type { }; error_code make_error_code(future_errc e) noexcept; error_condition make_error_condition(future_errc e) noexcept; const error_category& future_category() noexcept; class future_error : public logic_error { public: future_error(error_code ec); // exposition only explicit future_error(future_errc); // C++17 const error_code& code() const noexcept; const char* what() const noexcept; }; template class promise { public: promise(); template promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept; promise(const promise& rhs) = delete; ~promise(); // assignment promise& operator=(promise&& rhs) noexcept; promise& operator=(const promise& rhs) = delete; void swap(promise& other) noexcept; // retrieving the result future get_future(); // setting the result void set_value(const R& r); void set_value(R&& r); void set_exception(exception_ptr p); // setting the result with deferred notification void set_value_at_thread_exit(const R& r); void set_value_at_thread_exit(R&& r); void set_exception_at_thread_exit(exception_ptr p); }; template class promise { public: promise(); template promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept; promise(const promise& rhs) = delete; ~promise(); // assignment promise& operator=(promise&& rhs) noexcept; promise& operator=(const promise& rhs) = delete; void swap(promise& other) noexcept; // retrieving the result future get_future(); // setting the result void set_value(R& r); void set_exception(exception_ptr p); // setting the result with deferred notification void set_value_at_thread_exit(R&); void set_exception_at_thread_exit(exception_ptr p); }; template <> class promise { public: promise(); template promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept; promise(const promise& rhs) = delete; ~promise(); // assignment promise& operator=(promise&& rhs) noexcept; promise& operator=(const promise& rhs) = delete; void swap(promise& other) noexcept; // retrieving the result future get_future(); // setting the result void set_value(); void set_exception(exception_ptr p); // setting the result with deferred notification void set_value_at_thread_exit(); void set_exception_at_thread_exit(exception_ptr p); }; template void swap(promise& x, promise& y) noexcept; template struct uses_allocator, Alloc> : public true_type {}; template class future { public: future() noexcept; future(future&&) noexcept; future(const future& rhs) = delete; ~future(); future& operator=(const future& rhs) = delete; future& operator=(future&&) noexcept; shared_future share() noexcept; // retrieving the value R get(); // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template class future { public: future() noexcept; future(future&&) noexcept; future(const future& rhs) = delete; ~future(); future& operator=(const future& rhs) = delete; future& operator=(future&&) noexcept; shared_future share() noexcept; // retrieving the value R& get(); // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template <> class future { public: future() noexcept; future(future&&) noexcept; future(const future& rhs) = delete; ~future(); future& operator=(const future& rhs) = delete; future& operator=(future&&) noexcept; shared_future share() noexcept; // retrieving the value void get(); // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template class shared_future { public: shared_future() noexcept; shared_future(const shared_future& rhs); shared_future(future&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future(); shared_future& operator=(const shared_future& rhs); shared_future& operator=(shared_future&& rhs) noexcept; // retrieving the value const R& get() const; // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template class shared_future { public: shared_future() noexcept; shared_future(const shared_future& rhs); shared_future(future&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future(); shared_future& operator=(const shared_future& rhs); shared_future& operator=(shared_future&& rhs) noexcept; // retrieving the value R& get() const; // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template <> class shared_future { public: shared_future() noexcept; shared_future(const shared_future& rhs); shared_future(future&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future(); shared_future& operator=(const shared_future& rhs); shared_future& operator=(shared_future&& rhs) noexcept; // retrieving the value void get() const; // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template future::type(typename decay::type...)>::type> async(F&& f, Args&&... args); template future::type(typename decay::type...)>::type> async(launch policy, F&& f, Args&&... args); template class packaged_task; // undefined template class packaged_task { public: typedef R result_type; // extension // construction and destruction packaged_task() noexcept; template explicit packaged_task(F&& f); template packaged_task(allocator_arg_t, const Allocator& a, F&& f); ~packaged_task(); // no copy packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; // move support packaged_task(packaged_task&& other) noexcept; packaged_task& operator=(packaged_task&& other) noexcept; void swap(packaged_task& other) noexcept; bool valid() const noexcept; // result retrieval future get_future(); // execution void operator()(ArgTypes... ); void make_ready_at_thread_exit(ArgTypes...); void reset(); }; template void swap(packaged_task&) noexcept; template struct uses_allocator, Alloc>; } // std */ #include <__config> #include #include #include #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif #ifdef _LIBCPP_HAS_NO_THREADS #error is not supported on this single threaded system #else // !_LIBCPP_HAS_NO_THREADS _LIBCPP_BEGIN_NAMESPACE_STD //enum class future_errc _LIBCPP_DECLARE_STRONG_ENUM(future_errc) { future_already_retrieved = 1, promise_already_satisfied, no_state, broken_promise }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type {}; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type { }; #endif //enum class launch _LIBCPP_DECLARE_STRONG_ENUM(launch) { async = 1, deferred = 2, any = async | deferred }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) #ifndef _LIBCPP_HAS_NO_STRONG_ENUMS typedef underlying_type::type __launch_underlying_type; inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR launch operator&(launch __x, launch __y) { return static_cast(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y)); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR launch operator|(launch __x, launch __y) { return static_cast(static_cast<__launch_underlying_type>(__x) | static_cast<__launch_underlying_type>(__y)); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR launch operator^(launch __x, launch __y) { return static_cast(static_cast<__launch_underlying_type>(__x) ^ static_cast<__launch_underlying_type>(__y)); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR launch operator~(launch __x) { return static_cast(~static_cast<__launch_underlying_type>(__x) & 3); } inline _LIBCPP_INLINE_VISIBILITY launch& operator&=(launch& __x, launch __y) { __x = __x & __y; return __x; } inline _LIBCPP_INLINE_VISIBILITY launch& operator|=(launch& __x, launch __y) { __x = __x | __y; return __x; } inline _LIBCPP_INLINE_VISIBILITY launch& operator^=(launch& __x, launch __y) { __x = __x ^ __y; return __x; } #endif // !_LIBCPP_HAS_NO_STRONG_ENUMS //enum class future_status _LIBCPP_DECLARE_STRONG_ENUM(future_status) { ready, timeout, deferred }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_status) _LIBCPP_FUNC_VIS const error_category& future_category() _NOEXCEPT; inline _LIBCPP_INLINE_VISIBILITY error_code make_error_code(future_errc __e) _NOEXCEPT { return error_code(static_cast(__e), future_category()); } inline _LIBCPP_INLINE_VISIBILITY error_condition make_error_condition(future_errc __e) _NOEXCEPT { return error_condition(static_cast(__e), future_category()); } class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_FUTURE_ERROR future_error : public logic_error { error_code __ec_; public: future_error(error_code __ec); #if _LIBCPP_STD_VERS > 14 explicit future_error(future_errc _Ev) : logic_error(), __ec_(make_error_code(_Ev)) {} #endif _LIBCPP_INLINE_VISIBILITY const error_code& code() const _NOEXCEPT {return __ec_;} + future_error(const future_error&) _NOEXCEPT = default; virtual ~future_error() _NOEXCEPT; }; _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_NO_EXCEPTIONS _LIBCPP_AVAILABILITY_FUTURE_ERROR #endif void __throw_future_error(future_errc _Ev) { #ifndef _LIBCPP_NO_EXCEPTIONS throw future_error(make_error_code(_Ev)); #else ((void)_Ev); _VSTD::abort(); #endif } class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state : public __shared_count { protected: exception_ptr __exception_; mutable mutex __mut_; mutable condition_variable __cv_; unsigned __state_; virtual void __on_zero_shared() _NOEXCEPT; void __sub_wait(unique_lock& __lk); public: enum { __constructed = 1, __future_attached = 2, ready = 4, deferred = 8 }; _LIBCPP_INLINE_VISIBILITY __assoc_sub_state() : __state_(0) {} _LIBCPP_INLINE_VISIBILITY bool __has_value() const {return (__state_ & __constructed) || (__exception_ != nullptr);} _LIBCPP_INLINE_VISIBILITY void __attach_future() { lock_guard __lk(__mut_); bool __has_future_attached = (__state_ & __future_attached) != 0; if (__has_future_attached) __throw_future_error(future_errc::future_already_retrieved); this->__add_shared(); __state_ |= __future_attached; } _LIBCPP_INLINE_VISIBILITY void __set_deferred() {__state_ |= deferred;} void __make_ready(); _LIBCPP_INLINE_VISIBILITY bool __is_ready() const {return (__state_ & ready) != 0;} void set_value(); void set_value_at_thread_exit(); void set_exception(exception_ptr __p); void set_exception_at_thread_exit(exception_ptr __p); void copy(); void wait(); template future_status _LIBCPP_INLINE_VISIBILITY wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const; virtual void __execute(); }; template future_status __assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const { unique_lock __lk(__mut_); if (__state_ & deferred) return future_status::deferred; while (!(__state_ & ready) && _Clock::now() < __abs_time) __cv_.wait_until(__lk, __abs_time); if (__state_ & ready) return future_status::ready; return future_status::timeout; } template inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const { return wait_until(chrono::steady_clock::now() + __rel_time); } template class _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_HIDDEN __assoc_state : public __assoc_sub_state { typedef __assoc_sub_state base; typedef typename aligned_storage::value>::type _Up; protected: _Up __value_; virtual void __on_zero_shared() _NOEXCEPT; public: template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void set_value(_Arg&& __arg); #else void set_value(_Arg& __arg); #endif template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void set_value_at_thread_exit(_Arg&& __arg); #else void set_value_at_thread_exit(_Arg& __arg); #endif _Rp move(); typename add_lvalue_reference<_Rp>::type copy(); }; template void __assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT { if (this->__state_ & base::__constructed) reinterpret_cast<_Rp*>(&__value_)->~_Rp(); delete this; } template template _LIBCPP_AVAILABILITY_FUTURE void #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __assoc_state<_Rp>::set_value(_Arg&& __arg) #else __assoc_state<_Rp>::set_value(_Arg& __arg) #endif { unique_lock __lk(this->__mut_); if (this->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed | base::ready; __cv_.notify_all(); } template template void #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg) #else __assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg) #endif { unique_lock __lk(this->__mut_); if (this->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); } template _Rp __assoc_state<_Rp>::move() { unique_lock __lk(this->__mut_); this->__sub_wait(__lk); if (this->__exception_ != nullptr) rethrow_exception(this->__exception_); return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_)); } template typename add_lvalue_reference<_Rp>::type __assoc_state<_Rp>::copy() { unique_lock __lk(this->__mut_); this->__sub_wait(__lk); if (this->__exception_ != nullptr) rethrow_exception(this->__exception_); return *reinterpret_cast<_Rp*>(&__value_); } template class _LIBCPP_AVAILABILITY_FUTURE __assoc_state<_Rp&> : public __assoc_sub_state { typedef __assoc_sub_state base; typedef _Rp* _Up; protected: _Up __value_; virtual void __on_zero_shared() _NOEXCEPT; public: void set_value(_Rp& __arg); void set_value_at_thread_exit(_Rp& __arg); _Rp& copy(); }; template void __assoc_state<_Rp&>::__on_zero_shared() _NOEXCEPT { delete this; } template void __assoc_state<_Rp&>::set_value(_Rp& __arg) { unique_lock __lk(this->__mut_); if (this->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed | base::ready; __cv_.notify_all(); } template void __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) { unique_lock __lk(this->__mut_); if (this->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); } template _Rp& __assoc_state<_Rp&>::copy() { unique_lock __lk(this->__mut_); this->__sub_wait(__lk); if (this->__exception_ != nullptr) rethrow_exception(this->__exception_); return *__value_; } template class _LIBCPP_AVAILABILITY_FUTURE __assoc_state_alloc : public __assoc_state<_Rp> { typedef __assoc_state<_Rp> base; _Alloc __alloc_; virtual void __on_zero_shared() _NOEXCEPT; public: _LIBCPP_INLINE_VISIBILITY explicit __assoc_state_alloc(const _Alloc& __a) : __alloc_(__a) {} }; template void __assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT { if (this->__state_ & base::__constructed) reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp(); typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al; typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; _Al __a(__alloc_); this->~__assoc_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template class _LIBCPP_AVAILABILITY_FUTURE __assoc_state_alloc<_Rp&, _Alloc> : public __assoc_state<_Rp&> { typedef __assoc_state<_Rp&> base; _Alloc __alloc_; virtual void __on_zero_shared() _NOEXCEPT; public: _LIBCPP_INLINE_VISIBILITY explicit __assoc_state_alloc(const _Alloc& __a) : __alloc_(__a) {} }; template void __assoc_state_alloc<_Rp&, _Alloc>::__on_zero_shared() _NOEXCEPT { typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al; typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; _Al __a(__alloc_); this->~__assoc_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template class _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state_alloc : public __assoc_sub_state { typedef __assoc_sub_state base; _Alloc __alloc_; virtual void __on_zero_shared() _NOEXCEPT; public: _LIBCPP_INLINE_VISIBILITY explicit __assoc_sub_state_alloc(const _Alloc& __a) : __alloc_(__a) {} }; template void __assoc_sub_state_alloc<_Alloc>::__on_zero_shared() _NOEXCEPT { typedef typename __allocator_traits_rebind<_Alloc, __assoc_sub_state_alloc>::type _Al; typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; _Al __a(__alloc_); this->~__assoc_sub_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state : public __assoc_state<_Rp> { typedef __assoc_state<_Rp> base; _Fp __func_; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit __deferred_assoc_state(_Fp&& __f); #endif virtual void __execute(); }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { this->__set_deferred(); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __deferred_assoc_state<_Rp, _Fp>::__execute() { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->set_value(__func_()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state : public __assoc_sub_state { typedef __assoc_sub_state base; _Fp __func_; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit __deferred_assoc_state(_Fp&& __f); #endif virtual void __execute(); }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline __deferred_assoc_state::__deferred_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { this->__set_deferred(); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __deferred_assoc_state::__execute() { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __func_(); this->set_value(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state : public __assoc_state<_Rp> { typedef __assoc_state<_Rp> base; _Fp __func_; virtual void __on_zero_shared() _NOEXCEPT; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit __async_assoc_state(_Fp&& __f); #endif virtual void __execute(); }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __async_assoc_state<_Rp, _Fp>::__execute() { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->set_value(__func_()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void __async_assoc_state<_Rp, _Fp>::__on_zero_shared() _NOEXCEPT { this->wait(); base::__on_zero_shared(); } template class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state : public __assoc_sub_state { typedef __assoc_sub_state base; _Fp __func_; virtual void __on_zero_shared() _NOEXCEPT; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit __async_assoc_state(_Fp&& __f); #endif virtual void __execute(); }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline __async_assoc_state::__async_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __async_assoc_state::__execute() { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __func_(); this->set_value(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void __async_assoc_state::__on_zero_shared() _NOEXCEPT { this->wait(); base::__on_zero_shared(); } template class _LIBCPP_TEMPLATE_VIS promise; template class _LIBCPP_TEMPLATE_VIS shared_future; // future template class _LIBCPP_TEMPLATE_VIS future; template _LIBCPP_INLINE_VISIBILITY future<_Rp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __make_deferred_assoc_state(_Fp&& __f); #else __make_deferred_assoc_state(_Fp __f); #endif template _LIBCPP_INLINE_VISIBILITY future<_Rp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __make_async_assoc_state(_Fp&& __f); #else __make_async_assoc_state(_Fp __f); #endif template class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future { __assoc_state<_Rp>* __state_; explicit future(__assoc_state<_Rp>* __state); template friend class promise; template friend class shared_future; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend future<_R1> __make_deferred_assoc_state(_Fp&& __f); template friend future<_R1> __make_async_assoc_state(_Fp&& __f); #else template friend future<_R1> __make_deferred_assoc_state(_Fp __f); template friend future<_R1> __make_async_assoc_state(_Fp __f); #endif public: _LIBCPP_INLINE_VISIBILITY future() _NOEXCEPT : __state_(nullptr) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY future(future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} future(const future&) = delete; future& operator=(const future&) = delete; _LIBCPP_INLINE_VISIBILITY future& operator=(future&& __rhs) _NOEXCEPT { future(std::move(__rhs)).swap(*this); return *this; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: future(const future&); future& operator=(const future&); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); _LIBCPP_INLINE_VISIBILITY shared_future<_Rp> share() _NOEXCEPT; // retrieving the value _Rp get(); _LIBCPP_INLINE_VISIBILITY void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template future<_Rp>::future(__assoc_state<_Rp>* __state) : __state_(__state) { __state_->__attach_future(); } struct __release_shared_count { void operator()(__shared_count* p) {p->__release_shared();} }; template future<_Rp>::~future() { if (__state_) __state_->__release_shared(); } template _Rp future<_Rp>::get() { unique_ptr<__shared_count, __release_shared_count> __(__state_); __assoc_state<_Rp>* __s = __state_; __state_ = nullptr; return __s->move(); } template class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future<_Rp&> { __assoc_state<_Rp&>* __state_; explicit future(__assoc_state<_Rp&>* __state); template friend class promise; template friend class shared_future; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend future<_R1> __make_deferred_assoc_state(_Fp&& __f); template friend future<_R1> __make_async_assoc_state(_Fp&& __f); #else template friend future<_R1> __make_deferred_assoc_state(_Fp __f); template friend future<_R1> __make_async_assoc_state(_Fp __f); #endif public: _LIBCPP_INLINE_VISIBILITY future() _NOEXCEPT : __state_(nullptr) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY future(future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} future(const future&) = delete; future& operator=(const future&) = delete; _LIBCPP_INLINE_VISIBILITY future& operator=(future&& __rhs) _NOEXCEPT { future(std::move(__rhs)).swap(*this); return *this; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: future(const future&); future& operator=(const future&); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); _LIBCPP_INLINE_VISIBILITY shared_future<_Rp&> share() _NOEXCEPT; // retrieving the value _Rp& get(); _LIBCPP_INLINE_VISIBILITY void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template future<_Rp&>::future(__assoc_state<_Rp&>* __state) : __state_(__state) { __state_->__attach_future(); } template future<_Rp&>::~future() { if (__state_) __state_->__release_shared(); } template _Rp& future<_Rp&>::get() { unique_ptr<__shared_count, __release_shared_count> __(__state_); __assoc_state<_Rp&>* __s = __state_; __state_ = nullptr; return __s->copy(); } template <> class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE future { __assoc_sub_state* __state_; explicit future(__assoc_sub_state* __state); template friend class promise; template friend class shared_future; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend future<_R1> __make_deferred_assoc_state(_Fp&& __f); template friend future<_R1> __make_async_assoc_state(_Fp&& __f); #else template friend future<_R1> __make_deferred_assoc_state(_Fp __f); template friend future<_R1> __make_async_assoc_state(_Fp __f); #endif public: _LIBCPP_INLINE_VISIBILITY future() _NOEXCEPT : __state_(nullptr) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY future(future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} future(const future&) = delete; future& operator=(const future&) = delete; _LIBCPP_INLINE_VISIBILITY future& operator=(future&& __rhs) _NOEXCEPT { future(std::move(__rhs)).swap(*this); return *this; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: future(const future&); future& operator=(const future&); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); _LIBCPP_INLINE_VISIBILITY shared_future share() _NOEXCEPT; // retrieving the value void get(); _LIBCPP_INLINE_VISIBILITY void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template inline _LIBCPP_INLINE_VISIBILITY void swap(future<_Rp>& __x, future<_Rp>& __y) _NOEXCEPT { __x.swap(__y); } // promise template class packaged_task; template class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE promise { __assoc_state<_Rp>* __state_; _LIBCPP_INLINE_VISIBILITY explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} template friend class packaged_task; public: promise(); template promise(allocator_arg_t, const _Alloc& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} promise(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~promise(); // assignment #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise& operator=(promise&& __rhs) _NOEXCEPT { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise& operator=(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // retrieving the result future<_Rp> get_future(); // setting the result void set_value(const _Rp& __r); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void set_value(_Rp&& __r); #endif void set_exception(exception_ptr __p); // setting the result with deferred notification void set_value_at_thread_exit(const _Rp& __r); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void set_value_at_thread_exit(_Rp&& __r); #endif void set_exception_at_thread_exit(exception_ptr __p); }; template promise<_Rp>::promise() : __state_(new __assoc_state<_Rp>) { } template template promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0) { typedef __assoc_state_alloc<_Rp, _Alloc> _State; typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); __state_ = _VSTD::addressof(*__hold.release()); } template promise<_Rp>::~promise() { if (__state_) { if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); __state_->__release_shared(); } } template future<_Rp> promise<_Rp>::get_future() { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); return future<_Rp>(__state_); } template void promise<_Rp>::set_value(const _Rp& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value(__r); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template void promise<_Rp>::set_value(_Rp&& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value(_VSTD::move(__r)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void promise<_Rp>::set_exception(exception_ptr __p) { _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception: received nullptr" ); if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_exception(__p); } template void promise<_Rp>::set_value_at_thread_exit(const _Rp& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(__r); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template void promise<_Rp>::set_value_at_thread_exit(_Rp&& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(_VSTD::move(__r)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) { _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: received nullptr" ); if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } // promise template class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE promise<_Rp&> { __assoc_state<_Rp&>* __state_; _LIBCPP_INLINE_VISIBILITY explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} template friend class packaged_task; public: promise(); template promise(allocator_arg_t, const _Allocator& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} promise(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~promise(); // assignment #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise& operator=(promise&& __rhs) _NOEXCEPT { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise& operator=(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // retrieving the result future<_Rp&> get_future(); // setting the result void set_value(_Rp& __r); void set_exception(exception_ptr __p); // setting the result with deferred notification void set_value_at_thread_exit(_Rp&); void set_exception_at_thread_exit(exception_ptr __p); }; template promise<_Rp&>::promise() : __state_(new __assoc_state<_Rp&>) { } template template promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0) { typedef __assoc_state_alloc<_Rp&, _Alloc> _State; typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); __state_ = _VSTD::addressof(*__hold.release()); } template promise<_Rp&>::~promise() { if (__state_) { if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); __state_->__release_shared(); } } template future<_Rp&> promise<_Rp&>::get_future() { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); return future<_Rp&>(__state_); } template void promise<_Rp&>::set_value(_Rp& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value(__r); } template void promise<_Rp&>::set_exception(exception_ptr __p) { _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception: received nullptr" ); if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_exception(__p); } template void promise<_Rp&>::set_value_at_thread_exit(_Rp& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(__r); } template void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) { _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: received nullptr" ); if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } // promise template <> class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE promise { __assoc_sub_state* __state_; _LIBCPP_INLINE_VISIBILITY explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} template friend class packaged_task; public: promise(); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS promise(allocator_arg_t, const _Allocator& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} promise(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~promise(); // assignment #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise& operator=(promise&& __rhs) _NOEXCEPT { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise& operator=(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // retrieving the result future get_future(); // setting the result void set_value(); void set_exception(exception_ptr __p); // setting the result with deferred notification void set_value_at_thread_exit(); void set_exception_at_thread_exit(exception_ptr __p); }; template promise::promise(allocator_arg_t, const _Alloc& __a0) { typedef __assoc_sub_state_alloc<_Alloc> _State; typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); __state_ = _VSTD::addressof(*__hold.release()); } template inline _LIBCPP_INLINE_VISIBILITY void swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT { __x.swap(__y); } template struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc> : public true_type {}; #ifndef _LIBCPP_HAS_NO_VARIADICS // packaged_task template class __packaged_task_base; template class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)> { __packaged_task_base(const __packaged_task_base&); __packaged_task_base& operator=(const __packaged_task_base&); public: _LIBCPP_INLINE_VISIBILITY __packaged_task_base() {} _LIBCPP_INLINE_VISIBILITY virtual ~__packaged_task_base() {} virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0; virtual void destroy() = 0; virtual void destroy_deallocate() = 0; virtual _Rp operator()(_ArgTypes&& ...) = 0; }; template class __packaged_task_func; template class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __packaged_task_base<_Rp(_ArgTypes...)> { __compressed_pair<_Fp, _Alloc> __f_; public: _LIBCPP_INLINE_VISIBILITY explicit __packaged_task_func(const _Fp& __f) : __f_(__f, __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY explicit __packaged_task_func(_Fp&& __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {} _LIBCPP_INLINE_VISIBILITY __packaged_task_func(_Fp&& __f, const _Alloc& __a) : __f_(_VSTD::move(__f), __a) {} virtual void __move_to(__packaged_task_base<_Rp(_ArgTypes...)>*) _NOEXCEPT; virtual void destroy(); virtual void destroy_deallocate(); virtual _Rp operator()(_ArgTypes&& ... __args); }; template void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to( __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT { ::new (__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second())); } template void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() { __f_.~__compressed_pair<_Fp, _Alloc>(); } template void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() { typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap; typedef allocator_traits<_Ap> _ATraits; typedef pointer_traits _PTraits; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template _Rp __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) { return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); } template class __packaged_task_function; template class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)> { typedef __packaged_task_base<_Rp(_ArgTypes...)> __base; typename aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; public: typedef _Rp result_type; // construct/copy/destroy: _LIBCPP_INLINE_VISIBILITY __packaged_task_function() _NOEXCEPT : __f_(nullptr) {} template __packaged_task_function(_Fp&& __f); template __packaged_task_function(allocator_arg_t, const _Alloc& __a, _Fp&& __f); __packaged_task_function(__packaged_task_function&&) _NOEXCEPT; __packaged_task_function& operator=(__packaged_task_function&&) _NOEXCEPT; __packaged_task_function(const __packaged_task_function&) = delete; __packaged_task_function& operator=(const __packaged_task_function&) = delete; ~__packaged_task_function(); void swap(__packaged_task_function&) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY _Rp operator()(_ArgTypes...) const; }; template __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(__packaged_task_function&& __f) _NOEXCEPT { if (__f.__f_ == nullptr) __f_ = nullptr; else if (__f.__f_ == (__base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__move_to(__f_); } else { __f_ = __f.__f_; __f.__f_ = nullptr; } } template template __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f) : __f_(nullptr) { typedef typename remove_reference::type>::type _FR; typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) { __f_ = (__base*)&__buf_; ::new (__f_) _FF(_VSTD::forward<_Fp>(__f)); } else { typedef allocator<_FF> _Ap; _Ap __a; typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a)); __f_ = __hold.release(); } } template template __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function( allocator_arg_t, const _Alloc& __a0, _Fp&& __f) : __f_(nullptr) { typedef typename remove_reference::type>::type _FR; typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) { __f_ = (__base*)&__buf_; ::new (__f_) _FF(_VSTD::forward<_Fp>(__f)); } else { typedef typename __allocator_traits_rebind<_Alloc, _FF>::type _Ap; _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (static_cast(_VSTD::addressof(*__hold.get()))) _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a)); __f_ = _VSTD::addressof(*__hold.release()); } } template __packaged_task_function<_Rp(_ArgTypes...)>& __packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&& __f) _NOEXCEPT { if (__f_ == (__base*)&__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); __f_ = nullptr; if (__f.__f_ == nullptr) __f_ = nullptr; else if (__f.__f_ == (__base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__move_to(__f_); } else { __f_ = __f.__f_; __f.__f_ = nullptr; } return *this; } template __packaged_task_function<_Rp(_ArgTypes...)>::~__packaged_task_function() { if (__f_ == (__base*)&__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); } template void __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) _NOEXCEPT { if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) { typename aligned_storage::type __tempbuf; __base* __t = (__base*)&__tempbuf; __f_->__move_to(__t); __f_->destroy(); __f_ = nullptr; __f.__f_->__move_to((__base*)&__buf_); __f.__f_->destroy(); __f.__f_ = nullptr; __f_ = (__base*)&__buf_; __t->__move_to((__base*)&__f.__buf_); __t->destroy(); __f.__f_ = (__base*)&__f.__buf_; } else if (__f_ == (__base*)&__buf_) { __f_->__move_to((__base*)&__f.__buf_); __f_->destroy(); __f_ = __f.__f_; __f.__f_ = (__base*)&__f.__buf_; } else if (__f.__f_ == (__base*)&__f.__buf_) { __f.__f_->__move_to((__base*)&__buf_); __f.__f_->destroy(); __f.__f_ = __f_; __f_ = (__base*)&__buf_; } else _VSTD::swap(__f_, __f.__f_); } template inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); } template class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE packaged_task<_Rp(_ArgTypes...)> { public: typedef _Rp result_type; // extension private: __packaged_task_function __f_; promise __p_; public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} template ::type, packaged_task >::value >::type > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} template ::type, packaged_task >::value >::type > _LIBCPP_INLINE_VISIBILITY packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), __p_(allocator_arg, __a) {} // ~packaged_task() = default; // no copy packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; // move support _LIBCPP_INLINE_VISIBILITY packaged_task(packaged_task&& __other) _NOEXCEPT : __f_(_VSTD::move(__other.__f_)), __p_(_VSTD::move(__other.__p_)) {} _LIBCPP_INLINE_VISIBILITY packaged_task& operator=(packaged_task&& __other) _NOEXCEPT { __f_ = _VSTD::move(__other.__f_); __p_ = _VSTD::move(__other.__p_); return *this; } _LIBCPP_INLINE_VISIBILITY void swap(packaged_task& __other) _NOEXCEPT { __f_.swap(__other.__f_); __p_.swap(__other.__p_); } _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __p_.__state_ != nullptr;} // result retrieval _LIBCPP_INLINE_VISIBILITY future get_future() {return __p_.get_future();} // execution void operator()(_ArgTypes... __args); void make_ready_at_thread_exit(_ArgTypes... __args); void reset(); }; template void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { if (__p_.__state_ == nullptr) __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __p_.set_value(__f_(_VSTD::forward<_ArgTypes>(__args)...)); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) { if (__p_.__state_ == nullptr) __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __p_.set_value_at_thread_exit(__f_(_VSTD::forward<_ArgTypes>(__args)...)); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void packaged_task<_Rp(_ArgTypes...)>::reset() { if (!valid()) __throw_future_error(future_errc::no_state); __p_ = promise(); } template class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE packaged_task { public: typedef void result_type; // extension private: __packaged_task_function __f_; promise __p_; public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} template ::type, packaged_task >::value >::type > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} template ::type, packaged_task >::value >::type > _LIBCPP_INLINE_VISIBILITY packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), __p_(allocator_arg, __a) {} // ~packaged_task() = default; // no copy packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; // move support _LIBCPP_INLINE_VISIBILITY packaged_task(packaged_task&& __other) _NOEXCEPT : __f_(_VSTD::move(__other.__f_)), __p_(_VSTD::move(__other.__p_)) {} _LIBCPP_INLINE_VISIBILITY packaged_task& operator=(packaged_task&& __other) _NOEXCEPT { __f_ = _VSTD::move(__other.__f_); __p_ = _VSTD::move(__other.__p_); return *this; } _LIBCPP_INLINE_VISIBILITY void swap(packaged_task& __other) _NOEXCEPT { __f_.swap(__other.__f_); __p_.swap(__other.__p_); } _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __p_.__state_ != nullptr;} // result retrieval _LIBCPP_INLINE_VISIBILITY future get_future() {return __p_.get_future();} // execution void operator()(_ArgTypes... __args); void make_ready_at_thread_exit(_ArgTypes... __args); void reset(); }; template void packaged_task::operator()(_ArgTypes... __args) { if (__p_.__state_ == nullptr) __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __f_(_VSTD::forward<_ArgTypes>(__args)...); __p_.set_value(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void packaged_task::make_ready_at_thread_exit(_ArgTypes... __args) { if (__p_.__state_ == nullptr) __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __f_(_VSTD::forward<_ArgTypes>(__args)...); __p_.set_value_at_thread_exit(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void packaged_task::reset() { if (!valid()) __throw_future_error(future_errc::no_state); __p_ = promise(); } template inline _LIBCPP_INLINE_VISIBILITY void swap(packaged_task<_Callable>& __x, packaged_task<_Callable>& __y) _NOEXCEPT { __x.swap(__y); } template struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc> : public true_type {}; template _LIBCPP_INLINE_VISIBILITY future<_Rp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __make_deferred_assoc_state(_Fp&& __f) #else __make_deferred_assoc_state(_Fp __f) #endif { unique_ptr<__deferred_assoc_state<_Rp, _Fp>, __release_shared_count> __h(new __deferred_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f))); return future<_Rp>(__h.get()); } template _LIBCPP_INLINE_VISIBILITY future<_Rp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __make_async_assoc_state(_Fp&& __f) #else __make_async_assoc_state(_Fp __f) #endif { unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count> __h(new __async_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f))); _VSTD::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach(); return future<_Rp>(__h.get()); } template class _LIBCPP_HIDDEN __async_func { tuple<_Fp, _Args...> __f_; public: typedef typename __invoke_of<_Fp, _Args...>::type _Rp; _LIBCPP_INLINE_VISIBILITY explicit __async_func(_Fp&& __f, _Args&&... __args) : __f_(_VSTD::move(__f), _VSTD::move(__args)...) {} _LIBCPP_INLINE_VISIBILITY __async_func(__async_func&& __f) : __f_(_VSTD::move(__f.__f_)) {} _Rp operator()() { typedef typename __make_tuple_indices<1+sizeof...(_Args), 1>::type _Index; return __execute(_Index()); } private: template _Rp __execute(__tuple_indices<_Indices...>) { return __invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...); } }; inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, launch __value ) { return (int(__policy) & int(__value)) != 0; } template _LIBCPP_NODISCARD_AFTER_CXX17 future::type, typename decay<_Args>::type...>::type> async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func::type, typename decay<_Args>::type...> _BF; typedef typename _BF::_Rp _Rp; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif if (__does_policy_contain(__policy, launch::async)) return _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); #ifndef _LIBCPP_NO_EXCEPTIONS } catch ( ... ) { if (__policy == launch::async) throw ; } #endif if (__does_policy_contain(__policy, launch::deferred)) return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); return future<_Rp>{}; } template _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY future::type, typename decay<_Args>::type...>::type> async(_Fp&& __f, _Args&&... __args) { return _VSTD::async(launch::any, _VSTD::forward<_Fp>(__f), _VSTD::forward<_Args>(__args)...); } #endif // _LIBCPP_HAS_NO_VARIADICS // shared_future template class _LIBCPP_TEMPLATE_VIS shared_future { __assoc_state<_Rp>* __state_; public: _LIBCPP_INLINE_VISIBILITY shared_future() _NOEXCEPT : __state_(nullptr) {} _LIBCPP_INLINE_VISIBILITY shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {if (__state_) __state_->__add_shared();} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future(future<_Rp>&& __f) _NOEXCEPT : __state_(__f.__state_) {__f.__state_ = nullptr;} _LIBCPP_INLINE_VISIBILITY shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~shared_future(); shared_future& operator=(const shared_future& __rhs) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future& operator=(shared_future&& __rhs) _NOEXCEPT { shared_future(std::move(__rhs)).swap(*this); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES // retrieving the value _LIBCPP_INLINE_VISIBILITY const _Rp& get() const {return __state_->copy();} _LIBCPP_INLINE_VISIBILITY void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template shared_future<_Rp>::~shared_future() { if (__state_) __state_->__release_shared(); } template shared_future<_Rp>& shared_future<_Rp>::operator=(const shared_future& __rhs) _NOEXCEPT { if (__rhs.__state_) __rhs.__state_->__add_shared(); if (__state_) __state_->__release_shared(); __state_ = __rhs.__state_; return *this; } template class _LIBCPP_TEMPLATE_VIS shared_future<_Rp&> { __assoc_state<_Rp&>* __state_; public: _LIBCPP_INLINE_VISIBILITY shared_future() _NOEXCEPT : __state_(nullptr) {} _LIBCPP_INLINE_VISIBILITY shared_future(const shared_future& __rhs) : __state_(__rhs.__state_) {if (__state_) __state_->__add_shared();} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future(future<_Rp&>&& __f) _NOEXCEPT : __state_(__f.__state_) {__f.__state_ = nullptr;} _LIBCPP_INLINE_VISIBILITY shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~shared_future(); shared_future& operator=(const shared_future& __rhs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future& operator=(shared_future&& __rhs) _NOEXCEPT { shared_future(std::move(__rhs)).swap(*this); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES // retrieving the value _LIBCPP_INLINE_VISIBILITY _Rp& get() const {return __state_->copy();} _LIBCPP_INLINE_VISIBILITY void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template shared_future<_Rp&>::~shared_future() { if (__state_) __state_->__release_shared(); } template shared_future<_Rp&>& shared_future<_Rp&>::operator=(const shared_future& __rhs) { if (__rhs.__state_) __rhs.__state_->__add_shared(); if (__state_) __state_->__release_shared(); __state_ = __rhs.__state_; return *this; } template <> class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE shared_future { __assoc_sub_state* __state_; public: _LIBCPP_INLINE_VISIBILITY shared_future() _NOEXCEPT : __state_(nullptr) {} _LIBCPP_INLINE_VISIBILITY shared_future(const shared_future& __rhs) : __state_(__rhs.__state_) {if (__state_) __state_->__add_shared();} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future(future&& __f) _NOEXCEPT : __state_(__f.__state_) {__f.__state_ = nullptr;} _LIBCPP_INLINE_VISIBILITY shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~shared_future(); shared_future& operator=(const shared_future& __rhs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future& operator=(shared_future&& __rhs) _NOEXCEPT { shared_future(std::move(__rhs)).swap(*this); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES // retrieving the value _LIBCPP_INLINE_VISIBILITY void get() const {__state_->copy();} _LIBCPP_INLINE_VISIBILITY void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template inline _LIBCPP_INLINE_VISIBILITY void swap(shared_future<_Rp>& __x, shared_future<_Rp>& __y) _NOEXCEPT { __x.swap(__y); } template inline shared_future<_Rp> future<_Rp>::share() _NOEXCEPT { return shared_future<_Rp>(_VSTD::move(*this)); } template inline shared_future<_Rp&> future<_Rp&>::share() _NOEXCEPT { return shared_future<_Rp&>(_VSTD::move(*this)); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES inline shared_future future::share() _NOEXCEPT { return shared_future(_VSTD::move(*this)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_END_NAMESPACE_STD #endif // !_LIBCPP_HAS_NO_THREADS #endif // _LIBCPP_FUTURE Index: head/contrib/llvm-project/libcxx/include/ios =================================================================== --- head/contrib/llvm-project/libcxx/include/ios (revision 359086) +++ head/contrib/llvm-project/libcxx/include/ios (revision 359087) @@ -1,1066 +1,1067 @@ // -*- C++ -*- //===---------------------------- ios -------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_IOS #define _LIBCPP_IOS /* ios synopsis #include namespace std { typedef OFF_T streamoff; typedef SZ_T streamsize; template class fpos; class ios_base { public: class failure; typedef T1 fmtflags; static constexpr fmtflags boolalpha; static constexpr fmtflags dec; static constexpr fmtflags fixed; static constexpr fmtflags hex; static constexpr fmtflags internal; static constexpr fmtflags left; static constexpr fmtflags oct; static constexpr fmtflags right; static constexpr fmtflags scientific; static constexpr fmtflags showbase; static constexpr fmtflags showpoint; static constexpr fmtflags showpos; static constexpr fmtflags skipws; static constexpr fmtflags unitbuf; static constexpr fmtflags uppercase; static constexpr fmtflags adjustfield; static constexpr fmtflags basefield; static constexpr fmtflags floatfield; typedef T2 iostate; static constexpr iostate badbit; static constexpr iostate eofbit; static constexpr iostate failbit; static constexpr iostate goodbit; typedef T3 openmode; static constexpr openmode app; static constexpr openmode ate; static constexpr openmode binary; static constexpr openmode in; static constexpr openmode out; static constexpr openmode trunc; typedef T4 seekdir; static constexpr seekdir beg; static constexpr seekdir cur; static constexpr seekdir end; class Init; // 27.5.2.2 fmtflags state: fmtflags flags() const; fmtflags flags(fmtflags fmtfl); fmtflags setf(fmtflags fmtfl); fmtflags setf(fmtflags fmtfl, fmtflags mask); void unsetf(fmtflags mask); streamsize precision() const; streamsize precision(streamsize prec); streamsize width() const; streamsize width(streamsize wide); // 27.5.2.3 locales: locale imbue(const locale& loc); locale getloc() const; // 27.5.2.5 storage: static int xalloc(); long& iword(int index); void*& pword(int index); // destructor virtual ~ios_base(); // 27.5.2.6 callbacks; enum event { erase_event, imbue_event, copyfmt_event }; typedef void (*event_callback)(event, ios_base&, int index); void register_callback(event_callback fn, int index); ios_base(const ios_base&) = delete; ios_base& operator=(const ios_base&) = delete; static bool sync_with_stdio(bool sync = true); protected: ios_base(); }; template > class basic_ios : public ios_base { public: // types: typedef charT char_type; typedef typename traits::int_type int_type; // removed in C++17 typedef typename traits::pos_type pos_type; // removed in C++17 typedef typename traits::off_type off_type; // removed in C++17 typedef traits traits_type; operator unspecified-bool-type() const; bool operator!() const; iostate rdstate() const; void clear(iostate state = goodbit); void setstate(iostate state); bool good() const; bool eof() const; bool fail() const; bool bad() const; iostate exceptions() const; void exceptions(iostate except); // 27.5.4.1 Constructor/destructor: explicit basic_ios(basic_streambuf* sb); virtual ~basic_ios(); // 27.5.4.2 Members: basic_ostream* tie() const; basic_ostream* tie(basic_ostream* tiestr); basic_streambuf* rdbuf() const; basic_streambuf* rdbuf(basic_streambuf* sb); basic_ios& copyfmt(const basic_ios& rhs); char_type fill() const; char_type fill(char_type ch); locale imbue(const locale& loc); char narrow(char_type c, char dfault) const; char_type widen(char c) const; basic_ios(const basic_ios& ) = delete; basic_ios& operator=(const basic_ios&) = delete; protected: basic_ios(); void init(basic_streambuf* sb); void move(basic_ios& rhs); void swap(basic_ios& rhs) noexcept; void set_rdbuf(basic_streambuf* sb); }; // 27.5.5, manipulators: ios_base& boolalpha (ios_base& str); ios_base& noboolalpha(ios_base& str); ios_base& showbase (ios_base& str); ios_base& noshowbase (ios_base& str); ios_base& showpoint (ios_base& str); ios_base& noshowpoint(ios_base& str); ios_base& showpos (ios_base& str); ios_base& noshowpos (ios_base& str); ios_base& skipws (ios_base& str); ios_base& noskipws (ios_base& str); ios_base& uppercase (ios_base& str); ios_base& nouppercase(ios_base& str); ios_base& unitbuf (ios_base& str); ios_base& nounitbuf (ios_base& str); // 27.5.5.2 adjustfield: ios_base& internal (ios_base& str); ios_base& left (ios_base& str); ios_base& right (ios_base& str); // 27.5.5.3 basefield: ios_base& dec (ios_base& str); ios_base& hex (ios_base& str); ios_base& oct (ios_base& str); // 27.5.5.4 floatfield: ios_base& fixed (ios_base& str); ios_base& scientific (ios_base& str); ios_base& hexfloat (ios_base& str); ios_base& defaultfloat(ios_base& str); // 27.5.5.5 error reporting: enum class io_errc { stream = 1 }; concept_map ErrorCodeEnum { }; error_code make_error_code(io_errc e) noexcept; error_condition make_error_condition(io_errc e) noexcept; storage-class-specifier const error_category& iostream_category() noexcept; } // std */ #include <__config> #include #include <__locale> #include #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) #include // for __xindex_ #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD typedef ptrdiff_t streamsize; class _LIBCPP_TYPE_VIS ios_base { public: class _LIBCPP_EXCEPTION_ABI failure; typedef unsigned int fmtflags; static const fmtflags boolalpha = 0x0001; static const fmtflags dec = 0x0002; static const fmtflags fixed = 0x0004; static const fmtflags hex = 0x0008; static const fmtflags internal = 0x0010; static const fmtflags left = 0x0020; static const fmtflags oct = 0x0040; static const fmtflags right = 0x0080; static const fmtflags scientific = 0x0100; static const fmtflags showbase = 0x0200; static const fmtflags showpoint = 0x0400; static const fmtflags showpos = 0x0800; static const fmtflags skipws = 0x1000; static const fmtflags unitbuf = 0x2000; static const fmtflags uppercase = 0x4000; static const fmtflags adjustfield = left | right | internal; static const fmtflags basefield = dec | oct | hex; static const fmtflags floatfield = scientific | fixed; typedef unsigned int iostate; static const iostate badbit = 0x1; static const iostate eofbit = 0x2; static const iostate failbit = 0x4; static const iostate goodbit = 0x0; typedef unsigned int openmode; static const openmode app = 0x01; static const openmode ate = 0x02; static const openmode binary = 0x04; static const openmode in = 0x08; static const openmode out = 0x10; static const openmode trunc = 0x20; enum seekdir {beg, cur, end}; #if _LIBCPP_STD_VER <= 14 typedef iostate io_state; typedef openmode open_mode; typedef seekdir seek_dir; typedef _VSTD::streamoff streamoff; typedef _VSTD::streampos streampos; #endif class _LIBCPP_TYPE_VIS Init; // 27.5.2.2 fmtflags state: _LIBCPP_INLINE_VISIBILITY fmtflags flags() const; _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl); _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl); _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask); _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask); _LIBCPP_INLINE_VISIBILITY streamsize precision() const; _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec); _LIBCPP_INLINE_VISIBILITY streamsize width() const; _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide); // 27.5.2.3 locales: locale imbue(const locale& __loc); locale getloc() const; // 27.5.2.5 storage: static int xalloc(); long& iword(int __index); void*& pword(int __index); // destructor virtual ~ios_base(); // 27.5.2.6 callbacks; enum event { erase_event, imbue_event, copyfmt_event }; typedef void (*event_callback)(event, ios_base&, int __index); void register_callback(event_callback __fn, int __index); private: ios_base(const ios_base&); // = delete; ios_base& operator=(const ios_base&); // = delete; public: static bool sync_with_stdio(bool __sync = true); _LIBCPP_INLINE_VISIBILITY iostate rdstate() const; void clear(iostate __state = goodbit); _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state); _LIBCPP_INLINE_VISIBILITY bool good() const; _LIBCPP_INLINE_VISIBILITY bool eof() const; _LIBCPP_INLINE_VISIBILITY bool fail() const; _LIBCPP_INLINE_VISIBILITY bool bad() const; _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); void __set_badbit_and_consider_rethrow(); void __set_failbit_and_consider_rethrow(); _LIBCPP_INLINE_VISIBILITY void __setstate_nothrow(iostate __state) { if (__rdbuf_) __rdstate_ |= __state; else __rdstate_ |= __state | ios_base::badbit; } protected: _LIBCPP_INLINE_VISIBILITY ios_base() {// purposefully does no initialization } void init(void* __sb); _LIBCPP_INLINE_VISIBILITY void* rdbuf() const {return __rdbuf_;} _LIBCPP_INLINE_VISIBILITY void rdbuf(void* __sb) { __rdbuf_ = __sb; clear(); } void __call_callbacks(event); void copyfmt(const ios_base&); void move(ios_base&); void swap(ios_base&) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void set_rdbuf(void* __sb) { __rdbuf_ = __sb; } private: // All data members must be scalars fmtflags __fmtflags_; streamsize __precision_; streamsize __width_; iostate __rdstate_; iostate __exceptions_; void* __rdbuf_; void* __loc_; event_callback* __fn_; int* __index_; size_t __event_size_; size_t __event_cap_; // TODO(EricWF): Enable this for both Clang and GCC. Currently it is only // enabled with clang. #if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) static atomic __xindex_; #else static int __xindex_; #endif long* __iarray_; size_t __iarray_size_; size_t __iarray_cap_; void** __parray_; size_t __parray_size_; size_t __parray_cap_; }; //enum class io_errc _LIBCPP_DECLARE_STRONG_ENUM(io_errc) { stream = 1 }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type { }; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type { }; #endif _LIBCPP_FUNC_VIS const error_category& iostream_category() _NOEXCEPT; inline _LIBCPP_INLINE_VISIBILITY error_code make_error_code(io_errc __e) _NOEXCEPT { return error_code(static_cast(__e), iostream_category()); } inline _LIBCPP_INLINE_VISIBILITY error_condition make_error_condition(io_errc __e) _NOEXCEPT { return error_condition(static_cast(__e), iostream_category()); } class _LIBCPP_EXCEPTION_ABI ios_base::failure : public system_error { public: explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); - virtual ~failure() throw(); + failure(const failure&) _NOEXCEPT = default; + virtual ~failure() _NOEXCEPT; }; _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void __throw_failure(char const* __msg) { #ifndef _LIBCPP_NO_EXCEPTIONS throw ios_base::failure(__msg); #else ((void)__msg); _VSTD::abort(); #endif } class _LIBCPP_TYPE_VIS ios_base::Init { public: Init(); ~Init(); }; // fmtflags inline _LIBCPP_INLINE_VISIBILITY ios_base::fmtflags ios_base::flags() const { return __fmtflags_; } inline _LIBCPP_INLINE_VISIBILITY ios_base::fmtflags ios_base::flags(fmtflags __fmtfl) { fmtflags __r = __fmtflags_; __fmtflags_ = __fmtfl; return __r; } inline _LIBCPP_INLINE_VISIBILITY ios_base::fmtflags ios_base::setf(fmtflags __fmtfl) { fmtflags __r = __fmtflags_; __fmtflags_ |= __fmtfl; return __r; } inline _LIBCPP_INLINE_VISIBILITY void ios_base::unsetf(fmtflags __mask) { __fmtflags_ &= ~__mask; } inline _LIBCPP_INLINE_VISIBILITY ios_base::fmtflags ios_base::setf(fmtflags __fmtfl, fmtflags __mask) { fmtflags __r = __fmtflags_; unsetf(__mask); __fmtflags_ |= __fmtfl & __mask; return __r; } // precision inline _LIBCPP_INLINE_VISIBILITY streamsize ios_base::precision() const { return __precision_; } inline _LIBCPP_INLINE_VISIBILITY streamsize ios_base::precision(streamsize __prec) { streamsize __r = __precision_; __precision_ = __prec; return __r; } // width inline _LIBCPP_INLINE_VISIBILITY streamsize ios_base::width() const { return __width_; } inline _LIBCPP_INLINE_VISIBILITY streamsize ios_base::width(streamsize __wide) { streamsize __r = __width_; __width_ = __wide; return __r; } // iostate inline _LIBCPP_INLINE_VISIBILITY ios_base::iostate ios_base::rdstate() const { return __rdstate_; } inline _LIBCPP_INLINE_VISIBILITY void ios_base::setstate(iostate __state) { clear(__rdstate_ | __state); } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::good() const { return __rdstate_ == 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::eof() const { return (__rdstate_ & eofbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::fail() const { return (__rdstate_ & (failbit | badbit)) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::bad() const { return (__rdstate_ & badbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY ios_base::iostate ios_base::exceptions() const { return __exceptions_; } inline _LIBCPP_INLINE_VISIBILITY void ios_base::exceptions(iostate __iostate) { __exceptions_ = __iostate; clear(__rdstate_); } #if defined(_LIBCPP_CXX03_LANG) struct _LIBCPP_TYPE_VIS __cxx03_bool { typedef void (__cxx03_bool::*__bool_type)(); void __true_value() {} }; #endif template class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base { public: // types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; static_assert((is_same<_CharT, typename traits_type::char_type>::value), "traits_type::char_type must be the same type as CharT"); // __true_value will generate undefined references when linking unless // we give it internal linkage. #if defined(_LIBCPP_CXX03_LANG) _LIBCPP_INLINE_VISIBILITY operator __cxx03_bool::__bool_type() const { return !fail() ? &__cxx03_bool::__true_value : nullptr; } #else _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const {return !fail();} #endif _LIBCPP_INLINE_VISIBILITY bool operator!() const {return fail();} _LIBCPP_INLINE_VISIBILITY iostate rdstate() const {return ios_base::rdstate();} _LIBCPP_INLINE_VISIBILITY void clear(iostate __state = goodbit) {ios_base::clear(__state);} _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state) {ios_base::setstate(__state);} _LIBCPP_INLINE_VISIBILITY bool good() const {return ios_base::good();} _LIBCPP_INLINE_VISIBILITY bool eof() const {return ios_base::eof();} _LIBCPP_INLINE_VISIBILITY bool fail() const {return ios_base::fail();} _LIBCPP_INLINE_VISIBILITY bool bad() const {return ios_base::bad();} _LIBCPP_INLINE_VISIBILITY iostate exceptions() const {return ios_base::exceptions();} _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} // 27.5.4.1 Constructor/destructor: _LIBCPP_INLINE_VISIBILITY explicit basic_ios(basic_streambuf* __sb); virtual ~basic_ios(); // 27.5.4.2 Members: _LIBCPP_INLINE_VISIBILITY basic_ostream* tie() const; _LIBCPP_INLINE_VISIBILITY basic_ostream* tie(basic_ostream* __tiestr); _LIBCPP_INLINE_VISIBILITY basic_streambuf* rdbuf() const; _LIBCPP_INLINE_VISIBILITY basic_streambuf* rdbuf(basic_streambuf* __sb); basic_ios& copyfmt(const basic_ios& __rhs); _LIBCPP_INLINE_VISIBILITY char_type fill() const; _LIBCPP_INLINE_VISIBILITY char_type fill(char_type __ch); _LIBCPP_INLINE_VISIBILITY locale imbue(const locale& __loc); _LIBCPP_INLINE_VISIBILITY char narrow(char_type __c, char __dfault) const; _LIBCPP_INLINE_VISIBILITY char_type widen(char __c) const; protected: _LIBCPP_INLINE_VISIBILITY basic_ios() {// purposefully does no initialization } _LIBCPP_INLINE_VISIBILITY void init(basic_streambuf* __sb); _LIBCPP_INLINE_VISIBILITY void move(basic_ios& __rhs); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY void move(basic_ios&& __rhs) {move(__rhs);} #endif _LIBCPP_INLINE_VISIBILITY void swap(basic_ios& __rhs) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void set_rdbuf(basic_streambuf* __sb); private: basic_ostream* __tie_; mutable int_type __fill_; }; template inline _LIBCPP_INLINE_VISIBILITY basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf* __sb) { init(__sb); } template basic_ios<_CharT, _Traits>::~basic_ios() { } template inline _LIBCPP_INLINE_VISIBILITY void basic_ios<_CharT, _Traits>::init(basic_streambuf* __sb) { ios_base::init(__sb); __tie_ = 0; __fill_ = traits_type::eof(); } template inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>* basic_ios<_CharT, _Traits>::tie() const { return __tie_; } template inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>* basic_ios<_CharT, _Traits>::tie(basic_ostream* __tiestr) { basic_ostream* __r = __tie_; __tie_ = __tiestr; return __r; } template inline _LIBCPP_INLINE_VISIBILITY basic_streambuf<_CharT, _Traits>* basic_ios<_CharT, _Traits>::rdbuf() const { return static_cast*>(ios_base::rdbuf()); } template inline _LIBCPP_INLINE_VISIBILITY basic_streambuf<_CharT, _Traits>* basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf* __sb) { basic_streambuf* __r = rdbuf(); ios_base::rdbuf(__sb); return __r; } template inline _LIBCPP_INLINE_VISIBILITY locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc) { locale __r = getloc(); ios_base::imbue(__loc); if (rdbuf()) rdbuf()->pubimbue(__loc); return __r; } template inline _LIBCPP_INLINE_VISIBILITY char basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const { return use_facet >(getloc()).narrow(__c, __dfault); } template inline _LIBCPP_INLINE_VISIBILITY _CharT basic_ios<_CharT, _Traits>::widen(char __c) const { return use_facet >(getloc()).widen(__c); } template inline _LIBCPP_INLINE_VISIBILITY _CharT basic_ios<_CharT, _Traits>::fill() const { if (traits_type::eq_int_type(traits_type::eof(), __fill_)) __fill_ = widen(' '); return __fill_; } template inline _LIBCPP_INLINE_VISIBILITY _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) { char_type __r = __fill_; __fill_ = __ch; return __r; } template basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) { if (this != &__rhs) { __call_callbacks(erase_event); ios_base::copyfmt(__rhs); __tie_ = __rhs.__tie_; __fill_ = __rhs.__fill_; __call_callbacks(copyfmt_event); exceptions(__rhs.exceptions()); } return *this; } template inline _LIBCPP_INLINE_VISIBILITY void basic_ios<_CharT, _Traits>::move(basic_ios& __rhs) { ios_base::move(__rhs); __tie_ = __rhs.__tie_; __rhs.__tie_ = 0; __fill_ = __rhs.__fill_; } template inline _LIBCPP_INLINE_VISIBILITY void basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT { ios_base::swap(__rhs); _VSTD::swap(__tie_, __rhs.__tie_); _VSTD::swap(__fill_, __rhs.__fill_); } template inline _LIBCPP_INLINE_VISIBILITY void basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf* __sb) { ios_base::set_rdbuf(__sb); } inline _LIBCPP_INLINE_VISIBILITY ios_base& boolalpha(ios_base& __str) { __str.setf(ios_base::boolalpha); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noboolalpha(ios_base& __str) { __str.unsetf(ios_base::boolalpha); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& showbase(ios_base& __str) { __str.setf(ios_base::showbase); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noshowbase(ios_base& __str) { __str.unsetf(ios_base::showbase); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& showpoint(ios_base& __str) { __str.setf(ios_base::showpoint); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noshowpoint(ios_base& __str) { __str.unsetf(ios_base::showpoint); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& showpos(ios_base& __str) { __str.setf(ios_base::showpos); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noshowpos(ios_base& __str) { __str.unsetf(ios_base::showpos); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& skipws(ios_base& __str) { __str.setf(ios_base::skipws); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noskipws(ios_base& __str) { __str.unsetf(ios_base::skipws); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& uppercase(ios_base& __str) { __str.setf(ios_base::uppercase); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& nouppercase(ios_base& __str) { __str.unsetf(ios_base::uppercase); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& unitbuf(ios_base& __str) { __str.setf(ios_base::unitbuf); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& nounitbuf(ios_base& __str) { __str.unsetf(ios_base::unitbuf); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& internal(ios_base& __str) { __str.setf(ios_base::internal, ios_base::adjustfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& left(ios_base& __str) { __str.setf(ios_base::left, ios_base::adjustfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& right(ios_base& __str) { __str.setf(ios_base::right, ios_base::adjustfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& dec(ios_base& __str) { __str.setf(ios_base::dec, ios_base::basefield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& hex(ios_base& __str) { __str.setf(ios_base::hex, ios_base::basefield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& oct(ios_base& __str) { __str.setf(ios_base::oct, ios_base::basefield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& fixed(ios_base& __str) { __str.setf(ios_base::fixed, ios_base::floatfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& scientific(ios_base& __str) { __str.setf(ios_base::scientific, ios_base::floatfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& hexfloat(ios_base& __str) { __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& defaultfloat(ios_base& __str) { __str.unsetf(ios_base::floatfield); return __str; } template class __save_flags { typedef basic_ios<_CharT, _Traits> __stream_type; typedef typename __stream_type::fmtflags fmtflags; __stream_type& __stream_; fmtflags __fmtflags_; _CharT __fill_; __save_flags(const __save_flags&); __save_flags& operator=(const __save_flags&); public: _LIBCPP_INLINE_VISIBILITY explicit __save_flags(__stream_type& __stream) : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {} _LIBCPP_INLINE_VISIBILITY ~__save_flags() { __stream_.flags(__fmtflags_); __stream_.fill(__fill_); } }; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_IOS Index: head/contrib/llvm-project/libcxx/include/memory =================================================================== --- head/contrib/llvm-project/libcxx/include/memory (revision 359086) +++ head/contrib/llvm-project/libcxx/include/memory (revision 359087) @@ -1,5351 +1,5353 @@ // -*- C++ -*- //===-------------------------- memory ------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_MEMORY #define _LIBCPP_MEMORY /* memory synopsis namespace std { struct allocator_arg_t { }; inline constexpr allocator_arg_t allocator_arg = allocator_arg_t(); template struct uses_allocator; template struct pointer_traits { typedef Ptr pointer; typedef
element_type; typedef
difference_type; template using rebind =
; static pointer pointer_to(
); }; template struct pointer_traits { typedef T* pointer; typedef T element_type; typedef ptrdiff_t difference_type; template using rebind = U*; static pointer pointer_to(
) noexcept; // constexpr in C++20 }; template constexpr T* to_address(T* p) noexcept; // C++20 template auto to_address(const Ptr& p) noexcept; // C++20 template struct allocator_traits { typedef Alloc allocator_type; typedef typename allocator_type::value_type value_type; typedef Alloc::pointer | value_type* pointer; typedef Alloc::const_pointer | pointer_traits::rebind const_pointer; typedef Alloc::void_pointer | pointer_traits::rebind void_pointer; typedef Alloc::const_void_pointer | pointer_traits::rebind const_void_pointer; typedef Alloc::difference_type | pointer_traits::difference_type difference_type; typedef Alloc::size_type | make_unsigned::type size_type; typedef Alloc::propagate_on_container_copy_assignment | false_type propagate_on_container_copy_assignment; typedef Alloc::propagate_on_container_move_assignment | false_type propagate_on_container_move_assignment; typedef Alloc::propagate_on_container_swap | false_type propagate_on_container_swap; typedef Alloc::is_always_equal | is_empty is_always_equal; template using rebind_alloc = Alloc::rebind::other | Alloc; template using rebind_traits = allocator_traits>; static pointer allocate(allocator_type& a, size_type n); // [[nodiscard]] in C++20 static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // [[nodiscard]] in C++20 static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; template static void construct(allocator_type& a, T* p, Args&&... args); template static void destroy(allocator_type& a, T* p); static size_type max_size(const allocator_type& a); // noexcept in C++14 static allocator_type select_on_container_copy_construction(const allocator_type& a); }; template <> class allocator { public: typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind {typedef allocator<_Up> other;}; }; template class allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef typename add_lvalue_reference::type reference; typedef typename add_lvalue_reference::type const_reference; typedef T value_type; template struct rebind {typedef allocator other;}; constexpr allocator() noexcept; // constexpr in C++20 constexpr allocator(const allocator&) noexcept; // constexpr in C++20 template constexpr allocator(const allocator&) noexcept; // constexpr in C++20 ~allocator(); pointer address(reference x) const noexcept; const_pointer address(const_reference x) const noexcept; pointer allocate(size_type, allocator::const_pointer hint = 0); void deallocate(pointer p, size_type n) noexcept; size_type max_size() const noexcept; template void construct(U* p, Args&&... args); template void destroy(U* p); }; template bool operator==(const allocator&, const allocator&) noexcept; template bool operator!=(const allocator&, const allocator&) noexcept; template class raw_storage_iterator : public iterator // purposefully not C++03 { public: explicit raw_storage_iterator(OutputIterator x); raw_storage_iterator& operator*(); raw_storage_iterator& operator=(const T& element); raw_storage_iterator& operator++(); raw_storage_iterator operator++(int); }; template pair get_temporary_buffer(ptrdiff_t n) noexcept; template void return_temporary_buffer(T* p) noexcept; template T* addressof(T& r) noexcept; template T* addressof(const T&& r) noexcept = delete; template ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); template ForwardIterator uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); template void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); template ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x); template void destroy_at(T* location); template void destroy(ForwardIterator first, ForwardIterator last); template ForwardIterator destroy_n(ForwardIterator first, Size n); template ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result); template pair uninitialized_move_n(InputIterator first, Size n, ForwardIterator result); template void uninitialized_value_construct(ForwardIterator first, ForwardIterator last); template ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n); template void uninitialized_default_construct(ForwardIterator first, ForwardIterator last); template ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n); template struct auto_ptr_ref {}; // deprecated in C++11, removed in C++17 template class auto_ptr // deprecated in C++11, removed in C++17 { public: typedef X element_type; explicit auto_ptr(X* p =0) throw(); auto_ptr(auto_ptr&) throw(); template auto_ptr(auto_ptr&) throw(); auto_ptr& operator=(auto_ptr&) throw(); template auto_ptr& operator=(auto_ptr&) throw(); auto_ptr& operator=(auto_ptr_ref r) throw(); ~auto_ptr() throw(); typename add_lvalue_reference::type operator*() const throw(); X* operator->() const throw(); X* get() const throw(); X* release() throw(); void reset(X* p =0) throw(); auto_ptr(auto_ptr_ref) throw(); template operator auto_ptr_ref() throw(); template operator auto_ptr() throw(); }; template struct default_delete { constexpr default_delete() noexcept = default; template default_delete(const default_delete&) noexcept; void operator()(T*) const noexcept; }; template struct default_delete { constexpr default_delete() noexcept = default; void operator()(T*) const noexcept; template void operator()(U*) const = delete; }; template > class unique_ptr { public: typedef see below pointer; typedef T element_type; typedef D deleter_type; // constructors constexpr unique_ptr() noexcept; explicit unique_ptr(pointer p) noexcept; unique_ptr(pointer p, see below d1) noexcept; unique_ptr(pointer p, see below d2) noexcept; unique_ptr(unique_ptr&& u) noexcept; unique_ptr(nullptr_t) noexcept : unique_ptr() { } template unique_ptr(unique_ptr&& u) noexcept; template unique_ptr(auto_ptr&& u) noexcept; // removed in C++17 // destructor ~unique_ptr(); // assignment unique_ptr& operator=(unique_ptr&& u) noexcept; template unique_ptr& operator=(unique_ptr&& u) noexcept; unique_ptr& operator=(nullptr_t) noexcept; // observers typename add_lvalue_reference::type operator*() const; pointer operator->() const noexcept; pointer get() const noexcept; deleter_type& get_deleter() noexcept; const deleter_type& get_deleter() const noexcept; explicit operator bool() const noexcept; // modifiers pointer release() noexcept; void reset(pointer p = pointer()) noexcept; void swap(unique_ptr& u) noexcept; }; template class unique_ptr { public: typedef implementation-defined pointer; typedef T element_type; typedef D deleter_type; // constructors constexpr unique_ptr() noexcept; explicit unique_ptr(pointer p) noexcept; unique_ptr(pointer p, see below d) noexcept; unique_ptr(pointer p, see below d) noexcept; unique_ptr(unique_ptr&& u) noexcept; unique_ptr(nullptr_t) noexcept : unique_ptr() { } // destructor ~unique_ptr(); // assignment unique_ptr& operator=(unique_ptr&& u) noexcept; unique_ptr& operator=(nullptr_t) noexcept; // observers T& operator[](size_t i) const; pointer get() const noexcept; deleter_type& get_deleter() noexcept; const deleter_type& get_deleter() const noexcept; explicit operator bool() const noexcept; // modifiers pointer release() noexcept; void reset(pointer p = pointer()) noexcept; void reset(nullptr_t) noexcept; template void reset(U) = delete; void swap(unique_ptr& u) noexcept; }; template void swap(unique_ptr& x, unique_ptr& y) noexcept; template bool operator==(const unique_ptr& x, const unique_ptr& y); template bool operator!=(const unique_ptr& x, const unique_ptr& y); template bool operator<(const unique_ptr& x, const unique_ptr& y); template bool operator<=(const unique_ptr& x, const unique_ptr& y); template bool operator>(const unique_ptr& x, const unique_ptr& y); template bool operator>=(const unique_ptr& x, const unique_ptr& y); template bool operator==(const unique_ptr& x, nullptr_t) noexcept; template bool operator==(nullptr_t, const unique_ptr& y) noexcept; template bool operator!=(const unique_ptr& x, nullptr_t) noexcept; template bool operator!=(nullptr_t, const unique_ptr& y) noexcept; template bool operator<(const unique_ptr& x, nullptr_t); template bool operator<(nullptr_t, const unique_ptr& y); template bool operator<=(const unique_ptr& x, nullptr_t); template bool operator<=(nullptr_t, const unique_ptr& y); template bool operator>(const unique_ptr& x, nullptr_t); template bool operator>(nullptr_t, const unique_ptr& y); template bool operator>=(const unique_ptr& x, nullptr_t); template bool operator>=(nullptr_t, const unique_ptr& y); class bad_weak_ptr : public std::exception { bad_weak_ptr() noexcept; }; template unique_ptr make_unique(Args&&... args); // C++14 template unique_ptr make_unique(size_t n); // C++14 template unspecified make_unique(Args&&...) = delete; // C++14, T == U[N] template basic_ostream& operator<< (basic_ostream& os, unique_ptr const& p); template class shared_ptr { public: typedef T element_type; typedef weak_ptr weak_type; // C++17 // constructors: constexpr shared_ptr() noexcept; template explicit shared_ptr(Y* p); template shared_ptr(Y* p, D d); template shared_ptr(Y* p, D d, A a); template shared_ptr(nullptr_t p, D d); template shared_ptr(nullptr_t p, D d, A a); template shared_ptr(const shared_ptr& r, T *p) noexcept; shared_ptr(const shared_ptr& r) noexcept; template shared_ptr(const shared_ptr& r) noexcept; shared_ptr(shared_ptr&& r) noexcept; template shared_ptr(shared_ptr&& r) noexcept; template explicit shared_ptr(const weak_ptr& r); template shared_ptr(auto_ptr&& r); // removed in C++17 template shared_ptr(unique_ptr&& r); shared_ptr(nullptr_t) : shared_ptr() { } // destructor: ~shared_ptr(); // assignment: shared_ptr& operator=(const shared_ptr& r) noexcept; template shared_ptr& operator=(const shared_ptr& r) noexcept; shared_ptr& operator=(shared_ptr&& r) noexcept; template shared_ptr& operator=(shared_ptr&& r); template shared_ptr& operator=(auto_ptr&& r); // removed in C++17 template shared_ptr& operator=(unique_ptr&& r); // modifiers: void swap(shared_ptr& r) noexcept; void reset() noexcept; template void reset(Y* p); template void reset(Y* p, D d); template void reset(Y* p, D d, A a); // observers: T* get() const noexcept; T& operator*() const noexcept; T* operator->() const noexcept; long use_count() const noexcept; bool unique() const noexcept; explicit operator bool() const noexcept; template bool owner_before(shared_ptr const& b) const noexcept; template bool owner_before(weak_ptr const& b) const noexcept; }; // shared_ptr comparisons: template bool operator==(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator!=(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator<(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator>(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator<=(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator>=(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator==(const shared_ptr& x, nullptr_t) noexcept; template bool operator==(nullptr_t, const shared_ptr& y) noexcept; template bool operator!=(const shared_ptr& x, nullptr_t) noexcept; template bool operator!=(nullptr_t, const shared_ptr& y) noexcept; template bool operator<(const shared_ptr& x, nullptr_t) noexcept; template bool operator<(nullptr_t, const shared_ptr& y) noexcept; template bool operator<=(const shared_ptr& x, nullptr_t) noexcept; template bool operator<=(nullptr_t, const shared_ptr& y) noexcept; template bool operator>(const shared_ptr& x, nullptr_t) noexcept; template bool operator>(nullptr_t, const shared_ptr& y) noexcept; template bool operator>=(const shared_ptr& x, nullptr_t) noexcept; template bool operator>=(nullptr_t, const shared_ptr& y) noexcept; // shared_ptr specialized algorithms: template void swap(shared_ptr& a, shared_ptr& b) noexcept; // shared_ptr casts: template shared_ptr static_pointer_cast(shared_ptr const& r) noexcept; template shared_ptr dynamic_pointer_cast(shared_ptr const& r) noexcept; template shared_ptr const_pointer_cast(shared_ptr const& r) noexcept; // shared_ptr I/O: template basic_ostream& operator<< (basic_ostream& os, shared_ptr const& p); // shared_ptr get_deleter: template D* get_deleter(shared_ptr const& p) noexcept; template shared_ptr make_shared(Args&&... args); template shared_ptr allocate_shared(const A& a, Args&&... args); template class weak_ptr { public: typedef T element_type; // constructors constexpr weak_ptr() noexcept; template weak_ptr(shared_ptr const& r) noexcept; weak_ptr(weak_ptr const& r) noexcept; template weak_ptr(weak_ptr const& r) noexcept; weak_ptr(weak_ptr&& r) noexcept; // C++14 template weak_ptr(weak_ptr&& r) noexcept; // C++14 // destructor ~weak_ptr(); // assignment weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(shared_ptr const& r) noexcept; weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 template weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 // modifiers void swap(weak_ptr& r) noexcept; void reset() noexcept; // observers long use_count() const noexcept; bool expired() const noexcept; shared_ptr lock() const noexcept; template bool owner_before(shared_ptr const& b) const noexcept; template bool owner_before(weak_ptr const& b) const noexcept; }; // weak_ptr specialized algorithms: template void swap(weak_ptr& a, weak_ptr& b) noexcept; // class owner_less: template struct owner_less; template struct owner_less > : binary_function, shared_ptr, bool> { typedef bool result_type; bool operator()(shared_ptr const&, shared_ptr const&) const noexcept; bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; }; template struct owner_less > : binary_function, weak_ptr, bool> { typedef bool result_type; bool operator()(weak_ptr const&, weak_ptr const&) const noexcept; bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; }; template <> // Added in C++14 struct owner_less { template bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept; template bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept; template bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept; template bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept; typedef void is_transparent; }; template class enable_shared_from_this { protected: constexpr enable_shared_from_this() noexcept; enable_shared_from_this(enable_shared_from_this const&) noexcept; enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; ~enable_shared_from_this(); public: shared_ptr shared_from_this(); shared_ptr shared_from_this() const; }; template bool atomic_is_lock_free(const shared_ptr* p); template shared_ptr atomic_load(const shared_ptr* p); template shared_ptr atomic_load_explicit(const shared_ptr* p, memory_order mo); template void atomic_store(shared_ptr* p, shared_ptr r); template void atomic_store_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template shared_ptr atomic_exchange(shared_ptr* p, shared_ptr r); template shared_ptr atomic_exchange_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template bool atomic_compare_exchange_weak(shared_ptr* p, shared_ptr* v, shared_ptr w); template bool atomic_compare_exchange_strong( shared_ptr* p, shared_ptr* v, shared_ptr w); template bool atomic_compare_exchange_weak_explicit(shared_ptr* p, shared_ptr* v, shared_ptr w, memory_order success, memory_order failure); template bool atomic_compare_exchange_strong_explicit(shared_ptr* p, shared_ptr* v, shared_ptr w, memory_order success, memory_order failure); // Hash support template struct hash; template struct hash >; template struct hash >; template inline constexpr bool uses_allocator_v = uses_allocator::value; // Pointer safety enum class pointer_safety { relaxed, preferred, strict }; void declare_reachable(void *p); template T *undeclare_reachable(T *p); void declare_no_pointers(char *p, size_t n); void undeclare_no_pointers(char *p, size_t n); pointer_safety get_pointer_safety() noexcept; void* align(size_t alignment, size_t size, void*& ptr, size_t& space); } // std */ #include <__config> #include #include #include #include #include #include #include #include #include <__functional_base> #include #include #include #include #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) # include #endif #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_PUSH_MACROS #include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD template inline _LIBCPP_INLINE_VISIBILITY _ValueType __libcpp_relaxed_load(_ValueType const* __value) { #if !defined(_LIBCPP_HAS_NO_THREADS) && \ defined(__ATOMIC_RELAXED) && \ (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC)) return __atomic_load_n(__value, __ATOMIC_RELAXED); #else return *__value; #endif } template inline _LIBCPP_INLINE_VISIBILITY _ValueType __libcpp_acquire_load(_ValueType const* __value) { #if !defined(_LIBCPP_HAS_NO_THREADS) && \ defined(__ATOMIC_ACQUIRE) && \ (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC)) return __atomic_load_n(__value, __ATOMIC_ACQUIRE); #else return *__value; #endif } // addressof moved to template class allocator; template <> class _LIBCPP_TEMPLATE_VIS allocator { public: typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind {typedef allocator<_Up> other;}; }; template <> class _LIBCPP_TEMPLATE_VIS allocator { public: typedef const void* pointer; typedef const void* const_pointer; typedef const void value_type; template struct rebind {typedef allocator<_Up> other;}; }; // pointer_traits template struct __has_element_type : false_type {}; template struct __has_element_type<_Tp, typename __void_t::type> : true_type {}; template ::value> struct __pointer_traits_element_type; template struct __pointer_traits_element_type<_Ptr, true> { typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::element_type type; }; #ifndef _LIBCPP_HAS_NO_VARIADICS template