diff options
Diffstat (limited to 'include/experimental')
-rw-r--r-- | include/experimental/__config | 18 | ||||
-rw-r--r-- | include/experimental/__memory | 90 | ||||
-rw-r--r-- | include/experimental/algorithm | 2 | ||||
-rw-r--r-- | include/experimental/any | 12 | ||||
-rw-r--r-- | include/experimental/deque | 47 | ||||
-rw-r--r-- | include/experimental/dynarray | 15 | ||||
-rw-r--r-- | include/experimental/filesystem | 2052 | ||||
-rw-r--r-- | include/experimental/forward_list | 47 | ||||
-rw-r--r-- | include/experimental/functional | 39 | ||||
-rw-r--r-- | include/experimental/iterator | 114 | ||||
-rw-r--r-- | include/experimental/list | 47 | ||||
-rw-r--r-- | include/experimental/map | 57 | ||||
-rw-r--r-- | include/experimental/memory_resource | 422 | ||||
-rw-r--r-- | include/experimental/optional | 8 | ||||
-rw-r--r-- | include/experimental/propagate_const | 576 | ||||
-rw-r--r-- | include/experimental/regex | 62 | ||||
-rw-r--r-- | include/experimental/set | 57 | ||||
-rw-r--r-- | include/experimental/string | 62 | ||||
-rw-r--r-- | include/experimental/string_view | 45 | ||||
-rw-r--r-- | include/experimental/tuple | 3 | ||||
-rw-r--r-- | include/experimental/unordered_map | 65 | ||||
-rw-r--r-- | include/experimental/unordered_set | 59 | ||||
-rw-r--r-- | include/experimental/vector | 47 |
23 files changed, 3895 insertions, 51 deletions
diff --git a/include/experimental/__config b/include/experimental/__config index f64a3a90cd12..9a7bbe85d8d3 100644 --- a/include/experimental/__config +++ b/include/experimental/__config @@ -25,8 +25,26 @@ #define _LIBCPP_END_NAMESPACE_LFTS } } } #define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1 +#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 { +#define _LIBCPP_END_NAMESPACE_LFTS_V2 } } } +#define _VSTD_LFTS_V2 _VSTD_EXPERIMENTAL::fundamentals_v2 + +#define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr { +#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS } +#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr + #define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD \ namespace chrono { namespace experimental { inline namespace fundamentals_v1 { #define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } } +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem { \ + inline namespace v1 { + +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ + } } _LIBCPP_END_NAMESPACE_EXPERIMENTAL + + +#define _VSTD_FS ::std::experimental::filesystem::v1 + #endif diff --git a/include/experimental/__memory b/include/experimental/__memory new file mode 100644 index 000000000000..229fea605bfd --- /dev/null +++ b/include/experimental/__memory @@ -0,0 +1,90 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL___MEMORY +#define _LIBCPP_EXPERIMENTAL___MEMORY + +#include <experimental/__config> +#include <experimental/utility> // for erased_type +#include <__functional_base> +#include <type_traits> + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +template < + class _Tp, class _Alloc + , bool = uses_allocator<_Tp, _Alloc>::value + , bool = __has_allocator_type<_Tp>::value + > +struct __lfts_uses_allocator : public false_type {}; + +template <class _Tp, class _Alloc> +struct __lfts_uses_allocator<_Tp, _Alloc, false, false> : public false_type {}; + +template <class _Tp, class _Alloc, bool HasAlloc> +struct __lfts_uses_allocator<_Tp, _Alloc, true, HasAlloc> : public true_type {}; + +template <class _Tp, class _Alloc> +struct __lfts_uses_allocator<_Tp, _Alloc, false, true> + : public integral_constant<bool + , is_convertible<_Alloc, typename _Tp::allocator_type>::value + || is_same<erased_type, typename _Tp::allocator_type>::value + > +{}; + +template <bool _UsesAlloc, class _Tp, class _Alloc, class ..._Args> +struct __lfts_uses_alloc_ctor_imp +{ + static const int value = 0; +}; + +template <class _Tp, class _Alloc, class ..._Args> +struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...> +{ + static const bool __ic_first + = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; + + static const bool __ic_second = + conditional< + __ic_first, + false_type, + is_constructible<_Tp, _Args..., _Alloc> + >::type::value; + + static_assert(__ic_first || __ic_second, + "Request for uses allocator construction is ill-formed"); + + static const int value = __ic_first ? 1 : 2; +}; + +template <class _Tp, class _Alloc, class ..._Args> +struct __lfts_uses_alloc_ctor + : integral_constant<int, + __lfts_uses_alloc_ctor_imp< + __lfts_uses_allocator<_Tp, _Alloc>::value + , _Tp, _Alloc, _Args... + >::value + > +{}; + +template <class _Tp, class _Alloc, class ..._Args> +inline _LIBCPP_INLINE_VISIBILITY +void __lfts_user_alloc_construct( + _Tp * __store, const _Alloc & __a, _Args &&... __args) +{ + _VSTD::__user_alloc_construct_impl( + typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type() + , __store, __a, _VSTD::forward<_Args>(__args)... + ); +} + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL___MEMORY */ diff --git a/include/experimental/algorithm b/include/experimental/algorithm index ffaa793b6d4e..3902111c54ea 100644 --- a/include/experimental/algorithm +++ b/include/experimental/algorithm @@ -53,7 +53,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS template <class _ForwardIterator, class _Searcher> _LIBCPP_INLINE_VISIBILITY _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s) -{ return __s(__f, __l); } +{ return __s(__f, __l).first; } template <class _PopulationIterator, class _SampleIterator, class _Distance, diff --git a/include/experimental/any b/include/experimental/any index 603788484dd5..4c732496c52b 100644 --- a/include/experimental/any +++ b/include/experimental/any @@ -113,10 +113,12 @@ class any; template <class _ValueType> typename add_pointer<typename add_const<_ValueType>::type>::type +_LIBCPP_INLINE_VISIBILITY any_cast(any const *) _NOEXCEPT; template <class _ValueType> typename add_pointer<_ValueType>::type +_LIBCPP_INLINE_VISIBILITY any_cast(any *) _NOEXCEPT; namespace __any_imp @@ -185,6 +187,7 @@ public: class _ValueType , class = __any_imp::_EnableIfNotAny<_ValueType> > + _LIBCPP_INLINE_VISIBILITY any(_ValueType && __value); _LIBCPP_INLINE_VISIBILITY @@ -212,6 +215,7 @@ public: class _ValueType , class = __any_imp::_EnableIfNotAny<_ValueType> > + _LIBCPP_INLINE_VISIBILITY any & operator=(_ValueType && __rhs); // 6.3.3 any modifiers @@ -221,6 +225,7 @@ public: if (__h) this->__call(_Action::_Destroy); } + _LIBCPP_INLINE_VISIBILITY void swap(any & __rhs) _NOEXCEPT; // 6.3.4 any observers @@ -457,7 +462,6 @@ namespace __any_imp template <class _ValueType, class> -_LIBCPP_INLINE_VISIBILITY any::any(_ValueType && __v) : __h(nullptr) { typedef typename decay<_ValueType>::type _Tp; @@ -468,7 +472,6 @@ any::any(_ValueType && __v) : __h(nullptr) } template <class _ValueType, class> -_LIBCPP_INLINE_VISIBILITY any & any::operator=(_ValueType && __v) { typedef typename decay<_ValueType>::type _Tp; @@ -478,7 +481,7 @@ any & any::operator=(_ValueType && __v) return *this; } -inline _LIBCPP_INLINE_VISIBILITY +inline void any::swap(any & __rhs) _NOEXCEPT { if (__h && __rhs.__h) { @@ -550,7 +553,7 @@ _ValueType any_cast(any && __v) } template <class _ValueType> -inline _LIBCPP_INLINE_VISIBILITY +inline typename add_pointer<typename add_const<_ValueType>::type>::type any_cast(any const * __any) _NOEXCEPT { @@ -560,7 +563,6 @@ any_cast(any const * __any) _NOEXCEPT } template <class _ValueType> -_LIBCPP_INLINE_VISIBILITY typename add_pointer<_ValueType>::type any_cast(any * __any) _NOEXCEPT { diff --git a/include/experimental/deque b/include/experimental/deque new file mode 100644 index 000000000000..f8495743c1f9 --- /dev/null +++ b/include/experimental/deque @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===--------------------------- deque ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_DEQUE +#define _LIBCPP_EXPERIMENTAL_DEQUE +/* + experimental/deque synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T> + using deque = std::deque<T,polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <deque> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _ValueT> +using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */ diff --git a/include/experimental/dynarray b/include/experimental/dynarray index f40a6ca188b8..4a06908e11b1 100644 --- a/include/experimental/dynarray +++ b/include/experimental/dynarray @@ -159,9 +159,13 @@ private: public: + _LIBCPP_INLINE_VISIBILITY explicit dynarray(size_type __c); + _LIBCPP_INLINE_VISIBILITY dynarray(size_type __c, const value_type& __v); + _LIBCPP_INLINE_VISIBILITY dynarray(const dynarray& __d); + _LIBCPP_INLINE_VISIBILITY dynarray(initializer_list<value_type>); // We're not implementing these right now. @@ -176,6 +180,7 @@ public: // dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list<value_type>); dynarray& operator=(const dynarray&) = delete; + _LIBCPP_INLINE_VISIBILITY ~dynarray(); // iterators: @@ -219,7 +224,7 @@ public: }; template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline dynarray<_Tp>::dynarray(size_type __c) : dynarray () { __base_ = __allocate (__c); @@ -229,7 +234,7 @@ dynarray<_Tp>::dynarray(size_type __c) : dynarray () } template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray () { __base_ = __allocate (__c); @@ -239,7 +244,7 @@ dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray () } template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray () { size_t sz = __il.size(); @@ -251,7 +256,7 @@ dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray () } template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray () { size_t sz = __d.size(); @@ -263,7 +268,7 @@ dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray () } template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline dynarray<_Tp>::~dynarray() { value_type *__data = data () + __size_; diff --git a/include/experimental/filesystem b/include/experimental/filesystem new file mode 100644 index 000000000000..7de93fdf8f15 --- /dev/null +++ b/include/experimental/filesystem @@ -0,0 +1,2052 @@ +// -*- C++ -*- +//===--------------------------- filesystem -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#ifndef _LIBCPP_EXPERIMENTAL_FILESYSTEM +#define _LIBCPP_EXPERIMENTAL_FILESYSTEM +/* + filesystem synopsis + + namespace std { namespace experimental { namespace filesystem { inline namespace v1 { + + 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); + + template <class charT, class traits> + basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>& os, const path& p); + + template <class charT, class traits> + basic_istream<charT, traits>& + operator>>(basic_istream<charT, traits>& is, path& p); + + template <class Source> + path u8path(const Source& source); + template <class InputIterator> + 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 copy_options; + enum class directory_options; + + typedef chrono::time_point<trivial-clock> file_time_type; + + // operational functions + + path absolute(const path& p, const path& base=current_path()); + + path canonical(const path& p, const path& base = current_path()); + path canonical(const path& p, error_code& ec); + path canonical(const path& p, const path& base, error_code& ec); + + void copy(const path& from, const path& to); + void copy(const path& from, const path& to, error_code& ec) _NOEXCEPT; + 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) _NOEXCEPT; + + bool copy_file(const path& from, const path& to); + bool copy_file(const path& from, const path& to, error_code& ec) _NOEXCEPT; + 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) _NOEXCEPT; + + 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) _NOEXCEPT; + + 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); + void permissions(const path& p, perms prms, error_code& ec) _NOEXCEPT; + + path read_symlink(const path& p); + path read_symlink(const path& p, 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) _NOEXCEPT; + + 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 system_complete(const path& p); + path system_complete(const path& p, error_code& ec); + + path temp_directory_path(); + path temp_directory_path(error_code& ec); + +} } } } // namespaces std::experimental::filesystem::v1 + +*/ + +#include <experimental/__config> +#include <cstddef> +#include <chrono> +#include <iterator> +#include <iosfwd> +#include <locale> +#include <memory> +#include <stack> +#include <string> +#include <system_error> +#include <utility> +#include <iomanip> // for quoted +#include <experimental/string_view> + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#define __cpp_lib_experimental_filesystem 201406 + +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM + +typedef chrono::time_point<std::chrono::system_clock> file_time_type; + +struct _LIBCPP_TYPE_VIS space_info +{ + uintmax_t capacity; + uintmax_t free; + uintmax_t available; +}; + +enum class _LIBCPP_TYPE_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_TYPE_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, + + add_perms = 0x10000, + remove_perms = 0x20000, + symlink_nofollow = 0x40000 +}; + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR perms operator&(perms _LHS, perms _RHS) +{ return static_cast<perms>(static_cast<unsigned>(_LHS) & static_cast<unsigned>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR perms operator|(perms _LHS, perms _RHS) +{ return static_cast<perms>(static_cast<unsigned>(_LHS) | static_cast<unsigned>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR perms operator^(perms _LHS, perms _RHS) +{ return static_cast<perms>(static_cast<unsigned>(_LHS) ^ static_cast<unsigned>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR perms operator~(perms _LHS) +{ return static_cast<perms>(~static_cast<unsigned>(_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_TYPE_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 _LIBCPP_CONSTEXPR copy_options operator&(copy_options _LHS, copy_options _RHS) +{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) & static_cast<unsigned short>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR copy_options operator|(copy_options _LHS, copy_options _RHS) +{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) | static_cast<unsigned short>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR copy_options operator^(copy_options _LHS, copy_options _RHS) +{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^ static_cast<unsigned short>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR copy_options operator~(copy_options _LHS) +{ return static_cast<copy_options>(~static_cast<unsigned short>(_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 directory_options : unsigned char +{ + none = 0, + follow_directory_symlink = 1, + skip_permission_denied = 2 +}; + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR directory_options operator&(directory_options _LHS, directory_options _RHS) +{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) & static_cast<unsigned char>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR directory_options operator|(directory_options _LHS, directory_options _RHS) +{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) | static_cast<unsigned char>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR directory_options operator^(directory_options _LHS, directory_options _RHS) +{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^ static_cast<unsigned char>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR directory_options operator~(directory_options _LHS) +{ return static_cast<directory_options>(~static_cast<unsigned char>(_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 + explicit file_status(file_type __ft = file_type::none, + 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_ALWAYS_INLINE + file_type type() const _NOEXCEPT { + return __ft_; + } + + _LIBCPP_ALWAYS_INLINE + perms permissions() const _NOEXCEPT { + return __prms_; + } + + // modifiers + _LIBCPP_ALWAYS_INLINE + void type(file_type __ft) _NOEXCEPT { + __ft_ = __ft; + } + + _LIBCPP_ALWAYS_INLINE + void permissions(perms __p) _NOEXCEPT { + __prms_ = __p; + } +private: + file_type __ft_; + perms __prms_; +}; + +class _LIBCPP_TYPE_VIS directory_entry; + +template <class _Tp> struct __can_convert_char { + static const bool value = false; +}; +template <> struct __can_convert_char<char> { + static const bool value = true; + using __char_type = char; +}; +template <> struct __can_convert_char<wchar_t> { + static const bool value = true; + using __char_type = wchar_t; +}; +template <> struct __can_convert_char<char16_t> { + static const bool value = true; + using __char_type = char16_t; +}; +template <> struct __can_convert_char<char32_t> { + static const bool value = true; + using __char_type = char32_t; +}; + +template <class _ECharT> +typename enable_if<__can_convert_char<_ECharT>::value, bool>::type +__is_separator(_ECharT __e) { + return __e == _ECharT('/'); +}; + +struct _NullSentinal {}; + +template <class _Tp> +using _Void = void; + +template <class _Tp, class = void> +struct __is_pathable_string : public false_type {}; + +template <class _ECharT, class _Traits, class _Alloc> +struct __is_pathable_string<basic_string<_ECharT, _Traits, _Alloc>, + _Void<typename __can_convert_char<_ECharT>::__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 <class _Source, + class _DS = typename decay<_Source>::type, + class _UnqualPtrType = typename remove_const< + typename remove_pointer<_DS>::type>::type, + bool _IsCharPtr = is_pointer<_DS>::value && + __can_convert_char<_UnqualPtrType>::value + > +struct __is_pathable_char_array : false_type {}; + +template <class _Source, class _ECharT, class _UPtr> +struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> + : __can_convert_char<typename remove_const<_ECharT>::type> +{ + using _Base = __can_convert_char<typename remove_const<_ECharT>::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 <class _Iter, bool _IsIt = __is_input_iterator<_Iter>::value, class = void> +struct __is_pathable_iter : false_type {}; + +template <class _Iter> +struct __is_pathable_iter<_Iter, true, + _Void<typename __can_convert_char<typename iterator_traits<_Iter>::value_type>::__char_type>> + : __can_convert_char<typename iterator_traits<_Iter>::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 <class _Tp, bool _IsStringT = __is_pathable_string<_Tp>::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 <class _Tp> +struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {}; + + +template <class _Tp> +struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {}; + + +template <class _Tp> +struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {}; + + +template <class _ECharT> +struct _PathCVT { + static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible"); + + typedef __narrow_to_utf8<sizeof(_ECharT)*__CHAR_BIT__> _Narrower; + + static void __append_range(string& __dest, _ECharT const* __b, _ECharT const* __e) { + _Narrower()(back_inserter(__dest), __b, __e); + } + + template <class _Iter> + 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 <class _Iter> + 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 <class _Source> + 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<char> { + template <class _Iter> + static void __append_range(string& __dest, _Iter __b, _Iter __e) { + for (; __b != __e; ++__b) + __dest.push_back(*__b); + } + + template <class _Iter> + static void __append_range(string& __dest, _Iter __b, _NullSentinal) { + const char __sentinal = char{}; + for (; *__b != __sentinal; ++__b) + __dest.push_back(*__b); + } + + template <class _Source> + 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 <class _SourceOrIter, class _Tp = path&> + using _EnableIfPathable = typename + enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type; + + template <class _Tp> + using _SourceChar = typename __is_pathable<_Tp>::__char_type; + + template <class _Tp> + using _SourceCVT = _PathCVT<_SourceChar<_Tp>>; + +public: + typedef char value_type; + typedef basic_string<value_type> string_type; + static _LIBCPP_CONSTEXPR value_type preferred_separator = '/'; + + // 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) _NOEXCEPT : __pn_(_VSTD::move(__s)) {} + + template < + class _Source, + class = _EnableIfPathable<_Source, void> + > + path(const _Source& __src) { + _SourceCVT<_Source>::__append_source(__pn_, __src); + } + + template <class _InputIt> + path(_InputIt __first, _InputIt __last) { + typedef typename iterator_traits<_InputIt>::value_type _ItVal; + _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); + } + + // TODO Implement locale conversions. + template <class _Source, + class = _EnableIfPathable<_Source, void> + > + path(const _Source& __src, const locale& __loc); + template <class _InputIt> + path(_InputIt __first, _InputIt _last, const locale& __loc); + + _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; + } + + _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 <class _Source> + _LIBCPP_INLINE_VISIBILITY + _EnableIfPathable<_Source> + operator=(const _Source& __src) + { return this->assign(__src); } + + + template <class _Source> + _EnableIfPathable<_Source> + assign(const _Source& __src) { + __pn_.clear(); + _SourceCVT<_Source>::__append_source(__pn_, __src); + return *this; + } + + template <class _InputIt> + 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 <class _ECharT> + void __append_sep_if_needed(_ECharT __first_or_null) { + const _ECharT __null_val = {}; + bool __append_sep = !empty() && + !__is_separator(__pn_.back()) && + __first_or_null != __null_val && // non-empty + !__is_separator(__first_or_null); + if (__append_sep) + __pn_ += preferred_separator; + } + +public: + // appends + path& operator/=(const path& __p) { + __append_sep_if_needed(__p.empty() ? char{} : __p.__pn_[0]); + __pn_ += __p.native(); + return *this; + } + + template <class _Source> + _LIBCPP_INLINE_VISIBILITY + _EnableIfPathable<_Source> + operator/=(const _Source& __src) { + return this->append(__src); + } + + template <class _Source> + _EnableIfPathable<_Source> + append(const _Source& __src) { + using _Traits = __is_pathable<_Source>; + using _CVT = _PathCVT<_SourceChar<_Source>>; + __append_sep_if_needed(_Traits::__first_or_null(__src)); + _CVT::__append_source(__pn_, __src); + return *this; + } + + template <class _InputIt> + 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) { + __append_sep_if_needed(*__first); + _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+=(const value_type* __x) { + __pn_ += __x; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + path& operator+=(value_type __x) { + __pn_ += __x; + return *this; + } + + + template <class _ECharT> + 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 <class _Source> + _EnableIfPathable<_Source> + operator+=(const _Source& __x) { + return this->concat(__x); + } + + template <class _Source> + _EnableIfPathable<_Source> + concat(const _Source& __x) { + _SourceCVT<_Source>::__append_source(__pn_, __x); + return *this; + } + + template <class _InputIt> + 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; } + path& remove_filename() { return *this = parent_path(); } + + 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_); + } + + // 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 _ECharT, class _Traits = char_traits<_ECharT>, + class _Allocator = allocator<_ECharT> > + basic_string<_ECharT, _Traits, _Allocator> + string(const _Allocator& __a = _Allocator()) const { + using _CVT = __widen_from_utf8<sizeof(_ECharT)*__CHAR_BIT__>; + 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<wchar_t>(); } + _LIBCPP_INLINE_VISIBILITY std::string u8string() const { return __pn_; } + _LIBCPP_INLINE_VISIBILITY std::u16string u16string() const { return string<char16_t>(); } + _LIBCPP_INLINE_VISIBILITY std::u32string u32string() const { return string<char32_t>(); } + + // generic format observers + template <class _ECharT, class _Traits = char_traits<_ECharT>, + 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<wchar_t>(); } + std::string generic_u8string() const { return __pn_; } + std::u16string generic_u16string() const { return string<char16_t>(); } + std::u32string generic_u32string() const { return string<char32_t>(); } + +private: + _LIBCPP_FUNC_VIS int __compare(const value_type*) const; + _LIBCPP_FUNC_VIS string_view __root_name() const; + _LIBCPP_FUNC_VIS string_view __root_directory() const; + _LIBCPP_FUNC_VIS string_view __relative_path() const; + _LIBCPP_FUNC_VIS string_view __parent_path() const; + _LIBCPP_FUNC_VIS string_view __filename() const; + _LIBCPP_FUNC_VIS string_view __stem() const; + _LIBCPP_FUNC_VIS string_view __extension() const; + +public: + // compare + _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const _NOEXCEPT { return __compare(__p.c_str());} + _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { return __compare(__s.c_str()); } + _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const { return __compare(__s); } + + // decomposition + _LIBCPP_INLINE_VISIBILITY path root_name() const { return __root_name().to_string(); } + _LIBCPP_INLINE_VISIBILITY path root_directory() const { return __root_directory().to_string(); } + _LIBCPP_INLINE_VISIBILITY path root_path() const { return root_name().append(__root_directory().to_string()); } + _LIBCPP_INLINE_VISIBILITY path relative_path() const { return __relative_path().to_string(); } + _LIBCPP_INLINE_VISIBILITY path parent_path() const { return __parent_path().to_string(); } + _LIBCPP_INLINE_VISIBILITY path filename() const { return __filename().to_string(); } + _LIBCPP_INLINE_VISIBILITY path stem() const { return __stem().to_string();} + _LIBCPP_INLINE_VISIBILITY path extension() const { return __extension().to_string(); } + + // query + _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_name().empty() && __root_directory().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(); } + + // iterators + class _LIBCPP_TYPE_VIS iterator; + typedef iterator const_iterator; + + _LIBCPP_FUNC_VIS iterator begin() const; + _LIBCPP_FUNC_VIS iterator end() const; + +private: + inline _LIBCPP_INLINE_VISIBILITY + path& __assign_view(string_view const& __s) noexcept { __pn_ = __s.to_string(); return *this; } + string_type __pn_; +}; + +inline _LIBCPP_ALWAYS_INLINE +void swap(path& __lhs, path& __rhs) _NOEXCEPT { + __lhs.swap(__rhs); +} + +_LIBCPP_FUNC_VIS +size_t hash_value(const path& __p) _NOEXCEPT; + +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) == 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) != 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator<(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) < 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator<=(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) <= 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator>(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) > 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator>=(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) >= 0; } + +inline _LIBCPP_INLINE_VISIBILITY +path operator/(const path& __lhs, const path& __rhs) { + return path(__lhs) /= __rhs; +} + +template <class _CharT, class _Traits> +_LIBCPP_INLINE_VISIBILITY +typename enable_if<is_same<_CharT, char>::value && + is_same<_Traits, char_traits<char>>::value, + basic_ostream<_CharT, _Traits>& +>::type +operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { + __os << std::__quoted(__p.native()); + return __os; +} + +template <class _CharT, class _Traits> +_LIBCPP_INLINE_VISIBILITY +typename enable_if<!is_same<_CharT, char>::value || + !is_same<_Traits, char_traits<char>>::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 <class _CharT, class _Traits> +_LIBCPP_INLINE_VISIBILITY +basic_istream<_CharT, _Traits>& +operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) +{ + basic_string<_CharT, _Traits> __tmp; + __is >> __quoted(__tmp); + __p = __tmp; + return __is; +} + +template <class _Source> +_LIBCPP_INLINE_VISIBILITY +typename enable_if<__is_pathable<_Source>::value, path>::type +u8path(const _Source& __s){ + static_assert(is_same<typename __is_pathable<_Source>::__char_type, char>::value, + "u8path(Source const&) requires Source have a character type of type 'char'"); + return path(__s); +} + +template <class _InputIt> +_LIBCPP_INLINE_VISIBILITY +typename enable_if<__is_pathable<_InputIt>::value, path>::type +u8path(_InputIt __f, _InputIt __l) { + static_assert(is_same<typename __is_pathable<_InputIt>::__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: + typedef bidirectional_iterator_tag iterator_category; + typedef path value_type; + typedef std::ptrdiff_t difference_type; + typedef const path* pointer; + typedef const path& reference; +public: + _LIBCPP_INLINE_VISIBILITY + iterator() : __elem_(), __path_ptr_(nullptr), __pos_(0) {} + + iterator(const iterator&) = default; + ~iterator() = default; + + iterator& operator=(const iterator&) = default; + + _LIBCPP_INLINE_VISIBILITY + reference operator*() const { + return __elem_; + } + + _LIBCPP_INLINE_VISIBILITY + pointer operator->() const { + return &__elem_; + } + + _LIBCPP_INLINE_VISIBILITY + iterator& operator++() { + return __increment(); + } + + _LIBCPP_INLINE_VISIBILITY + iterator operator++(int) { + iterator __it(*this); + this->operator++(); + return __it; + } + + _LIBCPP_INLINE_VISIBILITY + iterator& operator--() { + return __decrement(); + } + + _LIBCPP_INLINE_VISIBILITY + iterator operator--(int) { + iterator __it(*this); + this->operator--(); + return __it; + } + +private: + friend class path; + friend bool operator==(const iterator&, const iterator&); + + _LIBCPP_FUNC_VIS iterator& __increment(); + _LIBCPP_FUNC_VIS iterator& __decrement(); + + path __elem_; + const path* __path_ptr_; + size_t __pos_; +}; + +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(const path::iterator& __lhs, const path::iterator& __rhs) { + return __lhs.__path_ptr_ == __rhs.__path_ptr_ && + __lhs.__pos_ == __rhs.__pos_; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(const path::iterator& __lhs, const path::iterator& __rhs) { + return !(__lhs == __rhs); +} + +class _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error +{ +public: + _LIBCPP_INLINE_VISIBILITY + filesystem_error(const string& __what, error_code __ec) + : system_error(__ec, __what), + __paths_(make_shared<_Storage>(path(), path())) + {} + + _LIBCPP_INLINE_VISIBILITY + filesystem_error(const string& __what, const path& __p1, error_code __ec) + : system_error(__ec, __what), + __paths_(make_shared<_Storage>(__p1, path())) + {} + + _LIBCPP_INLINE_VISIBILITY + filesystem_error(const string& __what, const path& __p1, const path& __p2, + error_code __ec) + : system_error(__ec, __what), + __paths_(make_shared<_Storage>(__p1, __p2)) + {} + + _LIBCPP_INLINE_VISIBILITY + const path& path1() const _NOEXCEPT { + return __paths_->first; + } + + _LIBCPP_INLINE_VISIBILITY + const path& path2() const _NOEXCEPT { + return __paths_->second; + } + + _LIBCPP_FUNC_VIS + ~filesystem_error() override; // key function + + // TODO(ericwf): Create a custom error message. + //const char* what() const _NOEXCEPT; + +private: + typedef pair<path, path> _Storage; + shared_ptr<_Storage> __paths_; +}; + +// operational functions + +_LIBCPP_FUNC_VIS +path __canonical(const path&, 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& p, perms prms, error_code *ec=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); + +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); +} + +_LIBCPP_FUNC_VIS +path absolute(const path&, const path& __p2 = current_path()); + +inline _LIBCPP_INLINE_VISIBILITY +path canonical(const path& __p, const path& __base = current_path()) { + return __canonical(__p, __base); +} + +inline _LIBCPP_INLINE_VISIBILITY +path canonical(const path& __p, error_code& __ec) { + path __base = __current_path(&__ec); + if (__ec) return {}; + return __canonical(__p, __base, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +path canonical(const path& __p, const path& __base, error_code& __ec) { + return __canonical(__p, __base, &__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) _NOEXCEPT { + __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) _NOEXCEPT { + __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) _NOEXCEPT { + 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) _NOEXCEPT { + 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) _NOEXCEPT { + 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) _NOEXCEPT { + 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) { + __permissions(__p, __prms); +} + +inline _LIBCPP_INLINE_VISIBILITY +void permissions(const path& __p, perms __prms, error_code& __ec) { + __permissions(__p, __prms, &__ec); +} + +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 +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) _NOEXCEPT { + 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 system_complete(const path& __p) { + return __system_complete(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +path system_complete(const path& __p, error_code& __ec) { + return __system_complete(__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); +} + + +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) {} + + ~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; + } + + _LIBCPP_INLINE_VISIBILITY + void replace_filename(_Path const& __p) { + __p_ = __p_.parent_path() / __p; + } + + _LIBCPP_INLINE_VISIBILITY + _Path const& path() const _NOEXCEPT { + return __p_; + } + + _LIBCPP_INLINE_VISIBILITY + operator const _Path&() const _NOEXCEPT { + return __p_; + } + + _LIBCPP_INLINE_VISIBILITY + file_status status() const { + return _VSTD_FS::status(__p_); + } + + _LIBCPP_INLINE_VISIBILITY + file_status status(error_code& __ec) const _NOEXCEPT { + return _VSTD_FS::status(__p_, __ec); + } + + _LIBCPP_INLINE_VISIBILITY + file_status symlink_status() const { + return _VSTD_FS::symlink_status(__p_); + } + + _LIBCPP_INLINE_VISIBILITY + file_status symlink_status(error_code& __ec) const _NOEXCEPT { + return _VSTD_FS::symlink_status(__p_, __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: + _Path __p_; +}; + + +class directory_iterator; +class recursive_directory_iterator; +class __dir_stream; + +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) _NOEXCEPT + : directory_iterator(__p, &__ec) + { } + + directory_iterator(const path& __p, directory_options __opts, + error_code& __ec) _NOEXCEPT + : 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 __deref(); + } + + 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) _NOEXCEPT + { return __increment(&__ec); } + +private: + 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& __deref() 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) _NOEXCEPT + : recursive_directory_iterator(__p, __xoptions, &__ec) + { } + + _LIBCPP_INLINE_VISIBILITY + recursive_directory_iterator(const path& __p, error_code& __ec) _NOEXCEPT + : 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 __deref(); } + + _LIBCPP_INLINE_VISIBILITY + const directory_entry* operator->() const + { return &__deref(); } + + 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) _NOEXCEPT + { 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: + recursive_directory_iterator(const path& __p, directory_options __opt, + error_code *__ec); + + _LIBCPP_FUNC_VIS + const directory_entry& __deref() 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); + + friend bool operator==(const recursive_directory_iterator&, + const recursive_directory_iterator&) _NOEXCEPT; + + struct __shared_imp; + shared_ptr<__shared_imp> __imp_; + bool __rec_; +}; // class recursive_directory_iterator + + +_LIBCPP_INLINE_VISIBILITY +inline 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_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM + +#endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM diff --git a/include/experimental/forward_list b/include/experimental/forward_list new file mode 100644 index 000000000000..55e195f446f5 --- /dev/null +++ b/include/experimental/forward_list @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===--------------------------- forward_list -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_FORWARD_LIST +#define _LIBCPP_EXPERIMENTAL_FORWARD_LIST +/* + experimental/forward_list synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T> + using forward_list = std::forward_list<T,polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <forward_list> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _ValueT> +using forward_list = _VSTD::forward_list<_ValueT, polymorphic_allocator<_ValueT>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_FORWARD_LIST */ diff --git a/include/experimental/functional b/include/experimental/functional index c7a78695b809..75fc8e99f352 100644 --- a/include/experimental/functional +++ b/include/experimental/functional @@ -119,9 +119,12 @@ public: template <typename _ForwardIterator2> _LIBCPP_INLINE_VISIBILITY - _ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const + pair<_ForwardIterator2, _ForwardIterator2> + operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const { - return _VSTD::search(__f, __l, __first_, __last_, __pred_); + return _VSTD::__search(__f, __l, __first_, __last_, __pred_, + typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(), + typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category()); } private: @@ -233,7 +236,7 @@ public: } template <typename _RandomAccessIterator2> - _RandomAccessIterator2 + pair<_RandomAccessIterator2, _RandomAccessIterator2> operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const { static_assert ( std::is_same< @@ -242,12 +245,12 @@ public: >::value, "Corpus and Pattern iterators must point to the same type" ); - if (__f == __l ) return __l; // empty corpus - if (__first_ == __last_) return __f; // empty pattern + if (__f == __l ) return make_pair(__l, __l); // empty corpus + if (__first_ == __last_) return make_pair(__f, __f); // empty pattern // If the pattern is larger than the corpus, we can't find it! if ( __pattern_length_ > _VSTD::distance (__f, __l)) - return __l; + return make_pair(__l, __l); // Do the search return this->__search(__f, __l); @@ -262,7 +265,8 @@ public: // TODO private: shared_ptr<vector<difference_type>> __suffix_; template <typename _RandomAccessIterator2> - _RandomAccessIterator2 __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + pair<_RandomAccessIterator2, _RandomAccessIterator2> + __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const { _RandomAccessIterator2 __cur = __f; const _RandomAccessIterator2 __last = __l - __pattern_length_; @@ -278,7 +282,7 @@ public: // TODO private: __j--; // We matched - we're done! if ( __j == 0 ) - return __cur; + return make_pair(__cur, __cur + __pattern_length_); } // Since we didn't match, figure out how far to skip forward @@ -290,7 +294,7 @@ public: // TODO private: __cur += __suffix[ __j ]; } - return __l; // We didn't find anything + return make_pair(__l, __l); // We didn't find anything } @@ -384,8 +388,8 @@ public: } } - template <typename _RandomAccessIterator2> - _RandomAccessIterator2 + template <typename _RandomAccessIterator2> + pair<_RandomAccessIterator2, _RandomAccessIterator2> operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const { static_assert ( std::is_same< @@ -394,12 +398,12 @@ public: >::value, "Corpus and Pattern iterators must point to the same type" ); - if (__f == __l ) return __l; // empty corpus - if (__first_ == __last_) return __f; // empty pattern + if (__f == __l ) return make_pair(__l, __l); // empty corpus + if (__first_ == __last_) return make_pair(__f, __f); // empty pattern // If the pattern is larger than the corpus, we can't find it! if ( __pattern_length_ > _VSTD::distance (__f, __l)) - return __l; + return make_pair(__l, __l); // Do the search return this->__search(__f, __l); @@ -413,7 +417,8 @@ private: shared_ptr<skip_table_type> __skip_; template <typename _RandomAccessIterator2> - _RandomAccessIterator2 __search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const { + pair<_RandomAccessIterator2, _RandomAccessIterator2> + __search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const { _RandomAccessIterator2 __cur = __f; const _RandomAccessIterator2 __last = __l - __pattern_length_; const skip_table_type & __skip = *__skip_.get(); @@ -427,12 +432,12 @@ private: __j--; // We matched - we're done! if ( __j == 0 ) - return __cur; + return make_pair(__cur, __cur + __pattern_length_); } __cur += __skip[__cur[__pattern_length_-1]]; } - return __l; + return make_pair(__l, __l); } }; diff --git a/include/experimental/iterator b/include/experimental/iterator new file mode 100644 index 000000000000..da593febe2b4 --- /dev/null +++ b/include/experimental/iterator @@ -0,0 +1,114 @@ +// -*- C++ -*- +//===----------------------------- iterator -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_ITERATOR +#define _LIBCPP_EXPERIMENTAL_ITERATOR + +/* +namespace std { + namespace experimental { + inline namespace fundamentals_v2 { + + template <class DelimT, class charT = char, class traits = char_traits<charT>> + class ostream_joiner { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_ostream<charT, traits> ostream_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + ostream_joiner(ostream_type& s, const DelimT& delimiter); + ostream_joiner(ostream_type& s, DelimT&& delimiter); + + template<typename T> + ostream_joiner& operator=(const T& value); + + ostream_joiner& operator*() noexcept; + ostream_joiner& operator++() noexcept; + ostream_joiner& operator++(int) noexcept; + private: + ostream_type* out_stream; // exposition only + DelimT delim; // exposition only + bool first_element; // exposition only + }; + + template <class charT, class traits, class DelimT> + ostream_joiner<decay_t<DelimT>, charT, traits> + make_ostream_joiner(basic_ostream<charT, traits>& os, DelimT&& delimiter); + + } // inline namespace fundamentals_v2 + } // namespace experimental +} // namespace std + +*/ + +#include <experimental/__config> + +#if _LIBCPP_STD_VER > 11 + +#include <iterator> + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>> +class ostream_joiner { +public: + + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<char_type,traits_type> ostream_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + ostream_joiner(ostream_type& __os, _Delim&& __d) + : __out(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {} + + ostream_joiner(ostream_type& __os, const _Delim& __d) + : __out(_VSTD::addressof(__os)), __delim(__d), __first(true) {} + + + template<typename _Tp> + ostream_joiner& operator=(const _Tp& __v) + { + if (!__first) + *__out << __delim; + __first = false; + *__out << __v; + return *this; + } + + ostream_joiner& operator*() _NOEXCEPT { return *this; } + ostream_joiner& operator++() _NOEXCEPT { return *this; } + ostream_joiner& operator++(int) _NOEXCEPT { return *this; } + +private: + ostream_type* __out; + _Delim __delim; + bool __first; +}; + + +template <class _CharT, class _Traits, class _Delim> +ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits> +make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d) +{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); } + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif // _LIBCPP_EXPERIMENTAL_ITERATOR diff --git a/include/experimental/list b/include/experimental/list new file mode 100644 index 000000000000..1678ee3e93cb --- /dev/null +++ b/include/experimental/list @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===--------------------------- list ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_LIST +#define _LIBCPP_EXPERIMENTAL_LIST +/* + experimental/list synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T> + using list = std::list<T,polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <list> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _ValueT> +using list = _VSTD::list<_ValueT, polymorphic_allocator<_ValueT>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_LIST */ diff --git a/include/experimental/map b/include/experimental/map new file mode 100644 index 000000000000..cff2c5e52c0d --- /dev/null +++ b/include/experimental/map @@ -0,0 +1,57 @@ +// -*- C++ -*- +//===----------------------------- map ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_MAP +#define _LIBCPP_EXPERIMENTAL_MAP +/* + experimental/map synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class Key, class T, class Compare = less<Key>> + using map = std::map<Key, T, Compare, + polymorphic_allocator<pair<const Key,T>>>; + + template <class Key, class T, class Compare = less<Key>> + using multimap = std::multimap<Key, T, Compare, + polymorphic_allocator<pair<const Key,T>>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <map> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _Key, class _Value, class _Compare = less<_Key>> +using map = _VSTD::map<_Key, _Value, _Compare, + polymorphic_allocator<pair<const _Key, _Value>>>; + +template <class _Key, class _Value, class _Compare = less<_Key>> +using multimap = _VSTD::multimap<_Key, _Value, _Compare, + polymorphic_allocator<pair<const _Key, _Value>>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_MAP */ diff --git a/include/experimental/memory_resource b/include/experimental/memory_resource new file mode 100644 index 000000000000..9b345210ee5e --- /dev/null +++ b/include/experimental/memory_resource @@ -0,0 +1,422 @@ +// -*- C++ -*- +//===------------------------ memory_resource -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE +#define _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE + +/** + experimental/memory_resource synopsis + +// C++1y + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + class memory_resource; + + bool operator==(const memory_resource& a, + const memory_resource& b) noexcept; + bool operator!=(const memory_resource& a, + const memory_resource& b) noexcept; + + template <class Tp> class polymorphic_allocator; + + template <class T1, class T2> + bool operator==(const polymorphic_allocator<T1>& a, + const polymorphic_allocator<T2>& b) noexcept; + template <class T1, class T2> + bool operator!=(const polymorphic_allocator<T1>& a, + const polymorphic_allocator<T2>& b) noexcept; + + // The name resource_adaptor_imp is for exposition only. + template <class Allocator> class resource_adaptor_imp; + + template <class Allocator> + using resource_adaptor = resource_adaptor_imp< + allocator_traits<Allocator>::rebind_alloc<char>>; + + // Global memory resources + memory_resource* new_delete_resource() noexcept; + memory_resource* null_memory_resource() noexcept; + + // The default memory resource + memory_resource* set_default_resource(memory_resource* r) noexcept; + memory_resource* get_default_resource() noexcept; + + // Standard memory resources + struct pool_options; + class synchronized_pool_resource; + class unsynchronized_pool_resource; + class monotonic_buffer_resource; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <experimental/__memory> +#include <limits> +#include <memory> +#include <new> +#include <stdexcept> +#include <tuple> +#include <type_traits> +#include <utility> +#include <cstddef> +#include <cstdlib> +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +// Round __s up to next multiple of __a. +inline _LIBCPP_INLINE_VISIBILITY +size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT +{ + _LIBCPP_ASSERT(__s + __a > __s, "aligned allocation size overflows"); + return (__s + __a - 1) & ~(__a - 1); +} + +// 8.5, memory.resource +class _LIBCPP_TYPE_VIS_ONLY memory_resource +{ + static const size_t __max_align = alignof(max_align_t); + +// 8.5.2, memory.resource.public +public: + virtual ~memory_resource() = default; + + _LIBCPP_INLINE_VISIBILITY + void* allocate(size_t __bytes, size_t __align = __max_align) + { return do_allocate(__bytes, __align); } + + _LIBCPP_INLINE_VISIBILITY + void deallocate(void * __p, size_t __bytes, size_t __align = __max_align) + { do_deallocate(__p, __bytes, __align); } + + _LIBCPP_INLINE_VISIBILITY + bool is_equal(memory_resource const & __other) const _NOEXCEPT + { return do_is_equal(__other); } + +// 8.5.3, memory.resource.priv +protected: + virtual void* do_allocate(size_t, size_t) = 0; + virtual void do_deallocate(void*, size_t, size_t) = 0; + virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0; +}; + +// 8.5.4, memory.resource.eq +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(memory_resource const & __lhs, + memory_resource const & __rhs) _NOEXCEPT +{ + return &__lhs == &__rhs || __lhs.is_equal(__rhs); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(memory_resource const & __lhs, + memory_resource const & __rhs) _NOEXCEPT +{ + return !(__lhs == __rhs); +} + +_LIBCPP_FUNC_VIS +memory_resource * new_delete_resource() _NOEXCEPT; + +_LIBCPP_FUNC_VIS +memory_resource * null_memory_resource() _NOEXCEPT; + +_LIBCPP_FUNC_VIS +memory_resource * get_default_resource() _NOEXCEPT; + +_LIBCPP_FUNC_VIS +memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT; + +// 8.6, memory.polymorphic.allocator.class + +// 8.6.1, memory.polymorphic.allocator.overview +template <class _ValueType> +class _LIBCPP_TYPE_VIS_ONLY polymorphic_allocator +{ +public: + typedef _ValueType value_type; + + // 8.6.2, memory.polymorphic.allocator.ctor + _LIBCPP_INLINE_VISIBILITY + polymorphic_allocator() _NOEXCEPT + : __res_(_VSTD_LFTS_PMR::get_default_resource()) + {} + + _LIBCPP_INLINE_VISIBILITY + polymorphic_allocator(memory_resource * __r) _NOEXCEPT + : __res_(__r) + {} + + polymorphic_allocator(polymorphic_allocator const &) = default; + + template <class _Tp> + _LIBCPP_INLINE_VISIBILITY + polymorphic_allocator(polymorphic_allocator<_Tp> const & __other) _NOEXCEPT + : __res_(__other.resource()) + {} + + polymorphic_allocator & + operator=(polymorphic_allocator const &) = delete; + + // 8.6.3, memory.polymorphic.allocator.mem + _LIBCPP_INLINE_VISIBILITY + _ValueType* allocate(size_t __n) { + if (__n > max_size()) { + __libcpp_throw(length_error( + "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)" + " 'n' exceeds maximum supported size")); + } + return static_cast<_ValueType*>( + __res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType)) + ); + } + + _LIBCPP_INLINE_VISIBILITY + void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT { + _LIBCPP_ASSERT(__n <= max_size(), + "deallocate called for size which exceeds max_size()"); + __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType)); + } + + template <class _Tp, class ..._Ts> + _LIBCPP_INLINE_VISIBILITY + void construct(_Tp* __p, _Ts &&... __args) + { + _VSTD_LFTS::__lfts_user_alloc_construct( + __p, resource(), _VSTD::forward<_Ts>(__args)... + ); + } + + template <class _T1, class _T2, class ..._Args1, class ..._Args2> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2>* __p, piecewise_construct_t, + tuple<_Args1...> __x, tuple<_Args2...> __y) + { + ::new ((void*)__p) pair<_T1, _T2>(piecewise_construct + , __transform_tuple( + typename __lfts_uses_alloc_ctor< + _T1, memory_resource*, _Args1... + >::type() + , _VSTD::move(__x) + , typename __make_tuple_indices<sizeof...(_Args1)>::type{} + ) + , __transform_tuple( + typename __lfts_uses_alloc_ctor< + _T2, memory_resource*, _Args2... + >::type() + , _VSTD::move(__y) + , typename __make_tuple_indices<sizeof...(_Args2)>::type{} + ) + ); + } + + template <class _T1, class _T2> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2>* __p) { + construct(__p, piecewise_construct, tuple<>(), tuple<>()); + } + + template <class _T1, class _T2, class _Up, class _Vp> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2> * __p, _Up && __u, _Vp && __v) { + construct(__p, piecewise_construct + , _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__u)) + , _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__v))); + } + + template <class _T1, class _T2, class _U1, class _U2> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> const & __pr) { + construct(__p, piecewise_construct + , _VSTD::forward_as_tuple(__pr.first) + , _VSTD::forward_as_tuple(__pr.second)); + } + + template <class _T1, class _T2, class _U1, class _U2> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> && __pr){ + construct(__p, piecewise_construct + , _VSTD::forward_as_tuple(_VSTD::forward<_U1>(__pr.first)) + , _VSTD::forward_as_tuple(_VSTD::forward<_U2>(__pr.second))); + } + + template <class _Tp> + _LIBCPP_INLINE_VISIBILITY + void destroy(_Tp * __p) _NOEXCEPT + { __p->~_Tp(); } + + _LIBCPP_INLINE_VISIBILITY + size_t max_size() const _NOEXCEPT + { return numeric_limits<size_t>::max() / sizeof(value_type); } + + _LIBCPP_INLINE_VISIBILITY + polymorphic_allocator + select_on_container_copy_construction() const _NOEXCEPT + { return polymorphic_allocator(); } + + _LIBCPP_INLINE_VISIBILITY + memory_resource * resource() const _NOEXCEPT + { return __res_; } + +private: + template <class ..._Args, size_t ..._Idx> + _LIBCPP_INLINE_VISIBILITY + tuple<_Args&&...> + __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, + __tuple_indices<_Idx...>) const + { + return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...); + } + + template <class ..._Args, size_t ..._Idx> + _LIBCPP_INLINE_VISIBILITY + tuple<allocator_arg_t const&, memory_resource*, _Args&&...> + __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t, + __tuple_indices<_Idx...>) const + { + using _Tup = tuple<allocator_arg_t const&, memory_resource*, _Args&&...>; + return _Tup(allocator_arg, resource(), + _VSTD::get<_Idx>(_VSTD::move(__t))...); + } + + template <class ..._Args, size_t ..._Idx> + _LIBCPP_INLINE_VISIBILITY + tuple<_Args&&..., memory_resource*> + __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t, + __tuple_indices<_Idx...>) const + { + using _Tup = tuple<_Args&&..., memory_resource*>; + return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource()); + } + + memory_resource * __res_; +}; + +// 8.6.4, memory.polymorphic.allocator.eq + +template <class _Tp, class _Up> +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(polymorphic_allocator<_Tp> const & __lhs, + polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT +{ + return *__lhs.resource() == *__rhs.resource(); +} + +template <class _Tp, class _Up> +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(polymorphic_allocator<_Tp> const & __lhs, + polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT +{ + return !(__lhs == __rhs); +} + +// 8.7, memory.resource.adaptor + +// 8.7.1, memory.resource.adaptor.overview +template <class _CharAlloc> +class _LIBCPP_TYPE_VIS_ONLY __resource_adaptor_imp + : public memory_resource +{ + using _CTraits = allocator_traits<_CharAlloc>; + static_assert(is_same<typename _CTraits::value_type, char>::value + && is_same<typename _CTraits::pointer, char*>::value + && is_same<typename _CTraits::void_pointer, void*>::value, ""); + + static const size_t _MaxAlign = alignof(max_align_t); + + using _Alloc = typename _CTraits::template rebind_alloc< + typename aligned_storage<_MaxAlign, _MaxAlign>::type + >; + + using _ValueType = typename _Alloc::value_type; + + _Alloc __alloc_; + +public: + typedef _CharAlloc allocator_type; + + __resource_adaptor_imp() = default; + __resource_adaptor_imp(__resource_adaptor_imp const &) = default; + __resource_adaptor_imp(__resource_adaptor_imp &&) = default; + + // 8.7.2, memory.resource.adaptor.ctor + + _LIBCPP_INLINE_VISIBILITY + explicit __resource_adaptor_imp(allocator_type const & __a) + : __alloc_(__a) + {} + + _LIBCPP_INLINE_VISIBILITY + explicit __resource_adaptor_imp(allocator_type && __a) + : __alloc_(_VSTD::move(__a)) + {} + + __resource_adaptor_imp & + operator=(__resource_adaptor_imp const &) = default; + + _LIBCPP_INLINE_VISIBILITY + allocator_type get_allocator() const + { return __alloc_; } + +// 8.7.3, memory.resource.adaptor.mem +protected: + virtual void * do_allocate(size_t __bytes, size_t) + { + if (__bytes > __max_size()) { + __libcpp_throw(length_error( + "std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)" + " 'bytes' exceeds maximum supported size")); + } + size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign; + return __alloc_.allocate(__s); + } + + virtual void do_deallocate(void * __p, size_t __bytes, size_t) + { + _LIBCPP_ASSERT(__bytes <= __max_size(), + "do_deallocate called for size which exceeds the maximum allocation size"); + size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign; + __alloc_.deallocate((_ValueType*)__p, __s); + } + + virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT { + __resource_adaptor_imp const * __p + = dynamic_cast<__resource_adaptor_imp const *>(&__other); + return __p ? __alloc_ == __p->__alloc_ : false; + } + +private: + _LIBCPP_INLINE_VISIBILITY + size_t __max_size() const _NOEXCEPT { + return numeric_limits<size_t>::max() - _MaxAlign; + } +}; + +template <class _Alloc> +using resource_adaptor = __resource_adaptor_imp< + typename allocator_traits<_Alloc>::template rebind_alloc<char> + >; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */ diff --git a/include/experimental/optional b/include/experimental/optional index a384882a1e12..3912438ec104 100644 --- a/include/experimental/optional +++ b/include/experimental/optional @@ -517,7 +517,11 @@ public: constexpr value_type const& value() const { if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); +#else + assert(!"bad optional access"); +#endif return this->__val_; } @@ -525,7 +529,11 @@ public: value_type& value() { if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); +#else + assert(!"bad optional access"); +#endif return this->__val_; } diff --git a/include/experimental/propagate_const b/include/experimental/propagate_const new file mode 100644 index 000000000000..f267ba275c2f --- /dev/null +++ b/include/experimental/propagate_const @@ -0,0 +1,576 @@ +// -*- C++ -*- +//===------------------------ propagate_const -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST +#define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST +/* + propagate_const synopsis + + namespace std { namespace experimental { inline namespace fundamentals_v2 { + + // [propagate_const] + template <class T> class propagate_const; + + // [propagate_const.underlying], underlying pointer access + constexpr const _Tp& _VSTD_LFTS_V2::get_underlying(const propagate_const<T>& pt) noexcept; + constexpr T& _VSTD_LFTS_V2::get_underlying(propagate_const<T>& pt) noexcept; + + // [propagate_const.relational], relational operators + template <class T> constexpr bool operator==(const propagate_const<T>& pt, nullptr_t); + template <class T> constexpr bool operator==(nullptr_t, const propagate_const<T>& pu); + template <class T> constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t); + template <class T> constexpr bool operator!=(nullptr_t, const propagate_const<T>& pu); + template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator==(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator!=(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator<(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator>(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator<=(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator>=(const _Tp& t, const propagate_const<_Up>& pu); + + // [propagate_const.algorithms], specialized algorithms + template <class T> constexpr void swap(propagate_const<T>& pt, propagate_const<T>& pu) noexcept(see below); + + template <class T> + class propagate_const + { + + public: + typedef remove_reference_t<decltype(*declval<T&>())> element_type; + + // [propagate_const.ctor], constructors + constexpr propagate_const() = default; + propagate_const(const propagate_const& p) = delete; + constexpr propagate_const(propagate_const&& p) = default; + template <class U> EXPLICIT constexpr propagate_const(propagate_const<_Up>&& pu); // see below + template <class U> EXPLICIT constexpr propagate_const(U&& u); // see below + + // [propagate_const.assignment], assignment + propagate_const& operator=(const propagate_const& p) = delete; + constexpr propagate_const& operator=(propagate_const&& p) = default; + template <class U> constexpr propagate_const& operator=(propagate_const<_Up>&& pu); + template <class U> constexpr propagate_const& operator=(U&& u); // see below + + // [propagate_const.const_observers], const observers + explicit constexpr operator bool() const; + constexpr const element_type* operator->() const; + constexpr operator const element_type*() const; // Not always defined + constexpr const element_type& operator*() const; + constexpr const element_type* get() const; + + // [propagate_const.non_const_observers], non-const observers + constexpr element_type* operator->(); + constexpr operator element_type*(); // Not always defined + constexpr element_type& operator*(); + constexpr element_type* get(); + + // [propagate_const.modifiers], modifiers + constexpr void swap(propagate_const& pt) noexcept(see below) + + private: + T t_; // exposition only + }; + + } // namespace fundamentals_v2 + } // namespace experimental + + // [propagate_const.hash], hash support + template <class T> struct hash<experimental::fundamentals_v2::propagate_const<T>>; + + // [propagate_const.comparison_function_objects], comparison function objects + template <class T> struct equal_to<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct not_equal_to<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct less<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct greater<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct less_equal<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct greater_equal<experimental::fundamentals_v2::propagate_const<T>>; + +} // namespace std + +*/ + +#include <experimental/__config> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER > 11 + +#include <type_traits> +#include <utility> +#include <functional> + +_LIBCPP_BEGIN_NAMESPACE_LFTS_V2 + + +template <class _Tp> +class propagate_const; +template <class _Up> _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; +template <class _Up> _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; + +template <class _Tp> +class propagate_const +{ +public: + typedef remove_reference_t<decltype(*_VSTD::declval<_Tp&>())> element_type; + + static_assert(!is_array<_Tp>::value, + "Instantiation of propagate_const with an array type is ill-formed."); + static_assert(!is_reference<_Tp>::value, + "Instantiation of propagate_const with a reference type is ill-formed."); + static_assert(!(is_pointer<_Tp>::value && is_function<typename remove_pointer<_Tp>::type>::value), + "Instantiation of propagate_const with a function-pointer type is ill-formed."); + static_assert(!(is_pointer<_Tp>::value && is_same<typename remove_cv<typename remove_pointer<_Tp>::type>::type, void>::value), + "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed."); + +private: + template <class _Up> + static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u) + { + return __u; + } + + template <class _Up> + static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u) + { + return __get_pointer(__u.get()); + } + + template <class _Up> + static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u) + { + return __u; + } + + template <class _Up> + static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u) + { + return __get_pointer(__u.get()); + } + + template <class _Up> + struct __is_propagate_const : false_type + { + }; + + template <class _Up> + struct __is_propagate_const<propagate_const<_Up>> : true_type + { + }; + + _Tp __t_; + +public: + + template <class _Up> friend _LIBCPP_CONSTEXPR const _Up& ::_VSTD_LFTS_V2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; + template <class _Up> friend _LIBCPP_CONSTEXPR _Up& ::_VSTD_LFTS_V2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; + + _LIBCPP_CONSTEXPR propagate_const() = default; + + propagate_const(const propagate_const&) = delete; + + _LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default; + + template <class _Up, enable_if_t<!is_convertible<_Up, _Tp>::value && + is_constructible<_Tp, _Up&&>::value,bool> = true> + explicit _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) + : __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu))) + { + } + + template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value && + is_constructible<_Tp, _Up&&>::value,bool> = false> + _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) + : __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu))) + { + } + + template <class _Up, enable_if_t<!is_convertible<_Up&&, _Tp>::value && + is_constructible<_Tp, _Up&&>::value && + !__is_propagate_const<decay_t<_Up>>::value,bool> = true> + explicit _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) + : __t_(std::forward<_Up>(__u)) + { + } + + template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value && + is_constructible<_Tp, _Up&&>::value && + !__is_propagate_const<decay_t<_Up>>::value,bool> = false> + _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) + : __t_(std::forward<_Up>(__u)) + { + } + + propagate_const& operator=(const propagate_const&) = delete; + + _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default; + + template <class _Up> + _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu) + { + __t_ = std::move(_VSTD_LFTS_V2::get_underlying(__pu)); + return *this; + } + + template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>> + _LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u) + { + __t_ = std::forward<_Up>(__u); + return *this; + } + + _LIBCPP_CONSTEXPR const element_type* get() const + { + return __get_pointer(__t_); + } + + _LIBCPP_CONSTEXPR element_type* get() + { + return __get_pointer(__t_); + } + + explicit _LIBCPP_CONSTEXPR operator bool() const + { + return get() != nullptr; + } + + _LIBCPP_CONSTEXPR const element_type* operator->() const + { + return get(); + } + + template <class _Tp_ = _Tp, class _Up = enable_if_t<is_convertible< + const _Tp_, const element_type *>::value>> + _LIBCPP_CONSTEXPR operator const element_type *() const { + return get(); + } + + _LIBCPP_CONSTEXPR const element_type& operator*() const + { + return *get(); + } + + _LIBCPP_CONSTEXPR element_type* operator->() + { + return get(); + } + + template <class _Tp_ = _Tp, class _Up = enable_if_t< + is_convertible<_Tp_, element_type *>::value>> + _LIBCPP_CONSTEXPR operator element_type *() { + return get(); + } + + _LIBCPP_CONSTEXPR element_type& operator*() + { + return *get(); + } + + _LIBCPP_CONSTEXPR void swap(propagate_const& __pt) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) + { + using _VSTD::swap; + swap(__t_, __pt.__t_); + } +}; + + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) == nullptr; +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) +{ + return nullptr == _VSTD_LFTS_V2::get_underlying(__pt); +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) != nullptr; +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) +{ + return nullptr != _VSTD_LFTS_V2::get_underlying(__pt); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) == _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) != _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) < _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) > _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) <= _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) >= _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) == __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) != __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) < __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) > __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) <= __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) >= __u; +} + + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t == _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t != _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t < _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t > _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t <= _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t >= _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) +{ + using _VSTD::swap; + swap(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT +{ + return __pt.__t_; +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT +{ + return __pt.__t_; +} + +_LIBCPP_END_NAMESPACE_LFTS_V2 + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct hash<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef size_t result_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> argument_type; + + size_t operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1) const + { + return std::hash<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1)); + } +}; + +template <class _Tp> +struct equal_to<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct not_equal_to<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::not_equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct less<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::less<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct greater<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::greater<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct less_equal<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::less_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct greater_equal<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::greater_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 +#endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST + diff --git a/include/experimental/regex b/include/experimental/regex new file mode 100644 index 000000000000..d38891c374bb --- /dev/null +++ b/include/experimental/regex @@ -0,0 +1,62 @@ +// -*- C++ -*- +//===----------------------------- regex ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_REGEX +#define _LIBCPP_EXPERIMENTAL_REGEX +/* + experimental/regex synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class BidirectionalIterator> + using match_results = + std::match_results<BidirectionalIterator, + polymorphic_allocator<sub_match<BidirectionalIterator>>>; + + typedef match_results<const char*> cmatch; + typedef match_results<const wchar_t*> wcmatch; + typedef match_results<string::const_iterator> smatch; + typedef match_results<wstring::const_iterator> wsmatch; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <regex> +#include <experimental/string> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _BiDirIter> +using match_results = + _VSTD::match_results<_BiDirIter, + polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>; + +typedef match_results<const char*> cmatch; +typedef match_results<const wchar_t*> wcmatch; +typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch; +typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_REGEX */ diff --git a/include/experimental/set b/include/experimental/set new file mode 100644 index 000000000000..20cf6d4a3890 --- /dev/null +++ b/include/experimental/set @@ -0,0 +1,57 @@ +// -*- C++ -*- +//===--------------------------- list ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_SET +#define _LIBCPP_EXPERIMENTAL_SET +/* + experimental/set synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class Key, class T, class Compare = less<Key>> + using set = std::set<Key, T, Compare, + polymorphic_allocator<pair<const Key,T>>>; + + template <class Key, class T, class Compare = less<Key>> + using multiset = std::multiset<Key, T, Compare, + polymorphic_allocator<pair<const Key,T>>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <set> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _Value, class _Compare = less<_Value>> +using set = _VSTD::set<_Value, _Compare, + polymorphic_allocator<_Value>>; + +template <class _Value, class _Compare = less<_Value>> +using multiset = _VSTD::multiset<_Value, _Compare, + polymorphic_allocator<_Value>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_SET */ diff --git a/include/experimental/string b/include/experimental/string new file mode 100644 index 000000000000..8b8545128f2a --- /dev/null +++ b/include/experimental/string @@ -0,0 +1,62 @@ +// -*- C++ -*- +//===--------------------------- string ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_STRING +#define _LIBCPP_EXPERIMENTAL_STRING +/* + experimental/string synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + // basic_string using polymorphic allocator in namespace pmr + template <class charT, class traits = char_traits<charT>> + using basic_string = + std::basic_string<charT, traits, polymorphic_allocator<charT>>; + + // basic_string typedef names using polymorphic allocator in namespace + // std::experimental::pmr + typedef basic_string<char> string; + typedef basic_string<char16_t> u16string; + typedef basic_string<char32_t> u32string; + typedef basic_string<wchar_t> wstring; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <string> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _CharT, class _Traits = char_traits<_CharT>> +using basic_string = + _VSTD::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>; + +typedef basic_string<char> string; +typedef basic_string<char16_t> u16string; +typedef basic_string<char32_t> u32string; +typedef basic_string<wchar_t> wstring; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_STRING */ diff --git a/include/experimental/string_view b/include/experimental/string_view index 2a20d7caa687..0a7239b4c0bb 100644 --- a/include/experimental/string_view +++ b/include/experimental/string_view @@ -180,6 +180,7 @@ namespace std { #include <algorithm> #include <iterator> #include <ostream> +#include <stdexcept> #include <iomanip> #include <__debug> @@ -227,7 +228,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS basic_string_view(const _CharT* __s, size_type __len) : __data(__s), __size(__len) { -// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): recieved nullptr"); +// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr"); } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY @@ -280,7 +281,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS const_reference at(size_type __pos) const { return __pos >= size() - ? (throw out_of_range("string_view::at"), __data[0]) + ? (__libcpp_throw(out_of_range("string_view::at")), __data[0]) : __data[__pos]; } @@ -351,7 +352,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const { if ( __pos > size()) - throw out_of_range("string_view::copy"); + __libcpp_throw(out_of_range("string_view::copy")); size_type __rlen = _VSTD::min( __n, size() - __pos ); _VSTD::copy_n(begin() + __pos, __rlen, __s ); return __rlen; @@ -365,7 +366,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS // size_type __rlen = _VSTD::min( __n, size() - __pos ); // return basic_string_view(data() + __pos, __rlen); return __pos > size() - ? throw out_of_range("string_view::substr") + ? (__libcpp_throw((out_of_range("string_view::substr"))), basic_string_view()) : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); } @@ -413,7 +414,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { - _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr"); + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); return _VSTD::__str_find<value_type, size_type, traits_type, npos> (data(), size(), __s.data(), __pos, __s.size()); } @@ -428,7 +429,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT* __s, size_type __pos, size_type __n) const { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr"); return _VSTD::__str_find<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -436,7 +437,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT* __s, size_type __pos = 0) const { - _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr"); return _VSTD::__str_find<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -445,7 +446,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr"); + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __s.data(), __pos, __s.size()); } @@ -460,7 +461,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr"); return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -468,7 +469,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT* __s, size_type __pos=npos) const { - _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr"); return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -477,7 +478,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { - _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): recieved nullptr"); + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr"); return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __s.data(), __pos, __s.size()); } @@ -489,7 +490,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr"); return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -497,7 +498,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT* __s, size_type __pos=0) const { - _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr"); return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -506,7 +507,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): recieved nullptr"); + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr"); return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __s.data(), __pos, __s.size()); } @@ -518,7 +519,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr"); return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -526,7 +527,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT* __s, size_type __pos=npos) const { - _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr"); return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -535,7 +536,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT { - _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): recieved nullptr"); + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr"); return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s.data(), __pos, __s.size()); } @@ -550,7 +551,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr"); return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -558,7 +559,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const { - _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr"); return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -567,7 +568,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): recieved nullptr"); + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr"); return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s.data(), __pos, __s.size()); } @@ -582,7 +583,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr"); return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -590,7 +591,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const { - _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr"); return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } diff --git a/include/experimental/tuple b/include/experimental/tuple index 50d1e0555bc4..e00d2ec1a92f 100644 --- a/include/experimental/tuple +++ b/include/experimental/tuple @@ -57,9 +57,10 @@ _LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value; template <class _Fn, class _Tuple, size_t ..._Id> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t, integer_sequence<size_t, _Id...>) { - return _VSTD::__invoke( + return _VSTD::__invoke_constexpr( _VSTD::forward<_Fn>(__f), _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))... ); diff --git a/include/experimental/unordered_map b/include/experimental/unordered_map new file mode 100644 index 000000000000..1f998c2d4c7e --- /dev/null +++ b/include/experimental/unordered_map @@ -0,0 +1,65 @@ +// -*- C++ -*- +//===------------------------- unordered_map ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_MAP +#define _LIBCPP_EXPERIMENTAL_UNORDERED_MAP +/* + experimental/unordered_map synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class Key, class T, + class Hash = hash<Key>, + class Pred = equal_to<Key>> + using unordered_map = + std::unordered_map<Key, T, Hash, Pred, + polymorphic_allocator<pair<const Key,T>>>; + + template <class Key, class T, + class Hash = hash<Key>, + class Pred = equal_to<Key>> + using unordered_multimap = + std::unordered_multimap<Key, T, Hash, Pred, + polymorphic_allocator<pair<const Key,T>>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <unordered_map> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _Key, class _Value, + class _Hash = hash<_Key>, class _Pred = equal_to<_Key>> +using unordered_map = _VSTD::unordered_map<_Key, _Value, _Hash, _Pred, + polymorphic_allocator<pair<const _Key, _Value>>>; + +template <class _Key, class _Value, + class _Hash = hash<_Key>, class _Pred = equal_to<_Key>> +using unordered_multimap = _VSTD::unordered_multimap<_Key, _Value, _Hash, _Pred, + polymorphic_allocator<pair<const _Key, _Value>>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_MAP */ diff --git a/include/experimental/unordered_set b/include/experimental/unordered_set new file mode 100644 index 000000000000..d00a83753401 --- /dev/null +++ b/include/experimental/unordered_set @@ -0,0 +1,59 @@ +// -*- C++ -*- +//===------------------------- unordered_set ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_SET +#define _LIBCPP_EXPERIMENTAL_UNORDERED_SET +/* + experimental/unordered_set synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T, class Hash = hash<T>, class Pred = equal_to<T>> + using unordered_set = std::unordered_set<T, Hash, Pred, + polymorphic_allocator<T>>; + + template <class T, class Hash = hash<T>, class Pred = equal_to<T>> + using unordered_multiset = std::unordered_multiset<T, Hash, Pred, + polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <unordered_set> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _Value, + class _Hash = hash<_Value>, class _Pred = equal_to<_Value>> +using unordered_set = _VSTD::unordered_set<_Value, _Hash, _Pred, + polymorphic_allocator<_Value>>; + +template <class _Value, + class _Hash = hash<_Value>, class _Pred = equal_to<_Value>> +using unordered_multiset = _VSTD::unordered_multiset<_Value, _Hash, _Pred, + polymorphic_allocator<_Value>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_SET */ diff --git a/include/experimental/vector b/include/experimental/vector new file mode 100644 index 000000000000..bd10492bfefc --- /dev/null +++ b/include/experimental/vector @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===--------------------------- vector ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_VECTOR +#define _LIBCPP_EXPERIMENTAL_VECTOR +/* + experimental/vector synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T> + using vector = std::vector<T, polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <vector> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _ValueT> +using vector = _VSTD::vector<_ValueT, polymorphic_allocator<_ValueT>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_VECTOR */ |