aboutsummaryrefslogtreecommitdiff
path: root/contrib/libc++/include/experimental
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libc++/include/experimental')
-rw-r--r--contrib/libc++/include/experimental/__config32
-rw-r--r--contrib/libc++/include/experimental/algorithm114
-rw-r--r--contrib/libc++/include/experimental/chrono59
-rw-r--r--contrib/libc++/include/experimental/dynarray316
-rw-r--r--contrib/libc++/include/experimental/optional894
-rw-r--r--contrib/libc++/include/experimental/ratio77
-rw-r--r--contrib/libc++/include/experimental/string_view812
-rw-r--r--contrib/libc++/include/experimental/system_error63
-rw-r--r--contrib/libc++/include/experimental/tuple81
-rw-r--r--contrib/libc++/include/experimental/type_traits427
-rw-r--r--contrib/libc++/include/experimental/utility47
11 files changed, 2922 insertions, 0 deletions
diff --git a/contrib/libc++/include/experimental/__config b/contrib/libc++/include/experimental/__config
new file mode 100644
index 000000000000..f64a3a90cd12
--- /dev/null
+++ b/contrib/libc++/include/experimental/__config
@@ -0,0 +1,32 @@
+// -*- C++ -*-
+//===--------------------------- __config ---------------------------------===//
+//
+// 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_CONFIG
+#define _LIBCPP_EXPERIMENTAL_CONFIG
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } }
+#define _VSTD_EXPERIMENTAL std::experimental
+
+#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
+#define _LIBCPP_END_NAMESPACE_LFTS } } }
+#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
+
+#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 } } }
+
+#endif
diff --git a/contrib/libc++/include/experimental/algorithm b/contrib/libc++/include/experimental/algorithm
new file mode 100644
index 000000000000..a2e956f281a0
--- /dev/null
+++ b/contrib/libc++/include/experimental/algorithm
@@ -0,0 +1,114 @@
+// -*- C++ -*-
+//===-------------------------- algorithm ---------------------------------===//
+//
+// 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_ALGORITHM
+#define _LIBCPP_EXPERIMENTAL_ALGORITHM
+
+/*
+ experimental/algorithm synopsis
+
+#include <algorithm>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+template <class ForwardIterator, class Searcher>
+ForwardIterator search(ForwardIterator first, ForwardIterator last,
+ const Searcher &searcher);
+template <class PopulationIterator, class SampleIterator, class Distance,
+ class UniformRandomNumberGenerator>
+SampleIterator sample(PopulationIterator first, PopulationIterator last,
+ SampleIterator out, Distance n,
+ UniformRandomNumberGenerator &&g);
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+#include <algorithm>
+#include <type_traits>
+
+#include <__undef_min_max>
+
+#include <__debug>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+ class _UniformRandomNumberGenerator>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator __sample(_PopulationIterator __first,
+ _PopulationIterator __last, _SampleIterator __out,
+ _Distance __n,
+ _UniformRandomNumberGenerator &&__g,
+ input_iterator_tag) {
+
+ _Distance __k = 0;
+ for (; __first != __last && __k < __n; ++__first, (void)++__k)
+ __out[__k] = *__first;
+ _Distance __sz = __k;
+ for (; __first != __last; ++__first, (void)++__k) {
+ _Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
+ if (__r < __sz)
+ __out[__r] = *__first;
+ }
+ return __out + _VSTD::min(__n, __k);
+}
+
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+ class _UniformRandomNumberGenerator>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator __sample(_PopulationIterator __first,
+ _PopulationIterator __last, _SampleIterator __out,
+ _Distance __n,
+ _UniformRandomNumberGenerator &&__g,
+ forward_iterator_tag) {
+ _Distance __unsampled_sz = _VSTD::distance(__first, __last);
+ for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
+ _Distance __r =
+ _VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
+ if (__r < __n) {
+ *__out++ = *__first;
+ --__n;
+ }
+ }
+ return __out;
+}
+
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+ class _UniformRandomNumberGenerator>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator sample(_PopulationIterator __first,
+ _PopulationIterator __last, _SampleIterator __out,
+ _Distance __n, _UniformRandomNumberGenerator &&__g) {
+ typedef typename iterator_traits<_PopulationIterator>::iterator_category
+ _PopCategory;
+ typedef typename iterator_traits<_PopulationIterator>::difference_type
+ _Difference;
+ typedef typename common_type<_Distance, _Difference>::type _CommonType;
+ _LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
+ return _VSTD_LFTS::__sample(
+ __first, __last, __out, _CommonType(__n),
+ _VSTD::forward<_UniformRandomNumberGenerator>(__g),
+ _PopCategory());
+}
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */
diff --git a/contrib/libc++/include/experimental/chrono b/contrib/libc++/include/experimental/chrono
new file mode 100644
index 000000000000..ca9e5f852ea2
--- /dev/null
+++ b/contrib/libc++/include/experimental/chrono
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+//===------------------------------ chrono ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
+#define _LIBCPP_EXPERIMENTAL_CHRONO
+
+/**
+ experimental/chrono synopsis
+
+// C++1y
+
+#include <chrono>
+
+namespace std {
+namespace chrono {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+ // See C++14 20.12.4, customization traits
+ template <class Rep> constexpr bool treat_as_floating_point_v
+ = treat_as_floating_point<Rep>::value;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace chrono
+} // namespace std
+
+ */
+
+#include <experimental/__config>
+#include <chrono>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 11
+
+_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+
+template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
+ = treat_as_floating_point<_Rep>::value;
+
+#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
+
+_LIBCPP_END_NAMESPACE_CHRONO_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_CHRONO */
diff --git a/contrib/libc++/include/experimental/dynarray b/contrib/libc++/include/experimental/dynarray
new file mode 100644
index 000000000000..a0258628dfa6
--- /dev/null
+++ b/contrib/libc++/include/experimental/dynarray
@@ -0,0 +1,316 @@
+// -*- C++ -*-
+//===-------------------------- dynarray ----------------------------------===//
+//
+// 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_DYNARRAY
+#define _LIBCPP_DYNARRAY
+
+#include <__config>
+#if _LIBCPP_STD_VER > 11
+
+/*
+ dynarray synopsis
+
+namespace std { namespace experimental {
+
+template< typename T >
+class dynarray
+{
+ // types:
+ typedef T value_type;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef implementation-defined iterator;
+ typedef implementation-defined const_iterator;
+ typedef reverse_iterator<iterator> reverse_iterator;
+ typedef reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+public:
+ // construct/copy/destroy:
+ explicit dynarray(size_type c);
+ dynarray(size_type c, const T& v);
+ dynarray(const dynarray& d);
+ dynarray(initializer_list<T>);
+
+ template <class Alloc>
+ dynarray(allocator_arg_t, const Alloc& a, size_type c, const Alloc& alloc);
+ template <class Alloc>
+ dynarray(allocator_arg_t, const Alloc& a, size_type c, const T& v, const Alloc& alloc);
+ template <class Alloc>
+ dynarray(allocator_arg_t, const Alloc& a, const dynarray& d, const Alloc& alloc);
+ template <class Alloc>
+ dynarray(allocator_arg_t, const Alloc& a, initializer_list<T>, const Alloc& alloc);
+ dynarray& operator=(const dynarray&) = delete;
+ ~dynarray();
+
+ // iterators:
+ iterator begin() noexcept;
+ const_iterator begin() const noexcept;
+ const_iterator cbegin() const noexcept;
+ iterator end() noexcept;
+ const_iterator end() const noexcept;
+ const_iterator cend() const noexcept;
+
+ reverse_iterator rbegin() noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ reverse_iterator rend() noexcept;
+ const_reverse_iterator rend() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ // capacity:
+ size_type size() const noexcept;
+ size_type max_size() const noexcept;
+ bool empty() const noexcept;
+
+ // element access:
+ reference operator[](size_type n);
+ const_reference operator[](size_type n) const;
+
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ const_reference at(size_type n) const;
+ reference at(size_type n);
+
+ // data access:
+ T* data() noexcept;
+ const T* data() const noexcept;
+
+ // mutating member functions:
+ void fill(const T& v);
+};
+
+}} // std::experimental
+
+*/
+
+#include <__functional_base>
+#include <iterator>
+#include <stdexcept>
+#include <initializer_list>
+#include <new>
+#include <algorithm>
+
+#include <__undef___deallocate>
+
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+ #include <cassert>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+namespace std { namespace experimental { inline namespace __array_extensions_v1 {
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY dynarray
+{
+public:
+ // types:
+ typedef dynarray __self;
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef value_type* iterator;
+ typedef const value_type* const_iterator;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+private:
+ size_t __size_;
+ value_type * __base_;
+ _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __base_(nullptr), __size_(0) {}
+
+ static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
+ {
+ if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count )
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_array_length();
+#else
+ assert(!"dynarray::allocation");
+#endif
+ }
+ return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
+ }
+
+ static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept
+ {
+ _VSTD::__deallocate (static_cast<void *> (__ptr));
+ }
+
+public:
+
+ explicit dynarray(size_type __c);
+ dynarray(size_type __c, const value_type& __v);
+ dynarray(const dynarray& __d);
+ dynarray(initializer_list<value_type>);
+
+// We're not implementing these right now.
+// Updated with the resolution of LWG issue #2255
+// template <typename _Alloc>
+// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c);
+// template <typename _Alloc>
+// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c, const value_type& __v);
+// template <typename _Alloc>
+// dynarray(allocator_arg_t, const _Alloc& __alloc, const dynarray& __d);
+// template <typename _Alloc>
+// dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list<value_type>);
+
+ dynarray& operator=(const dynarray&) = delete;
+ ~dynarray();
+
+ // iterators:
+ inline _LIBCPP_INLINE_VISIBILITY iterator begin() noexcept { return iterator(data()); }
+ inline _LIBCPP_INLINE_VISIBILITY const_iterator begin() const noexcept { return const_iterator(data()); }
+ inline _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const noexcept { return const_iterator(data()); }
+ inline _LIBCPP_INLINE_VISIBILITY iterator end() noexcept { return iterator(data() + __size_); }
+ inline _LIBCPP_INLINE_VISIBILITY const_iterator end() const noexcept { return const_iterator(data() + __size_); }
+ inline _LIBCPP_INLINE_VISIBILITY const_iterator cend() const noexcept { return const_iterator(data() + __size_); }
+
+ inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }
+ inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
+ inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
+ inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() noexcept { return reverse_iterator(begin()); }
+ inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
+ inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
+
+ // capacity:
+ inline _LIBCPP_INLINE_VISIBILITY size_type size() const noexcept { return __size_; }
+ inline _LIBCPP_INLINE_VISIBILITY size_type max_size() const noexcept { return __size_; }
+ inline _LIBCPP_INLINE_VISIBILITY bool empty() const noexcept { return __size_ == 0; }
+
+ // element access:
+ inline _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) { return data()[__n]; }
+ inline _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const { return data()[__n]; }
+
+ inline _LIBCPP_INLINE_VISIBILITY reference front() { return data()[0]; }
+ inline _LIBCPP_INLINE_VISIBILITY const_reference front() const { return data()[0]; }
+ inline _LIBCPP_INLINE_VISIBILITY reference back() { return data()[__size_-1]; }
+ inline _LIBCPP_INLINE_VISIBILITY const_reference back() const { return data()[__size_-1]; }
+
+ inline _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __n) const;
+ inline _LIBCPP_INLINE_VISIBILITY reference at(size_type __n);
+
+ // data access:
+ inline _LIBCPP_INLINE_VISIBILITY _Tp* data() noexcept { return __base_; }
+ inline _LIBCPP_INLINE_VISIBILITY const _Tp* data() const noexcept { return __base_; }
+
+ // mutating member functions:
+ inline _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __v) { fill_n(begin(), __size_, __v); }
+};
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::dynarray(size_type __c) : dynarray ()
+{
+ __base_ = __allocate (__c);
+ value_type *__data = data ();
+ for ( __size_ = 0; __size_ < __c; ++__size_, ++__data )
+ ::new (__data) value_type;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray ()
+{
+ __base_ = __allocate (__c);
+ value_type *__data = data ();
+ for ( __size_ = 0; __size_ < __c; ++__size_, ++__data )
+ ::new (__data) value_type (__v);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray ()
+{
+ size_t sz = __il.size();
+ __base_ = __allocate (sz);
+ value_type *__data = data ();
+ auto src = __il.begin();
+ for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src )
+ ::new (__data) value_type (*src);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray ()
+{
+ size_t sz = __d.size();
+ __base_ = __allocate (sz);
+ value_type *__data = data ();
+ auto src = __d.begin();
+ for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src )
+ ::new (__data) value_type (*src);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::~dynarray()
+{
+ value_type *__data = data () + __size_;
+ for ( size_t i = 0; i < __size_; ++i )
+ (--__data)->value_type::~value_type();
+ __deallocate ( __base_ );
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename dynarray<_Tp>::reference
+dynarray<_Tp>::at(size_type __n)
+{
+ if (__n >= __size_)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw out_of_range("dynarray::at");
+#else
+ assert(!"dynarray::at out_of_range");
+#endif
+ }
+ return data()[__n];
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename dynarray<_Tp>::const_reference
+dynarray<_Tp>::at(size_type __n) const
+{
+ if (__n >= __size_)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw out_of_range("dynarray::at");
+#else
+ assert(!"dynarray::at out_of_range");
+#endif
+ }
+ return data()[__n];
+}
+
+}}}
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Tp, class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {};
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // if _LIBCPP_STD_VER > 11
+#endif // _LIBCPP_DYNARRAY
diff --git a/contrib/libc++/include/experimental/optional b/contrib/libc++/include/experimental/optional
new file mode 100644
index 000000000000..a384882a1e12
--- /dev/null
+++ b/contrib/libc++/include/experimental/optional
@@ -0,0 +1,894 @@
+// -*- C++ -*-
+//===-------------------------- optional ----------------------------------===//
+//
+// 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_OPTIONAL
+#define _LIBCPP_OPTIONAL
+
+/*
+ optional synopsis
+
+// C++1y
+
+namespace std { namespace experimental { inline namespace fundamentals_v1 {
+
+ // 5.3, optional for object types
+ template <class T> class optional;
+
+ // 5.4, In-place construction
+ struct in_place_t{};
+ constexpr in_place_t in_place{};
+
+ // 5.5, No-value state indicator
+ struct nullopt_t{see below};
+ constexpr nullopt_t nullopt(unspecified);
+
+ // 5.6, Class bad_optional_access
+ class bad_optional_access;
+
+ // 5.7, Relational operators
+ template <class T>
+ constexpr bool operator==(const optional<T>&, const optional<T>&);
+ template <class T>
+ constexpr bool operator!=(const optional<T>&, const optional<T>&);
+ template <class T>
+ constexpr bool operator<(const optional<T>&, const optional<T>&);
+ template <class T>
+ constexpr bool operator>(const optional<T>&, const optional<T>&);
+ template <class T>
+ constexpr bool operator<=(const optional<T>&, const optional<T>&);
+ template <class T>
+ constexpr bool operator>=(const optional<T>&, const optional<T>&);
+
+ // 5.8, Comparison with nullopt
+ template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept;
+ template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept;
+ template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept;
+
+ // 5.9, Comparison with T
+ template <class T> constexpr bool operator==(const optional<T>&, const T&);
+ template <class T> constexpr bool operator==(const T&, const optional<T>&);
+ template <class T> constexpr bool operator!=(const optional<T>&, const T&);
+ template <class T> constexpr bool operator!=(const T&, const optional<T>&);
+ template <class T> constexpr bool operator<(const optional<T>&, const T&);
+ template <class T> constexpr bool operator<(const T&, const optional<T>&);
+ template <class T> constexpr bool operator<=(const optional<T>&, const T&);
+ template <class T> constexpr bool operator<=(const T&, const optional<T>&);
+ template <class T> constexpr bool operator>(const optional<T>&, const T&);
+ template <class T> constexpr bool operator>(const T&, const optional<T>&);
+ template <class T> constexpr bool operator>=(const optional<T>&, const T&);
+ template <class T> constexpr bool operator>=(const T&, const optional<T>&);
+
+ // 5.10, Specialized algorithms
+ template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below);
+ template <class T> constexpr optional<see below> make_optional(T&&);
+
+ template <class T>
+ class optional
+ {
+ public:
+ typedef T value_type;
+
+ // 5.3.1, Constructors
+ constexpr optional() noexcept;
+ constexpr optional(nullopt_t) noexcept;
+ optional(const optional&);
+ optional(optional&&) noexcept(see below);
+ constexpr optional(const T&);
+ constexpr optional(T&&);
+ template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
+ template <class U, class... Args>
+ constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
+
+ // 5.3.2, Destructor
+ ~optional();
+
+ // 5.3.3, Assignment
+ optional& operator=(nullopt_t) noexcept;
+ optional& operator=(const optional&);
+ optional& operator=(optional&&) noexcept(see below);
+ template <class U> optional& operator=(U&&);
+ template <class... Args> void emplace(Args&&...);
+ template <class U, class... Args>
+ void emplace(initializer_list<U>, Args&&...);
+
+ // 5.3.4, Swap
+ void swap(optional&) noexcept(see below);
+
+ // 5.3.5, Observers
+ constexpr T const* operator ->() const;
+ constexpr T* operator ->();
+ constexpr T const& operator *() const &;
+ constexpr T& operator *() &;
+ constexpr T&& operator *() &&;
+ constexpr const T&& operator *() const &&;
+ constexpr explicit operator bool() const noexcept;
+ constexpr T const& value() const &;
+ constexpr T& value() &;
+ constexpr T&& value() &&;
+ constexpr const T&& value() const &&;
+ template <class U> constexpr T value_or(U&&) const &;
+ template <class U> constexpr T value_or(U&&) &&;
+
+ private:
+ T* val; // exposition only
+ };
+
+ } // namespace fundamentals_v1
+ } // namespace experimental
+
+ // 5.11, Hash support
+ template <class T> struct hash;
+ template <class T> struct hash<experimental::optional<T>>;
+
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+#include <functional>
+#include <stdexcept>
+
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
+class _LIBCPP_EXCEPTION_ABI bad_optional_access
+ : public std::logic_error
+{
+public:
+ bad_optional_access() : std::logic_error("Bad optional Access") {}
+
+// Get the key function ~bad_optional_access() into the dylib
+ virtual ~bad_optional_access() _NOEXCEPT;
+};
+
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL
+
+
+#if _LIBCPP_STD_VER > 11
+
+#include <initializer_list>
+#include <type_traits>
+#include <new>
+#include <__functional_base>
+#include <__undef_min_max>
+#include <__debug>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+struct in_place_t {};
+constexpr in_place_t in_place{};
+
+struct nullopt_t
+{
+ explicit constexpr nullopt_t(int) noexcept {}
+};
+
+constexpr nullopt_t nullopt{0};
+
+template <class _Tp, bool = is_trivially_destructible<_Tp>::value>
+class __optional_storage
+{
+protected:
+ typedef _Tp value_type;
+ union
+ {
+ char __null_state_;
+ value_type __val_;
+ };
+ bool __engaged_ = false;
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__optional_storage()
+ {
+ if (__engaged_)
+ __val_.~value_type();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_storage() noexcept
+ : __null_state_('\0') {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_storage(const __optional_storage& __x)
+ : __engaged_(__x.__engaged_)
+ {
+ if (__engaged_)
+ ::new(_VSTD::addressof(__val_)) value_type(__x.__val_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_storage(__optional_storage&& __x)
+ noexcept(is_nothrow_move_constructible<value_type>::value)
+ : __engaged_(__x.__engaged_)
+ {
+ if (__engaged_)
+ ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_storage(const value_type& __v)
+ : __val_(__v),
+ __engaged_(true) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_storage(value_type&& __v)
+ : __val_(_VSTD::move(__v)),
+ __engaged_(true) {}
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ explicit __optional_storage(in_place_t, _Args&&... __args)
+ : __val_(_VSTD::forward<_Args>(__args)...),
+ __engaged_(true) {}
+};
+
+template <class _Tp>
+class __optional_storage<_Tp, true>
+{
+protected:
+ typedef _Tp value_type;
+ union
+ {
+ char __null_state_;
+ value_type __val_;
+ };
+ bool __engaged_ = false;
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_storage() noexcept
+ : __null_state_('\0') {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_storage(const __optional_storage& __x)
+ : __engaged_(__x.__engaged_)
+ {
+ if (__engaged_)
+ ::new(_VSTD::addressof(__val_)) value_type(__x.__val_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_storage(__optional_storage&& __x)
+ noexcept(is_nothrow_move_constructible<value_type>::value)
+ : __engaged_(__x.__engaged_)
+ {
+ if (__engaged_)
+ ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_storage(const value_type& __v)
+ : __val_(__v),
+ __engaged_(true) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr __optional_storage(value_type&& __v)
+ : __val_(_VSTD::move(__v)),
+ __engaged_(true) {}
+
+ template <class... _Args>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ explicit __optional_storage(in_place_t, _Args&&... __args)
+ : __val_(_VSTD::forward<_Args>(__args)...),
+ __engaged_(true) {}
+};
+
+template <class _Tp>
+class optional
+ : private __optional_storage<_Tp>
+{
+ typedef __optional_storage<_Tp> __base;
+public:
+ typedef _Tp value_type;
+
+ static_assert(!is_reference<value_type>::value,
+ "Instantiation of optional with a reference type is ill-formed.");
+ static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value,
+ "Instantiation of optional with a in_place_t type is ill-formed.");
+ static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value,
+ "Instantiation of optional with a nullopt_t type is ill-formed.");
+ static_assert(is_object<value_type>::value,
+ "Instantiation of optional with a non-object type is undefined behavior.");
+ static_assert(is_nothrow_destructible<value_type>::value,
+ "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior.");
+
+ _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
+ _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
+ _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default;
+ _LIBCPP_INLINE_VISIBILITY ~optional() = default;
+ _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
+ _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v)
+ : __base(__v) {}
+ _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v)
+ : __base(_VSTD::move(__v)) {}
+
+ template <class... _Args,
+ class = typename enable_if
+ <
+ is_constructible<value_type, _Args...>::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ explicit optional(in_place_t, _Args&&... __args)
+ : __base(in_place, _VSTD::forward<_Args>(__args)...) {}
+
+ template <class _Up, class... _Args,
+ class = typename enable_if
+ <
+ is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
+ : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ optional& operator=(nullopt_t) noexcept
+ {
+ if (this->__engaged_)
+ {
+ this->__val_.~value_type();
+ this->__engaged_ = false;
+ }
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ optional&
+ operator=(const optional& __opt)
+ {
+ if (this->__engaged_ == __opt.__engaged_)
+ {
+ if (this->__engaged_)
+ this->__val_ = __opt.__val_;
+ }
+ else
+ {
+ if (this->__engaged_)
+ this->__val_.~value_type();
+ else
+ ::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_);
+ this->__engaged_ = __opt.__engaged_;
+ }
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ optional&
+ operator=(optional&& __opt)
+ noexcept(is_nothrow_move_assignable<value_type>::value &&
+ is_nothrow_move_constructible<value_type>::value)
+ {
+ if (this->__engaged_ == __opt.__engaged_)
+ {
+ if (this->__engaged_)
+ this->__val_ = _VSTD::move(__opt.__val_);
+ }
+ else
+ {
+ if (this->__engaged_)
+ this->__val_.~value_type();
+ else
+ ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_));
+ this->__engaged_ = __opt.__engaged_;
+ }
+ return *this;
+ }
+
+ template <class _Up,
+ class = typename enable_if
+ <
+ is_same<typename remove_reference<_Up>::type, value_type>::value &&
+ is_constructible<value_type, _Up>::value &&
+ is_assignable<value_type&, _Up>::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ optional&
+ operator=(_Up&& __v)
+ {
+ if (this->__engaged_)
+ this->__val_ = _VSTD::forward<_Up>(__v);
+ else
+ {
+ ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v));
+ this->__engaged_ = true;
+ }
+ return *this;
+ }
+
+ template <class... _Args,
+ class = typename enable_if
+ <
+ is_constructible<value_type, _Args...>::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ void
+ emplace(_Args&&... __args)
+ {
+ *this = nullopt;
+ ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
+ this->__engaged_ = true;
+ }
+
+ template <class _Up, class... _Args,
+ class = typename enable_if
+ <
+ is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ void
+ emplace(initializer_list<_Up> __il, _Args&&... __args)
+ {
+ *this = nullopt;
+ ::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...);
+ this->__engaged_ = true;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void
+ swap(optional& __opt)
+ noexcept(is_nothrow_move_constructible<value_type>::value &&
+ __is_nothrow_swappable<value_type>::value)
+ {
+ using _VSTD::swap;
+ if (this->__engaged_ == __opt.__engaged_)
+ {
+ if (this->__engaged_)
+ swap(this->__val_, __opt.__val_);
+ }
+ else
+ {
+ if (this->__engaged_)
+ {
+ ::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_));
+ this->__val_.~value_type();
+ }
+ else
+ {
+ ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_));
+ __opt.__val_.~value_type();
+ }
+ swap(this->__engaged_, __opt.__engaged_);
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ value_type const*
+ operator->() const
+ {
+ _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
+ return __operator_arrow(__has_operator_addressof<value_type>{});
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ value_type*
+ operator->()
+ {
+ _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
+ return _VSTD::addressof(this->__val_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ const value_type&
+ operator*() const
+ {
+ _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
+ return this->__val_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ value_type&
+ operator*()
+ {
+ _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
+ return this->__val_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr explicit operator bool() const noexcept {return this->__engaged_;}
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type const& value() const
+ {
+ if (!this->__engaged_)
+ throw bad_optional_access();
+ return this->__val_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ value_type& value()
+ {
+ if (!this->__engaged_)
+ throw bad_optional_access();
+ return this->__val_;
+ }
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type value_or(_Up&& __v) const&
+ {
+ static_assert(is_copy_constructible<value_type>::value,
+ "optional<T>::value_or: T must be copy constructible");
+ static_assert(is_convertible<_Up, value_type>::value,
+ "optional<T>::value_or: U must be convertible to T");
+ return this->__engaged_ ? this->__val_ :
+ static_cast<value_type>(_VSTD::forward<_Up>(__v));
+ }
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ value_type value_or(_Up&& __v) &&
+ {
+ static_assert(is_move_constructible<value_type>::value,
+ "optional<T>::value_or: T must be move constructible");
+ static_assert(is_convertible<_Up, value_type>::value,
+ "optional<T>::value_or: U must be convertible to T");
+ return this->__engaged_ ? _VSTD::move(this->__val_) :
+ static_cast<value_type>(_VSTD::forward<_Up>(__v));
+ }
+
+private:
+ _LIBCPP_INLINE_VISIBILITY
+ value_type const*
+ __operator_arrow(true_type) const
+ {
+ return _VSTD::addressof(this->__val_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ value_type const*
+ __operator_arrow(false_type) const
+ {
+ return &this->__val_;
+ }
+};
+
+// Comparisons between optionals
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
+{
+ if (static_cast<bool>(__x) != static_cast<bool>(__y))
+ return false;
+ if (!static_cast<bool>(__x))
+ return true;
+ return *__x == *__y;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
+{
+ if (!static_cast<bool>(__y))
+ return false;
+ if (!static_cast<bool>(__x))
+ return true;
+ return *__x < *__y;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>(const optional<_Tp>& __x, const optional<_Tp>& __y)
+{
+ return __y < __x;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+{
+ return !(__x < __y);
+}
+
+
+// Comparisons with nullopt
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+ return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator!=(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator!=(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(const optional<_Tp>&, nullopt_t) noexcept
+{
+ return false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+ return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<=(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>=(const optional<_Tp>&, nullopt_t) noexcept
+{
+ return true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+ return !static_cast<bool>(__x);
+}
+
+// Comparisons with T
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(const optional<_Tp>& __x, const _Tp& __v)
+{
+ return static_cast<bool>(__x) ? *__x == __v : false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(const _Tp& __v, const optional<_Tp>& __x)
+{
+ return static_cast<bool>(__x) ? *__x == __v : false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator!=(const optional<_Tp>& __x, const _Tp& __v)
+{
+ return static_cast<bool>(__x) ? !(*__x == __v) : true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator!=(const _Tp& __v, const optional<_Tp>& __x)
+{
+ return static_cast<bool>(__x) ? !(*__x == __v) : true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(const optional<_Tp>& __x, const _Tp& __v)
+{
+ return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(const _Tp& __v, const optional<_Tp>& __x)
+{
+ return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<=(const optional<_Tp>& __x, const _Tp& __v)
+{
+ return !(__x > __v);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<=(const _Tp& __v, const optional<_Tp>& __x)
+{
+ return !(__v > __x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>(const optional<_Tp>& __x, const _Tp& __v)
+{
+ return static_cast<bool>(__x) ? __v < __x : false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>(const _Tp& __v, const optional<_Tp>& __x)
+{
+ return static_cast<bool>(__x) ? __x < __v : true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>=(const optional<_Tp>& __x, const _Tp& __v)
+{
+ return !(__x < __v);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>=(const _Tp& __v, const optional<_Tp>& __x)
+{
+ return !(__v < __x);
+}
+
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+optional<typename decay<_Tp>::type>
+make_optional(_Tp&& __v)
+{
+ return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
+}
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::optional<_Tp> >
+{
+ typedef std::experimental::optional<_Tp> argument_type;
+ typedef size_t result_type;
+
+ _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(const argument_type& __opt) const _NOEXCEPT
+ {
+ return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0;
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 11
+
+#endif // _LIBCPP_OPTIONAL
diff --git a/contrib/libc++/include/experimental/ratio b/contrib/libc++/include/experimental/ratio
new file mode 100644
index 000000000000..757f24e08614
--- /dev/null
+++ b/contrib/libc++/include/experimental/ratio
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//===------------------------------ ratio ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_RATIO
+#define _LIBCPP_EXPERIMENTAL_RATIO
+
+/**
+ experimental/ratio synopsis
+ C++1y
+#include <ratio>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+ // See C++14 20.11.5, ratio comparison
+ template <class R1, class R2> constexpr bool ratio_equal_v
+ = ratio_equal<R1, R2>::value;
+ template <class R1, class R2> constexpr bool ratio_not_equal_v
+ = ratio_not_equal<R1, R2>::value;
+ template <class R1, class R2> constexpr bool ratio_less_v
+ = ratio_less<R1, R2>::value;
+ template <class R1, class R2> constexpr bool ratio_less_equal_v
+ = ratio_less_equal<R1, R2>::value;
+ template <class R1, class R2> constexpr bool ratio_greater_v
+ = ratio_greater<R1, R2>::value;
+ template <class R1, class R2> constexpr bool ratio_greater_equal_v
+ = ratio_greater_equal<R1, R2>::value;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <ratio>
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_equal_v
+ = ratio_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_not_equal_v
+ = ratio_not_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_v
+ = ratio_less<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_equal_v
+ = ratio_less_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_v
+ = ratio_greater<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
+ = ratio_greater_equal<_R1, _R2>::value;
+
+#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif // _LIBCPP_EXPERIMENTAL_RATIO
diff --git a/contrib/libc++/include/experimental/string_view b/contrib/libc++/include/experimental/string_view
new file mode 100644
index 000000000000..2a20d7caa687
--- /dev/null
+++ b/contrib/libc++/include/experimental/string_view
@@ -0,0 +1,812 @@
+// -*- C++ -*-
+//===------------------------ string_view ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_LFTS_STRING_VIEW
+#define _LIBCPP_LFTS_STRING_VIEW
+
+/*
+string_view synopsis
+
+namespace std {
+ namespace experimental {
+ inline namespace library_fundamentals_v1 {
+
+ // 7.2, Class template basic_string_view
+ template<class charT, class traits = char_traits<charT>>
+ class basic_string_view;
+
+ // 7.9, basic_string_view non-member comparison functions
+ template<class charT, class traits>
+ constexpr bool operator==(basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator!=(basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator< (basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator> (basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator<=(basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits>
+ constexpr bool operator>=(basic_string_view<charT, traits> x,
+ basic_string_view<charT, traits> y) noexcept;
+ // see below, sufficient additional overloads of comparison functions
+
+ // 7.10, Inserters and extractors
+ template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ basic_string_view<charT, traits> str);
+
+ // basic_string_view typedef names
+ typedef basic_string_view<char> string_view;
+ typedef basic_string_view<char16_t> u16string_view;
+ typedef basic_string_view<char32_t> u32string_view;
+ typedef basic_string_view<wchar_t> wstring_view;
+
+ template<class charT, class traits = char_traits<charT>>
+ class basic_string_view {
+ public:
+ // types
+ typedef traits traits_type;
+ typedef charT value_type;
+ typedef charT* pointer;
+ typedef const charT* const_pointer;
+ typedef charT& reference;
+ typedef const charT& const_reference;
+ typedef implementation-defined const_iterator;
+ typedef const_iterator iterator;
+ typedef reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef const_reverse_iterator reverse_iterator;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ static constexpr size_type npos = size_type(-1);
+
+ // 7.3, basic_string_view constructors and assignment operators
+ constexpr basic_string_view() noexcept;
+ constexpr basic_string_view(const basic_string_view&) noexcept = default;
+ basic_string_view& operator=(const basic_string_view&) noexcept = default;
+ template<class Allocator>
+ basic_string_view(const basic_string<charT, traits, Allocator>& str) noexcept;
+ constexpr basic_string_view(const charT* str);
+ constexpr basic_string_view(const charT* str, size_type len);
+
+ // 7.4, basic_string_view iterator support
+ constexpr const_iterator begin() const noexcept;
+ constexpr const_iterator end() const noexcept;
+ constexpr const_iterator cbegin() const noexcept;
+ constexpr const_iterator cend() const noexcept;
+ const_reverse_iterator rbegin() const noexcept;
+ const_reverse_iterator rend() const noexcept;
+ const_reverse_iterator crbegin() const noexcept;
+ const_reverse_iterator crend() const noexcept;
+
+ // 7.5, basic_string_view capacity
+ constexpr size_type size() const noexcept;
+ constexpr size_type length() const noexcept;
+ constexpr size_type max_size() const noexcept;
+ constexpr bool empty() const noexcept;
+
+ // 7.6, basic_string_view element access
+ constexpr const_reference operator[](size_type pos) const;
+ constexpr const_reference at(size_type pos) const;
+ constexpr const_reference front() const;
+ constexpr const_reference back() const;
+ constexpr const_pointer data() const noexcept;
+
+ // 7.7, basic_string_view modifiers
+ constexpr void clear() noexcept;
+ constexpr void remove_prefix(size_type n);
+ constexpr void remove_suffix(size_type n);
+ constexpr void swap(basic_string_view& s) noexcept;
+
+ // 7.8, basic_string_view string operations
+ template<class Allocator>
+ explicit operator basic_string<charT, traits, Allocator>() const;
+ template<class Allocator = allocator<charT>>
+ basic_string<charT, traits, Allocator> to_string(
+ const Allocator& a = Allocator()) const;
+
+ size_type copy(charT* s, size_type n, size_type pos = 0) const;
+
+ constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
+ constexpr int compare(basic_string_view s) const noexcept;
+ constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
+ constexpr int compare(size_type pos1, size_type n1,
+ basic_string_view s, size_type pos2, size_type n2) const;
+ constexpr int compare(const charT* s) const;
+ constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
+ constexpr int compare(size_type pos1, size_type n1,
+ const charT* s, size_type n2) const;
+ constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
+ constexpr size_type find(charT c, size_type pos = 0) const noexcept;
+ constexpr size_type find(const charT* s, size_type pos, size_type n) const;
+ constexpr size_type find(const charT* s, size_type pos = 0) const;
+ constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
+ constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
+ constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
+ constexpr size_type rfind(const charT* s, size_type pos = npos) const;
+ constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
+ constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
+ constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
+ constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
+ constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
+ constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
+ constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
+ constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
+ constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
+ constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
+ constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
+ constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
+ constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
+ constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
+ constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
+ constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
+
+ private:
+ const_pointer data_; // exposition only
+ size_type size_; // exposition only
+ };
+
+ } // namespace fundamentals_v1
+ } // namespace experimental
+
+ // 7.11, Hash support
+ template <class T> struct hash;
+ template <> struct hash<experimental::string_view>;
+ template <> struct hash<experimental::u16string_view>;
+ template <> struct hash<experimental::u32string_view>;
+ template <> struct hash<experimental::wstring_view>;
+
+} // namespace std
+
+
+*/
+
+#include <experimental/__config>
+
+#include <string>
+#include <algorithm>
+#include <iterator>
+#include <ostream>
+#include <iomanip>
+
+#include <__debug>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+ template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
+ class _LIBCPP_TYPE_VIS_ONLY basic_string_view {
+ public:
+ // types
+ typedef _Traits traits_type;
+ typedef _CharT value_type;
+ typedef const _CharT* pointer;
+ typedef const _CharT* const_pointer;
+ typedef const _CharT& reference;
+ typedef const _CharT& const_reference;
+ typedef const_pointer const_iterator; // See [string.view.iterators]
+ typedef const_iterator iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef const_reverse_iterator reverse_iterator;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
+
+ // [string.view.cons], construct/copy
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string_view(const basic_string_view&) _NOEXCEPT = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
+
+ template<class _Allocator>
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT
+ : __data (__str.data()), __size(__str.size()) {}
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ 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_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ basic_string_view(const _CharT* __s)
+ : __data(__s), __size(_Traits::length(__s)) {}
+
+ // [string.view.iterators], iterators
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_iterator begin() const _NOEXCEPT { return cbegin(); }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_iterator end() const _NOEXCEPT { return cend(); }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_iterator cbegin() const _NOEXCEPT { return __data; }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_iterator cend() const _NOEXCEPT { return __data + __size; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
+
+ // [string.view.capacity], capacity
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ size_type size() const _NOEXCEPT { return __size; }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ size_type length() const _NOEXCEPT { return __size; }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ size_type max_size() const _NOEXCEPT { return _VSTD::numeric_limits<size_type>::max(); }
+
+ _LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY
+ empty() const _NOEXCEPT { return __size == 0; }
+
+ // [string.view.access], element access
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_reference operator[](size_type __pos) const { return __data[__pos]; }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_reference at(size_type __pos) const
+ {
+ return __pos >= size()
+ ? (throw out_of_range("string_view::at"), __data[0])
+ : __data[__pos];
+ }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_reference front() const
+ {
+ return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
+ }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_reference back() const
+ {
+ return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
+ }
+
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ const_pointer data() const _NOEXCEPT { return __data; }
+
+ // [string.view.modifiers], modifiers:
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ void clear() _NOEXCEPT
+ {
+ __data = nullptr;
+ __size = 0;
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ void remove_prefix(size_type __n) _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
+ __data += __n;
+ __size -= __n;
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ void remove_suffix(size_type __n) _NOEXCEPT
+ {
+ _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
+ __size -= __n;
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ void swap(basic_string_view& __other) _NOEXCEPT
+ {
+ const value_type *__p = __data;
+ __data = __other.__data;
+ __other.__data = __p;
+
+ size_type __sz = __size;
+ __size = __other.__size;
+ __other.__size = __sz;
+// _VSTD::swap( __data, __other.__data );
+// _VSTD::swap( __size, __other.__size );
+ }
+
+ // [string.view.ops], string operations:
+ template<class _Allocator>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
+ { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
+
+ template<class _Allocator = allocator<_CharT> >
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string<_CharT, _Traits, _Allocator>
+ to_string( const _Allocator& __a = _Allocator()) const
+ { return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); }
+
+ size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
+ {
+ if ( __pos > size())
+ throw out_of_range("string_view::copy");
+ size_type __rlen = _VSTD::min( __n, size() - __pos );
+ _VSTD::copy_n(begin() + __pos, __rlen, __s );
+ return __rlen;
+ }
+
+ _LIBCPP_CONSTEXPR
+ basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
+ {
+// if (__pos > size())
+// throw out_of_range("string_view::substr");
+// 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")
+ : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
+ {
+ size_type __rlen = _VSTD::min( size(), __sv.size());
+ int __retval = _Traits::compare(data(), __sv.data(), __rlen);
+ if ( __retval == 0 ) // first __rlen chars matched
+ __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
+ return __retval;
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
+ {
+ return substr(__pos1, __n1).compare(__sv);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare( size_type __pos1, size_type __n1,
+ basic_string_view _sv, size_type __pos2, size_type __n2) const
+ {
+ return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2));
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare(const _CharT* __s) const
+ {
+ return compare(basic_string_view(__s));
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
+ {
+ return substr(__pos1, __n1).compare(basic_string_view(__s));
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
+ {
+ return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
+ }
+
+ // find
+ _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");
+ return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
+ {
+ return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+ }
+
+ _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");
+ return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _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");
+ return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // rfind
+ _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");
+ return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
+ {
+ return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+ }
+
+ _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");
+ return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _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");
+ return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // find_first_of
+ _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");
+ return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
+ { return find(__c, __pos); }
+
+ _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");
+ return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _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");
+ return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // find_last_of
+ _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");
+ return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
+ { return rfind(__c, __pos); }
+
+ _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");
+ return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _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");
+ return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // find_first_not_of
+ _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");
+ return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
+ {
+ return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+ }
+
+ _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");
+ return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _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");
+ return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ // find_last_not_of
+ _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");
+ return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s.data(), __pos, __s.size());
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
+ {
+ return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __c, __pos);
+ }
+
+ _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");
+ return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, __n);
+ }
+
+ _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");
+ return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+ (data(), size(), __s, __pos, traits_type::length(__s));
+ }
+
+ private:
+ const value_type* __data;
+ size_type __size;
+ };
+
+
+ // [string.view.comparison]
+ // operator ==
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator==(basic_string_view<_CharT, _Traits> __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ if ( __lhs.size() != __rhs.size()) return false;
+ return __lhs.compare(__rhs) == 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator==(basic_string_view<_CharT, _Traits> __lhs,
+ typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ {
+ if ( __lhs.size() != __rhs.size()) return false;
+ return __lhs.compare(__rhs) == 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ if ( __lhs.size() != __rhs.size()) return false;
+ return __lhs.compare(__rhs) == 0;
+ }
+
+
+ // operator !=
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ if ( __lhs.size() != __rhs.size())
+ return true;
+ return __lhs.compare(__rhs) != 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
+ typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ {
+ if ( __lhs.size() != __rhs.size())
+ return true;
+ return __lhs.compare(__rhs) != 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ if ( __lhs.size() != __rhs.size())
+ return true;
+ return __lhs.compare(__rhs) != 0;
+ }
+
+
+ // operator <
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) < 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator<(basic_string_view<_CharT, _Traits> __lhs,
+ typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) < 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) < 0;
+ }
+
+
+ // operator >
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) > 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator>(basic_string_view<_CharT, _Traits> __lhs,
+ typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) > 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) > 0;
+ }
+
+
+ // operator <=
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) <= 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
+ typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) <= 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) <= 0;
+ }
+
+
+ // operator >=
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) >= 0;
+ }
+
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
+ typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) >= 0;
+ }
+
+ template<class _CharT, class _Traits>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
+ basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+ {
+ return __lhs.compare(__rhs) >= 0;
+ }
+
+
+ // [string.view.io]
+ template<class _CharT, class _Traits>
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv)
+ {
+ return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
+ }
+
+ typedef basic_string_view<char> string_view;
+ typedef basic_string_view<char16_t> u16string_view;
+ typedef basic_string_view<char32_t> u32string_view;
+ typedef basic_string_view<wchar_t> wstring_view;
+
+_LIBCPP_END_NAMESPACE_LFTS
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// [string.view.hash]
+// Shamelessly stolen from <string>
+template<class _CharT, class _Traits>
+struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> >
+ : public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
+{
+ size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;
+};
+
+template<class _CharT, class _Traits>
+size_t
+hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()(
+ const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT
+{
+ return __do_string_hash(__val.data(), __val.data() + __val.size());
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _CharT, class _Traits>
+__quoted_output_proxy<_CharT, const _CharT *, _Traits>
+quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv,
+ _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+ return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
+ ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_LFTS_STRING_VIEW
diff --git a/contrib/libc++/include/experimental/system_error b/contrib/libc++/include/experimental/system_error
new file mode 100644
index 000000000000..2ec238544615
--- /dev/null
+++ b/contrib/libc++/include/experimental/system_error
@@ -0,0 +1,63 @@
+// -*- C++ -*-
+//===-------------------------- system_error ------------------------------===//
+//
+// 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_SYSTEM_ERROR
+#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
+
+/**
+ experimental/system_error synopsis
+
+// C++1y
+
+#include <system_error>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+ // See C++14 19.5, System error support
+ template <class T> constexpr bool is_error_code_enum_v
+ = is_error_code_enum<T>::value;
+ template <class T> constexpr bool is_error_condition_enum_v
+ = is_error_condition_enum<T>::value;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <system_error>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_code_enum_v
+ = is_error_code_enum<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_condition_enum_v
+ = is_error_condition_enum<_Tp>::value;
+
+#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR */
diff --git a/contrib/libc++/include/experimental/tuple b/contrib/libc++/include/experimental/tuple
new file mode 100644
index 000000000000..50d1e0555bc4
--- /dev/null
+++ b/contrib/libc++/include/experimental/tuple
@@ -0,0 +1,81 @@
+// -*- C++ -*-
+//===----------------------------- tuple ----------------------------------===//
+//
+// 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_TUPLE
+#define _LIBCPP_EXPERIMENTAL_TUPLE
+
+/*
+ experimental/tuple synopsis
+
+// C++1y
+
+#include <tuple>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+ // See C++14 20.4.2.5, tuple helper classes
+ template <class T> constexpr size_t tuple_size_v
+ = tuple_size<T>::value;
+
+ // 3.2.2, Calling a function with a tuple of arguments
+ template <class F, class Tuple>
+ constexpr decltype(auto) apply(F&& f, Tuple&& t);
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+ */
+
+# include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+# include <tuple>
+# include <utility>
+# include <__functional_base>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+template <class _Tp>
+_LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value;
+#endif
+
+template <class _Fn, class _Tuple, size_t ..._Id>
+inline _LIBCPP_INLINE_VISIBILITY
+decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
+ integer_sequence<size_t, _Id...>) {
+ return _VSTD::__invoke(
+ _VSTD::forward<_Fn>(__f),
+ _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...
+ );
+}
+
+template <class _Fn, class _Tuple>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+decltype(auto) apply(_Fn && __f, _Tuple && __t) {
+ return _VSTD_LFTS::__apply_tuple_impl(
+ _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
+ make_index_sequence<tuple_size<typename decay<_Tuple>::type>::value>()
+ );
+}
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_TUPLE */
diff --git a/contrib/libc++/include/experimental/type_traits b/contrib/libc++/include/experimental/type_traits
new file mode 100644
index 000000000000..ae49fc176c01
--- /dev/null
+++ b/contrib/libc++/include/experimental/type_traits
@@ -0,0 +1,427 @@
+// -*- C++ -*-
+//===-------------------------- type_traits -------------------------------===//
+//
+// 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_TYPE_TRAITS
+#define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
+
+/**
+ experimental/type_traits synopsis
+
+// C++1y
+#include <type_traits>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+ // See C++14 20.10.4.1, primary type categories
+ template <class T> constexpr bool is_void_v
+ = is_void<T>::value;
+ template <class T> constexpr bool is_null_pointer_v
+ = is_null_pointer<T>::value;
+ template <class T> constexpr bool is_integral_v
+ = is_integral<T>::value;
+ template <class T> constexpr bool is_floating_point_v
+ = is_floating_point<T>::value;
+ template <class T> constexpr bool is_array_v
+ = is_array<T>::value;
+ template <class T> constexpr bool is_pointer_v
+ = is_pointer<T>::value;
+ template <class T> constexpr bool is_lvalue_reference_v
+ = is_lvalue_reference<T>::value;
+ template <class T> constexpr bool is_rvalue_reference_v
+ = is_rvalue_reference<T>::value;
+ template <class T> constexpr bool is_member_object_pointer_v
+ = is_member_object_pointer<T>::value;
+ template <class T> constexpr bool is_member_function_pointer_v
+ = is_member_function_pointer<T>::value;
+ template <class T> constexpr bool is_enum_v
+ = is_enum<T>::value;
+ template <class T> constexpr bool is_union_v
+ = is_union<T>::value;
+ template <class T> constexpr bool is_class_v
+ = is_class<T>::value;
+ template <class T> constexpr bool is_function_v
+ = is_function<T>::value;
+
+ // See C++14 20.10.4.2, composite type categories
+ template <class T> constexpr bool is_reference_v
+ = is_reference<T>::value;
+ template <class T> constexpr bool is_arithmetic_v
+ = is_arithmetic<T>::value;
+ template <class T> constexpr bool is_fundamental_v
+ = is_fundamental<T>::value;
+ template <class T> constexpr bool is_object_v
+ = is_object<T>::value;
+ template <class T> constexpr bool is_scalar_v
+ = is_scalar<T>::value;
+ template <class T> constexpr bool is_compound_v
+ = is_compound<T>::value;
+ template <class T> constexpr bool is_member_pointer_v
+ = is_member_pointer<T>::value;
+
+ // See C++14 20.10.4.3, type properties
+ template <class T> constexpr bool is_const_v
+ = is_const<T>::value;
+ template <class T> constexpr bool is_volatile_v
+ = is_volatile<T>::value;
+ template <class T> constexpr bool is_trivial_v
+ = is_trivial<T>::value;
+ template <class T> constexpr bool is_trivially_copyable_v
+ = is_trivially_copyable<T>::value;
+ template <class T> constexpr bool is_standard_layout_v
+ = is_standard_layout<T>::value;
+ template <class T> constexpr bool is_pod_v
+ = is_pod<T>::value;
+ template <class T> constexpr bool is_literal_type_v
+ = is_literal_type<T>::value;
+ template <class T> constexpr bool is_empty_v
+ = is_empty<T>::value;
+ template <class T> constexpr bool is_polymorphic_v
+ = is_polymorphic<T>::value;
+ template <class T> constexpr bool is_abstract_v
+ = is_abstract<T>::value;
+ template <class T> constexpr bool is_final_v
+ = is_final<T>::value;
+ template <class T> constexpr bool is_signed_v
+ = is_signed<T>::value;
+ template <class T> constexpr bool is_unsigned_v
+ = is_unsigned<T>::value;
+ template <class T, class... Args> constexpr bool is_constructible_v
+ = is_constructible<T, Args...>::value;
+ template <class T> constexpr bool is_default_constructible_v
+ = is_default_constructible<T>::value;
+ template <class T> constexpr bool is_copy_constructible_v
+ = is_copy_constructible<T>::value;
+ template <class T> constexpr bool is_move_constructible_v
+ = is_move_constructible<T>::value;
+ template <class T, class U> constexpr bool is_assignable_v
+ = is_assignable<T, U>::value;
+ template <class T> constexpr bool is_copy_assignable_v
+ = is_copy_assignable<T>::value;
+ template <class T> constexpr bool is_move_assignable_v
+ = is_move_assignable<T>::value;
+ template <class T> constexpr bool is_destructible_v
+ = is_destructible<T>::value;
+ template <class T, class... Args> constexpr bool is_trivially_constructible_v
+ = is_trivially_constructible<T, Args...>::value;
+ template <class T> constexpr bool is_trivially_default_constructible_v
+ = is_trivially_default_constructible<T>::value;
+ template <class T> constexpr bool is_trivially_copy_constructible_v
+ = is_trivially_copy_constructible<T>::value;
+ template <class T> constexpr bool is_trivially_move_constructible_v
+ = is_trivially_move_constructible<T>::value;
+ template <class T, class U> constexpr bool is_trivially_assignable_v
+ = is_trivially_assignable<T, U>::value;
+ template <class T> constexpr bool is_trivially_copy_assignable_v
+ = is_trivially_copy_assignable<T>::value;
+ template <class T> constexpr bool is_trivially_move_assignable_v
+ = is_trivially_move_assignable<T>::value;
+ template <class T> constexpr bool is_trivially_destructible_v
+ = is_trivially_destructible<T>::value;
+ template <class T, class... Args> constexpr bool is_nothrow_constructible_v
+ = is_nothrow_constructible<T, Args...>::value;
+ template <class T> constexpr bool is_nothrow_default_constructible_v
+ = is_nothrow_default_constructible<T>::value;
+ template <class T> constexpr bool is_nothrow_copy_constructible_v
+ = is_nothrow_copy_constructible<T>::value;
+ template <class T> constexpr bool is_nothrow_move_constructible_v
+ = is_nothrow_move_constructible<T>::value;
+ template <class T, class U> constexpr bool is_nothrow_assignable_v
+ = is_nothrow_assignable<T, U>::value;
+ template <class T> constexpr bool is_nothrow_copy_assignable_v
+ = is_nothrow_copy_assignable<T>::value;
+ template <class T> constexpr bool is_nothrow_move_assignable_v
+ = is_nothrow_move_assignable<T>::value;
+ template <class T> constexpr bool is_nothrow_destructible_v
+ = is_nothrow_destructible<T>::value;
+ template <class T> constexpr bool has_virtual_destructor_v
+ = has_virtual_destructor<T>::value;
+
+ // See C++14 20.10.5, type property queries
+ template <class T> constexpr size_t alignment_of_v
+ = alignment_of<T>::value;
+ template <class T> constexpr size_t rank_v
+ = rank<T>::value;
+ template <class T, unsigned I = 0> constexpr size_t extent_v
+ = extent<T, I>::value;
+
+ // See C++14 20.10.6, type relations
+ template <class T, class U> constexpr bool is_same_v
+ = is_same<T, U>::value;
+ template <class Base, class Derived> constexpr bool is_base_of_v
+ = is_base_of<Base, Derived>::value;
+ template <class From, class To> constexpr bool is_convertible_v
+ = is_convertible<From, To>::value;
+
+ // 3.3.2, Other type transformations
+ template <class> class invocation_type; // not defined
+ template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
+ template <class> class raw_invocation_type; // not defined
+ template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>;
+
+ template <class T>
+ using invocation_type_t = typename invocation_type<T>::type;
+ template <class T>
+ using raw_invocation_type_t = typename raw_invocation_type<T>::type;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+ */
+
+#include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+
+// C++14 20.10.4.1, primary type categories
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
+ = is_void<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
+ = is_null_pointer<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
+ = is_integral<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
+ = is_floating_point<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
+ = is_array<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
+ = is_pointer<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
+ = is_lvalue_reference<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
+ = is_rvalue_reference<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
+ = is_member_object_pointer<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
+ = is_member_function_pointer<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
+ = is_enum<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
+ = is_union<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
+ = is_class<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
+ = is_function<_Tp>::value;
+
+// C++14 20.10.4.2, composite type categories
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
+ = is_reference<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
+ = is_arithmetic<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
+ = is_fundamental<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
+ = is_object<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
+ = is_scalar<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
+ = is_compound<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
+ = is_member_pointer<_Tp>::value;
+
+// C++14 20.10.4.3, type properties
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
+ = is_const<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
+ = is_volatile<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
+ = is_trivial<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
+ = is_trivially_copyable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
+ = is_standard_layout<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
+ = is_pod<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
+ = is_literal_type<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
+ = is_empty<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
+ = is_polymorphic<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
+ = is_abstract<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
+ = is_final<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
+ = is_signed<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
+ = is_unsigned<_Tp>::value;
+
+template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v
+ = is_constructible<_Tp, _Ts...>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
+ = is_default_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
+ = is_copy_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
+ = is_move_constructible<_Tp>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v
+ = is_assignable<_Tp, _Up>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
+ = is_copy_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
+ = is_move_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
+ = is_destructible<_Tp>::value;
+
+template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
+ = is_trivially_constructible<_Tp, _Ts...>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
+ = is_trivially_default_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
+ = is_trivially_copy_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
+ = is_trivially_move_constructible<_Tp>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
+ = is_trivially_assignable<_Tp, _Up>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
+ = is_trivially_copy_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
+ = is_trivially_move_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
+ = is_trivially_destructible<_Tp>::value;
+
+template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
+ = is_nothrow_constructible<_Tp, _Ts...>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
+ = is_nothrow_default_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
+ = is_nothrow_copy_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
+ = is_nothrow_move_constructible<_Tp>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
+ = is_nothrow_assignable<_Tp, _Up>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
+ = is_nothrow_copy_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
+ = is_nothrow_move_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
+ = is_nothrow_destructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
+ = has_virtual_destructor<_Tp>::value;
+
+// C++14 20.10.5, type properties queries
+
+template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
+ = alignment_of<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
+ = rank<_Tp>::value;
+
+template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v
+ = extent<_Tp, _Id>::value;
+
+// C++14 20.10.6, type relations
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
+ = is_same<_Tp, _Up>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
+ = is_base_of<_Tp, _Up>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
+ = is_convertible<_Tp, _Up>::value;
+
+#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
+
+// 3.3.2, Other type transformations
+/*
+template <class>
+class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type;
+
+template <class _Fn, class ..._Args>
+class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>;
+
+template <class>
+class _LIBCPP_TYPE_VIS_ONLY invokation_type;
+
+template <class _Fn, class ..._Args>
+class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>;
+
+template <class _Tp>
+using invokation_type_t = typename invokation_type<_Tp>::type;
+
+template <class _Tp>
+using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
+*/
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */
diff --git a/contrib/libc++/include/experimental/utility b/contrib/libc++/include/experimental/utility
new file mode 100644
index 000000000000..b5fca6c775bc
--- /dev/null
+++ b/contrib/libc++/include/experimental/utility
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===-------------------------- utility ----------------------------------===//
+//
+// 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_UTILITY
+#define _LIBCPP_EXPERIMENTAL_UTILITY
+
+/*
+ experimental/utility synopsis
+
+// C++1y
+
+#include <utility>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+ 3.1.2, erased-type placeholder
+ struct erased_type { };
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+ */
+
+#include <experimental/__config>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+ struct _LIBCPP_TYPE_VIS_ONLY erased_type { };
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */