llvm: libc++(abi) and libunwind 7.0.1

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

llvm: libc++(abi) and libunwind 7.0.1

Patrick Wildt-3
Hi,

to complete our LLVM update, here is a diff for libc++, libc++abi and
libunwind.  This also needs a proper amd64 ports test, since there the
update will make the biggest difference.  In addition there have been
a few changes to libunwind for mips64 (defines mostly) and powerpc64
(a bit more), so it would be nice to see if exceptions/unwinding still
work there and on sparc64.

There have only been dynamic export changes in libc++, adding a symbol,
so that one received a minor bump.

One more LLVM upgrade to go. ;)

Patrick

diff --git distrib/sets/lists/base/md.amd64 distrib/sets/lists/base/md.amd64
index 6fdd09994b2..92377c8b9ed 100644
--- distrib/sets/lists/base/md.amd64
+++ distrib/sets/lists/base/md.amd64
@@ -81,7 +81,7 @@
 ./usr/lib/gcc-lib/amd64-unknown-openbsd6.4/4.2.1/collect2
 ./usr/lib/gcc-lib/amd64-unknown-openbsd6.4/4.2.1/libgcc.a
 ./usr/lib/gcc-lib/amd64-unknown-openbsd6.4/4.2.1/specs
-./usr/lib/libc++.so.2.0
+./usr/lib/libc++.so.2.1
 ./usr/lib/libc++abi.so.0.1
 ./usr/lib/libcompiler_rt.a
 ./usr/lib/libstdc++.so.57.0
diff --git distrib/sets/lists/base/md.arm64 distrib/sets/lists/base/md.arm64
index 45403ec963a..667121d4454 100644
--- distrib/sets/lists/base/md.arm64
+++ distrib/sets/lists/base/md.arm64
@@ -37,7 +37,7 @@
 ./usr/lib/crtbeginS.o
 ./usr/lib/crtend.o
 ./usr/lib/crtendS.o
-./usr/lib/libc++.so.2.0
+./usr/lib/libc++.so.2.1
 ./usr/lib/libc++abi.so.0.1
 ./usr/lib/libcompiler_rt.a
 ./usr/libdata/perl5/aarch64-openbsd
diff --git distrib/sets/lists/base/md.armv7 distrib/sets/lists/base/md.armv7
index 15f4bc4fce0..a951a948de2 100644
--- distrib/sets/lists/base/md.armv7
+++ distrib/sets/lists/base/md.armv7
@@ -42,7 +42,7 @@
 ./usr/lib/gcc-lib/arm-unknown-openbsd6.4/4.2.1/collect2
 ./usr/lib/gcc-lib/arm-unknown-openbsd6.4/4.2.1/libgcc.a
 ./usr/lib/gcc-lib/arm-unknown-openbsd6.4/4.2.1/specs
-./usr/lib/libc++.so.2.0
+./usr/lib/libc++.so.2.1
 ./usr/lib/libc++abi.so.0.1
 ./usr/lib/libcompiler_rt.a
 ./usr/lib/libstdc++.so.57.0
diff --git distrib/sets/lists/base/md.i386 distrib/sets/lists/base/md.i386
index 9880d788448..af82ed6cc61 100644
--- distrib/sets/lists/base/md.i386
+++ distrib/sets/lists/base/md.i386
@@ -83,7 +83,7 @@
 ./usr/lib/gcc-lib/i386-unknown-openbsd6.4/4.2.1/collect2
 ./usr/lib/gcc-lib/i386-unknown-openbsd6.4/4.2.1/libgcc.a
 ./usr/lib/gcc-lib/i386-unknown-openbsd6.4/4.2.1/specs
-./usr/lib/libc++.so.2.0
+./usr/lib/libc++.so.2.1
 ./usr/lib/libc++abi.so.0.1
 ./usr/lib/libcompiler_rt.a
 ./usr/lib/libstdc++.so.57.0
diff --git distrib/sets/lists/base/md.loongson distrib/sets/lists/base/md.loongson
index 50fb7b1c076..af6ca9d75b9 100644
--- distrib/sets/lists/base/md.loongson
+++ distrib/sets/lists/base/md.loongson
@@ -48,7 +48,7 @@
 ./usr/lib/gcc-lib/mips64el-unknown-openbsd6.4/4.2.1/collect2
 ./usr/lib/gcc-lib/mips64el-unknown-openbsd6.4/4.2.1/libgcc.a
 ./usr/lib/gcc-lib/mips64el-unknown-openbsd6.4/4.2.1/specs
-./usr/lib/libc++.so.2.0
+./usr/lib/libc++.so.2.1
 ./usr/lib/libc++abi.so.0.1
 ./usr/lib/libcompiler_rt.a
 ./usr/lib/libstdc++.so.57.0
diff --git distrib/sets/lists/base/md.octeon distrib/sets/lists/base/md.octeon
index 49d5431507d..5bd45f79e24 100644
--- distrib/sets/lists/base/md.octeon
+++ distrib/sets/lists/base/md.octeon
@@ -46,7 +46,7 @@
 ./usr/lib/gcc-lib/mips64-unknown-openbsd6.4/4.2.1/collect2
 ./usr/lib/gcc-lib/mips64-unknown-openbsd6.4/4.2.1/libgcc.a
 ./usr/lib/gcc-lib/mips64-unknown-openbsd6.4/4.2.1/specs
-./usr/lib/libc++.so.2.0
+./usr/lib/libc++.so.2.1
 ./usr/lib/libc++abi.so.0.1
 ./usr/lib/libcompiler_rt.a
 ./usr/lib/libstdc++.so.57.0
diff --git distrib/sets/lists/base/md.sgi distrib/sets/lists/base/md.sgi
index 1ae4af52e12..8bfea4939d4 100644
--- distrib/sets/lists/base/md.sgi
+++ distrib/sets/lists/base/md.sgi
@@ -77,7 +77,7 @@
 ./usr/lib/gcc-lib/mips64-unknown-openbsd6.4/4.2.1/collect2
 ./usr/lib/gcc-lib/mips64-unknown-openbsd6.4/4.2.1/libgcc.a
 ./usr/lib/gcc-lib/mips64-unknown-openbsd6.4/4.2.1/specs
-./usr/lib/libc++.so.2.0
+./usr/lib/libc++.so.2.1
 ./usr/lib/libc++abi.so.0.1
 ./usr/lib/libcompiler_rt.a
 ./usr/lib/libstdc++.so.57.0
diff --git distrib/sets/lists/base/md.sparc64 distrib/sets/lists/base/md.sparc64
index 8b23b6aa660..09b07c50cb6 100644
--- distrib/sets/lists/base/md.sparc64
+++ distrib/sets/lists/base/md.sparc64
@@ -79,7 +79,7 @@
 ./usr/lib/gcc-lib/sparc64-unknown-openbsd6.4/4.2.1/collect2
 ./usr/lib/gcc-lib/sparc64-unknown-openbsd6.4/4.2.1/libgcc.a
 ./usr/lib/gcc-lib/sparc64-unknown-openbsd6.4/4.2.1/specs
-./usr/lib/libc++.so.2.0
+./usr/lib/libc++.so.2.1
 ./usr/lib/libc++abi.so.0.1
 ./usr/lib/libcompiler_rt.a
 ./usr/lib/libstdc++.so.57.0
diff --git lib/libcxx/CMakeLists.txt lib/libcxx/CMakeLists.txt
index 9e8e9d5e3d9..acb49565ce9 100644
--- lib/libcxx/CMakeLists.txt
+++ lib/libcxx/CMakeLists.txt
@@ -11,6 +11,10 @@ endif()
 if(POLICY CMP0022)
   cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
 endif()
+if(POLICY CMP0068)
+  cmake_policy(SET CMP0068 NEW)
+  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+endif()
 
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
@@ -23,7 +27,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION 6.0.0)
+  set(PACKAGE_VERSION 7.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "[hidden email]")
 
@@ -68,7 +72,7 @@ set(ENABLE_FILESYSTEM_DEFAULT ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
 if (WIN32)
   set(ENABLE_FILESYSTEM_DEFAULT OFF)
 endif()
-option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++experimental.a"
+option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++fs.a"
     ${ENABLE_FILESYSTEM_DEFAULT})
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
 
@@ -93,14 +97,30 @@ set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
     "Define suffix of library directory name (32/64)")
 option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
 option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
+cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY
+  "Install the static libc++ library." ON
+  "LIBCXX_ENABLE_STATIC;LIBCXX_INSTALL_LIBRARY" OFF)
+cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY
+  "Install the shared libc++ library." ON
+  "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF)
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
 cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
         "Install libc++experimental.a" ON
         "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
-set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
+cmake_dependent_option(LIBCXX_INSTALL_FILESYSTEM_LIBRARY
+        "Install libc++fs.a" ON
+        "LIBCXX_ENABLE_FILESYSTEM;LIBCXX_INSTALL_LIBRARY" OFF)
+
+if (FUCHSIA)
+  set(DEFAULT_ABI_VERSION 2)
+else()
+  set(DEFAULT_ABI_VERSION 1)
+endif()
+set(LIBCXX_ABI_VERSION ${DEFAULT_ABI_VERSION} CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
+option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by default. To be used by vendors." OFF)
 set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 
@@ -123,6 +143,7 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
           ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
           ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include
     NO_DEFAULT_PATH
+    NO_CMAKE_FIND_ROOT_PATH
   )
   if (LIBCXX_TARGETING_MSVC)
     # FIXME: Figure out how to configure the ABI library on Windows.
@@ -149,13 +170,21 @@ endif()
 # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
 option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
 
+cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY
+  "Statically link the ABI library to static library" ON
+  "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF)
+
+cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
+  "Statically link the ABI library to shared library" ON
+  "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_SHARED" OFF)
+
 # Generate and install a linker script inplace of libc++.so. The linker script
 # will link libc++ to the correct ABI library. This option is on by default
 # on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
 # is on. This option is also disabled when the ABI library is not specified
 # or is specified to be "none".
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
-if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
+if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
       AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
       AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"
       AND PYTHONINTERP_FOUND
@@ -205,6 +234,7 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK
    This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
 option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF)
 option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
+option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF)
 option(LIBCXX_HAS_EXTERNAL_THREAD_API
   "Build libc++ with an externalized threading API.
    This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
@@ -276,6 +306,10 @@ if(NOT LIBCXX_ENABLE_THREADS)
     message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set "
                         "to ON when LIBCXX_ENABLE_THREADS is also set to ON.")
   endif()
+  if (LIBCXX_HAS_WIN32_THREAD_API)
+    message(FATAL_ERROR "LIBCXX_HAS_WIN32_THREAD_API can only be set to ON"
+                        " when LIBCXX_ENABLE_THREADS is also set to ON.")
+  endif()
 
 endif()
 
@@ -290,6 +324,19 @@ if (LIBCXX_HAS_EXTERNAL_THREAD_API)
                         "and LIBCXX_HAS_PTHREAD_API cannot be both"
                         "set to ON at the same time.")
   endif()
+  if (LIBCXX_HAS_WIN32_THREAD_API)
+    message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
+                        "and LIBCXX_HAS_WIN32_THREAD_API cannot be both"
+                        "set to ON at the same time.")
+  endif()
+endif()
+
+if (LIBCXX_HAS_PTHREAD_API)
+  if (LIBCXX_HAS_WIN32_THREAD_API)
+    message(FATAL_ERROR "The options LIBCXX_HAS_PTHREAD_API"
+                        "and LIBCXX_HAS_WIN32_THREAD_API cannot be both"
+                        "set to ON at the same time.")
+  endif()
 endif()
 
 # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
@@ -332,7 +379,7 @@ if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
     endif()
 endif()
 
-if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
+if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
     message(FATAL_ERROR "Conflicting options given.
         LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with
         LIBCXX_ENABLE_ABI_LINKER_SCRIPT")
@@ -355,19 +402,29 @@ set(LIBCXX_COMPILER    ${CMAKE_CXX_COMPILER})
 set(LIBCXX_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBCXX_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
-if (LLVM_LIBRARY_OUTPUT_INTDIR)
+
+string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
+       ${PACKAGE_VERSION})
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+  set(DEFAULT_INSTALL_PREFIX lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/)
+  set(DEFAULT_INSTALL_HEADER_PREFIX lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/)
+  set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LIBCXX_LIBDIR_SUFFIX})
+  set(LIBCXX_HEADER_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
+elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
+  set(LIBCXX_HEADER_DIR  ${LLVM_BINARY_DIR})
 else()
   set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
 endif()
+
 file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
 
-set(LIBCXX_INSTALL_PREFIX "" CACHE STRING
+set(LIBCXX_INSTALL_PREFIX ${DEFAULT_INSTALL_PREFIX} CACHE STRING
     "Define libc++ destination prefix.")
 
-if (NOT LIBCXX_INSTALL_PREFIX MATCHES "^$|.*/")
-  message(FATAL_ERROR "LIBCXX_INSTALL_PREFIX has to end with \"/\".")
-endif()
+set(LIBCXX_INSTALL_HEADER_PREFIX ${DEFAULT_INSTALL_HEADER_PREFIX} CACHE STRING
+    "Define libc++ header destination prefix.")
 
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
@@ -600,12 +657,13 @@ if (LIBCXX_STANDALONE_BUILD)
 endif()
 
 # Configuration file flags =====================================================
-if (NOT LIBCXX_ABI_VERSION EQUAL "1")
+if (NOT LIBCXX_ABI_VERSION EQUAL DEFAULT_ABI_VERSION)
   config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
 endif()
 config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
 config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM)
 config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT)
+config_define_if(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT)
 
 config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
 config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN)
@@ -616,6 +674,7 @@ config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THRE
 
 config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
+config_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32)
 config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
diff --git lib/libcxx/Makefile lib/libcxx/Makefile
index 96579b071db..438809509d6 100644
--- lib/libcxx/Makefile
+++ lib/libcxx/Makefile
@@ -23,6 +23,7 @@ LIB= c++
 SRCS+= algorithm.cpp \
  any.cpp \
  bind.cpp \
+ charconv.cpp \
  chrono.cpp \
  condition_variable.cpp \
  debug.cpp \
@@ -67,6 +68,7 @@ STD_HEADERS= __bit_reference \
  __config \
  __config_site.in \
  __debug \
+ __errc \
  __functional_03 \
  __functional_base \
  __functional_base_03 \
@@ -74,6 +76,7 @@ STD_HEADERS= __bit_reference \
  __libcpp_version \
  __locale \
  __mutex_base \
+ __node_handle \
  __nullptr \
  __split_buffer \
  __sso_allocator \
@@ -94,6 +97,7 @@ STD_HEADERS= __bit_reference \
  cerrno \
  cfenv \
  cfloat \
+ charconv \
  chrono \
  cinttypes \
  ciso646 \
@@ -101,6 +105,7 @@ STD_HEADERS= __bit_reference \
  clocale \
  cmath \
  codecvt \
+ compare \
  complex \
  complex.h \
  condition_variable \
@@ -121,6 +126,7 @@ STD_HEADERS= __bit_reference \
  deque \
  errno.h \
  exception \
+ filesystem \
  float.h \
  forward_list \
  fstream \
@@ -156,6 +162,7 @@ STD_HEADERS= __bit_reference \
  set \
  setjmp.h \
  shared_mutex \
+ span \
  sstream \
  stack \
  stdbool.h \
@@ -182,6 +189,7 @@ STD_HEADERS= __bit_reference \
  valarray \
  variant \
  vector \
+ version \
  wchar.h \
  wctype.h
 
@@ -221,6 +229,7 @@ EXP_HEADERS= __config \
  ratio \
  regex \
  set \
+ simd \
  string \
  string_view \
  system_error \
diff --git lib/libcxx/NOTES.TXT lib/libcxx/NOTES.TXT
index f0597de64ae..24d245d437c 100644
--- lib/libcxx/NOTES.TXT
+++ lib/libcxx/NOTES.TXT
@@ -26,3 +26,4 @@ to libc++.
 1. Add a test under `test/libcxx` that the header defines `_LIBCPP_VERSION`.
 2. Update `test/libcxx/double_include.sh.cpp` to include the new header.
 3. Create a submodule in `include/module.modulemap` for the new header.
+4. Update the include/CMakeLists.txt file to include the new header.
diff --git lib/libcxx/benchmarks/CMakeLists.txt lib/libcxx/benchmarks/CMakeLists.txt
index 8211ebd009a..f557d4aea39 100644
--- lib/libcxx/benchmarks/CMakeLists.txt
+++ lib/libcxx/benchmarks/CMakeLists.txt
@@ -59,6 +59,7 @@ if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
           -DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
 endif()
 
+
 #==============================================================================
 # Benchmark tests configuration
 #==============================================================================
@@ -67,7 +68,7 @@ set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
 set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx)
 set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native)
 set(BENCHMARK_TEST_COMPILE_FLAGS
-    -std=c++14 -O2
+    -std=c++17 -O2
     -I${BENCHMARK_LIBCXX_INSTALL}/include
     -I${LIBCXX_SOURCE_DIR}/test/support
 )
diff --git lib/libcxx/benchmarks/ContainerBenchmarks.hpp lib/libcxx/benchmarks/ContainerBenchmarks.hpp
index dc268e7ebca..509e3d23ed9 100644
--- lib/libcxx/benchmarks/ContainerBenchmarks.hpp
+++ lib/libcxx/benchmarks/ContainerBenchmarks.hpp
@@ -3,7 +3,7 @@
 
 #include <cassert>
 
-#include "benchmark/benchmark_api.h"
+#include "benchmark/benchmark.h"
 
 namespace ContainerBenchmarks {
 
diff --git lib/libcxx/benchmarks/GenerateInput.hpp lib/libcxx/benchmarks/GenerateInput.hpp
index 9d5adac4af4..8c97f5881f1 100644
--- lib/libcxx/benchmarks/GenerateInput.hpp
+++ lib/libcxx/benchmarks/GenerateInput.hpp
@@ -29,14 +29,16 @@ inline std::default_random_engine& getRandomEngine() {
     return RandEngine;
 }
 
+
 inline char getRandomChar() {
     std::uniform_int_distribution<> LettersDist(0, LettersSize-1);
     return Letters[LettersDist(getRandomEngine())];
 }
 
 template <class IntT>
-inline IntT getRandomInteger() {
-    std::uniform_int_distribution<IntT> dist;
+inline IntT getRandomInteger(IntT Min = 0,
+                             IntT Max = std::numeric_limits<IntT>::max()) {
+    std::uniform_int_distribution<IntT> dist(Min, Max);
     return dist(getRandomEngine());
 }
 
diff --git lib/libcxx/benchmarks/algorithms.bench.cpp lib/libcxx/benchmarks/algorithms.bench.cpp
index 745cc172718..86315390e0d 100644
--- lib/libcxx/benchmarks/algorithms.bench.cpp
+++ lib/libcxx/benchmarks/algorithms.bench.cpp
@@ -2,7 +2,7 @@
 #include <vector>
 #include <cstdint>
 
-#include "benchmark/benchmark_api.h"
+#include "benchmark/benchmark.h"
 #include "GenerateInput.hpp"
 
 constexpr std::size_t TestNumInputs = 1024;
@@ -59,4 +59,4 @@ BENCHMARK_CAPTURE(BM_Sort, single_element_strings,
     getDuplicateStringInputs)->Arg(TestNumInputs);
 
 
-BENCHMARK_MAIN()
+BENCHMARK_MAIN();
diff --git lib/libcxx/benchmarks/filesystem.bench.cpp lib/libcxx/benchmarks/filesystem.bench.cpp
index f7949a163a7..3e495605915 100644
--- lib/libcxx/benchmarks/filesystem.bench.cpp
+++ lib/libcxx/benchmarks/filesystem.bench.cpp
@@ -1,17 +1,14 @@
-#include <experimental/filesystem>
-
-#include "benchmark/benchmark_api.h"
+#include "benchmark/benchmark.h"
 #include "GenerateInput.hpp"
 #include "test_iterators.h"
-
-namespace fs = std::experimental::filesystem;
+#include "filesystem_include.hpp"
 
 static const size_t TestNumInputs = 1024;
 
 
 template <class GenInputs>
 void BM_PathConstructString(benchmark::State &st, GenInputs gen) {
-  using namespace fs;
+  using fs::path;
   const auto in = gen(st.range(0));
   path PP;
   for (auto& Part : in)
@@ -21,14 +18,15 @@ void BM_PathConstructString(benchmark::State &st, GenInputs gen) {
     const path P(PP.native());
     benchmark::DoNotOptimize(P.native().data());
   }
+  st.SetComplexityN(st.range(0));
 }
 BENCHMARK_CAPTURE(BM_PathConstructString, large_string,
-  getRandomStringInputs)->Arg(TestNumInputs);
+  getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
 
 
 template <class GenInputs>
 void BM_PathConstructCStr(benchmark::State &st, GenInputs gen) {
-  using namespace fs;
+  using fs::path;
   const auto in = gen(st.range(0));
   path PP;
   for (auto& Part : in)
@@ -45,7 +43,7 @@ BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string,
 
 template <template <class...> class ItType, class GenInputs>
 void BM_PathConstructIter(benchmark::State &st, GenInputs gen) {
-  using namespace fs;
+  using fs::path;
   using Iter = ItType<std::string::const_iterator>;
   const auto in = gen(st.range(0));
   path PP;
@@ -60,6 +58,7 @@ void BM_PathConstructIter(benchmark::State &st, GenInputs gen) {
     const path P(Start, End);
     benchmark::DoNotOptimize(P.native().data());
   }
+  st.SetComplexityN(st.range(0));
 }
 template <class GenInputs>
 void BM_PathConstructInputIter(benchmark::State &st, GenInputs gen) {
@@ -70,14 +69,14 @@ void BM_PathConstructForwardIter(benchmark::State &st, GenInputs gen) {
   BM_PathConstructIter<forward_iterator>(st, gen);
 }
 BENCHMARK_CAPTURE(BM_PathConstructInputIter, large_string,
-  getRandomStringInputs)->Arg(TestNumInputs);
+  getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
 BENCHMARK_CAPTURE(BM_PathConstructForwardIter, large_string,
-  getRandomStringInputs)->Arg(TestNumInputs);
+  getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
 
 
 template <class GenInputs>
 void BM_PathIterateMultipleTimes(benchmark::State &st, GenInputs gen) {
-  using namespace fs;
+  using fs::path;
   const auto in = gen(st.range(0));
   path PP;
   for (auto& Part : in)
@@ -89,14 +88,15 @@ void BM_PathIterateMultipleTimes(benchmark::State &st, GenInputs gen) {
     }
     benchmark::ClobberMemory();
   }
+  st.SetComplexityN(st.range(0));
 }
 BENCHMARK_CAPTURE(BM_PathIterateMultipleTimes, iterate_elements,
-  getRandomStringInputs)->Arg(TestNumInputs);
+  getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
 
 
 template <class GenInputs>
 void BM_PathIterateOnce(benchmark::State &st, GenInputs gen) {
-  using namespace fs;
+  using fs::path;
   const auto in = gen(st.range(0));
   path PP;
   for (auto& Part : in)
@@ -109,13 +109,14 @@ void BM_PathIterateOnce(benchmark::State &st, GenInputs gen) {
     }
     benchmark::ClobberMemory();
   }
+  st.SetComplexityN(st.range(0));
 }
 BENCHMARK_CAPTURE(BM_PathIterateOnce, iterate_elements,
-  getRandomStringInputs)->Arg(TestNumInputs);
+  getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
 
 template <class GenInputs>
 void BM_PathIterateOnceBackwards(benchmark::State &st, GenInputs gen) {
-  using namespace fs;
+  using fs::path;
   const auto in = gen(st.range(0));
   path PP;
   for (auto& Part : in)
@@ -135,4 +136,28 @@ void BM_PathIterateOnceBackwards(benchmark::State &st, GenInputs gen) {
 BENCHMARK_CAPTURE(BM_PathIterateOnceBackwards, iterate_elements,
   getRandomStringInputs)->Arg(TestNumInputs);
 
-BENCHMARK_MAIN()
+static fs::path getRandomPaths(int NumParts, int PathLen) {
+  fs::path Result;
+  while (NumParts--) {
+    std::string Part = getRandomString(PathLen);
+    Result /= Part;
+  }
+  return Result;
+}
+
+template <class GenInput>
+void BM_LexicallyNormal(benchmark::State &st, GenInput gen, size_t PathLen) {
+  using fs::path;
+  auto In = gen(st.range(0), PathLen);
+  benchmark::DoNotOptimize(&In);
+  while (st.KeepRunning()) {
+    benchmark::DoNotOptimize(In.lexically_normal());
+  }
+  st.SetComplexityN(st.range(0));
+}
+BENCHMARK_CAPTURE(BM_LexicallyNormal, small_path,
+  getRandomPaths, /*PathLen*/5)->RangeMultiplier(2)->Range(2, 256)->Complexity();
+BENCHMARK_CAPTURE(BM_LexicallyNormal, large_path,
+  getRandomPaths, /*PathLen*/32)->RangeMultiplier(2)->Range(2, 256)->Complexity();
+
+BENCHMARK_MAIN();
diff --git lib/libcxx/benchmarks/string.bench.cpp lib/libcxx/benchmarks/string.bench.cpp
index ef892391688..8a09e738d9b 100644
--- lib/libcxx/benchmarks/string.bench.cpp
+++ lib/libcxx/benchmarks/string.bench.cpp
@@ -2,7 +2,7 @@
 #include <vector>
 #include <cstdint>
 
-#include "benchmark/benchmark_api.h"
+#include "benchmark/benchmark.h"
 #include "GenerateInput.hpp"
 
 constexpr std::size_t MAX_STRING_LEN = 8 << 14;
@@ -46,4 +46,25 @@ static void BM_StringFindMatch2(benchmark::State &state) {
 }
 BENCHMARK(BM_StringFindMatch2)->Range(1, MAX_STRING_LEN / 4);
 
-BENCHMARK_MAIN()
+static void BM_StringCtorDefault(benchmark::State &state) {
+  while (state.KeepRunning()) {
+    for (unsigned I=0; I < 1000; ++I) {
+      std::string Default;
+      benchmark::DoNotOptimize(Default.c_str());
+    }
+  }
+}
+BENCHMARK(BM_StringCtorDefault);
+
+static void BM_StringCtorCStr(benchmark::State &state) {
+  std::string Input = getRandomString(state.range(0));
+  const char *Str = Input.c_str();
+  benchmark::DoNotOptimize(Str);
+  while (state.KeepRunning()) {
+    std::string Tmp(Str);
+    benchmark::DoNotOptimize(Tmp.c_str());
+  }
+}
+BENCHMARK(BM_StringCtorCStr)->Arg(1)->Arg(8)->Range(16, MAX_STRING_LEN / 4);
+
+BENCHMARK_MAIN();
diff --git lib/libcxx/benchmarks/stringstream.bench.cpp lib/libcxx/benchmarks/stringstream.bench.cpp
index 6023cf775bc..75a7a284e07 100644
--- lib/libcxx/benchmarks/stringstream.bench.cpp
+++ lib/libcxx/benchmarks/stringstream.bench.cpp
@@ -1,4 +1,4 @@
-#include "benchmark/benchmark_api.h"
+#include "benchmark/benchmark.h"
 
 #include <sstream>
 double __attribute__((noinline)) istream_numbers();
@@ -35,4 +35,4 @@ static void BM_Istream_numbers(benchmark::State &state) {
 }
 
 BENCHMARK(BM_Istream_numbers)->RangeMultiplier(2)->Range(1024, 4096);
-BENCHMARK_MAIN()
+BENCHMARK_MAIN();
diff --git lib/libcxx/benchmarks/unordered_set_operations.bench.cpp lib/libcxx/benchmarks/unordered_set_operations.bench.cpp
index e2afdde56dc..ee0ea29b8d2 100644
--- lib/libcxx/benchmarks/unordered_set_operations.bench.cpp
+++ lib/libcxx/benchmarks/unordered_set_operations.bench.cpp
@@ -5,7 +5,7 @@
 #include <cstdlib>
 #include <cstring>
 
-#include "benchmark/benchmark_api.h"
+#include "benchmark/benchmark.h"
 
 #include "ContainerBenchmarks.hpp"
 #include "GenerateInput.hpp"
@@ -303,4 +303,4 @@ BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
     std::unordered_set<std::string>{},
     getRandomCStringInputs)->Arg(TestNumInputs);
 
-BENCHMARK_MAIN()
+BENCHMARK_MAIN();
diff --git lib/libcxx/benchmarks/util_smartptr.bench.cpp lib/libcxx/benchmarks/util_smartptr.bench.cpp
index ad3f03a0448..c984b2ca666 100644
--- lib/libcxx/benchmarks/util_smartptr.bench.cpp
+++ lib/libcxx/benchmarks/util_smartptr.bench.cpp
@@ -9,7 +9,7 @@
 
 #include <memory>
 
-#include "benchmark/benchmark_api.h"
+#include "benchmark/benchmark.h"
 
 static void BM_SharedPtrCreateDestroy(benchmark::State& st) {
   while (st.KeepRunning()) {
@@ -39,4 +39,4 @@ static void BM_WeakPtrIncDecRef(benchmark::State& st) {
 }
 BENCHMARK(BM_WeakPtrIncDecRef);
 
-BENCHMARK_MAIN()
+BENCHMARK_MAIN();
diff --git lib/libcxx/benchmarks/vector_operations.bench.cpp lib/libcxx/benchmarks/vector_operations.bench.cpp
index 004e801f0be..a2c4e5dbbc0 100644
--- lib/libcxx/benchmarks/vector_operations.bench.cpp
+++ lib/libcxx/benchmarks/vector_operations.bench.cpp
@@ -4,7 +4,7 @@
 #include <cstdlib>
 #include <cstring>
 
-#include "benchmark/benchmark_api.h"
+#include "benchmark/benchmark.h"
 
 #include "ContainerBenchmarks.hpp"
 #include "GenerateInput.hpp"
@@ -29,4 +29,4 @@ BENCHMARK_CAPTURE(BM_ConstructIterIter,
   getRandomStringInputs)->Arg(TestNumInputs);
 
 
-BENCHMARK_MAIN()
+BENCHMARK_MAIN();
diff --git lib/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake lib/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake
index a7ae667a155..98862d42397 100644
--- lib/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake
+++ lib/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake
@@ -9,7 +9,7 @@ INCLUDE(CheckCXXSourceCompiles)
 
 function(check_cxx_atomics varname)
   set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
-  set(CMAKE_REQUIRED_FLAGS "-nodefaultlibs -std=c++11 -nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include")
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs -std=c++11 -nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include")
   if (${LIBCXX_GCC_TOOLCHAIN})
     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}")
   endif()
@@ -31,7 +31,14 @@ int main() {
   set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
 endfunction(check_cxx_atomics)
 
+# Perform the check for 64bit atomics without libatomic. It may have been
+# added to the required libraries during in the configuration of LLVM, which
+# would cause the check for CXX atomics without libatomic to incorrectly pass.
+set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic")
 check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
+set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
+
 check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
 # If not, check if the library exists, and atomics work with it.
 if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
diff --git lib/libcxx/cmake/Modules/HandleCompilerRT.cmake lib/libcxx/cmake/Modules/HandleCompilerRT.cmake
index e9da3c43a21..2e0e69e5e08 100644
--- lib/libcxx/cmake/Modules/HandleCompilerRT.cmake
+++ lib/libcxx/cmake/Modules/HandleCompilerRT.cmake
@@ -14,6 +14,7 @@ function(find_compiler_rt_library name dest)
       OUTPUT_VARIABLE LIBRARY_FILE
   )
   string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
+  file(TO_CMAKE_PATH "${LIBRARY_FILE}" LIBRARY_FILE)
   string(REPLACE "builtins" "${name}" LIBRARY_FILE "${LIBRARY_FILE}")
   if (NOT HAD_ERROR AND EXISTS "${LIBRARY_FILE}")
     message(STATUS "Found compiler-rt library: ${LIBRARY_FILE}")
@@ -37,6 +38,7 @@ function(find_compiler_rt_dir dest)
         OUTPUT_VARIABLE LIBRARY_DIR
     )
     string(STRIP "${LIBRARY_DIR}" LIBRARY_DIR)
+    file(TO_CMAKE_PATH "${LIBRARY_DIR}" LIBRARY_DIR)
     set(LIBRARY_DIR "${LIBRARY_DIR}/darwin")
   else()
     set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
@@ -47,6 +49,7 @@ function(find_compiler_rt_dir dest)
         OUTPUT_VARIABLE LIBRARY_FILE
     )
     string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
+    file(TO_CMAKE_PATH "${LIBRARY_FILE}" LIBRARY_FILE)
     get_filename_component(LIBRARY_DIR "${LIBRARY_FILE}" DIRECTORY)
   endif()
   if (NOT HAD_ERROR AND EXISTS "${LIBRARY_DIR}")
diff --git lib/libcxx/cmake/Modules/HandleLibCXXABI.cmake lib/libcxx/cmake/Modules/HandleLibCXXABI.cmake
index 558e11ba2cc..1c19d7e01af 100644
--- lib/libcxx/cmake/Modules/HandleLibCXXABI.cmake
+++ lib/libcxx/cmake/Modules/HandleLibCXXABI.cmake
@@ -32,14 +32,6 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
   set(LIBCXX_CXX_ABI_LIBRARY ${abilib})
   set(LIBCXX_ABILIB_FILES ${abifiles})
 
-  # The place in the build tree where we store out-of-source headers.
-  file(MAKE_DIRECTORY "${LIBCXX_BUILD_HEADERS_ROOT}")
-  file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1")
-  foreach(_d ${abidirs})
-    file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}/${_d}")
-    file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1/${_d}")
-  endforeach()
-
   foreach(fpath ${LIBCXX_ABILIB_FILES})
     set(found FALSE)
     foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS})
@@ -47,20 +39,31 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
         set(found TRUE)
         get_filename_component(dstdir ${fpath} PATH)
         get_filename_component(ifile ${fpath} NAME)
-        file(COPY "${incpath}/${fpath}"
-          DESTINATION "${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}"
-          )
-        file(COPY "${incpath}/${fpath}"
-          DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}"
-          )
+        set(src ${incpath}/${fpath})
+
+        set(dst ${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}/${ifile})
+        add_custom_command(OUTPUT ${dst}
+            DEPENDS ${src}
+            COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+            COMMENT "Copying C++ ABI header ${fpath}...")
+        list(APPEND abilib_headers "${dst}")
+
+        if (NOT LIBCXX_USING_INSTALLED_LLVM AND LIBCXX_HEADER_DIR)
+          set(dst "${LIBCXX_HEADER_DIR}/include/c++/v1/${dstdir}/${fpath}")
+          add_custom_command(OUTPUT ${dst}
+              DEPENDS ${src}
+              COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+              COMMENT "Copying C++ ABI header ${fpath}...")
+          list(APPEND abilib_headers "${dst}")
+        endif()
+
         if (LIBCXX_INSTALL_HEADERS)
           install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
-            DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1/${dstdir}
+            DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dstdir}
             COMPONENT cxx-headers
             PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
             )
         endif()
-        list(APPEND abilib_headers "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}")
       endif()
     endforeach()
     if (NOT found)
@@ -69,6 +72,8 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
   endforeach()
 
   include_directories("${LIBCXX_BINARY_INCLUDE_DIR}")
+  add_custom_target(cxx_abi_headers ALL DEPENDS ${abilib_headers})
+  set(LIBCXX_CXX_ABI_HEADER_TARGET "cxx_abi_headers")
 endmacro()
 
 
@@ -93,10 +98,10 @@ if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
 elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
   if (LIBCXX_CXX_ABI_INTREE)
     # Link against just-built "cxxabi" target.
-    if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
-        set(CXXABI_LIBNAME cxxabi_static)
+    if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+      set(CXXABI_LIBNAME cxxabi_static)
     else()
-        set(CXXABI_LIBNAME cxxabi_shared)
+      set(CXXABI_LIBNAME cxxabi_shared)
     endif()
     set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE)
   else()
diff --git lib/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake lib/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
index 83948b14fd1..70eed1d70ba 100644
--- lib/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
+++ lib/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
@@ -46,10 +46,11 @@ macro(find_llvm_parts)
       OUTPUT_VARIABLE CONFIG_OUTPUT
       ERROR_QUIET)
     if(NOT HAD_ERROR)
-      string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH)
+      string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH_FROM_LLVM_CONFIG)
+      file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH_FROM_LLVM_CONFIG}" LLVM_CMAKE_PATH)
     else()
-      set(LLVM_CMAKE_PATH
-          "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+      file(TO_CMAKE_PATH "${LLVM_BINARY_DIR}" LLVM_BINARY_DIR_CMAKE_STYLE)
+      set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR_CMAKE_STYLE}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
     endif()
   else()
     set(LLVM_FOUND OFF)
diff --git lib/libcxx/docs/BuildingLibcxx.rst lib/libcxx/docs/BuildingLibcxx.rst
index 3dae2f41c27..daf9229a0d0 100644
--- lib/libcxx/docs/BuildingLibcxx.rst
+++ lib/libcxx/docs/BuildingLibcxx.rst
@@ -242,11 +242,15 @@ libc++experimental Specific Options
 
 .. option:: LIBCXX_ENABLE_FILESYSTEM:BOOL
 
-  **Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY``
+  **Default**: ``ON``
+
+  Build filesystem as a standalone library libc++fs.a.
 
-  Build filesystem as part of libc++experimental.a. This allows filesystem
-  to be disabled without turning off the entire experimental library.
+.. option:: LIBCXX_INSTALL_FILESYSTEM_LIBRARY:BOOL
 
+  **Default**: ``LIBCXX_ENABLE_FILESYSTEM AND LIBCXX_INSTALL_LIBRARY``
+
+  Install libc++fs.a alongside libc++.
 
 .. _ABI Library Specific Options:
 
@@ -328,6 +332,15 @@ libc++ Feature Options
   Use the specified GCC toolchain and standard library when building the native
   stdlib benchmark tests.
 
+.. option:: LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT:BOOL
+
+  **Default**: ``OFF``
+
+  Pick the default for whether to constrain ABI-unstable symbols to
+  each individual translation unit. This setting controls whether
+  `_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT` is defined by default --
+  see the documentation of that macro for details.
+
 
 libc++ ABI Feature Options
 --------------------------
diff --git lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst
index 4a85c698f23..b8b44509790 100644
--- lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst
+++ lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst
@@ -58,7 +58,7 @@ Testing
 Some parameters can be passed to lit to run the test-suite and exercising the
 availability.
 
-* The `platform` parameter controls the deployement target. For example lit can
+* The `platform` parameter controls the deployment target. For example lit can
   be invoked with `--param=platform=macosx10.8`. Default is the current host.
 * The `use_system_cxx_lib` parameter indicates to use another library than the
   just built one. Invoking lit with `--param=use_system_cxx_lib=true` will run
diff --git lib/libcxx/docs/DesignDocs/CapturingConfigInfo.rst lib/libcxx/docs/DesignDocs/CapturingConfigInfo.rst
index 73378a21c0a..88102251d93 100644
--- lib/libcxx/docs/DesignDocs/CapturingConfigInfo.rst
+++ lib/libcxx/docs/DesignDocs/CapturingConfigInfo.rst
@@ -46,7 +46,7 @@ we do NOTHING.
 
 Otherwise we create a custom installation rule that modifies the installed __config
 header. The rule first generates a dummy "__config_site" header containing the required
-#defines. The contents of the dummy header are then prependend to the installed
+#defines. The contents of the dummy header are then prepended to the installed
 __config header. By manually prepending the files we avoid the cost of an
 extra #include and we allow the __config header to be ignorant of the extra
 configuration all together. An example "__config" header generated when
diff --git lib/libcxx/docs/DesignDocs/FileTimeType.rst lib/libcxx/docs/DesignDocs/FileTimeType.rst
new file mode 100644
index 00000000000..488ff174b34
--- /dev/null
+++ lib/libcxx/docs/DesignDocs/FileTimeType.rst
@@ -0,0 +1,494 @@
+==============
+File Time Type
+==============
+
+.. contents::
+   :local:
+
+.. _file-time-type-motivation:
+
+Motivation
+==========
+
+The filesystem library provides interfaces for getting and setting the last
+write time of a file or directory. The interfaces use the ``file_time_type``
+type, which is a specialization of ``chrono::time_point`` for the
+"filesystem clock". According to [fs.filesystem.syn]
+
+  trivial-clock is an implementation-defined type that satisfies the
+  Cpp17TrivialClock requirements ([time.clock.req]) and that is capable of
+  representing and measuring file time values. Implementations should ensure
+  that the resolution and range of file_¬≠time_¬≠type reflect the operating
+  system dependent resolution and range of file time values.
+
+
+On POSIX systems, file times are represented using the ``timespec`` struct,
+which is defined as follows:
+
+.. code-block:: cpp
+
+  struct timespec {
+    time_t tv_sec;
+    long   tv_nsec;
+  };
+
+To represent the range and resolution of ``timespec``, we need to (A) have
+nanosecond resolution, and (B) use more than 64 bits (assuming a 64 bit ``time_t``).
+
+As the standard requires us to use the ``chrono`` interface, we have to define
+our own filesystem clock which specifies the period and representation of
+the time points and duration it provides. It will look like this:
+
+.. code-block:: cpp
+
+  struct _FilesystemClock {
+    using period = nano;
+    using rep = TBD; // What is this?
+
+    using duration = chrono::duration<rep, period>;
+    using time_point = chrono::time_point<_FilesystemClock>;
+
+    // ... //
+  };
+
+  using file_time_type = _FilesystemClock::time_point;
+
+
+To get nanosecond resolution, we simply define ``period`` to be ``std::nano``.
+But what type can we use as the arithmetic representation that is capable
+of representing the range of the ``timespec`` struct?
+
+Problems To Consider
+====================
+
+Before considering solutions, let's consider the problems they should solve,
+and how important solving those problems are:
+
+
+Having a Smaller Range than ``timespec``
+----------------------------------------
+
+One solution to the range problem is to simply reduce the resolution of
+``file_time_type`` to be less than that of nanoseconds. This is what libc++'s
+initial implementation of ``file_time_type`` did; it's also what
+``std::system_clock`` does. As a result, it can represent time points about
+292 thousand years on either side of the epoch, as opposed to only 292 years
+at nanosecond resolution.
+
+``timespec`` can represent time points +/- 292 billion years from the epoch
+(just in case you needed a time point 200 billion years before the big bang,
+and with nanosecond resolution).
+
+To get the same range, we would need to drop our resolution to that of seconds
+to come close to having the same range.
+
+This begs the question, is the range problem "really a problem"? Sane usages
+of file time stamps shouldn't exceed +/- 300 years, so should we care to support it?
+
+I believe the answer is yes. We're not designing the filesystem time API, we're
+providing glorified C++ wrappers for it. If the underlying API supports
+a value, then we should too. Our wrappers should not place artificial restrictions
+on users that are not present in the underlying filesystem.
+
+Having a smaller range that the underlying filesystem forces the
+implementation to report ``value_too_large`` errors when it encounters a time
+point that it can't represent. This can cause the call to ``last_write_time``
+to throw in cases where the user was confident the call should succeed. (See below)
+
+
+.. code-block:: cpp
+
+  #include <filesystem>
+  using namespace std::filesystem;
+
+  // Set the times using the system interface.
+  void set_file_times(const char* path, struct timespec ts) {
+    timespec both_times[2];
+    both_times[0] = ts;
+    both_times[1] = ts;
+    int result = ::utimensat(AT_FDCWD, path, both_times, 0);
+    assert(result != -1);
+  }
+
+  // Called elsewhere to set the file time to something insane, and way
+  // out of the 300 year range we might expect.
+  void some_bad_persons_code() {
+    struct timespec new_times;
+    new_times.tv_sec = numeric_limits<time_t>::max();
+    new_times.tv_nsec = 0;
+    set_file_times("/tmp/foo", new_times); // OK, supported by most FSes
+  }
+
+  int main() {
+    path p = "/tmp/foo";
+    file_status st = status(p);
+    if (!exists(st) || !is_regular_file(st))
+      return 1;
+    if ((st.permissions() & perms::others_read) == perms::none)
+      return 1;
+    // It seems reasonable to assume this call should succeed.
+    file_time_type tp = last_write_time(p); // BAD! Throws value_too_large.
+  }
+
+
+Having a Smaller Resolution than ``timespec``
+---------------------------------------------
+
+As mentioned in the previous section, one way to solve the range problem
+is by reducing the resolution. But matching the range of ``timespec`` using a
+64 bit representation requires limiting the resolution to seconds.
+
+So we might ask: Do users "need" nanosecond precision? Is seconds not good enough?
+I limit my consideration of the point to this: Why was it not good enough for
+the underlying system interfaces? If it wasn't good enough for them, then it
+isn't good enough for us. Our job is to match the filesystems range and
+representation, not design it.
+
+
+Having a Larger Range than ``timespec``
+----------------------------------------
+
+We should also consider the opposite problem of having a ``file_time_type``
+that is able to represent a larger range than ``timespec``. At least in
+this case ``last_write_time`` can be used to get and set all possible values
+supported by the underlying filesystem; meaning ``last_write_time(p)`` will
+never throw a overflow error when retrieving a value.
+
+However, this introduces a new problem, where users are allowed to attempt to
+create a time point beyond what the filesystem can represent. Two particular
+values which cause this are ``file_time_type::min()`` and
+``file_time_type::max()``. As a result, the following code would throw:
+
+.. code-block:: cpp
+
+  void test() {
+    last_write_time("/tmp/foo", file_time_type::max()); // Throws
+    last_write_time("/tmp/foo", file_time_type::min()); // Throws.
+  }
+
+Apart from cases explicitly using ``min`` and ``max``, I don't see users taking
+a valid time point, adding a couple hundred billions of years in error,
+and then trying to update a file's write time to that value very often.
+
+Compared to having a smaller range, this problem seems preferable. At least
+now we can represent any time point the filesystem can, so users won't be forced
+to revert back to system interfaces to avoid limitations in the C++ STL.
+
+I posit that we should only consider this concern *after* we have something
+with at least the same range and resolution of the underlying filesystem. The
+latter two problems are much more important to solve.
+
+Potential Solutions And Their Complications
+===========================================
+
+Source Code Portability Across Implementations
+-----------------------------------------------
+
+As we've discussed, ``file_time_type`` needs a representation that uses more
+than 64 bits. The possible solutions include using ``__int128_t``, emulating a
+128 bit integer using a class, or potentially defining a ``timespec`` like
+arithmetic type. All three will allow us to, at minimum, match the range
+and resolution, and the last one might even allow us to match them exactly.
+
+But when considering these potential solutions we need to consider more than
+just the values they can represent. We need to consider the effects they will
+have on users and their code. For example, each of them breaks the following
+code in some way:
+
+.. code-block:: cpp
+
+  // Bug caused by an unexpected 'rep' type returned by count.
+  void print_time(path p) {
+    // __int128_t doesn't have streaming operators, and neither would our
+    // custom arithmetic types.
+    cout << last_write_time(p).time_since_epoch().count() << endl;
+  }
+
+  // Overflow during creation bug.
+  file_time_type timespec_to_file_time_type(struct timespec ts) {
+    // woops! chrono::seconds and chrono::nanoseconds use a 64 bit representation
+    // this may overflow before it's converted to a file_time_type.
+    auto dur = seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec);
+    return file_time_type(dur);
+  }
+
+  file_time_type correct_timespec_to_file_time_type(struct timespec ts) {
+    // This is the correct version of the above example, where we
+    // avoid using the chrono typedefs as they're not sufficient.
+    // Can we expect users to avoid this bug?
+    using fs_seconds = chrono::duration<file_time_type::rep>;
+    using fs_nanoseconds = chrono::duration<file_time_type::rep, nano>;
+    auto dur = fs_seconds(ts.tv_sec) + fs_nanoseconds(tv.tv_nsec);
+    return file_time_type(dur);
+  }
+
+  // Implicit truncation during conversion bug.
+  intmax_t get_time_in_seconds(path p) {
+    using fs_seconds = duration<file_time_type::rep, ratio<1, 1> >;
+    auto tp = last_write_time(p);
+
+    // This works with truncation for __int128_t, but what does it do for
+    // our custom arithmetic types.
+    return duration_cast<fs_seconds>().count();
+  }
+
+
+Each of the above examples would require a user to adjust their filesystem code
+to the particular eccentricities of the representation, hopefully only in such
+a way that the code is still portable across implementations.
+
+At least some of the above issues are unavoidable, no matter what
+representation we choose. But some representations may be quirkier than others,
+and, as I'll argue later, using an actual arithmetic type (``__int128_t``)
+provides the least aberrant behavior.
+
+
+Chrono and ``timespec`` Emulation.
+----------------------------------
+
+One of the options we've considered is using something akin to ``timespec``
+to represent the ``file_time_type``. It only seems natural seeing as that's
+what the underlying system uses, and because it might allow us to match
+the range and resolution exactly. But would it work with chrono? And could
+it still act at all like a ``timespec`` struct?
+
+For ease of consideration, let's consider what the implementation might
+look like.
+
+.. code-block:: cpp
+
+  struct fs_timespec_rep {
+    fs_timespec_rep(long long v)
+      : tv_sec(v / nano::den), tv_nsec(v % nano::den)
+    { }
+  private:
+    time_t tv_sec;
+    long tv_nsec;
+  };
+  bool operator==(fs_timespec_rep, fs_timespec_rep);
+  fs_int128_rep operator+(fs_timespec_rep, fs_timespec_rep);
+  // ... arithmetic operators ... //
+
+The first thing to notice is that we can't construct ``fs_timespec_rep`` like
+a ``timespec`` by passing ``{secs, nsecs}``. Instead we're limited to
+constructing it from a single 64 bit integer.
+
+We also can't allow the user to inspect the ``tv_sec`` or ``tv_nsec`` values
+directly. A ``chrono::duration`` represents its value as a tick period and a
+number of ticks stored using ``rep``. The representation is unaware of the
+tick period it is being used to represent, but ``timespec`` is setup to assume
+a nanosecond tick period; which is the only case where the names ``tv_sec``
+and ``tv_nsec`` match the values they store.
+
+When we convert a nanosecond duration to seconds, ``fs_timespec_rep`` will
+use ``tv_sec`` to represent the number of giga seconds, and ``tv_nsec`` the
+remaining seconds. Let's consider how this might cause a bug were users allowed
+to manipulate the fields directly.
+
+.. code-block:: cpp
+
+  template <class Period>
+  timespec convert_to_timespec(duration<fs_time_rep, Period> dur) {
+    fs_timespec_rep rep = dur.count();
+    return {rep.tv_sec, rep.tv_nsec}; // Oops! Period may not be nanoseconds.
+  }
+
+  template <class Duration>
+  Duration convert_to_duration(timespec ts) {
+    Duration dur({ts.tv_sec, ts.tv_nsec}); // Oops! Period may not be nanoseconds.
+    return file_time_type(dur);
+    file_time_type tp = last_write_time(p);
+    auto dur =
+  }
+
+  time_t extract_seconds(file_time_type tp) {
+    // Converting to seconds is a silly bug, but I could see it happening.
+    using SecsT = chrono::duration<file_time_type::rep, ratio<1, 1>>;
+    auto secs = duration_cast<Secs>(tp.time_since_epoch());
+    // tv_sec is now representing gigaseconds.
+    return secs.count().tv_sec; // Oops!
+  }
+
+Despite ``fs_timespec_rep`` not being usable in any manner resembling
+``timespec``, it still might buy us our goal of matching its range exactly,
+right?
+
+Sort of. Chrono provides a specialization point which specifies the minimum
+and maximum values for a custom representation. It looks like this:
+
+.. code-block:: cpp
+
+  template <>
+  struct duration_values<fs_timespec_rep> {
+    static fs_timespec_rep zero();
+    static fs_timespec_rep min();
+    static fs_timespec_rep max() { // assume friendship.
+      fs_timespec_rep val;
+      val.tv_sec = numeric_limits<time_t>::max();
+      val.tv_nsec = nano::den - 1;
+      return val;
+    }
+  };
+
+Notice that ``duration_values`` doesn't tell the representation what tick
+period it's actually representing. This would indeed correctly limit the range
+of ``duration<fs_timespec_rep, nano>`` to exactly that of ``timespec``. But
+nanoseconds isn't the only tick period it will be used to represent. For
+example:
+
+.. code-block:: cpp
+
+  void test() {
+    using rep = file_time_type::rep;
+    using fs_nsec = duration<rep, nano>;
+    using fs_sec = duration<rep>;
+    fs_nsec nsecs(fs_seconds::max()); // Truncates
+  }
+
+Though the above example may appear silly, I think it follows from the incorrect
+notion that using a ``timespec`` rep in chrono actually makes it act as if it
+were an actual ``timespec``.
+
+Interactions with 32 bit ``time_t``
+-----------------------------------
+
+Up until now we've only be considering cases where ``time_t`` is 64 bits, but what
+about 32 bit systems/builds where ``time_t`` is 32 bits? (this is the common case
+for 32 bit builds).
+
+When ``time_t`` is 32 bits, we can implement ``file_time_type`` simply using 64-bit
+``long long``. There is no need to get either ``__int128_t`` or ``timespec`` emulation
+involved. And nor should we, as it would suffer from the numerous complications
+described by this paper.
+
+Obviously our implementation for 32-bit builds should act as similarly to the
+64-bit build as possible. Code which compiles in one, should compile in the other.
+This consideration is important when choosing between ``__int128_t`` and
+emulating ``timespec``. The solution which provides the most uniformity with
+the least eccentricity is the preferable one.
+
+Summary
+=======
+
+The ``file_time_type`` time point is used to represent the write times for files.
+Its job is to act as part of a C++ wrapper for less ideal system interfaces. The
+underlying filesystem uses the ``timespec`` struct for the same purpose.
+
+However, the initial implementation of ``file_time_type`` could not represent
+either the range or resolution of ``timespec``, making it unsuitable. Fixing
+this requires an implementation which uses more than 64 bits to store the
+time point.
+
+We primarily considered two solutions: Using ``__int128_t`` and using a
+arithmetic emulation of ``timespec``. Each has its pros and cons, and both
+come with more than one complication.
+
+The Potential Solutions
+-----------------------
+
+``long long`` - The Status Quo
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Pros:
+
+* As a type ``long long`` plays the nicest with others:
+
+  * It works with streaming operators and other library entities which support
+    builtin integer types, but don't support ``__int128_t``.
+  * Its the representation used by chrono's ``nanosecond`` and ``second`` typedefs.
+
+Cons:
+
+* It cannot provide the same resolution as ``timespec`` unless we limit it
+  to a range of +/- 300 years from the epoch.
+* It cannot provide the same range as ``timespec`` unless we limit its resolution
+  to seconds.
+* ``last_write_time`` has to report an error when the time reported by the filesystem
+  is unrepresentable.
+
+__int128_t
+~~~~~~~~~~~
+
+Pros:
+
+* It is an integer type.
+* It makes the implementation simple and efficient.
+* Acts exactly like other arithmetic types.
+* Can be implicitly converted to a builtin integer type by the user.
+
+  * This is important for doing things like:
+
+    .. code-block:: cpp
+
+      void c_interface_using_time_t(const char* p, time_t);
+
+      void foo(path p) {
+        file_time_type tp = last_write_time(p);
+        time_t secs = duration_cast<seconds>(tp.time_since_epoch()).count();
+        c_interface_using_time_t(p.c_str(), secs);
+      }
+
+Cons:
+
+* It isn't always available (but on 64 bit machines, it normally is).
+* It causes ``file_time_type`` to have a larger range than ``timespec``.
+* It doesn't always act the same as other builtin integer types. For example
+  with ``cout`` or ``to_string``.
+* Allows implicit truncation to 64 bit integers.
+* It can be implicitly converted to a builtin integer type by the user,
+  truncating its value.
+
+Arithmetic ``timespec`` Emulation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Pros:
+
+* It has the exact same range and resolution of ``timespec`` when representing
+  a nanosecond tick period.
+* It's always available, unlike ``__int128_t``.
+
+Cons:
+
+* It has a larger range when representing any period longer than a nanosecond.
+* Doesn't actually allow users to use it like a ``timespec``.
+* The required representation of using ``tv_sec`` to store the giga tick count
+  and ``tv_nsec`` to store the remainder adds nothing over a 128 bit integer,
+  but complicates a lot.
+* It isn't a builtin integer type, and can't be used anything like one.
+* Chrono can be made to work with it, but not nicely.
+* Emulating arithmetic classes come with their own host of problems regarding
+  overload resolution (Each operator needs three SFINAE constrained versions of
+  it in order to act like builtin integer types).
+* It offers little over simply using ``__int128_t``.
+* It acts the most differently than implementations using an actual integer type,
+  which has a high chance of breaking source compatibility.
+
+
+Selected Solution - Using ``__int128_t``
+=========================================
+
+The solution I selected for libc++ is using ``__int128_t`` when available,
+and otherwise falling back to using ``long long`` with nanosecond precision.
+
+When ``__int128_t`` is available, or when ``time_t`` is 32-bits, the implementation
+provides same resolution and a greater range than ``timespec``. Otherwise
+it still provides the same resolution, but is limited to a range of +/- 300
+years. This final case should be rather rare, as ``__int128_t``
+is normally available in 64-bit builds, and ``time_t`` is normally 32-bits
+during 32-bit builds.
+
+Although falling back to ``long long`` and nanosecond precision is less than
+ideal, it also happens to be the implementation provided by both libstdc++
+and MSVC. (So that makes it better, right?)
+
+Although the ``timespec`` emulation solution is feasible and would largely
+do what we want, it comes with too many complications, potential problems
+and discrepancies when compared to "normal" chrono time points and durations.
+
+An emulation of a builtin arithmetic type using a class is never going to act
+exactly the same, and the difference will be felt by users. It's not reasonable
+to expect them to tolerate and work around these differences. And once
+we commit to an ABI it will be too late to change. Committing to this seems
+risky.
+
+Therefore, ``__int128_t`` seems like the better solution.
diff --git lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst
index 556c45b7e1f..330ce74cf77 100644
--- lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst
+++ lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst
@@ -66,6 +66,10 @@ Threading Configuration Macros
   This macro is defined when libc++ should use POSIX threads to implement the
   internal threading API.
 
+**_LIBCPP_HAS_THREAD_API_WIN32**
+  This macro is defined when libc++ should use Win32 threads to implement the
+  internal threading API.
+
 **_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL**
   This macro is defined when libc++ expects the definitions of the internal
   threading API to be provided by an external library. When defined
diff --git lib/libcxx/docs/DesignDocs/VisibilityMacros.rst lib/libcxx/docs/DesignDocs/VisibilityMacros.rst
index 993ce2cca5f..ab577df1364 100644
--- lib/libcxx/docs/DesignDocs/VisibilityMacros.rst
+++ lib/libcxx/docs/DesignDocs/VisibilityMacros.rst
@@ -40,11 +40,44 @@ Visibility Macros
   this macro therefore expands to `__declspec(dllexport)` when building the
   library and has an empty definition otherwise.
 
-**_LIBCPP_INLINE_VISIBILITY**
-  Mark a function as hidden and force inlining whenever possible.
-
-**_LIBCPP_ALWAYS_INLINE**
-  A synonym for `_LIBCPP_INLINE_VISIBILITY`
+**_LIBCPP_HIDE_FROM_ABI**
+  Mark a function as not being part of the ABI of any final linked image that
+  uses it.
+
+**_LIBCPP_HIDE_FROM_ABI_PER_TU**
+  This macro controls whether symbols hidden from the ABI with `_LIBCPP_HIDE_FROM_ABI`
+  are local to each translation unit in addition to being local to each final
+  linked image. This macro is defined to either 0 or 1. When it is defined to
+  1, translation units compiled with different versions of libc++ can be linked
+  together, since all non ABI-facing functions are local to each translation unit.
+  This allows static archives built with different versions of libc++ to be linked
+  together. This also means that functions marked with `_LIBCPP_HIDE_FROM_ABI`
+  are not guaranteed to have the same address across translation unit boundaries.
+
+  When the macro is defined to 0, there is no guarantee that translation units
+  compiled with different versions of libc++ can interoperate. However, this
+  leads to code size improvements, since non ABI-facing functions can be
+  deduplicated across translation unit boundaries.
+
+  This macro can be defined by users to control the behavior they want from
+  libc++. The default value of this macro (0 or 1) is controlled by whether
+  `_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT` is defined, which is intended to
+  be used by vendors only (see below).
+
+**_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT**
+  This macro controls the default value for `_LIBCPP_HIDE_FROM_ABI_PER_TU`.
+  When the macro is defined, per TU ABI insulation is enabled by default, and
+  `_LIBCPP_HIDE_FROM_ABI_PER_TU` is defined to 1 unless overriden by users.
+  Otherwise, per TU ABI insulation is disabled by default, and
+  `_LIBCPP_HIDE_FROM_ABI_PER_TU` is defined to 0 unless overriden by users.
+
+  This macro is intended for vendors to control whether they want to ship
+  libc++ with per TU ABI insulation enabled by default. Users can always
+  control the behavior they want by defining `_LIBCPP_HIDE_FROM_ABI_PER_TU`
+  appropriately.
+
+  By default, this macro is not defined, which means that per TU ABI insulation
+  is not provided unless explicitly overriden by users.
 
 **_LIBCPP_TYPE_VIS**
   Mark a type's typeinfo, vtable and members as having default visibility.
@@ -155,6 +188,22 @@ Visibility Macros
   versioning namespace. This allows throwing and catching some exception types
   between libc++ and libstdc++.
 
+**_LIBCPP_INTERNAL_LINKAGE**
+  Mark the affected entity as having internal linkage (i.e. the `static`
+  keyword in C). This is only a best effort: when the `internal_linkage`
+  attribute is not available, we fall back to forcing the function to be
+  inlined, which approximates internal linkage since an externally visible
+  symbol is never generated for that function. This is an internal macro
+  used as an implementation detail by other visibility macros. Never mark
+  a function or a class with this macro directly.
+
+**_LIBCPP_ALWAYS_INLINE**
+  Forces inlining of the function it is applied to. For visibility purposes,
+  this macro is used to make sure that an externally visible symbol is never
+  generated in an object file when the `internal_linkage` attribute is not
+  available. This is an internal macro used by other visibility macros, and
+  it should not be used directly.
+
 Links
 =====
 
diff --git lib/libcxx/docs/Makefile.sphinx lib/libcxx/docs/Makefile.sphinx
index ae37a34b54e..a34f0cc0bad 100644
--- lib/libcxx/docs/Makefile.sphinx
+++ lib/libcxx/docs/Makefile.sphinx
@@ -5,7 +5,7 @@
 # out-of-tree builds.
 
 # You can set these variables from the command line.
-SPHINXOPTS    = -n -W
+SPHINXOPTS    = -n -W -v
 SPHINXBUILD   = sphinx-build
 PAPER         =
 BUILDDIR      = _build
diff --git lib/libcxx/docs/UsingLibcxx.rst lib/libcxx/docs/UsingLibcxx.rst
index f54234d6aa3..e10a27c598a 100644
--- lib/libcxx/docs/UsingLibcxx.rst
+++ lib/libcxx/docs/UsingLibcxx.rst
@@ -49,6 +49,24 @@ An example of using ``LD_LIBRARY_PATH``:
   $ export LD_LIBRARY_PATH=<libcxx-install-prefix>/lib
   $ ./a.out # Searches for libc++ along LD_LIBRARY_PATH
 
+
+Using ``<filesystem>`` and libc++fs
+====================================
+
+Libc++ provides the implementation of the filesystem library in a separate
+library. Users of ``<filesystem>`` and ``<experimental/filesystem>`` are
+required to link ``-lc++fs``.
+
+.. note::
+  Prior to libc++ 7.0, users of ``<experimental/filesystem>`` were required
+  to link libc++experimental.
+
+.. warning::
+  The Filesystem library is still experimental in nature. As such normal
+  guarantees about ABI stability and backwards compatibility do not yet apply
+  to it. In the future, this restriction will be removed.
+
+
 Using libc++experimental and ``<experimental/...>``
 =====================================================
 
@@ -65,6 +83,9 @@ installed. For information on building libc++experimental from source see
 :ref:`Building Libc++ <build instructions>` and
 :ref:`libc++experimental CMake Options <libc++experimental options>`.
 
+Note that as of libc++ 7.0 using the ``<experimental/filesystem>`` requires linking
+libc++fs instead of libc++experimental.
+
 Also see the `Experimental Library Implementation Status <http://libcxx.llvm.org/ts1z_status.html>`__
 page.
 
diff --git lib/libcxx/docs/conf.py lib/libcxx/docs/conf.py
index bb231ac3e35..4c1ea3653cd 100644
--- lib/libcxx/docs/conf.py
+++ lib/libcxx/docs/conf.py
@@ -47,9 +47,9 @@ copyright = u'2011-2017, LLVM Project'
 # built documents.
 #
 # The short X.Y version.
-version = '6.0'
+version = '7.0'
 # The full version, including alpha/beta/rc tags.
-release = '6.0'
+release = '7.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git lib/libcxx/docs/index.rst lib/libcxx/docs/index.rst
index 3526b47210f..e4b3a879da9 100644
--- lib/libcxx/docs/index.rst
+++ lib/libcxx/docs/index.rst
@@ -134,6 +134,7 @@ Design Documents
    DesignDocs/ABIVersioning
    DesignDocs/VisibilityMacros
    DesignDocs/ThreadingSupportAPI
+   DesignDocs/FileTimeType
 
 * `<atomic> design <http://libcxx.llvm.org/atomic_design.html>`_
 * `<type_traits> design <http://libcxx.llvm.org/type_traits_design.html>`_
diff --git lib/libcxx/include/CMakeLists.txt lib/libcxx/include/CMakeLists.txt
index b98e09260ca..d9def18d725 100644
--- lib/libcxx/include/CMakeLists.txt
+++ lib/libcxx/include/CMakeLists.txt
@@ -1,58 +1,264 @@
-if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
-  set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
-endif()
-
-set(LIBCXX_HEADER_PATTERN
-  PATTERN "*"
-  PATTERN "CMakeLists.txt" EXCLUDE
-  PATTERN ".svn" EXCLUDE
-  PATTERN "__config_site.in" EXCLUDE
-  ${LIBCXX_SUPPORT_HEADER_PATTERN}
+set(files
+  __bit_reference
+  __bsd_locale_defaults.h
+  __bsd_locale_fallbacks.h
+  __errc
+  __debug
+  __functional_03
+  __functional_base
+  __functional_base_03
+  __hash_table
+  __libcpp_version
+  __locale
+  __mutex_base
+  __node_handle
+  __nullptr
+  __split_buffer
+  __sso_allocator
+  __std_stream
+  __string
+  __threading_support
+  __tree
+  __tuple
+  __undef_macros
+  algorithm
+  any
+  array
+  atomic
+  bitset
+  cassert
+  ccomplex
+  cctype
+  cerrno
+  cfenv
+  cfloat
+  charconv
+  chrono
+  cinttypes
+  ciso646
+  climits
+  clocale
+  cmath
+  codecvt
+  compare
+  complex
+  complex.h
+  condition_variable
+  csetjmp
+  csignal
+  cstdarg
+  cstdbool
+  cstddef
+  cstdint
+  cstdio
+  cstdlib
+  cstring
+  ctgmath
+  ctime
+  ctype.h
+  cwchar
+  cwctype
+  deque
+  errno.h
+  exception
+  experimental/__config
+  experimental/__memory
+  experimental/algorithm
+  experimental/any
+  experimental/chrono
+  experimental/coroutine
+  experimental/deque
+  experimental/dynarray
+  experimental/filesystem
+  experimental/forward_list
+  experimental/functional
+  experimental/iterator
+  experimental/list
+  experimental/map
+  experimental/memory_resource
+  experimental/numeric
+  experimental/optional
+  experimental/propagate_const
+  experimental/ratio
+  experimental/regex
+  experimental/set
+  experimental/simd
+  experimental/string
+  experimental/string_view
+  experimental/system_error
+  experimental/tuple
+  experimental/type_traits
+  experimental/unordered_map
+  experimental/unordered_set
+  experimental/utility
+  experimental/vector
+  ext/__hash
+  ext/hash_map
+  ext/hash_set
+  filesystem
+  float.h
+  forward_list
+  fstream
+  functional
+  future
+  initializer_list
+  inttypes.h
+  iomanip
+  ios
+  iosfwd
+  iostream
+  istream
+  iterator
+  limits
+  limits.h
+  list
+  locale
+  locale.h
+  map
+  math.h
+  memory
+  module.modulemap
+  mutex
+  new
+  numeric
+  optional
+  ostream
+  queue
+  random
+  ratio
+  regex
+  scoped_allocator
+  set
+  setjmp.h
+  shared_mutex
+  span
+  sstream
+  stack
+  stdbool.h
+  stddef.h
+  stdexcept
+  stdint.h
+  stdio.h
+  stdlib.h
+  streambuf
+  string
+  string.h
+  string_view
+  strstream
+  system_error
+  tgmath.h
+  thread
+  tuple
+  type_traits
+  typeindex
+  typeinfo
+  unordered_map
+  unordered_set
+  utility
+  valarray
+  variant
+  vector
+  version
+  wchar.h
+  wctype.h
   )
 
-if(NOT LIBCXX_USING_INSTALLED_LLVM AND LLVM_BINARY_DIR)
-  file(COPY .
-    DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
-    FILES_MATCHING
-    ${LIBCXX_HEADER_PATTERN}
+if(LIBCXX_INSTALL_SUPPORT_HEADERS)
+  set(files
+    ${files}
+    support/android/locale_bionic.h
+    support/fuchsia/xlocale.h
+    support/ibm/limits.h
+    support/ibm/locale_mgmt_aix.h
+    support/ibm/support.h
+    support/ibm/xlocale.h
+    support/musl/xlocale.h
+    support/newlib/xlocale.h
+    support/solaris/floatingpoint.h
+    support/solaris/wchar.h
+    support/solaris/xlocale.h
+    support/win32/limits_msvc_win32.h
+    support/win32/locale_win32.h
+    support/xlocale/__nop_locale_mgmt.h
+    support/xlocale/__posix_l_fallback.h
+    support/xlocale/__strtonum_fallback.h
+    support/xlocale/xlocale.h
     )
 endif()
 
-if (LIBCXX_INSTALL_HEADERS)
-  install(DIRECTORY .
-    DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1
-    COMPONENT cxx-headers
-    FILES_MATCHING
-    ${LIBCXX_HEADER_PATTERN}
-    PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+if (LIBCXX_NEEDS_SITE_CONFIG)
+  # Generate a custom __config header. The new header is created
+  # by prepending __config_site to the current __config header.
+  add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config
+    COMMAND ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py
+      ${LIBCXX_BINARY_DIR}/__config_site
+      ${LIBCXX_SOURCE_DIR}/include/__config
+      -o ${LIBCXX_BINARY_DIR}/__generated_config
+    DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config
+            ${LIBCXX_BINARY_DIR}/__config_site
   )
+  # Add a target that executes the generation commands.
+  add_custom_target(cxx-generated-config ALL
+    DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config)
+  set(generated_config_deps cxx-generated-config)
+else()
+  set(files
+    ${files}
+    __config
+    )
+endif()
+
+if(NOT LIBCXX_USING_INSTALLED_LLVM AND LIBCXX_HEADER_DIR)
+  set(output_dir ${LIBCXX_HEADER_DIR}/include/c++/v1)
+
+  set(out_files)
+  foreach(f ${files})
+    set(src ${CMAKE_CURRENT_SOURCE_DIR}/${f})
+    set(dst ${output_dir}/${f})
+    add_custom_command(OUTPUT ${dst}
+      DEPENDS ${src}
+      COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+      COMMENT "Copying CXX header ${f}")
+    list(APPEND out_files ${dst})
+  endforeach()
 
   if (LIBCXX_NEEDS_SITE_CONFIG)
-    # Generate and install a custom __config header. The new header is created
-    # by  prepending __config_site to the current __config header.
-    add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config
-      COMMAND ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py
-        ${LIBCXX_BINARY_DIR}/__config_site
-        ${LIBCXX_SOURCE_DIR}/include/__config
-        -o ${LIBCXX_BINARY_DIR}/__generated_config
-      DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config
-              ${LIBCXX_BINARY_DIR}/__config_site
+    # Copy the generated header as __config into build directory.
+    set(src ${LIBCXX_BINARY_DIR}/__generated_config)
+    set(dst ${output_dir}/__config)
+    add_custom_command(OUTPUT ${dst}
+        DEPENDS ${src} ${generated_config_deps}
+        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+        COMMENT "Copying CXX __config")
+    list(APPEND out_files ${dst})
+  endif()
+
+  add_custom_target(cxx-headers ALL DEPENDS ${out_files} ${LIBCXX_CXX_ABI_HEADER_TARGET})
+else()
+  add_custom_target(cxx-headers)
+endif()
+set_target_properties(cxx-headers PROPERTIES FOLDER "Misc")
+
+if (LIBCXX_INSTALL_HEADERS)
+  foreach(file ${files})
+    get_filename_component(dir ${file} DIRECTORY)
+    install(FILES ${file}
+      DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dir}
+      COMPONENT cxx-headers
+      PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
     )
-    # Add a target that executes the generation commands.
-    add_custom_target(generate_config_header ALL
-      DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config)
-    set(generated_config_deps generate_config_header)
+  endforeach()
+
+  if (LIBCXX_NEEDS_SITE_CONFIG)
     # Install the generated header as __config.
     install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
-      DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1
+      DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1
       PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
       RENAME __config
       COMPONENT cxx-headers)
   endif()
 
   if (NOT CMAKE_CONFIGURATION_TYPES)
-    # this target is just needed as a placeholder for the distribution target
-    add_custom_target(cxx-headers)
     add_custom_target(install-cxx-headers
                       DEPENDS cxx-headers ${generated_config_deps}
                       COMMAND "${CMAKE_COMMAND}"
@@ -61,9 +267,7 @@ if (LIBCXX_INSTALL_HEADERS)
     # Stripping is a no-op for headers
     add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
-    add_custom_target(libcxx-headers)
     add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
     add_custom_target(install-libcxx-headers-stripped DEPENDS install-cxx-headers-stripped)
   endif()
-
 endif()
diff --git lib/libcxx/include/__bsd_locale_fallbacks.h lib/libcxx/include/__bsd_locale_fallbacks.h
index 5e9e0948307..3097b01410d 100644
--- lib/libcxx/include/__bsd_locale_fallbacks.h
+++ lib/libcxx/include/__bsd_locale_fallbacks.h
@@ -24,28 +24,28 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l)
 {
     __libcpp_locale_guard __current(__l);
     return MB_CUR_MAX;
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 wint_t __libcpp_btowc_l(int __c, locale_t __l)
 {
     __libcpp_locale_guard __current(__l);
     return btowc(__c);
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 int __libcpp_wctob_l(wint_t __c, locale_t __l)
 {
     __libcpp_locale_guard __current(__l);
     return wctob(__c);
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
                          size_t __len, mbstate_t *__ps, locale_t __l)
 {
@@ -53,14 +53,14 @@ size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
     return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
 {
     __libcpp_locale_guard __current(__l);
     return wcrtomb(__s, __wc, __ps);
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
                       size_t __len, mbstate_t *__ps, locale_t __l)
 {
@@ -68,7 +68,7 @@ size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
     return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
                    mbstate_t *__ps, locale_t __l)
 {
@@ -76,28 +76,28 @@ size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
     return mbrtowc(__pwc, __s, __n, __ps);
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
 {
     __libcpp_locale_guard __current(__l);
     return mbtowc(__pwc, __pmb, __max);
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
 {
     __libcpp_locale_guard __current(__l);
     return mbrlen(__s, __n, __ps);
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 lconv *__libcpp_localeconv_l(locale_t __l)
 {
     __libcpp_locale_guard __current(__l);
     return localeconv();
 }
 
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
                      mbstate_t *__ps, locale_t __l)
 {
diff --git lib/libcxx/include/__config lib/libcxx/include/__config
index 4be3d2c06be..d6942af125d 100644
--- lib/libcxx/include/__config
+++ lib/libcxx/include/__config
@@ -12,9 +12,9 @@
 #define _LIBCPP_CONFIG
 
 #if defined(_MSC_VER) && !defined(__clang__)
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#endif
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#    define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+#  endif
 #endif
 
 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
@@ -24,79 +24,95 @@
 #ifdef __cplusplus
 
 #ifdef __GNUC__
-#define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
+#  define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
 // The _GNUC_VER_NEW macro better represents the new GCC versioning scheme
 // introduced in GCC 5.0.
-#define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
+#  define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
 #else
-#define _GNUC_VER 0
-#define _GNUC_VER_NEW 0
+#  define _GNUC_VER 0
+#  define _GNUC_VER_NEW 0
 #endif
 
-#define _LIBCPP_VERSION 6000
+#define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
-#define _LIBCPP_ABI_VERSION 1
+#  ifdef __Fuchsia__
+#    define _LIBCPP_ABI_VERSION 2
+#  else
+#    define _LIBCPP_ABI_VERSION 1
+#  endif
 #endif
 
+#ifndef _LIBCPP_STD_VER
+#  if  __cplusplus <= 201103L
+#    define _LIBCPP_STD_VER 11
+#  elif __cplusplus <= 201402L
+#    define _LIBCPP_STD_VER 14
+#  elif __cplusplus <= 201703L
+#    define _LIBCPP_STD_VER 17
+#  else
+#    define _LIBCPP_STD_VER 18  // current year, or date of c++2a ratification
+#  endif
+#endif  // _LIBCPP_STD_VER
+
 #if defined(__ELF__)
-#define _LIBCPP_OBJECT_FORMAT_ELF   1
+#  define _LIBCPP_OBJECT_FORMAT_ELF   1
 #elif defined(__MACH__)
-#define _LIBCPP_OBJECT_FORMAT_MACHO 1
+#  define _LIBCPP_OBJECT_FORMAT_MACHO 1
 #elif defined(_WIN32)
-#define _LIBCPP_OBJECT_FORMAT_COFF  1
+#  define _LIBCPP_OBJECT_FORMAT_COFF  1
 #elif defined(__wasm__)
-#define _LIBCPP_OBJECT_FORMAT_WASM  1
+#  define _LIBCPP_OBJECT_FORMAT_WASM  1
 #else
-#error Unknown object file format
+#  error Unknown object file format
 #endif
 
 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
 // Change short string representation so that string data starts at offset 0,
 // improving its alignment in some cases.
-#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#  define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 // Fix deque iterator type in order to support incomplete types.
-#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+#  define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
 // Fix undefined behavior in how std::list stores its linked nodes.
-#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
+#  define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
 // Fix undefined behavior in  how __tree stores its end and parent nodes.
-#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
+#  define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
 // Fix undefined behavior in how __hash_table stores its pointer types.
-#define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
-#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
-#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
+#  define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
+#  define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
+#  define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
 // Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
 // provided under the alternate keyword __nullptr, which changes the mangling
 // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
-#define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
+#  define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
 // Define the `pointer_safety` enum as a C++11 strongly typed enumeration
 // instead of as a class simulating an enum. If this option is enabled
 // `pointer_safety` and `get_pointer_safety()` will no longer be available
 // in C++03.
-#define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+#  define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
 // Define a key function for `bad_function_call` in the library, to centralize
 // its vtable and typeinfo to libc++ rather than having all other libraries
 // using that class define their own copies.
-#define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+#  define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
 // Enable optimized version of __do_get_(un)signed which avoids redundant copies.
-#define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+#  define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
 // Use the smallest possible integer type to represent the index of the variant.
 // Previously libc++ used "unsigned int" exclusivly.
-#define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+#  define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
 #elif _LIBCPP_ABI_VERSION == 1
-#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+#  if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
 // Enable compiling copies of now inline methods into the dylib to support
 // applications compiled against older libraries. This is unnecessary with
 // COFF dllexport semantics, since dllexport forces a non-inline definition
 // of inline functions to be emitted anyway. Our own non-inline copy would
 // conflict with the dllexport-emitted copy, so we disable it.
-#define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
-#endif
+#    define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
+#  endif
 // Feature macros for disabling pre ABI v1 features. All of these options
 // are deprecated.
-#if defined(__FreeBSD__)
-#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
-#endif
+#  if defined(__FreeBSD__)
+#    define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
+#  endif
 #endif
 
 #ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
@@ -116,46 +132,50 @@
 #ifndef __has_attribute
 #define __has_attribute(__x) 0
 #endif
+
 #ifndef __has_builtin
 #define __has_builtin(__x) 0
 #endif
+
 #ifndef __has_extension
 #define __has_extension(__x) 0
 #endif
+
 #ifndef __has_feature
 #define __has_feature(__x) 0
 #endif
+
 #ifndef __has_cpp_attribute
 #define __has_cpp_attribute(__x) 0
 #endif
+
 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
 // the compiler and '1' otherwise.
 #ifndef __is_identifier
 #define __is_identifier(__x) 1
 #endif
+
 #ifndef __has_declspec_attribute
 #define __has_declspec_attribute(__x) 0
 #endif
 
 #define __has_keyword(__x) !(__is_identifier(__x))
 
-#ifdef __has_include
-#define __libcpp_has_include(__x) __has_include(__x)
-#else
-#define __libcpp_has_include(__x) 0
+#ifndef __has_include
+#define __has_include(...) 0
 #endif
 
 #if defined(__clang__)
-#define _LIBCPP_COMPILER_CLANG
-# ifndef __apple_build_version__
-#   define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
-# endif
+#  define _LIBCPP_COMPILER_CLANG
+#  ifndef __apple_build_version__
+#    define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
+#  endif
 #elif defined(__GNUC__)
-#define _LIBCPP_COMPILER_GCC
+#  define _LIBCPP_COMPILER_GCC
 #elif defined(_MSC_VER)
-#define _LIBCPP_COMPILER_MSVC
+#  define _LIBCPP_COMPILER_MSVC
 #elif defined(__IBMCPP__)
-#define _LIBCPP_COMPILER_IBM
+#  define _LIBCPP_COMPILER_IBM
 #endif
 
 #ifndef _LIBCPP_CLANG_VER
@@ -168,67 +188,69 @@
 // and allow the user to explicitly specify the ABI to handle cases where this
 // heuristic falls short.
 #if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
-# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
+#  error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
 #elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
-# define _LIBCPP_ABI_ITANIUM
+#  define _LIBCPP_ABI_ITANIUM
 #elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
-# define _LIBCPP_ABI_MICROSOFT
-#else
-# if defined(_WIN32) && defined(_MSC_VER)
 #  define _LIBCPP_ABI_MICROSOFT
-# else
-#  define _LIBCPP_ABI_ITANIUM
-# endif
+#else
+#  if defined(_WIN32) && defined(_MSC_VER)
+#    define _LIBCPP_ABI_MICROSOFT
+#  else
+#    define _LIBCPP_ABI_ITANIUM
+#  endif
 #endif
 
 // Need to detect which libc we're using if we're on Linux.
 #if defined(__linux__)
-#include <features.h>
-#if !defined(__GLIBC_PREREQ)
-#define __GLIBC_PREREQ(a, b) 0
-#endif // !defined(__GLIBC_PREREQ)
+#  include <features.h>
+#  if defined(__GLIBC_PREREQ)
+#    define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
+#  else
+#    define _LIBCPP_GLIBC_PREREQ(a, b) 0
+#  endif // defined(__GLIBC_PREREQ)
 #endif // defined(__linux__)
 
 #ifdef __LITTLE_ENDIAN__
-#if __LITTLE_ENDIAN__
-#define _LIBCPP_LITTLE_ENDIAN
-#endif  // __LITTLE_ENDIAN__
+#  if __LITTLE_ENDIAN__
+#    define _LIBCPP_LITTLE_ENDIAN
+#  endif  // __LITTLE_ENDIAN__
 #endif  // __LITTLE_ENDIAN__
 
 #ifdef __BIG_ENDIAN__
-#if __BIG_ENDIAN__
-#define _LIBCPP_BIG_ENDIAN
-#endif  // __BIG_ENDIAN__
+#  if __BIG_ENDIAN__
+#    define _LIBCPP_BIG_ENDIAN
+#  endif  // __BIG_ENDIAN__
 #endif  // __BIG_ENDIAN__
 
 #ifdef __BYTE_ORDER__
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-#define _LIBCPP_LITTLE_ENDIAN
-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-#define _LIBCPP_BIG_ENDIAN
-#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#  if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#    define _LIBCPP_LITTLE_ENDIAN
+#  elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#    define _LIBCPP_BIG_ENDIAN
+#  endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 #endif // __BYTE_ORDER__
 
 #ifdef __FreeBSD__
-# include <sys/endian.h>
+#  include <sys/endian.h>
 #  if _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN
-# else  // _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_BIG_ENDIAN
-# endif  // _BYTE_ORDER == _LITTLE_ENDIAN
-# ifndef __LONG_LONG_SUPPORTED
-#  define _LIBCPP_HAS_NO_LONG_LONG
-# endif  // __LONG_LONG_SUPPORTED
+#    define _LIBCPP_LITTLE_ENDIAN
+#  else  // _BYTE_ORDER == _LITTLE_ENDIAN
+#    define _LIBCPP_BIG_ENDIAN
+#  endif  // _BYTE_ORDER == _LITTLE_ENDIAN
+#  ifndef __LONG_LONG_SUPPORTED
+#    define _LIBCPP_HAS_NO_LONG_LONG
+#  endif  // __LONG_LONG_SUPPORTED
 #endif  // __FreeBSD__
 
 #ifdef __NetBSD__
-# include <sys/endian.h>
+#  include <sys/endian.h>
 #  if _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN
-# else  // _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_BIG_ENDIAN
-# endif  // _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_HAS_QUICK_EXIT
+#    define _LIBCPP_LITTLE_ENDIAN
+#  else  // _BYTE_ORDER == _LITTLE_ENDIAN
+#    define _LIBCPP_BIG_ENDIAN
+#  endif  // _BYTE_ORDER == _LITTLE_ENDIAN
+#  define _LIBCPP_HAS_QUICK_EXIT
 #endif  // __NetBSD__
 
 #ifdef __OpenBSD__
@@ -254,64 +276,90 @@
 #  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
 #    define _LIBCPP_HAS_BITSCAN64
 #  endif
-# if defined(_LIBCPP_MSVCRT)
-#   define _LIBCPP_HAS_QUICK_EXIT
-# endif
+#  define _LIBCPP_HAS_OPEN_WITH_WCHAR
+#  if defined(_LIBCPP_MSVCRT)
+#    define _LIBCPP_HAS_QUICK_EXIT
+#  endif
 
 // Some CRT APIs are unavailable to store apps
-#if defined(WINAPI_FAMILY)
-#include <winapifamily.h>
-#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) &&                      \
-    (!defined(WINAPI_PARTITION_SYSTEM) ||                                      \
-     !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
-#define _LIBCPP_WINDOWS_STORE_APP
-#endif
-#endif
+#  if defined(WINAPI_FAMILY)
+#    include <winapifamily.h>
+#    if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) &&                  \
+        (!defined(WINAPI_PARTITION_SYSTEM) ||                                  \
+         !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
+#      define _LIBCPP_WINDOWS_STORE_APP
+#    endif
+#  endif
 #endif // defined(_WIN32)
 
 #ifdef __sun__
-# include <sys/isa_defs.h>
-# ifdef _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN
-# else
-#   define _LIBCPP_BIG_ENDIAN
-# endif
+#  include <sys/isa_defs.h>
+#  ifdef _LITTLE_ENDIAN
+#    define _LIBCPP_LITTLE_ENDIAN
+#  else
+#    define _LIBCPP_BIG_ENDIAN
+#  endif
 #endif // __sun__
 
 #if defined(__CloudABI__) || defined(__OpenBSD__)
-  // Certain architectures provide arc4random(). Prefer using
-  // arc4random() over /dev/{u,}random to make it possible to obtain
-  // random data even when using sandboxing mechanisms such as chroots,
-  // Capsicum, etc.
-# define _LIBCPP_USING_ARC4_RANDOM
+   // Certain architectures provide arc4random(). Prefer using
+   // arc4random() over /dev/{u,}random to make it possible to obtain
+   // random data even when using sandboxing mechanisms such as chroots,
+   // Capsicum, etc.
+#  define _LIBCPP_USING_ARC4_RANDOM
 #elif defined(__Fuchsia__)
-# define _LIBCPP_USING_GETENTROPY
+#  define _LIBCPP_USING_GETENTROPY
 #elif defined(__native_client__)
-  // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
-  // including accesses to the special files under /dev. C++11's
-  // std::random_device is instead exposed through a NaCl syscall.
-# define _LIBCPP_USING_NACL_RANDOM
+   // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
+   // including accesses to the special files under /dev. C++11's
+   // std::random_device is instead exposed through a NaCl syscall.
+#  define _LIBCPP_USING_NACL_RANDOM
 #elif defined(_LIBCPP_WIN32API)
-# define _LIBCPP_USING_WIN32_RANDOM
+#  define _LIBCPP_USING_WIN32_RANDOM
 #else
-# define _LIBCPP_USING_DEV_RANDOM
+#  define _LIBCPP_USING_DEV_RANDOM
 #endif
 
 #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
-# include <endian.h>
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-#  define _LIBCPP_LITTLE_ENDIAN
-# elif __BYTE_ORDER == __BIG_ENDIAN
-#  define _LIBCPP_BIG_ENDIAN
-# else  // __BYTE_ORDER == __BIG_ENDIAN
-#  error unable to determine endian
-# endif
+#  include <endian.h>
+#  if __BYTE_ORDER == __LITTLE_ENDIAN
+#    define _LIBCPP_LITTLE_ENDIAN
+#  elif __BYTE_ORDER == __BIG_ENDIAN
+#    define _LIBCPP_BIG_ENDIAN
+#  else  // __BYTE_ORDER == __BIG_ENDIAN
+#    error unable to determine endian
+#  endif
 #endif  // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
 
 #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
-#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#  define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
 #else
-#define _LIBCPP_NO_CFI
+#  define _LIBCPP_NO_CFI
+#endif
+
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#  if defined(__FreeBSD__)
+#    define _LIBCPP_HAS_QUICK_EXIT
+#    define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__Fuchsia__)
+#    define _LIBCPP_HAS_QUICK_EXIT
+#    define _LIBCPP_HAS_TIMESPEC_GET
+#    define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__linux__)
+#    if !defined(_LIBCPP_HAS_MUSL_LIBC)
+#      if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
+#        define _LIBCPP_HAS_QUICK_EXIT
+#      endif
+#      if _LIBCPP_GLIBC_PREREQ(2, 17)
+#        define _LIBCPP_HAS_C11_FEATURES
+#        define _LIBCPP_HAS_TIMESPEC_GET
+#      endif
+#    else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#      define _LIBCPP_HAS_QUICK_EXIT
+#      define _LIBCPP_HAS_TIMESPEC_GET
+#      define _LIBCPP_HAS_C11_FEATURES
+#    endif
+#  endif // __linux__
 #endif
 
 #if defined(_LIBCPP_COMPILER_CLANG)
@@ -364,11 +412,11 @@ typedef __char32_t char32_t;
 #endif
 
 #if !(__has_feature(cxx_nullptr))
-# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
-#   define nullptr __nullptr
-# else
-#   define _LIBCPP_HAS_NO_NULLPTR
-# endif
+#  if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
+#    define nullptr __nullptr
+#  else
+#    define _LIBCPP_HAS_NO_NULLPTR
+#  endif
 #endif
 
 #if !(__has_feature(cxx_rvalue_references))
@@ -388,11 +436,11 @@ typedef __char32_t char32_t;
 #endif
 
 #if __has_feature(is_base_of)
-#  define _LIBCPP_HAS_IS_BASE_OF
+#define _LIBCPP_HAS_IS_BASE_OF
 #endif
 
 #if __has_feature(is_final)
-#  define _LIBCPP_HAS_IS_FINAL
+#define _LIBCPP_HAS_IS_FINAL
 #endif
 
 // Objective-C++ features (opt-in)
@@ -416,38 +464,16 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-#if defined(__FreeBSD__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#elif defined(__Fuchsia__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#endif
-#if __GLIBC_PREREQ(2, 17)
-#define _LIBCPP_HAS_C11_FEATURES
-#endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#endif
-#endif // __linux__
-#endif
-
 #if !(__has_feature(cxx_noexcept))
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #endif
 
 #if __has_feature(underlying_type)
-#  define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
+#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
 #endif
 
 #if __has_feature(is_literal)
-#  define _LIBCPP_IS_LITERAL(T) __is_literal(T)
+#define _LIBCPP_IS_LITERAL(T) __is_literal(T)
 #endif
 
 // Inline namespaces are available in Clang regardless of C++ dialect.
@@ -467,7 +493,7 @@ namespace std {
 // Allow for build-time disabling of unsigned integer sanitization
 #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
-#endif
+#endif
 
 #if __has_builtin(__builtin_launder)
 #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
@@ -477,6 +503,8 @@ namespace std {
 #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
 #endif
 
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
 #elif defined(_LIBCPP_COMPILER_GCC)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -491,19 +519,19 @@ namespace std {
 #endif
 
 #if defined(__GNUC__) && _GNUC_VER >= 403
-#  define _LIBCPP_HAS_IS_BASE_OF
+#define _LIBCPP_HAS_IS_BASE_OF
 #endif
 
-#if !__EXCEPTIONS
+#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)
 #define _LIBCPP_NO_EXCEPTIONS
 #endif
 
 // constexpr was added to GCC in 4.6.
 #if _GNUC_VER < 406
-#define _LIBCPP_HAS_NO_CONSTEXPR
+#  define _LIBCPP_HAS_NO_CONSTEXPR
 // Can only use constexpr in c++11 mode.
 #elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
-#define _LIBCPP_HAS_NO_CONSTEXPR
+#  define _LIBCPP_HAS_NO_CONSTEXPR
 #endif
 
 // Determine if GCC supports relaxed constexpr
@@ -517,6 +545,7 @@ namespace std {
 #endif
 
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
+
 #define _LIBCPP_HAS_NO_DECLTYPE
 #define _LIBCPP_HAS_NO_NULLPTR
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
@@ -567,6 +596,8 @@ namespace std {
 #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
 #endif
 
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
 #elif defined(_LIBCPP_COMPILER_MSVC)
 
 #define _LIBCPP_TOSTRING2(x) #x
@@ -581,25 +612,28 @@ namespace std {
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
-#if _MSC_VER <= 1800
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#endif
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
 #define _ALIGNAS(x) __declspec(align(x))
+#define _ALIGNAS_TYPE(x) alignas(x)
 #define _LIBCPP_HAS_NO_VARIADICS
 
 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
 #define _LIBCPP_END_NAMESPACE_STD  }
 #define _VSTD std
 
-#  define _LIBCPP_WEAK
 namespace std {
 }
 
+#define _LIBCPP_WEAK
+
 #define _LIBCPP_HAS_NO_ASAN
 
+#define _LIBCPP_ALWAYS_INLINE __forceinline
+
+#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
 #elif defined(_LIBCPP_COMPILER_IBM)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -630,24 +664,49 @@ namespace std {
 
 #define _LIBCPP_HAS_NO_ASAN
 
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
+#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
 
+#if _LIBCPP_STD_VER >= 17
+#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
+  _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
+#else
+#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
+  _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
+#endif
+
+#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
+  _LIBCPP_END_NAMESPACE_STD } }
+
+#define _VSTD_FS _VSTD::__fs::filesystem
+
+
 #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
+
+#ifdef _DLL
+#  define _LIBCPP_CRT_FUNC __declspec(dllimport)
+#else
+#  define _LIBCPP_CRT_FUNC
+#endif
+
 #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_DLL_VIS
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+#  define _LIBCPP_DLL_VIS
+#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+#  define _LIBCPP_OVERRIDABLE_FUNC_VIS
 #elif defined(_LIBCPP_BUILDING_LIBRARY)
-# define _LIBCPP_DLL_VIS __declspec(dllexport)
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
+#  define _LIBCPP_DLL_VIS __declspec(dllexport)
+#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
+#  define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
 #else
-# define _LIBCPP_DLL_VIS __declspec(dllimport)
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+#  define _LIBCPP_DLL_VIS __declspec(dllimport)
+#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
+#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+#  define _LIBCPP_OVERRIDABLE_FUNC_VIS
 #endif
 
 #define _LIBCPP_TYPE_VIS            _LIBCPP_DLL_VIS
@@ -660,39 +719,36 @@ namespace std {
 #define _LIBCPP_ENUM_VIS
 
 #if defined(_LIBCPP_COMPILER_MSVC)
-# define _LIBCPP_INLINE_VISIBILITY __forceinline
-# define _LIBCPP_ALWAYS_INLINE     __forceinline
-# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#  define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
 #else
-# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
-# define _LIBCPP_ALWAYS_INLINE     __attribute__ ((__always_inline__))
-# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+#  define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
 #endif
+
 #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
 
 #ifndef _LIBCPP_HIDDEN
-#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
-#else
-#define _LIBCPP_HIDDEN
-#endif
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#    define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
+#  else
+#    define _LIBCPP_HIDDEN
+#  endif
 #endif
 
 #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
-#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 // The inline should be removed once PR32114 is resolved
-#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
-#else
-#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
-#endif
+#    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
+#  else
+#    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+#  endif
 #endif
 
 #ifndef _LIBCPP_FUNC_VIS
-#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
-#else
-#define _LIBCPP_FUNC_VIS
-#endif
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#    define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
+#  else
+#    define _LIBCPP_FUNC_VIS
+#  endif
 #endif
 
 #ifndef _LIBCPP_TYPE_VIS
@@ -716,19 +772,19 @@ namespace std {
 #endif
 
 #ifndef _LIBCPP_EXTERN_VIS
-# define _LIBCPP_EXTERN_VIS
+#define _LIBCPP_EXTERN_VIS
 #endif
 
 #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
+#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
 #endif
 
 #ifndef _LIBCPP_EXCEPTION_ABI
-#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
-#else
-#define _LIBCPP_EXCEPTION_ABI
-#endif
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#    define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
+#  else
+#    define _LIBCPP_EXCEPTION_ABI
+#  endif
 #endif
 
 #ifndef _LIBCPP_ENUM_VIS
@@ -748,31 +804,40 @@ namespace std {
 #endif
 
 #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
 #endif
 
-#ifndef _LIBCPP_INLINE_VISIBILITY
-#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
+#if __has_attribute(internal_linkage)
+#  define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
 #else
-#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
-#endif
+#  define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
 #endif
 
-#ifndef _LIBCPP_ALWAYS_INLINE
-#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
-#else
-#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__always_inline__))
+#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
+#  ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
+#    define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
+#  else
+#    define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
+#  endif
 #endif
+
+#ifndef _LIBCPP_HIDE_FROM_ABI
+#  if _LIBCPP_HIDE_FROM_ABI_PER_TU
+#    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+#  else
+#    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE
+#  endif
 #endif
 
+// Just so we can migrate to _LIBCPP_HIDE_FROM_ABI gradually.
+#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
+
 #ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#  define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
-# else
-#  define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__))
-# endif
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#    define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
+#  else
+#    define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__))
+#  endif
 #endif
 
 #ifndef _LIBCPP_PREFERRED_OVERLOAD
@@ -790,14 +855,19 @@ namespace std {
 #endif
 
 #if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
-# if !defined(_LIBCPP_DEBUG)
-#   error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
-# endif
-# define _NOEXCEPT_DEBUG noexcept(false)
-# define _NOEXCEPT_DEBUG_(x) noexcept(false)
+#  if !defined(_LIBCPP_DEBUG)
+#    error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
+#  endif
+#  ifdef _LIBCPP_HAS_NO_NOEXCEPT
+#    define _NOEXCEPT_DEBUG
+#    define _NOEXCEPT_DEBUG_(x)
+#  else
+#    define _NOEXCEPT_DEBUG noexcept(false)
+#    define _NOEXCEPT_DEBUG_(x) noexcept(false)
+#  endif
 #else
-# define _NOEXCEPT_DEBUG _NOEXCEPT
-# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
+#  define _NOEXCEPT_DEBUG _NOEXCEPT
+#  define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
 #endif
 
 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
@@ -810,88 +880,88 @@ typedef unsigned int   char32_t;
 #endif
 
 #ifdef _LIBCPP_CXX03_LANG
-# if __has_extension(c_static_assert)
-#   define static_assert(__b, __m) _Static_assert(__b, __m)
-# else
+#  if __has_extension(c_static_assert)
+#    define static_assert(__b, __m) _Static_assert(__b, __m)
+#  else
 extern "C++" {
 template <bool> struct __static_assert_test;
 template <> struct __static_assert_test<true> {};
 template <unsigned> struct __static_assert_check {};
 }
-#define static_assert(__b, __m) \
-    typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
-    _LIBCPP_CONCAT(__t, __LINE__)
-# endif // __has_extension(c_static_assert)
+#    define static_assert(__b, __m) \
+       typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
+       _LIBCPP_CONCAT(__t, __LINE__)
+#  endif // __has_extension(c_static_assert)
 #endif  // _LIBCPP_CXX03_LANG
 
 #ifdef _LIBCPP_HAS_NO_DECLTYPE
 // GCC 4.6 provides __decltype in all standard modes.
-#if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406
-#  define decltype(__x) __decltype(__x)
-#else
-#  define decltype(__x) __typeof__(__x)
-#endif
+#  if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406
+#    define decltype(__x) __decltype(__x)
+#  else
+#    define decltype(__x) __typeof__(__x)
+#  endif
 #endif
 
 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
-#define _LIBCPP_CONSTEXPR
+#  define _LIBCPP_CONSTEXPR
 #else
-#define _LIBCPP_CONSTEXPR constexpr
+#  define _LIBCPP_CONSTEXPR constexpr
 #endif
 
 #ifdef _LIBCPP_CXX03_LANG
-#define _LIBCPP_DEFAULT {}
+#  define _LIBCPP_DEFAULT {}
 #else
-#define _LIBCPP_DEFAULT = default;
+#  define _LIBCPP_DEFAULT = default;
 #endif
 
 #ifdef _LIBCPP_CXX03_LANG
-#define _LIBCPP_EQUAL_DELETE
+#  define _LIBCPP_EQUAL_DELETE
 #else
-#define _LIBCPP_EQUAL_DELETE = delete
+#  define _LIBCPP_EQUAL_DELETE = delete
 #endif
 
 #ifdef __GNUC__
-#define _NOALIAS __attribute__((__malloc__))
+#  define _NOALIAS __attribute__((__malloc__))
 #else
-#define _NOALIAS
+#  define _NOALIAS
 #endif
 
 #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
     (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
-#   define _LIBCPP_EXPLICIT explicit
+#  define _LIBCPP_EXPLICIT explicit
 #else
-#   define _LIBCPP_EXPLICIT
+#  define _LIBCPP_EXPLICIT
 #endif
 
 #if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
-#   define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
+#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
 #endif
 
 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
-#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
-    __lx __v_; \
-    _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
-    _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
-    _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
-    };
+#  define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
+#  define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
+     __lx __v_; \
+     _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
+     _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
+     _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
+     };
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
-#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
+#  define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
+#  define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
 #endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
 
 #ifdef _LIBCPP_DEBUG
-#   if _LIBCPP_DEBUG == 0
-#       define _LIBCPP_DEBUG_LEVEL 1
-#   elif _LIBCPP_DEBUG == 1
-#       define _LIBCPP_DEBUG_LEVEL 2
-#   else
-#       error Supported values for _LIBCPP_DEBUG are 0 and 1
-#   endif
-# if !defined(_LIBCPP_BUILDING_LIBRARY)
-#   define _LIBCPP_EXTERN_TEMPLATE(...)
-# endif
+#  if _LIBCPP_DEBUG == 0
+#    define _LIBCPP_DEBUG_LEVEL 1
+#  elif _LIBCPP_DEBUG == 1
+#    define _LIBCPP_DEBUG_LEVEL 2
+#  else
+#    error Supported values for _LIBCPP_DEBUG are 0 and 1
+#  endif
+#  if !defined(_LIBCPP_BUILDING_LIBRARY)
+#    define _LIBCPP_EXTERN_TEMPLATE(...)
+#  endif
 #endif
 
 #ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
@@ -918,27 +988,39 @@ template <unsigned> struct __static_assert_check {};
 
 #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 // Most unix variants have catopen.  These are the specific ones that don't.
-#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
-#define _LIBCPP_HAS_CATOPEN 1
-#endif
+#  if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
+#    define _LIBCPP_HAS_CATOPEN 1
+#  endif
 #endif
 
 #ifdef __FreeBSD__
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
 
+// If we are getting operator new from the MSVC CRT, then allocation overloads
+// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
+#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+#define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
+
 #if defined(__APPLE__)
-# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
-     defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
-#   define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
-# endif
-# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
-#   if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
-#     define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-#   endif
-# endif
+#  if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
+      defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
+#    define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
+#  endif
+#  if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+#    if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+#      define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#    endif
+#  endif
 #endif // defined(__APPLE__)
 
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
+    !defined(_LIBCPP_BUILDING_LIBRARY) && \
+    (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
+#  define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
+
 #if defined(__APPLE__) || defined(__FreeBSD__)
 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
 #endif
@@ -947,60 +1029,48 @@ template <unsigned> struct __static_assert_check {};
 #define _LIBCPP_WCTYPE_IS_MASK
 #endif
 
-#ifndef _LIBCPP_STD_VER
-#  if  __cplusplus <= 201103L
-#    define _LIBCPP_STD_VER 11
-#  elif __cplusplus <= 201402L
-#    define _LIBCPP_STD_VER 14
-#  elif __cplusplus <= 201703L
-#    define _LIBCPP_STD_VER 17
-#  else
-#    define _LIBCPP_STD_VER 18  // current year, or date of c++2a ratification
-#  endif
-#endif  // _LIBCPP_STD_VER
-
 #if _LIBCPP_STD_VER > 11
-#define _LIBCPP_DEPRECATED [[deprecated]]
+#  define _LIBCPP_DEPRECATED [[deprecated]]
 #else
-#define _LIBCPP_DEPRECATED
+#  define _LIBCPP_DEPRECATED
 #endif
 
 #if _LIBCPP_STD_VER <= 11
-#define _LIBCPP_EXPLICIT_AFTER_CXX11
-#define _LIBCPP_DEPRECATED_AFTER_CXX11
+#  define _LIBCPP_EXPLICIT_AFTER_CXX11
+#  define _LIBCPP_DEPRECATED_AFTER_CXX11
 #else
-#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
-#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
+#  define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
+#  define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
 #endif
 
 #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
-#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
+#  define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
 #else
-#define _LIBCPP_CONSTEXPR_AFTER_CXX11
+#  define _LIBCPP_CONSTEXPR_AFTER_CXX11
 #endif
 
 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
-#define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
+#  define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
 #else
-#define _LIBCPP_CONSTEXPR_AFTER_CXX14
+#  define _LIBCPP_CONSTEXPR_AFTER_CXX14
 #endif
 
 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
-#define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
+#  define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
 #else
-#define _LIBCPP_CONSTEXPR_AFTER_CXX17
+#  define _LIBCPP_CONSTEXPR_AFTER_CXX17
 #endif
 
 #if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17)
-#define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
+#  define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
 #else
-#define _LIBCPP_NODISCARD_AFTER_CXX17
+#  define _LIBCPP_NODISCARD_AFTER_CXX17
 #endif
 
 #if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
-# define _LIBCPP_INLINE_VAR  inline
+#  define _LIBCPP_INLINE_VAR inline
 #else
-# define _LIBCPP_INLINE_VAR  
+#  define _LIBCPP_INLINE_VAR
 #endif
 
 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1009,6 +1079,14 @@ template <unsigned> struct __static_assert_check {};
 #  define _LIBCPP_EXPLICIT_MOVE(x) (x)
 #endif
 
+#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
+#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#define _LIBCPP_CONSTEXPR_IF_NODEBUG
+#else
+#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
+#endif
+#endif
+
 #ifndef _LIBCPP_HAS_NO_ASAN
 _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
   const void *, const void *, const void *, const void *);
@@ -1018,8 +1096,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
 // g++ and cl.exe have RTTI on by default and define a macro when it is.
 // g++ only defines the macro in 4.3.2 and onwards.
 #if !defined(_LIBCPP_NO_RTTI)
-#  if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
-   (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
+#  if defined(__GNUC__) && \
+      ((__GNUC__ >= 5) || \
+       (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \
+      !defined(__GXX_RTTI)
 #    define _LIBCPP_NO_RTTI
 #  elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
 #    define _LIBCPP_NO_RTTI
@@ -1027,7 +1107,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
 #endif
 
 #ifndef _LIBCPP_WEAK
-#  define _LIBCPP_WEAK __attribute__((__weak__))
+#define _LIBCPP_WEAK __attribute__((__weak__))
 #endif
 
 // Thread API
@@ -1035,36 +1115,36 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
     !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
     !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
     !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-# if defined(__FreeBSD__) || \
-    defined(__Fuchsia__) || \
-    defined(__NetBSD__) || \
-    defined(__linux__) || \
-    defined(__APPLE__) || \
-    defined(__CloudABI__) || \
-    defined(__sun__) || \
-    (defined(__MINGW32__) && __libcpp_has_include(<pthread.h>)) || \
-    defined(__OpenBSD__)
-#   define _LIBCPP_HAS_THREAD_API_PTHREAD
-# elif defined(_LIBCPP_WIN32API)
-#  define _LIBCPP_HAS_THREAD_API_WIN32
-# else
-#  error "No thread API"
-# endif // _LIBCPP_HAS_THREAD_API
+#  if defined(__FreeBSD__) || \
+      defined(__Fuchsia__) || \
+      defined(__NetBSD__) || \
+      defined(__linux__) || \
+      defined(__APPLE__) || \
+      defined(__CloudABI__) || \
+      defined(__sun__) || \
+      (defined(__MINGW32__) && __has_include(<pthread.h>)) || \
+      defined(__OpenBSD__)
+#    define _LIBCPP_HAS_THREAD_API_PTHREAD
+#  elif defined(_LIBCPP_WIN32API)
+#    define _LIBCPP_HAS_THREAD_API_WIN32
+#  else
+#    error "No thread API"
+#  endif // _LIBCPP_HAS_THREAD_API
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
-#  error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
-         _LIBCPP_HAS_NO_THREADS is not defined.
+#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
+       _LIBCPP_HAS_NO_THREADS is not defined.
 #endif
 
 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-#  error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
-         _LIBCPP_HAS_NO_THREADS is defined.
+#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
+       _LIBCPP_HAS_NO_THREADS is defined.
 #endif
 
 #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
-#  error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
-         _LIBCPP_HAS_NO_THREADS is defined.
+#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
+       _LIBCPP_HAS_NO_THREADS is defined.
 #endif
 
 // Systems that use capability-based security (FreeBSD with Capsicum,
@@ -1095,9 +1175,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
 #endif
 
 #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
-#define _LIBCPP_HAS_C_ATOMIC_IMP
+#  define _LIBCPP_HAS_C_ATOMIC_IMP
 #elif _GNUC_VER > 407
-#define _LIBCPP_HAS_GCC_ATOMIC_IMP
+#  define _LIBCPP_HAS_GCC_ATOMIC_IMP
 #endif
 
 #if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
@@ -1110,139 +1190,144 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
 #endif
 
 #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
-#if defined(__clang__) && __has_attribute(acquire_capability)
+#  if defined(__clang__) && __has_attribute(acquire_capability)
 // Work around the attribute handling in clang.  When both __declspec and
 // __attribute__ are present, the processing goes awry preventing the definition
 // of the types.
-#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
-#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
-#endif
-#endif
+#    if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+#      define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#    endif
+#  endif
 #endif
 
 #if __has_attribute(require_constant_initialization)
-#define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
+#  define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
 #else
-#define _LIBCPP_SAFE_STATIC
+#  define _LIBCPP_SAFE_STATIC
 #endif
 
 #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
-# define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
+#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
 #endif
 
 #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
-#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
-#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
-#endif
+#  if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
+#    define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
+#  endif
 #endif
 
 #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
-# define _LIBCPP_DIAGNOSE_WARNING(...) \
-    __attribute__((diagnose_if(__VA_ARGS__, "warning")))
-# define _LIBCPP_DIAGNOSE_ERROR(...) \
-    __attribute__((diagnose_if(__VA_ARGS__, "error")))
+#  define _LIBCPP_DIAGNOSE_WARNING(...) \
+     __attribute__((diagnose_if(__VA_ARGS__, "warning")))
+#  define _LIBCPP_DIAGNOSE_ERROR(...) \
+     __attribute__((diagnose_if(__VA_ARGS__, "error")))
 #else
-# define _LIBCPP_DIAGNOSE_WARNING(...)
-# define _LIBCPP_DIAGNOSE_ERROR(...)
+#  define _LIBCPP_DIAGNOSE_WARNING(...)
+#  define _LIBCPP_DIAGNOSE_ERROR(...)
 #endif
 
 #if __has_attribute(fallthough) || _GNUC_VER >= 700
 // Use a function like macro to imply that it must be followed by a semicolon
-#define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
+#  define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
 #else
-#define _LIBCPP_FALLTHROUGH() ((void)0)
+#  define _LIBCPP_FALLTHROUGH() ((void)0)
 #endif
 
 #if defined(_LIBCPP_ABI_MICROSOFT) && \
-   (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
-# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
+    (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
+#  define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
 #else
-# define _LIBCPP_DECLSPEC_EMPTY_BASES
+#  define _LIBCPP_DECLSPEC_EMPTY_BASES
 #endif
 
 #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
-# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
-# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
-# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
+#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
+#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
 #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
 
 #if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
-# define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
 #endif
 
 #if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
-# define _LIBCPP_HAS_NO_IS_AGGREGATE
+#define _LIBCPP_HAS_NO_IS_AGGREGATE
 #endif
 
 #if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
-# define _LIBCPP_HAS_NO_COROUTINES
+#define _LIBCPP_HAS_NO_COROUTINES
 #endif
 
+// FIXME: Correct this macro when either (A) a feature test macro for the
+// spaceship operator is provided, or (B) a compiler provides a complete
+// implementation.
+#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+
 // Decide whether to use availability macros.
 #if !defined(_LIBCPP_BUILDING_LIBRARY) &&                                      \
     !defined(_LIBCPP_DISABLE_AVAILABILITY) &&                                  \
     __has_feature(attribute_availability_with_strict) &&                       \
     __has_feature(attribute_availability_in_templates)
-#ifdef __APPLE__
-#define _LIBCPP_USE_AVAILABILITY_APPLE
-#endif
+#  ifdef __APPLE__
+#    define _LIBCPP_USE_AVAILABILITY_APPLE
+#  endif
 #endif
 
 // Define availability macros.
 #if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
-#define _LIBCPP_AVAILABILITY_SHARED_MUTEX                                      \
-  __attribute__((availability(macosx,strict,introduced=10.12)))                \
-  __attribute__((availability(ios,strict,introduced=10.0)))                    \
-  __attribute__((availability(tvos,strict,introduced=10.0)))                   \
-  __attribute__((availability(watchos,strict,introduced=3.0)))
-#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
-#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable))
-#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable))
-#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS                               \
-  __attribute__((availability(macosx,strict,introduced=10.12)))                \
-  __attribute__((availability(ios,strict,introduced=10.0)))                    \
-  __attribute__((availability(tvos,strict,introduced=10.0)))                   \
-  __attribute__((availability(watchos,strict,introduced=3.0)))
-#define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE                                  \
-  __attribute__((availability(macosx,strict,introduced=10.12)))                \
-  __attribute__((availability(ios,strict,introduced=10.0)))                    \
-  __attribute__((availability(tvos,strict,introduced=10.0)))                   \
-  __attribute__((availability(watchos,strict,introduced=3.0)))
-#define _LIBCPP_AVAILABILITY_FUTURE_ERROR                                      \
-  __attribute__((availability(ios,strict,introduced=6.0)))
-#define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE                                   \
-  __attribute__((availability(macosx,strict,introduced=10.9)))                 \
-  __attribute__((availability(ios,strict,introduced=7.0)))
-#define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY                                   \
-  __attribute__((availability(macosx,strict,introduced=10.9)))                 \
-  __attribute__((availability(ios,strict,introduced=7.0)))
-#define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR                                 \
-  __attribute__((availability(macosx,strict,introduced=10.9)))                 \
-  __attribute__((availability(ios,strict,introduced=7.0)))
+#  define _LIBCPP_AVAILABILITY_SHARED_MUTEX                                    \
+     __attribute__((availability(macosx,strict,introduced=10.12)))             \
+     __attribute__((availability(ios,strict,introduced=10.0)))                 \
+     __attribute__((availability(tvos,strict,introduced=10.0)))                \
+     __attribute__((availability(watchos,strict,introduced=3.0)))
+#  define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
+#  define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable))
+#  define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable))
+#  define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS                             \
+     __attribute__((availability(macosx,strict,introduced=10.12)))             \
+     __attribute__((availability(ios,strict,introduced=10.0)))                 \
+     __attribute__((availability(tvos,strict,introduced=10.0)))                \
+     __attribute__((availability(watchos,strict,introduced=3.0)))
+#  define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE                                \
+     __attribute__((availability(macosx,strict,introduced=10.12)))             \
+     __attribute__((availability(ios,strict,introduced=10.0)))                 \
+     __attribute__((availability(tvos,strict,introduced=10.0)))                \
+     __attribute__((availability(watchos,strict,introduced=3.0)))
+#  define _LIBCPP_AVAILABILITY_FUTURE_ERROR                                    \
+     __attribute__((availability(ios,strict,introduced=6.0)))
+#  define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE                                 \
+     __attribute__((availability(macosx,strict,introduced=10.9)))              \
+     __attribute__((availability(ios,strict,introduced=7.0)))
+#  define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY                                 \
+     __attribute__((availability(macosx,strict,introduced=10.9)))              \
+     __attribute__((availability(ios,strict,introduced=7.0)))
+#  define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR                               \
+     __attribute__((availability(macosx,strict,introduced=10.9)))              \
+     __attribute__((availability(ios,strict,introduced=7.0)))
 #else
-#define _LIBCPP_AVAILABILITY_SHARED_MUTEX
-#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
-#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
-#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
-#define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
-#define _LIBCPP_AVAILABILITY_FUTURE_ERROR
-#define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
-#define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
-#define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+#  define _LIBCPP_AVAILABILITY_SHARED_MUTEX
+#  define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+#  define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
+#  define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+#  define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
+#  define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
+#  define _LIBCPP_AVAILABILITY_FUTURE_ERROR
+#  define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
+#  define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
+#  define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
 #endif
 
 // Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
 #ifdef _LIBCPP_NO_EXCEPTIONS
-#define _LIBCPP_AVAILABILITY_DYNARRAY
-#define _LIBCPP_AVAILABILITY_FUTURE
-#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
+#  define _LIBCPP_AVAILABILITY_DYNARRAY
+#  define _LIBCPP_AVAILABILITY_FUTURE
+#  define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
 #else
-#define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
-#define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
-#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST                                \
-  _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+#  define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
+#  define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
+#  define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST                              \
+     _LIBCPP_AVAILABILITY_BAD_ANY_CAST
 #endif
 
 // Availability of stream API in the dylib got dropped and re-added.  The
@@ -1262,38 +1347,40 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
 #endif
 
 #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
-# define _LIBCPP_PUSH_MACROS
-# define _LIBCPP_POP_MACROS
+#  define _LIBCPP_PUSH_MACROS
+#  define _LIBCPP_POP_MACROS
 #else
   // Don't warn about macro conflicts when we can restore them at the
   // end of the header.
-# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
-#   define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
-# endif
-# if defined(_LIBCPP_COMPILER_MSVC)
-#   define _LIBCPP_PUSH_MACROS    \
-      __pragma(push_macro("min")) \
-      __pragma(push_macro("max"))
-#   define _LIBCPP_POP_MACROS     \
-      __pragma(pop_macro("min"))  \
-      __pragma(pop_macro("max"))
-# else
-#   define _LIBCPP_PUSH_MACROS        \
-      _Pragma("push_macro(\"min\")")  \
-      _Pragma("push_macro(\"max\")")
-#   define _LIBCPP_POP_MACROS         \
-      _Pragma("pop_macro(\"min\")")   \
-      _Pragma("pop_macro(\"max\")")
-# endif
+#  ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
+#    define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
+#  endif
+#  if defined(_LIBCPP_COMPILER_MSVC)
+#    define _LIBCPP_PUSH_MACROS    \
+       __pragma(push_macro("min")) \
+       __pragma(push_macro("max"))
+#    define _LIBCPP_POP_MACROS     \
+       __pragma(pop_macro("min"))  \
+       __pragma(pop_macro("max"))
+#  else
+#    define _LIBCPP_PUSH_MACROS        \
+       _Pragma("push_macro(\"min\")")  \
+       _Pragma("push_macro(\"max\")")
+#    define _LIBCPP_POP_MACROS         \
+       _Pragma("pop_macro(\"min\")")   \
+       _Pragma("pop_macro(\"max\")")
+#  endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
 
-#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
-# if defined(_DLL)
-#   pragma(lib, "c++.lib")
-# else
-#   pragma(lib, "libc++.lib")
-# endif
-#endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#ifndef _LIBCPP_NO_AUTO_LINK
+#  if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#    if defined(_DLL)
+#      pragma comment(lib, "c++.lib")
+#    else
+#      pragma comment(lib, "libc++.lib")
+#    endif
+#  endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#endif // _LIBCPP_NO_AUTO_LINK
 
 #endif // __cplusplus
 
diff --git lib/libcxx/include/__config_site.in lib/libcxx/include/__config_site.in
index 86418a3e17b..7c7c226c492 100644
--- lib/libcxx/include/__config_site.in
+++ lib/libcxx/include/__config_site.in
@@ -14,6 +14,7 @@
 #cmakedefine _LIBCPP_ABI_UNSTABLE
 #cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
 #cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
+#cmakedefine _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
 #cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 #cmakedefine _LIBCPP_HAS_NO_STDIN
 #cmakedefine _LIBCPP_HAS_NO_STDOUT
@@ -23,6 +24,7 @@
 #cmakedefine _LIBCPP_HAS_MUSL_LIBC
 #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
+#cmakedefine _LIBCPP_HAS_THREAD_API_WIN32
 #cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
 #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
 #cmakedefine _LIBCPP_NO_VCRUNTIME
diff --git lib/libcxx/include/__errc lib/libcxx/include/__errc
new file mode 100644
index 00000000000..d0f00b7f0be
--- /dev/null
+++ lib/libcxx/include/__errc
@@ -0,0 +1,218 @@
+// -*- C++ -*-
+//===---------------------------- __errc ----------------------------------===//
+//
+//                     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___ERRC
+#define _LIBCPP___ERRC
+
+/*
+    system_error synopsis
+
+namespace std
+{
+
+enum class errc
+{
+    address_family_not_supported,       // EAFNOSUPPORT
+    address_in_use,                     // EADDRINUSE
+    address_not_available,              // EADDRNOTAVAIL
+    already_connected,                  // EISCONN
+    argument_list_too_long,             // E2BIG
+    argument_out_of_domain,             // EDOM
+    bad_address,                        // EFAULT
+    bad_file_descriptor,                // EBADF
+    bad_message,                        // EBADMSG
+    broken_pipe,                        // EPIPE
+    connection_aborted,                 // ECONNABORTED
+    connection_already_in_progress,     // EALREADY
+    connection_refused,                 // ECONNREFUSED
+    connection_reset,                   // ECONNRESET
+    cross_device_link,                  // EXDEV
+    destination_address_required,       // EDESTADDRREQ
+    device_or_resource_busy,            // EBUSY
+    directory_not_empty,                // ENOTEMPTY
+    executable_format_error,            // ENOEXEC
+    file_exists,                        // EEXIST
+    file_too_large,                     // EFBIG
+    filename_too_long,                  // ENAMETOOLONG
+    function_not_supported,             // ENOSYS
+    host_unreachable,                   // EHOSTUNREACH
+    identifier_removed,                 // EIDRM
+    illegal_byte_sequence,              // EILSEQ
+    inappropriate_io_control_operation, // ENOTTY
+    interrupted,                        // EINTR
+    invalid_argument,                   // EINVAL
+    invalid_seek,                       // ESPIPE
+    io_error,                           // EIO
+    is_a_directory,                     // EISDIR
+    message_size,                       // EMSGSIZE
+    network_down,                       // ENETDOWN
+    network_reset,                      // ENETRESET
+    network_unreachable,                // ENETUNREACH
+    no_buffer_space,                    // ENOBUFS
+    no_child_process,                   // ECHILD
+    no_link,                            // ENOLINK
+    no_lock_available,                  // ENOLCK
+    no_message_available,               // ENODATA
+    no_message,                         // ENOMSG
+    no_protocol_option,                 // ENOPROTOOPT
+    no_space_on_device,                 // ENOSPC
+    no_stream_resources,                // ENOSR
+    no_such_device_or_address,          // ENXIO
+    no_such_device,                     // ENODEV
+    no_such_file_or_directory,          // ENOENT
+    no_such_process,                    // ESRCH
+    not_a_directory,                    // ENOTDIR
+    not_a_socket,                       // ENOTSOCK
+    not_a_stream,                       // ENOSTR
+    not_connected,                      // ENOTCONN
+    not_enough_memory,                  // ENOMEM
+    not_supported,                      // ENOTSUP
+    operation_canceled,                 // ECANCELED
+    operation_in_progress,              // EINPROGRESS
+    operation_not_permitted,            // EPERM
+    operation_not_supported,            // EOPNOTSUPP
+    operation_would_block,              // EWOULDBLOCK
+    owner_dead,                         // EOWNERDEAD
+    permission_denied,                  // EACCES
+    protocol_error,                     // EPROTO
+    protocol_not_supported,             // EPROTONOSUPPORT
+    read_only_file_system,              // EROFS
+    resource_deadlock_would_occur,      // EDEADLK
+    resource_unavailable_try_again,     // EAGAIN
+    result_out_of_range,                // ERANGE
+    state_not_recoverable,              // ENOTRECOVERABLE
+    stream_timeout,                     // ETIME
+    text_file_busy,                     // ETXTBSY
+    timed_out,                          // ETIMEDOUT
+    too_many_files_open_in_system,      // ENFILE
+    too_many_files_open,                // EMFILE
+    too_many_links,                     // EMLINK
+    too_many_symbolic_link_levels,      // ELOOP
+    value_too_large,                    // EOVERFLOW
+    wrong_protocol_type                 // EPROTOTYPE
+};
+
+*/
+
+#include <__config>
+#include <cerrno>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Some error codes are not present on all platforms, so we provide equivalents
+// for them:
+
+//enum class errc
+_LIBCPP_DECLARE_STRONG_ENUM(errc)
+{
+    address_family_not_supported        = EAFNOSUPPORT,
+    address_in_use                      = EADDRINUSE,
+    address_not_available               = EADDRNOTAVAIL,
+    already_connected                   = EISCONN,
+    argument_list_too_long              = E2BIG,
+    argument_out_of_domain              = EDOM,
+    bad_address                         = EFAULT,
+    bad_file_descriptor                 = EBADF,
+    bad_message                         = EBADMSG,
+    broken_pipe                         = EPIPE,
+    connection_aborted                  = ECONNABORTED,
+    connection_already_in_progress      = EALREADY,
+    connection_refused                  = ECONNREFUSED,
+    connection_reset                    = ECONNRESET,
+    cross_device_link                   = EXDEV,
+    destination_address_required        = EDESTADDRREQ,
+    device_or_resource_busy             = EBUSY,
+    directory_not_empty                 = ENOTEMPTY,
+    executable_format_error             = ENOEXEC,
+    file_exists                         = EEXIST,
+    file_too_large                      = EFBIG,
+    filename_too_long                   = ENAMETOOLONG,
+    function_not_supported              = ENOSYS,
+    host_unreachable                    = EHOSTUNREACH,
+    identifier_removed                  = EIDRM,
+    illegal_byte_sequence               = EILSEQ,
+    inappropriate_io_control_operation  = ENOTTY,
+    interrupted                         = EINTR,
+    invalid_argument                    = EINVAL,
+    invalid_seek                        = ESPIPE,
+    io_error                            = EIO,
+    is_a_directory                      = EISDIR,
+    message_size                        = EMSGSIZE,
+    network_down                        = ENETDOWN,
+    network_reset                       = ENETRESET,
+    network_unreachable                 = ENETUNREACH,
+    no_buffer_space                     = ENOBUFS,
+    no_child_process                    = ECHILD,
+    no_link                             = ENOLINK,
+    no_lock_available                   = ENOLCK,
+#ifdef ENODATA
+    no_message_available                = ENODATA,
+#else
+    no_message_available                = ENOMSG,
+#endif
+    no_message                          = ENOMSG,
+    no_protocol_option                  = ENOPROTOOPT,
+    no_space_on_device                  = ENOSPC,
+#ifdef ENOSR
+    no_stream_resources                 = ENOSR,
+#else
+    no_stream_resources                 = ENOMEM,
+#endif
+    no_such_device_or_address           = ENXIO,
+    no_such_device                      = ENODEV,
+    no_such_file_or_directory           = ENOENT,
+    no_such_process                     = ESRCH,
+    not_a_directory                     = ENOTDIR,
+    not_a_socket                        = ENOTSOCK,
+#ifdef ENOSTR
+    not_a_stream                        = ENOSTR,
+#else
+    not_a_stream                        = EINVAL,
+#endif
+    not_connected                       = ENOTCONN,
+    not_enough_memory                   = ENOMEM,
+    not_supported                       = ENOTSUP,
+    operation_canceled                  = ECANCELED,
+    operation_in_progress               = EINPROGRESS,
+    operation_not_permitted             = EPERM,
+    operation_not_supported             = EOPNOTSUPP,
+    operation_would_block               = EWOULDBLOCK,
+    owner_dead                          = EOWNERDEAD,
+    permission_denied                   = EACCES,
+    protocol_error                      = EPROTO,
+    protocol_not_supported              = EPROTONOSUPPORT,
+    read_only_file_system               = EROFS,
+    resource_deadlock_would_occur       = EDEADLK,
+    resource_unavailable_try_again      = EAGAIN,
+    result_out_of_range                 = ERANGE,
+    state_not_recoverable               = ENOTRECOVERABLE,
+#ifdef ETIME
+    stream_timeout                      = ETIME,
+#else
+    stream_timeout                      = ETIMEDOUT,
+#endif
+    text_file_busy                      = ETXTBSY,
+    timed_out                           = ETIMEDOUT,
+    too_many_files_open_in_system       = ENFILE,
+    too_many_files_open                 = EMFILE,
+    too_many_links                      = EMLINK,
+    too_many_symbolic_link_levels       = ELOOP,
+    value_too_large                     = EOVERFLOW,
+    wrong_protocol_type                 = EPROTOTYPE
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP___ERRC
diff --git lib/libcxx/include/__functional_03 lib/libcxx/include/__functional_03
index 13d8a3d9600..0a3bfbaa3d2 100644
--- lib/libcxx/include/__functional_03
+++ lib/libcxx/include/__functional_03
@@ -600,7 +600,10 @@ template<class _Rp>
 function<_Rp()>&
 function<_Rp()>::operator=(const function& __f)
 {
-    function(__f).swap(*this);
+    if (__f)
+        function(__f).swap(*this);
+    else
+        *this = nullptr;
     return *this;
 }
 
@@ -608,11 +611,12 @@ template<class _Rp>
 function<_Rp()>&
 function<_Rp()>::operator=(nullptr_t)
 {
-    if (__f_ == (__base*)&__buf_)
-        __f_->destroy();
-    else if (__f_)
-        __f_->destroy_deallocate();
+    __base* __t = __f_;
     __f_ = 0;
+    if (__t == (__base*)&__buf_)
+        __t->destroy();
+    else if (__t)
+        __t->destroy_deallocate();
     return *this;
 }
 
@@ -876,7 +880,10 @@ template<class _Rp, class _A0>
 function<_Rp(_A0)>&
 function<_Rp(_A0)>::operator=(const function& __f)
 {
-    function(__f).swap(*this);
+    if (__f)
+        function(__f).swap(*this);
+    else
+        *this = nullptr;
     return *this;
 }
 
@@ -884,11 +891,12 @@ template<class _Rp, class _A0>
 function<_Rp(_A0)>&
 function<_Rp(_A0)>::operator=(nullptr_t)
 {
-    if (__f_ == (__base*)&__buf_)
-        __f_->destroy();
-    else if (__f_)
-        __f_->destroy_deallocate();
+    __base* __t = __f_;
     __f_ = 0;
+    if (__t == (__base*)&__buf_)
+        __t->destroy();
+    else if (__t)
+        __t->destroy_deallocate();
     return *this;
 }
 
@@ -1152,7 +1160,10 @@ template<class _Rp, class _A0, class _A1>
 function<_Rp(_A0, _A1)>&
 function<_Rp(_A0, _A1)>::operator=(const function& __f)
 {
-    function(__f).swap(*this);
+    if (__f)
+        function(__f).swap(*this);
+    else
+        *this = nullptr;
     return *this;
 }
 
@@ -1160,11 +1171,12 @@ template<class _Rp, class _A0, class _A1>
 function<_Rp(_A0, _A1)>&
 function<_Rp(_A0, _A1)>::operator=(nullptr_t)
 {
-    if (__f_ == (__base*)&__buf_)
-        __f_->destroy();
-    else if (__f_)
-        __f_->destroy_deallocate();
+    __base* __t = __f_;
     __f_ = 0;
+    if (__t == (__base*)&__buf_)
+        __t->destroy();
+    else if (__t)
+        __t->destroy_deallocate();
     return *this;
 }
 
@@ -1428,7 +1440,10 @@ template<class _Rp, class _A0, class _A1, class _A2>
 function<_Rp(_A0, _A1, _A2)>&
 function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
 {
-    function(__f).swap(*this);
+    if (__f)
+        function(__f).swap(*this);
+    else
+        *this = nullptr;
     return *this;
 }
 
@@ -1436,11 +1451,12 @@ template<class _Rp, class _A0, class _A1, class _A2>
 function<_Rp(_A0, _A1, _A2)>&
 function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
 {
-    if (__f_ == (__base*)&__buf_)
-        __f_->destroy();
-    else if (__f_)
-        __f_->destroy_deallocate();
+    __base* __t = __f_;
     __f_ = 0;
+    if (__t == (__base*)&__buf_)
+        __t->destroy();
+    else if (__t)
+        __t->destroy_deallocate();
     return *this;
 }
 
diff --git lib/libcxx/include/__functional_base lib/libcxx/include/__functional_base
index 12af4dc9675..57fdf2b9f66 100644
--- lib/libcxx/include/__functional_base
+++ lib/libcxx/include/__functional_base
@@ -561,7 +561,7 @@ struct __is_transparent<_Tp, _Up,
 
 struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { };
 
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_MEMORY)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 extern const allocator_arg_t allocator_arg;
 #else
 /* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
@@ -646,16 +646,6 @@ void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, con
     new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
 }
 
-// FIXME: Theis should have a version which takes a non-const alloc.
-template <class _Tp, class _Allocator, class... _Args>
-inline _LIBCPP_INLINE_VISIBILITY
-void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args)
-{
-    __user_alloc_construct_impl(
-             __uses_alloc_ctor<_Tp, _Allocator>(),
-             __storage, __a, _VSTD::forward<_Args>(__args)...
-        );
-}
 #endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_END_NAMESPACE_STD
diff --git lib/libcxx/include/__hash_table lib/libcxx/include/__hash_table
index 3f430af1283..c77de961be6 100644
--- lib/libcxx/include/__hash_table
+++ lib/libcxx/include/__hash_table
@@ -32,13 +32,8 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Key, class _Tp>
-union __hash_value_type;
-#else
 template <class _Key, class _Tp>
 struct __hash_value_type;
-#endif
 
 template <class _Key, class _Cp, class _Hash,
           bool =  is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
@@ -172,7 +167,7 @@ struct __hash_key_value_types {
   }
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static  __container_value_type&& __move(__node_value_type& __v) {
+  static __container_value_type&& __move(__node_value_type& __v) {
     return _VSTD::move(__v);
   }
 #endif
@@ -184,7 +179,6 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
   typedef _Tp                                          mapped_type;
   typedef __hash_value_type<_Key, _Tp>                 __node_value_type;
   typedef pair<const _Key, _Tp>                        __container_value_type;
-  typedef pair<_Key, _Tp>                              __nc_value_type;
   typedef __container_value_type                       __map_value_type;
   static const bool __is_map = true;
 
@@ -198,7 +192,7 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
   static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
       __container_value_type const&>::type
   __get_value(_Up& __t) {
-    return __t.__cc;
+    return __t.__get_value();
   }
 
   template <class _Up>
@@ -211,12 +205,12 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
 
   _LIBCPP_INLINE_VISIBILITY
   static __container_value_type* __get_ptr(__node_value_type& __n) {
-    return _VSTD::addressof(__n.__cc);
+    return _VSTD::addressof(__n.__get_value());
   }
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static __nc_value_type&& __move(__node_value_type& __v) {
-    return _VSTD::move(__v.__nc);
+  static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
+    return __v.__move();
   }
 #endif
 
@@ -865,6 +859,17 @@ public:
     template <class> friend class __hash_map_node_destructor;
 };
 
+#if _LIBCPP_STD_VER > 14
+template <class _NodeType, class _Alloc>
+struct __generic_container_node_destructor;
+
+template <class _Tp, class _VoidPtr, class _Alloc>
+struct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc>
+    : __hash_node_destructor<_Alloc>
+{
+    using __hash_node_destructor<_Alloc>::__hash_node_destructor;
+};
+#endif
 
 #ifndef _LIBCPP_CXX03_LANG
 template <class _Key, class _Hash, class _Equal, class _Alloc>
@@ -1157,6 +1162,30 @@ public:
         return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
     }
 
+#if _LIBCPP_STD_VER > 14
+    template <class _NodeHandle, class _InsertReturnType>
+    _LIBCPP_INLINE_VISIBILITY
+    _InsertReturnType __node_handle_insert_unique(_NodeHandle&& __nh);
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __node_handle_insert_unique(const_iterator __hint,
+                                         _NodeHandle&& __nh);
+
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __node_handle_insert_multi(_NodeHandle&& __nh);
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh);
+
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    _NodeHandle __node_handle_extract(key_type const& __key);
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    _NodeHandle __node_handle_extract(const_iterator __it);
+#endif
+
     void clear() _NOEXCEPT;
     void rehash(size_type __n);
     _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)
@@ -2132,6 +2161,91 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
 
 #endif  // _LIBCPP_CXX03_LANG
 
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle, class _InsertReturnType>
+_LIBCPP_INLINE_VISIBILITY
+_InsertReturnType
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
+    _NodeHandle&& __nh)
+{
+    if (__nh.empty())
+        return _InsertReturnType{end(), false, _NodeHandle()};
+    pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
+    if (__result.second)
+        __nh.__release();
+    return _InsertReturnType{__result.first, __result.second, _VSTD::move(__nh)};
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
+    const_iterator, _NodeHandle&& __nh)
+{
+    if (__nh.empty())
+        return end();
+    pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
+    if (__result.second)
+        __nh.__release();
+    return __result.first;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(
+    key_type const& __key)
+{
+    iterator __i = find(__key);
+    if (__i == end())
+        return _NodeHandle();
+    return __node_handle_extract<_NodeHandle>(__i);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(
+    const_iterator __p)
+{
+    allocator_type __alloc(__node_alloc());
+    return _NodeHandle(remove(__p).release(), __alloc);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
+    _NodeHandle&& __nh)
+{
+    if (__nh.empty())
+        return end();
+    iterator __result = __node_insert_multi(__nh.__ptr_);
+    __nh.__release();
+    return __result;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
+    const_iterator __hint, _NodeHandle&& __nh)
+{
+    if (__nh.empty())
+        return end();
+    iterator __result = __node_insert_multi(__hint, __nh.__ptr_);
+    __nh.__release();
+    return __result;
+}
+
+#endif  // _LIBCPP_STD_VER > 14
+
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
diff --git lib/libcxx/include/__libcpp_version lib/libcxx/include/__libcpp_version
index a77fd92cf17..2bdc6533bec 100644
--- lib/libcxx/include/__libcpp_version
+++ lib/libcxx/include/__libcpp_version
@@ -1 +1 @@
-6000
+7000
diff --git lib/libcxx/include/__locale lib/libcxx/include/__locale
index bface07aa68..79063e08c85 100644
--- lib/libcxx/include/__locale
+++ lib/libcxx/include/__locale
@@ -24,11 +24,7 @@
 #elif defined(_AIX)
 # include <support/ibm/xlocale.h>
 #elif defined(__ANDROID__)
-// Android gained the locale aware functions in L (API level 21)
-# include <android/api-level.h>
-# if __ANDROID_API__ <= 20
-#  include <support/android/locale_bionic.h>
-# endif
+# include <support/android/locale_bionic.h>
 #elif defined(__sun__)
 # include <xlocale.h>
 # include <support/solaris/xlocale.h>
@@ -473,7 +469,7 @@ public:
     static const mask alnum  = alpha | digit;
     static const mask graph  = alnum | punct;
 
-    _LIBCPP_ALWAYS_INLINE ctype_base() {}
+    _LIBCPP_INLINE_VISIBILITY ctype_base() {}
 };
 
 template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
@@ -486,77 +482,77 @@ class _LIBCPP_TYPE_VIS ctype<wchar_t>
 public:
     typedef wchar_t char_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit ctype(size_t __refs = 0)
         : locale::facet(__refs) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     bool is(mask __m, char_type __c) const
     {
         return do_is(__m, __c);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
     {
         return do_is(__low, __high, __vec);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const
     {
         return do_scan_is(__m, __low, __high);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
     {
         return do_scan_not(__m, __low, __high);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     char_type toupper(char_type __c) const
     {
         return do_toupper(__c);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* toupper(char_type* __low, const char_type* __high) const
     {
         return do_toupper(__low, __high);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     char_type tolower(char_type __c) const
     {
         return do_tolower(__c);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* tolower(char_type* __low, const char_type* __high) const
     {
         return do_tolower(__low, __high);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     char_type widen(char __c) const
     {
         return do_widen(__c);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char* widen(const char* __low, const char* __high, char_type* __to) const
     {
         return do_widen(__low, __high, __to);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     char narrow(char_type __c, char __dfault) const
     {
         return do_narrow(__c, __dfault);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
     {
         return do_narrow(__low, __high, __dfault, __to);
@@ -591,13 +587,13 @@ public:
 
     explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     bool is(mask __m, char_type __c) const
     {
         return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
     {
         for (; __low != __high; ++__low, ++__vec)
@@ -605,7 +601,7 @@ public:
         return __low;
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const
     {
         for (; __low != __high; ++__low)
@@ -614,7 +610,7 @@ public:
         return __low;
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
     {
         for (; __low != __high; ++__low)
@@ -623,49 +619,49 @@ public:
         return __low;
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     char_type toupper(char_type __c) const
     {
         return do_toupper(__c);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* toupper(char_type* __low, const char_type* __high) const
     {
         return do_toupper(__low, __high);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     char_type tolower(char_type __c) const
     {
         return do_tolower(__c);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char_type* tolower(char_type* __low, const char_type* __high) const
     {
         return do_tolower(__low, __high);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     char_type widen(char __c) const
     {
         return do_widen(__c);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char* widen(const char* __low, const char* __high, char_type* __to) const
     {
         return do_widen(__low, __high, __to);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     char narrow(char_type __c, char __dfault) const
     {
         return do_narrow(__c, __dfault);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
     {
         return do_narrow(__low, __high, __dfault, __to);
@@ -678,7 +674,7 @@ public:
 #else
     static const size_t table_size = 256;  // FIXME: Don't hardcode this.
 #endif
-    _LIBCPP_ALWAYS_INLINE const mask* table() const  _NOEXCEPT {return __tab_;}
+    _LIBCPP_INLINE_VISIBILITY const mask* table() const  _NOEXCEPT {return __tab_;}
     static const mask* classic_table()  _NOEXCEPT;
 #if defined(__GLIBC__) || defined(__EMSCRIPTEN__)
     static const int* __classic_upper_table() _NOEXCEPT;
@@ -858,7 +854,7 @@ tolower(_CharT __c, const locale& __loc)
 class _LIBCPP_TYPE_VIS codecvt_base
 {
 public:
-    _LIBCPP_ALWAYS_INLINE codecvt_base() {}
+    _LIBCPP_INLINE_VISIBILITY codecvt_base() {}
     enum result {ok, partial, error, noconv};
 };
 
@@ -878,11 +874,11 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt(size_t __refs = 0)
         : locale::facet(__refs) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result out(state_type& __st,
                const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
                extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
@@ -890,14 +886,14 @@ public:
         return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result unshift(state_type& __st,
                    extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
     {
         return do_unshift(__st, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result in(state_type& __st,
               const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
               intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
@@ -905,25 +901,25 @@ public:
         return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int encoding() const  _NOEXCEPT
     {
         return do_encoding();
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     bool always_noconv() const  _NOEXCEPT
     {
         return do_always_noconv();
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
     {
         return do_length(__st, __frm, __end, __mx);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int max_length() const  _NOEXCEPT
     {
         return do_max_length();
@@ -932,7 +928,7 @@ public:
     static locale::id id;
 
 protected:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt(const char*, size_t __refs = 0)
         : locale::facet(__refs) {}
 
@@ -967,7 +963,7 @@ public:
 
     explicit codecvt(size_t __refs = 0);
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result out(state_type& __st,
                const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
                extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
@@ -975,14 +971,14 @@ public:
         return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result unshift(state_type& __st,
                    extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
     {
         return do_unshift(__st, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result in(state_type& __st,
               const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
               intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
@@ -990,25 +986,25 @@ public:
         return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int encoding() const  _NOEXCEPT
     {
         return do_encoding();
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     bool always_noconv() const  _NOEXCEPT
     {
         return do_always_noconv();
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
     {
         return do_length(__st, __frm, __end, __mx);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int max_length() const  _NOEXCEPT
     {
         return do_max_length();
@@ -1047,11 +1043,11 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt(size_t __refs = 0)
         : locale::facet(__refs) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result out(state_type& __st,
                const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
                extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
@@ -1059,14 +1055,14 @@ public:
         return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result unshift(state_type& __st,
                    extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
     {
         return do_unshift(__st, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result in(state_type& __st,
               const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
               intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
@@ -1074,25 +1070,25 @@ public:
         return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int encoding() const  _NOEXCEPT
     {
         return do_encoding();
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     bool always_noconv() const  _NOEXCEPT
     {
         return do_always_noconv();
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
     {
         return do_length(__st, __frm, __end, __mx);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int max_length() const  _NOEXCEPT
     {
         return do_max_length();
@@ -1101,7 +1097,7 @@ public:
     static locale::id id;
 
 protected:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt(const char*, size_t __refs = 0)
         : locale::facet(__refs) {}
 
@@ -1133,11 +1129,11 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt(size_t __refs = 0)
         : locale::facet(__refs) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result out(state_type& __st,
                const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
                extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
@@ -1145,14 +1141,14 @@ public:
         return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result unshift(state_type& __st,
                    extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
     {
         return do_unshift(__st, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     result in(state_type& __st,
               const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
               intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
@@ -1160,25 +1156,25 @@ public:
         return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int encoding() const  _NOEXCEPT
     {
         return do_encoding();
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     bool always_noconv() const  _NOEXCEPT
     {
         return do_always_noconv();
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
     {
         return do_length(__st, __frm, __end, __mx);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     int max_length() const  _NOEXCEPT
     {
         return do_max_length();
@@ -1187,7 +1183,7 @@ public:
     static locale::id id;
 
 protected:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt(const char*, size_t __refs = 0)
         : locale::facet(__refs) {}
 
@@ -1214,10 +1210,10 @@ class _LIBCPP_TEMPLATE_VIS codecvt_byname
     : public codecvt<_InternT, _ExternT, _StateT>
 {
 public:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt_byname(const char* __nm, size_t __refs = 0)
         : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt_byname(const string& __nm, size_t __refs = 0)
         : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
 protected:
@@ -1248,7 +1244,7 @@ template <>
 struct __narrow_to_utf8<8>
 {
     template <class _OutputIterator, class _CharT>
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _OutputIterator
     operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
     {
@@ -1262,13 +1258,13 @@ template <>
 struct __narrow_to_utf8<16>
     : public codecvt<char16_t, char, mbstate_t>
 {
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
 
     ~__narrow_to_utf8();
 
     template <class _OutputIterator, class _CharT>
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _OutputIterator
     operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
     {
@@ -1296,13 +1292,13 @@ template <>
 struct __narrow_to_utf8<32>
     : public codecvt<char32_t, char, mbstate_t>
 {
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
 
     ~__narrow_to_utf8();
 
     template <class _OutputIterator, class _CharT>
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _OutputIterator
     operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
     {
@@ -1338,7 +1334,7 @@ template <>
 struct __widen_from_utf8<8>
 {
     template <class _OutputIterator>
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _OutputIterator
     operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
     {
@@ -1352,13 +1348,13 @@ template <>
 struct __widen_from_utf8<16>
     : public codecvt<char16_t, char, mbstate_t>
 {
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
 
     ~__widen_from_utf8();
 
     template <class _OutputIterator>
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _OutputIterator
     operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
     {
@@ -1386,13 +1382,13 @@ template <>
 struct __widen_from_utf8<32>
     : public codecvt<char32_t, char, mbstate_t>
 {
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
 
     ~__widen_from_utf8();
 
     template <class _OutputIterator>
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _OutputIterator
     operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
     {
@@ -1430,11 +1426,11 @@ public:
 
     explicit numpunct(size_t __refs = 0);
 
-    _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
-    _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
-    _LIBCPP_ALWAYS_INLINE string grouping() const         {return do_grouping();}
-    _LIBCPP_ALWAYS_INLINE string_type truename() const    {return do_truename();}
-    _LIBCPP_ALWAYS_INLINE string_type falsename() const   {return do_falsename();}
+    _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
+    _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
+    _LIBCPP_INLINE_VISIBILITY string grouping() const         {return do_grouping();}
+    _LIBCPP_INLINE_VISIBILITY string_type truename() const    {return do_truename();}
+    _LIBCPP_INLINE_VISIBILITY string_type falsename() const   {return do_falsename();}
 
     static locale::id id;
 
@@ -1461,11 +1457,11 @@ public:
 
     explicit numpunct(size_t __refs = 0);
 
-    _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
-    _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
-    _LIBCPP_ALWAYS_INLINE string grouping() const         {return do_grouping();}
-    _LIBCPP_ALWAYS_INLINE string_type truename() const    {return do_truename();}
-    _LIBCPP_ALWAYS_INLINE string_type falsename() const   {return do_falsename();}
+    _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
+    _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
+    _LIBCPP_INLINE_VISIBILITY string grouping() const         {return do_grouping();}
+    _LIBCPP_INLINE_VISIBILITY string_type truename() const    {return do_truename();}
+    _LIBCPP_INLINE_VISIBILITY string_type falsename() const   {return do_falsename();}
 
     static locale::id id;
 
diff --git lib/libcxx/include/__mutex_base lib/libcxx/include/__mutex_base
index 402a52d945e..4659ca9298c 100644
--- lib/libcxx/include/__mutex_base
+++ lib/libcxx/include/__mutex_base
@@ -74,7 +74,7 @@ struct _LIBCPP_TYPE_VIS defer_lock_t {};
 struct _LIBCPP_TYPE_VIS try_to_lock_t {};
 struct _LIBCPP_TYPE_VIS adopt_lock_t {};
 
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_MUTEX)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 
 extern const defer_lock_t  defer_lock;
 extern const try_to_lock_t try_to_lock;
diff --git lib/libcxx/include/__node_handle lib/libcxx/include/__node_handle
new file mode 100644
index 00000000000..567f8b047a3
--- /dev/null
+++ lib/libcxx/include/__node_handle
@@ -0,0 +1,213 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___NODE_HANDLE
+#define _LIBCPP___NODE_HANDLE
+
+#include <__config>
+#include <memory>
+#include <optional>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+// FIXME: Uncomment this when we support the 'merge' functionality.
+// #define __cpp_lib_node_extract 201606L
+
+// Specialized in __tree & __hash_table for their _NodeType.
+template <class _NodeType, class _Alloc>
+struct __generic_container_node_destructor;
+
+template <class _NodeType, class _Alloc,
+          template <class, class> class _MapOrSetSpecifics>
+class _LIBCPP_TEMPLATE_VIS __basic_node_handle
+    : public _MapOrSetSpecifics<
+          _NodeType,
+          __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>
+{
+    template <class _Tp, class _Compare, class _Allocator>
+        friend class __tree;
+    template <class _Tp, class _Hash, class _Equal, class _Allocator>
+        friend class __hash_table;
+    friend struct _MapOrSetSpecifics<
+        _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>;
+
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_pointer<typename __alloc_traits::void_pointer,
+                                      _NodeType>::type
+        __node_pointer_type;
+
+public:
+    typedef _Alloc allocator_type;
+
+private:
+    __node_pointer_type __ptr_ = nullptr;
+    optional<allocator_type> __alloc_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __release()
+    {
+        __ptr_ = nullptr;
+        __alloc_ = _VSTD::nullopt;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __destroy_node_pointer()
+    {
+        if (__ptr_ != nullptr)
+        {
+            typedef typename __allocator_traits_rebind<
+                allocator_type, _NodeType>::type __node_alloc_type;
+            __node_alloc_type __alloc(*__alloc_);
+            __generic_container_node_destructor<_NodeType, __node_alloc_type>(
+                __alloc, true)(__ptr_);
+            __ptr_ = nullptr;
+        }
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __basic_node_handle(__node_pointer_type __ptr,
+                        allocator_type const& __alloc)
+            : __ptr_(__ptr), __alloc_(__alloc)
+    {
+    }
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __basic_node_handle() = default;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __basic_node_handle(__basic_node_handle&& __other) noexcept
+            : __ptr_(__other.__ptr_),
+              __alloc_(_VSTD::move(__other.__alloc_))
+    {
+        __other.__ptr_ = nullptr;
+        __other.__alloc_ = _VSTD::nullopt;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __basic_node_handle& operator=(__basic_node_handle&& __other)
+    {
+        _LIBCPP_ASSERT(
+            __alloc_ == _VSTD::nullopt ||
+            __alloc_traits::propagate_on_container_move_assignment::value ||
+            __alloc_ == __other.__alloc_,
+            "node_type with incompatible allocator passed to "
+            "node_type::operator=(node_type&&)");
+
+        __destroy_node_pointer();
+        __ptr_ = __other.__ptr_;
+
+        if (__alloc_traits::propagate_on_container_move_assignment::value ||
+            __alloc_ == _VSTD::nullopt)
+            __alloc_ = _VSTD::move(__other.__alloc_);
+
+        __other.__ptr_ = nullptr;
+        __other.__alloc_ = _VSTD::nullopt;
+
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const { return *__alloc_; }
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit operator bool() const { return __ptr_ != nullptr; }
+
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+    bool empty() const { return __ptr_ == nullptr; }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(__basic_node_handle& __other) noexcept(
+        __alloc_traits::propagate_on_container_swap::value ||
+        __alloc_traits::is_always_equal::value)
+    {
+        using _VSTD::swap;
+        swap(__ptr_, __other.__ptr_);
+        if (__alloc_traits::propagate_on_container_swap::value ||
+            __alloc_ == _VSTD::nullopt || __other.__alloc_ == _VSTD::nullopt)
+            swap(__alloc_, __other.__alloc_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    friend void swap(__basic_node_handle& __a, __basic_node_handle& __b)
+        noexcept(noexcept(__a.swap(__b))) { __a.swap(__b); }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__basic_node_handle()
+    {
+        __destroy_node_pointer();
+    }
+};
+
+template <class _NodeType, class _Derived>
+struct __set_node_handle_specifics
+{
+    typedef typename _NodeType::__node_value_type value_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type& value() const
+    {
+        return static_cast<_Derived const*>(this)->__ptr_->__value_;
+    }
+};
+
+template <class _NodeType, class _Derived>
+struct __map_node_handle_specifics
+{
+    typedef typename _NodeType::__node_value_type::key_type key_type;
+    typedef typename _NodeType::__node_value_type::mapped_type mapped_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    key_type& key() const
+    {
+        return static_cast<_Derived const*>(this)->
+            __ptr_->__value_.__ref().first;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    mapped_type& mapped() const
+    {
+        return static_cast<_Derived const*>(this)->
+            __ptr_->__value_.__ref().second;
+    }
+};
+
+template <class _NodeType, class _Alloc>
+using __set_node_handle =
+    __basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>;
+
+template <class _NodeType, class _Alloc>
+using __map_node_handle =
+    __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>;
+
+template <class _Iterator, class _NodeType>
+_LIBCPP_TEMPLATE_VIS
+struct __insert_return_type
+{
+    _Iterator position;
+    bool inserted;
+    _NodeType node;
+};
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
+#endif
diff --git lib/libcxx/include/__nullptr lib/libcxx/include/__nullptr
index a341234f5d1..aa3b4d2145a 100644
--- lib/libcxx/include/__nullptr
+++ lib/libcxx/include/__nullptr
@@ -27,24 +27,24 @@ struct _LIBCPP_TEMPLATE_VIS nullptr_t
 
     struct __nat {int __for_bool_;};
 
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
 
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
 
     template <class _Tp>
-        _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
         operator _Tp* () const {return 0;}
 
     template <class _Tp, class _Up>
-        _LIBCPP_ALWAYS_INLINE
+        _LIBCPP_INLINE_VISIBILITY
         operator _Tp _Up::* () const {return 0;}
 
-    friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
-    friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
+    friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
+    friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
 };
 
-inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
 
 #define nullptr _VSTD::__get_nullptr_t()
 
diff --git lib/libcxx/include/__sso_allocator lib/libcxx/include/__sso_allocator
index 8147e75ec2c..40027363a18 100644
--- lib/libcxx/include/__sso_allocator
+++ lib/libcxx/include/__sso_allocator
@@ -55,14 +55,14 @@ public:
             __allocated_ = true;
             return (pointer)&buf_;
         }
-        return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
+        return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), __alignof(_Tp)));
     }
     _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type)
     {
         if (__p == (pointer)&buf_)
             __allocated_ = false;
         else
-            _VSTD::__libcpp_deallocate(__p);
+            _VSTD::__libcpp_deallocate(__p, __alignof(_Tp));
     }
     _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
 
diff --git lib/libcxx/include/__string lib/libcxx/include/__string
index d30c7fddc8d..44c55987f9f 100644
--- lib/libcxx/include/__string
+++ lib/libcxx/include/__string
@@ -266,7 +266,7 @@ const char*
 char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
 {
     if (__n == 0)
-        return NULL;
+        return nullptr;
 #if __has_feature(cxx_constexpr_string_builtins)
     return __builtin_char_memchr(__s, to_int_type(__a), __n);
 #elif _LIBCPP_STD_VER <= 14
@@ -278,7 +278,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a)
             return __s;
         ++__s;
     }
-    return NULL;
+    return nullptr;
 #endif
 }
 
@@ -372,9 +372,9 @@ const wchar_t*
 char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
 {
     if (__n == 0)
-        return NULL;
+        return nullptr;
 #if __has_feature(cxx_constexpr_string_builtins)
-        return __builtin_wmemchr(__s, __a, __n);
+    return __builtin_wmemchr(__s, __a, __n);
 #elif _LIBCPP_STD_VER <= 14
     return wmemchr(__s, __a, __n);
 #else
@@ -384,7 +384,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
             return __s;
         ++__s;
     }
-    return NULL;
+    return nullptr;
 #endif
 }
 
diff --git lib/libcxx/include/__threading_support lib/libcxx/include/__threading_support
index 5d4c907966e..3c1eff22f53 100644
--- lib/libcxx/include/__threading_support
+++ lib/libcxx/include/__threading_support
@@ -26,18 +26,14 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include <pthread.h>
 # include <sched.h>
-#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
-#include <windows.h>
-#include <process.h>
-#include <fibersapi.h>
 #endif
 
 _LIBCPP_PUSH_MACROS
 #include <__undef_macros>
 
-
 #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
-    defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
+    defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) || \
+    defined(_LIBCPP_HAS_THREAD_API_WIN32)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
 #else
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
@@ -80,31 +76,37 @@ typedef pthread_key_t __libcpp_tls_key;
 #define _LIBCPP_TLS_DESTRUCTOR_CC
 #else
 // Mutex
-typedef SRWLOCK __libcpp_mutex_t;
-#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+typedef void* __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER 0
 
-typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
+typedef void* __libcpp_recursive_mutex_t[6];
+#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
+typedef void* __libcpp_recursive_mutex_t[5];
+#else
+# error Unsupported architecture
+#endif
 
 // Condition Variable
-typedef CONDITION_VARIABLE __libcpp_condvar_t;
-#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+typedef void* __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER 0
 
 // Execute Once
-typedef INIT_ONCE __libcpp_exec_once_flag;
-#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
+typedef void* __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER 0
 
 // Thread ID
-typedef DWORD __libcpp_thread_id;
+typedef long __libcpp_thread_id;
 
 // Thread
 #define _LIBCPP_NULL_THREAD 0U
 
-typedef HANDLE __libcpp_thread_t;
+typedef void* __libcpp_thread_t;
 
 // Thread Local Storage
-typedef DWORD __libcpp_tls_key;
+typedef long __libcpp_tls_key;
 
-#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
+#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
 #endif
 
 // Mutex
@@ -201,10 +203,9 @@ void *__libcpp_tls_get(__libcpp_tls_key __key);
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
 
-#if !defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
-    defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
-
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+     defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) && \
+    defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
 {
@@ -390,244 +391,6 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
     return pthread_setspecific(__key, __p);
 }
 
-#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
-
-// Mutex
-int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
-{
-  InitializeCriticalSection(__m);
-  return 0;
-}
-
-int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
-{
-  EnterCriticalSection(__m);
-  return 0;
-}
-
-bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
-{
-  return TryEnterCriticalSection(__m) != 0;
-}
-
-int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
-{
-  LeaveCriticalSection(__m);
-  return 0;
-}
-
-int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
-{
-  DeleteCriticalSection(__m);
-  return 0;
-}
-
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
-{
-  AcquireSRWLockExclusive(__m);
-  return 0;
-}
-
-bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
-{
-  return TryAcquireSRWLockExclusive(__m) != 0;
-}
-
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
-{
-  ReleaseSRWLockExclusive(__m);
-  return 0;
-}
-
-int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
-{
-  static_cast<void>(__m);
-  return 0;
-}
-
-// Condition Variable
-int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
-{
-  WakeConditionVariable(__cv);
-  return 0;
-}
-
-int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
-{
-  WakeAllConditionVariable(__cv);
-  return 0;
-}
-
-int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
-{
-  SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
-  return 0;
-}
-
-int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
-                               timespec *__ts)
-{
-  using namespace _VSTD::chrono;
-
-  auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
-  auto abstime =
-      system_clock::time_point(duration_cast<system_clock::duration>(duration));
-  auto timeout_ms = duration_cast<milliseconds>(abstime - system_clock::now());
-
-  if (!SleepConditionVariableSRW(__cv, __m,
-                                 timeout_ms.count() > 0 ? timeout_ms.count()
-                                                        : 0,
-                                 0))
-    {
-      auto __ec = GetLastError();
-      return __ec == ERROR_TIMEOUT ? ETIMEDOUT : __ec;
-    }
-  return 0;
-}
-
-int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
-{
-  static_cast<void>(__cv);
-  return 0;
-}
-
-// Execute Once
-static inline _LIBCPP_ALWAYS_INLINE BOOL CALLBACK
-__libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
-                                      PVOID *__context)
-{
-  static_cast<void>(__init_once);
-  static_cast<void>(__context);
-
-  void (*init_routine)(void) = reinterpret_cast<void (*)(void)>(__parameter);
-  init_routine();
-  return TRUE;
-}
-
-int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
-                          void (*__init_routine)(void))
-{
-  if (!InitOnceExecuteOnce(__flag, __libcpp_init_once_execute_once_thunk,
-                           reinterpret_cast<void *>(__init_routine), NULL))
-    return GetLastError();
-  return 0;
-}
-
-// Thread ID
-bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
-                              __libcpp_thread_id __rhs)
-{
-  return __lhs == __rhs;
-}
-
-bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
-{
-  return __lhs < __rhs;
-}
-
-// Thread
-struct __libcpp_beginthreadex_thunk_data
-{
-  void *(*__func)(void *);
-  void *__arg;
-};
-
-static inline _LIBCPP_ALWAYS_INLINE unsigned WINAPI
-__libcpp_beginthreadex_thunk(void *__raw_data)
-{
-  auto *__data =
-      static_cast<__libcpp_beginthreadex_thunk_data *>(__raw_data);
-  auto *__func = __data->__func;
-  void *__arg = __data->__arg;
-  delete __data;
-  return static_cast<unsigned>(reinterpret_cast<uintptr_t>(__func(__arg)));
-}
-
-bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
-  return *__t == 0;
-}
-
-int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
-                           void *__arg)
-{
-  auto *__data = new __libcpp_beginthreadex_thunk_data;
-  __data->__func = __func;
-  __data->__arg = __arg;
-
-  *__t = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0,
-                                                 __libcpp_beginthreadex_thunk,
-                                                 __data, 0, nullptr));
-
-  if (*__t)
-    return 0;
-  return GetLastError();
-}
-
-__libcpp_thread_id __libcpp_thread_get_current_id()
-{
-  return GetCurrentThreadId();
-}
-
-__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
-{
-  return GetThreadId(*__t);
-}
-
-int __libcpp_thread_join(__libcpp_thread_t *__t)
-{
-  if (WaitForSingleObjectEx(*__t, INFINITE, FALSE) == WAIT_FAILED)
-    return GetLastError();
-  if (!CloseHandle(*__t))
-    return GetLastError();
-  return 0;
-}
-
-int __libcpp_thread_detach(__libcpp_thread_t *__t)
-{
-  if (!CloseHandle(*__t))
-    return GetLastError();
-  return 0;
-}
-
-void __libcpp_thread_yield()
-{
-  SwitchToThread();
-}
-
-void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
-{
-  using namespace chrono;
-  // round-up to the nearest milisecond
-  milliseconds __ms =
-      duration_cast<milliseconds>(__ns + chrono::nanoseconds(999999));
-  // FIXME(compnerd) this should be an alertable sleep (WFSO or SleepEx)
-  Sleep(__ms.count());
-}
-
-// Thread Local Storage
-int __libcpp_tls_create(__libcpp_tls_key* __key,
-                        void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*))
-{
-  *__key = FlsAlloc(__at_exit);
-  if (*__key == FLS_OUT_OF_INDEXES)
-    return GetLastError();
-  return 0;
-}
-
-void *__libcpp_tls_get(__libcpp_tls_key __key)
-{
-  return FlsGetValue(__key);
-}
-
-int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
-{
-  if (!FlsSetValue(__key, __p))
-    return GetLastError();
-  return 0;
-}
-
-#endif // _LIBCPP_HAS_THREAD_API_PTHREAD
-
 #endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
 
 _LIBCPP_END_NAMESPACE_STD
diff --git lib/libcxx/include/__tree lib/libcxx/include/__tree
index 3ccfcb70031..af9b9616df8 100644
--- lib/libcxx/include/__tree
+++ lib/libcxx/include/__tree
@@ -37,13 +37,8 @@ template <class _Pointer> class __tree_end_node;
 template <class _VoidPtr> class __tree_node_base;
 template <class _Tp, class _VoidPtr> class __tree_node;
 
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Key, class _Value>
-union __value_type;
-#else
 template <class _Key, class _Value>
 struct __value_type;
-#endif
 
 template <class _Key, class _CP, class _Compare,
     bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
@@ -569,10 +564,9 @@ struct __tree_key_value_types {
   static __container_value_type* __get_ptr(__node_value_type& __n) {
     return _VSTD::addressof(__n);
   }
-
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static  __container_value_type&& __move(__node_value_type& __v) {
+  static __container_value_type&& __move(__node_value_type& __v) {
     return _VSTD::move(__v);
   }
 #endif
@@ -584,14 +578,13 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
   typedef _Tp                                          mapped_type;
   typedef __value_type<_Key, _Tp>                      __node_value_type;
   typedef pair<const _Key, _Tp>                        __container_value_type;
-  typedef pair<_Key, _Tp>                              __nc_value_type;
   typedef __container_value_type                       __map_value_type;
   static const bool __is_map = true;
 
   _LIBCPP_INLINE_VISIBILITY
   static key_type const&
   __get_key(__node_value_type const& __t) {
-    return __t.__cc.first;
+    return __t.__get_value().first;
   }
 
   template <class _Up>
@@ -605,7 +598,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
   _LIBCPP_INLINE_VISIBILITY
   static __container_value_type const&
   __get_value(__node_value_type const& __t) {
-    return __t.__cc;
+    return __t.__get_value();
   }
 
   template <class _Up>
@@ -618,13 +611,13 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
 
   _LIBCPP_INLINE_VISIBILITY
   static __container_value_type* __get_ptr(__node_value_type& __n) {
-    return _VSTD::addressof(__n.__cc);
+    return _VSTD::addressof(__n.__get_value());
   }
 
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static  __nc_value_type&& __move(__node_value_type& __v) {
-    return _VSTD::move(__v.__nc);
+  static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
+    return __v.__move();
   }
 #endif
 };
@@ -803,6 +796,16 @@ public:
     template <class> friend class __map_node_destructor;
 };
 
+#if _LIBCPP_STD_VER > 14
+template <class _NodeType, class _Alloc>
+struct __generic_container_node_destructor;
+template <class _Tp, class _VoidPtr, class _Alloc>
+struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc>
+    : __tree_node_destructor<_Alloc>
+{
+    using __tree_node_destructor<_Alloc>::__tree_node_destructor;
+};
+#endif
 
 template <class _Tp, class _NodePtr, class _DiffType>
 class _LIBCPP_TEMPLATE_VIS __tree_iterator
@@ -1345,6 +1348,33 @@ public:
     iterator __node_insert_multi(__node_pointer __nd);
     iterator __node_insert_multi(const_iterator __p, __node_pointer __nd);
 
+
+    _LIBCPP_INLINE_VISIBILITY iterator __remove_node_pointer(__node_pointer);
+
+#if _LIBCPP_STD_VER > 14
+    template <class _NodeHandle, class _InsertReturnType>
+    _LIBCPP_INLINE_VISIBILITY
+    _InsertReturnType __node_handle_insert_unique(_NodeHandle&&);
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&);
+
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __node_handle_insert_multi(_NodeHandle&&);
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&);
+
+
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    _NodeHandle __node_handle_extract(key_type const&);
+    template <class _NodeHandle>
+    _LIBCPP_INLINE_VISIBILITY
+    _NodeHandle __node_handle_extract(const_iterator);
+#endif
+
     iterator erase(const_iterator __p);
     iterator erase(const_iterator __f, const_iterator __l);
     template <class _Key>
@@ -2354,17 +2384,138 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p,
 
 template <class _Tp, class _Compare, class _Allocator>
 typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p)
+__tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr)
 {
-    __node_pointer __np = __p.__get_np();
-    iterator __r(__p.__ptr_);
+    iterator __r(__ptr);
     ++__r;
-    if (__begin_node() == __p.__ptr_)
+    if (__begin_node() == __ptr)
         __begin_node() = __r.__ptr_;
     --size();
-    __node_allocator& __na = __node_alloc();
     __tree_remove(__end_node()->__left_,
-                  static_cast<__node_base_pointer>(__np));
+                  static_cast<__node_base_pointer>(__ptr));
+    return __r;
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle, class _InsertReturnType>
+_LIBCPP_INLINE_VISIBILITY
+_InsertReturnType
+__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(
+    _NodeHandle&& __nh)
+{
+    if (__nh.empty())
+        return _InsertReturnType{end(), false, _NodeHandle()};
+
+    __node_pointer __ptr = __nh.__ptr_;
+    __parent_pointer __parent;
+    __node_base_pointer& __child = __find_equal(__parent,
+                                                __ptr->__value_);
+    if (__child != nullptr)
+        return _InsertReturnType{
+            iterator(static_cast<__node_pointer>(__child)),
+            false, _VSTD::move(__nh)};
+
+    __insert_node_at(__parent, __child,
+                     static_cast<__node_base_pointer>(__ptr));
+    __nh.__release();
+    return _InsertReturnType{iterator(__ptr), true, _NodeHandle()};
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(
+    const_iterator __hint, _NodeHandle&& __nh)
+{
+    if (__nh.empty())
+        return end();
+
+    __node_pointer __ptr = __nh.__ptr_;
+    __parent_pointer __parent;
+    __node_base_pointer __dummy;
+    __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy,
+                                                __ptr->__value_);
+    __node_pointer __r = static_cast<__node_pointer>(__child);
+    if (__child == nullptr)
+    {
+        __insert_node_at(__parent, __child,
+                         static_cast<__node_base_pointer>(__ptr));
+        __r = __ptr;
+        __nh.__release();
+    }
+    return iterator(__r);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key)
+{
+    iterator __it = find(__key);
+    if (__it == end())
+        return _NodeHandle();
+    return __node_handle_extract<_NodeHandle>(__it);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p)
+{
+    __node_pointer __np = __p.__get_np();
+    __remove_node_pointer(__np);
+    return _NodeHandle(__np, __alloc());
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh)
+{
+    if (__nh.empty())
+        return end();
+    __node_pointer __ptr = __nh.__ptr_;
+    __parent_pointer __parent;
+    __node_base_pointer& __child = __find_leaf_high(
+        __parent, _NodeTypes::__get_key(__ptr->__value_));
+    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
+    __nh.__release();
+    return iterator(__ptr);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(
+    const_iterator __hint, _NodeHandle&& __nh)
+{
+    if (__nh.empty())
+        return end();
+
+    __node_pointer __ptr = __nh.__ptr_;
+    __parent_pointer __parent;
+    __node_base_pointer& __child = __find_leaf(__hint, __parent,
+                                               _NodeTypes::__get_key(__ptr->__value_));
+    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
+    __nh.__release();
+    return iterator(__ptr);
+}
+
+#endif  // _LIBCPP_STD_VER > 14
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p)
+{
+    __node_pointer __np = __p.__get_np();
+    iterator __r = __remove_node_pointer(__np);
+    __node_allocator& __na = __node_alloc();
     __node_traits::destroy(__na, _NodeTypes::__get_ptr(
         const_cast<__node_value_type&>(*__p)));
     __node_traits::deallocate(__na, __np, 1);
diff --git lib/libcxx/include/algorithm lib/libcxx/include/algorithm
index 35c6129ea50..90f1d246c63 100644
--- lib/libcxx/include/algorithm
+++ lib/libcxx/include/algorithm
@@ -20,149 +20,150 @@ namespace std
 {
 
 template <class InputIterator, class Predicate>
-    bool
+    constexpr bool     // constexpr in C++20
     all_of(InputIterator first, InputIterator last, Predicate pred);
 
 template <class InputIterator, class Predicate>
-    bool
+    constexpr bool     // constexpr in C++20
     any_of(InputIterator first, InputIterator last, Predicate pred);
 
 template <class InputIterator, class Predicate>
-    bool
+    constexpr bool     // constexpr in C++20
     none_of(InputIterator first, InputIterator last, Predicate pred);
 
 template <class InputIterator, class Function>
-    Function
+    constexpr Function          // constexpr in C++20
     for_each(InputIterator first, InputIterator last, Function f);
 
 template<class InputIterator, class Size, class Function>
-    InputIterator for_each_n(InputIterator first, Size n, Function f); // C++17
+    constexpr InputIterator     // constexpr in C++20
+    for_each_n(InputIterator first, Size n, Function f); // C++17
 
 template <class InputIterator, class T>
-    InputIterator
+    constexpr InputIterator     // constexpr in C++20
     find(InputIterator first, InputIterator last, const T& value);
 
 template <class InputIterator, class Predicate>
-    InputIterator
+    constexpr InputIterator     // constexpr in C++20
     find_if(InputIterator first, InputIterator last, Predicate pred);
 
 template<class InputIterator, class Predicate>
-    InputIterator
+    InputIterator               // constexpr in C++20
     find_if_not(InputIterator first, InputIterator last, Predicate pred);
 
 template <class ForwardIterator1, class ForwardIterator2>
-    ForwardIterator1
+    ForwardIterator1            // constexpr in C++20
     find_end(ForwardIterator1 first1, ForwardIterator1 last1,
              ForwardIterator2 first2, ForwardIterator2 last2);
 
 template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
-    ForwardIterator1
+    ForwardIterator1            // constexpr in C++20
     find_end(ForwardIterator1 first1, ForwardIterator1 last1,
              ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
 
 template <class ForwardIterator1, class ForwardIterator2>
-    ForwardIterator1
+    constexpr ForwardIterator1  // constexpr in C++20
     find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
                   ForwardIterator2 first2, ForwardIterator2 last2);
 
 template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
-    ForwardIterator1
+    constexpr ForwardIterator1  // constexpr in C++20
     find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
                   ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
 
 template <class ForwardIterator>
-    ForwardIterator
+    constexpr ForwardIterator   // constexpr in C++20
     adjacent_find(ForwardIterator first, ForwardIterator last);
 
 template <class ForwardIterator, class BinaryPredicate>
-    ForwardIterator
+    constexpr ForwardIterator   // constexpr in C++20
     adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
 
 template <class InputIterator, class T>
-    typename iterator_traits<InputIterator>::difference_type
+    constexpr typename iterator_traits<InputIterator>::difference_type  // constexpr in C++20
     count(InputIterator first, InputIterator last, const T& value);
 
 template <class InputIterator, class Predicate>
-    typename iterator_traits<InputIterator>::difference_type
+    constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
     count_if(InputIterator first, InputIterator last, Predicate pred);
 
 template <class InputIterator1, class InputIterator2>
-    pair<InputIterator1, InputIterator2>
+    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
     mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
 
 template <class InputIterator1, class InputIterator2>
-    pair<InputIterator1, InputIterator2>
+    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
     mismatch(InputIterator1 first1, InputIterator1 last1,
              InputIterator2 first2, InputIterator2 last2); // **C++14**
 
 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
-    pair<InputIterator1, InputIterator2>
+    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
     mismatch(InputIterator1 first1, InputIterator1 last1,
              InputIterator2 first2, BinaryPredicate pred);
 
 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
-    pair<InputIterator1, InputIterator2>
+    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
     mismatch(InputIterator1 first1, InputIterator1 last1,
              InputIterator2 first2, InputIterator2 last2,
              BinaryPredicate pred); // **C++14**
 
 template <class InputIterator1, class InputIterator2>
-    bool
+    constexpr bool      // constexpr in C++20
     equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
 
 template <class InputIterator1, class InputIterator2>
-    bool
+    constexpr bool      // constexpr in C++20
     equal(InputIterator1 first1, InputIterator1 last1,
           InputIterator2 first2, InputIterator2 last2); // **C++14**
 
 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
-    bool
+    constexpr bool      // constexpr in C++20
     equal(InputIterator1 first1, InputIterator1 last1,
           InputIterator2 first2, BinaryPredicate pred);
 
 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
-    bool
+    constexpr bool      // constexpr in C++20
     equal(InputIterator1 first1, InputIterator1 last1,
           InputIterator2 first2, InputIterator2 last2,
           BinaryPredicate pred); // **C++14**
 
 template<class ForwardIterator1, class ForwardIterator2>
-    bool
+    constexpr bool      // constexpr in C++20
     is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
                    ForwardIterator2 first2);
 
 template<class ForwardIterator1, class ForwardIterator2>
-    bool
+    constexpr bool      // constexpr in C++20
     is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
                    ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
 
 template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
-    bool
+    constexpr bool      // constexpr in C++20
     is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
                    ForwardIterator2 first2, BinaryPredicate pred);
 
 template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
-    bool
+    constexpr bool      // constexpr in C++20
     is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
                    ForwardIterator2 first2, ForwardIterator2 last2,
                    BinaryPredicate pred);  // **C++14**
 
 template <class ForwardIterator1, class ForwardIterator2>
-    ForwardIterator1
+    constexpr ForwardIterator1      // constexpr in C++20
     search(ForwardIterator1 first1, ForwardIterator1 last1,
            ForwardIterator2 first2, ForwardIterator2 last2);
 
 template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
-    ForwardIterator1
+    constexpr ForwardIterator1      // constexpr in C++20
     search(ForwardIterator1 first1, ForwardIterator1 last1,
            ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
 
 template <class ForwardIterator, class Size, class T>
-    ForwardIterator
+    constexpr ForwardIterator       // constexpr in C++20
     search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
 
 template <class ForwardIterator, class Size, class T, class BinaryPredicate>
-    ForwardIterator
+    constexpr ForwardIterator       // constexpr in C++20
     search_n(ForwardIterator first, ForwardIterator last,
              Size count, const T& value, BinaryPredicate pred);
 
@@ -193,61 +194,61 @@ template <class ForwardIterator1, class ForwardIterator2>
     iter_swap(ForwardIterator1 a, ForwardIterator2 b);
 
 template <class InputIterator, class OutputIterator, class UnaryOperation>
-    OutputIterator
+    constexpr OutputIterator      // constexpr in C++20
     transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
 
 template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
-    OutputIterator
+    constexpr OutputIterator      // constexpr in C++20
     transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
               OutputIterator result, BinaryOperation binary_op);
 
 template <class ForwardIterator, class T>
-    void
+    constexpr void      // constexpr in C++20
     replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
 
 template <class ForwardIterator, class Predicate, class T>
-    void
+    constexpr void      // constexpr in C++20
     replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
 
 template <class InputIterator, class OutputIterator, class T>
-    OutputIterator
+    constexpr OutputIterator      // constexpr in C++20
     replace_copy(InputIterator first, InputIterator last, OutputIterator result,
                  const T& old_value, const T& new_value);
 
 template <class InputIterator, class OutputIterator, class Predicate, class T>
-    OutputIterator
+    constexpr OutputIterator      // constexpr in C++20
     replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
 
 template <class ForwardIterator, class T>
-    void
+    constexpr void      // constexpr in C++20
     fill(ForwardIterator first, ForwardIterator last, const T& value);
 
 template <class OutputIterator, class Size, class T>
-    OutputIterator
+    constexpr OutputIterator      // constexpr in C++20
     fill_n(OutputIterator first, Size n, const T& value);
 
 template <class ForwardIterator, class Generator>
-    void
+    constexpr void      // constexpr in C++20
     generate(ForwardIterator first, ForwardIterator last, Generator gen);
 
 template <class OutputIterator, class Size, class Generator>
-    OutputIterator
+    constexpr OutputIterator      // constexpr in C++20
     generate_n(OutputIterator first, Size n, Generator gen);
 
 template <class ForwardIterator, class T>
-    ForwardIterator
+    constexpr ForwardIterator     // constexpr in C++20
     remove(ForwardIterator first, ForwardIterator last, const T& value);
 
 template <class ForwardIterator, class Predicate>
-    ForwardIterator
+    constexpr ForwardIterator     // constexpr in C++20
     remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
 
 template <class InputIterator, class OutputIterator, class T>
-    OutputIterator
+    constexpr OutputIterator     // constexpr in C++20
     remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
 
 template <class InputIterator, class OutputIterator, class Predicate>
-    OutputIterator
+    constexpr OutputIterator     // constexpr in C++20
     remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
 
 template <class ForwardIterator>
@@ -271,7 +272,7 @@ template <class BidirectionalIterator>
     reverse(BidirectionalIterator first, BidirectionalIterator last);
 
 template <class BidirectionalIterator, class OutputIterator>
-    OutputIterator
+    constexpr OutputIterator       // constexpr in C++20
     reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
 
 template <class ForwardIterator>
@@ -302,7 +303,7 @@ template<class RandomAccessIterator, class UniformRandomNumberGenerator>
                  UniformRandomNumberGenerator&& g);
 
 template <class InputIterator, class Predicate>
-    bool
+    constexpr bool  // constexpr in C++20
     is_partitioned(InputIterator first, InputIterator last, Predicate pred);
 
 template <class ForwardIterator, class Predicate>
@@ -311,7 +312,7 @@ template <class ForwardIterator, class Predicate>
 
 template <class InputIterator, class OutputIterator1,
           class OutputIterator2, class Predicate>
-    pair<OutputIterator1, OutputIterator2>
+    constexpr pair<OutputIterator1, OutputIterator2>   // constexpr in C++20
     partition_copy(InputIterator first, InputIterator last,
                    OutputIterator1 out_true, OutputIterator2 out_false,
                    Predicate pred);
@@ -321,11 +322,11 @@ template <class ForwardIterator, class Predicate>
     stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
 
 template<class ForwardIterator, class Predicate>
-    ForwardIterator
+    constexpr ForwardIterator  // constexpr in C++20
     partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
 
 template <class ForwardIterator>
-    bool
+    constexpr bool  // constexpr in C++20
     is_sorted(ForwardIterator first, ForwardIterator last);
 
 template <class ForwardIterator, class Compare>
@@ -333,11 +334,11 @@ template <class ForwardIterator, class Compare>
     is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
 
 template<class ForwardIterator>
-    ForwardIterator
+    constexpr ForwardIterator    // constexpr in C++20
     is_sorted_until(ForwardIterator first, ForwardIterator last);
 
 template <class ForwardIterator, class Compare>
-    ForwardIterator
+    constexpr ForwardIterator    // constexpr in C++20
     is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
 
 template <class RandomAccessIterator>
@@ -383,35 +384,35 @@ template <class RandomAccessIterator, class Compare>
     nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
 
 template <class ForwardIterator, class T>
-    ForwardIterator
+    constexpr ForwardIterator                         // constexpr in C++20
     lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
 
 template <class ForwardIterator, class T, class Compare>
-    ForwardIterator
+    constexpr ForwardIterator                         // constexpr in C++20
     lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
 
 template <class ForwardIterator, class T>
-    ForwardIterator
+    constexpr ForwardIterator                         // constexpr in C++20
     upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
 
 template <class ForwardIterator, class T, class Compare>
-    ForwardIterator
+    constexpr ForwardIterator                         // constexpr in C++20
     upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
 
 template <class ForwardIterator, class T>
-    pair<ForwardIterator, ForwardIterator>
+    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++20
     equal_range(ForwardIterator first, ForwardIterator last, const T& value);
 
 template <class ForwardIterator, class T, class Compare>
-    pair<ForwardIterator, ForwardIterator>
+    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++20
     equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
 
 template <class ForwardIterator, class T>
-    bool
+    constexpr bool                                    // constexpr in C++20
     binary_search(ForwardIterator first, ForwardIterator last, const T& value);
 
 template <class ForwardIterator, class T, class Compare>
-    bool
+    constexpr bool                                    // constexpr in C++20
     binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
 
 template <class InputIterator1, class InputIterator2, class OutputIterator>
@@ -433,11 +434,11 @@ template <class BidirectionalIterator, class Compare>
     inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
 
 template <class InputIterator1, class InputIterator2>
-    bool
+    constexpr bool                                    // constexpr in C++20
     includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
 
 template <class InputIterator1, class InputIterator2, class Compare>
-    bool
+    constexpr bool                                    // constexpr in C++20
     includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
 
 template <class InputIterator1, class InputIterator2, class OutputIterator>
@@ -451,12 +452,12 @@ template <class InputIterator1, class InputIterator2, class OutputIterator, clas
               InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
 
 template <class InputIterator1, class InputIterator2, class OutputIterator>
-    OutputIterator
+    constexpr OutputIterator                         // constexpr in C++20
     set_intersection(InputIterator1 first1, InputIterator1 last1,
                      InputIterator2 first2, InputIterator2 last2, OutputIterator result);
 
 template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
-    OutputIterator
+    constexpr OutputIterator                         // constexpr in C++20
     set_intersection(InputIterator1 first1, InputIterator1 last1,
                      InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
 
@@ -513,19 +514,19 @@ template <class RandomAccessIterator, class Compare>
     sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
 
 template <class RandomAccessIterator>
-    bool
+    constexpr bool   // constexpr in C++20
     is_heap(RandomAccessIterator first, RandomAccessiterator last);
 
 template <class RandomAccessIterator, class Compare>
-    bool
+    constexpr bool   // constexpr in C++20
     is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
 
 template <class RandomAccessIterator>
-    RandomAccessIterator
+    constexpr RandomAccessIterator   // constexpr in C++20
     is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
 
 template <class RandomAccessIterator, class Compare>
-    RandomAccessIterator
+    constexpr RandomAccessIterator   // constexpr in C++20
     is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
 
 template <class ForwardIterator>
@@ -607,11 +608,11 @@ template<class T, class Compare>
     minmax(initializer_list<T> t, Compare comp);  // constexpr in C++14
 
 template <class InputIterator1, class InputIterator2>
-    bool
+    constexpr bool     // constexpr in C++20
     lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
 
 template <class InputIterator1, class InputIterator2, class Compare>
-    bool
+    constexpr bool     // constexpr in C++20
     lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
                             InputIterator2 first2, InputIterator2 last2, Compare comp);
 
@@ -641,6 +642,7 @@ template <class BidirectionalIterator, class Compare>
 #include <cstring>
 #include <utility> // needed to provide swap_ranges.
 #include <memory>
+#include <functional>
 #include <iterator>
 #include <cstddef>
 
@@ -669,10 +671,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _T1, class _T2 = _T1>
 struct __equal_to
 {
-    _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
-    _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;}
-    _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;}
-    _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;}
 };
 
 template <class _T1>
@@ -918,7 +920,7 @@ inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long long __x) {
 // all_of
 
 template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 {
@@ -931,7 +933,7 @@ all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 // any_of
 
 template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 {
@@ -944,7 +946,7 @@ any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 // none_of
 
 template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 {
@@ -957,7 +959,7 @@ none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 // for_each
 
 template <class _InputIterator, class _Function>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _Function
 for_each(_InputIterator __first, _InputIterator __last, _Function __f)
 {
@@ -970,7 +972,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f)
 // for_each_n
 
 template <class _InputIterator, class _Size, class _Function>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _InputIterator
 for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
 {
@@ -989,7 +991,7 @@ for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
 // find
 
 template <class _InputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _InputIterator
 find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
 {
@@ -1002,7 +1004,7 @@ find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
 // find_if
 
 template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _InputIterator
 find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 {
@@ -1015,7 +1017,7 @@ find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 // find_if_not
 
 template<class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _InputIterator
 find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 {
@@ -1028,7 +1030,7 @@ find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 // find_end
 
 template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-_ForwardIterator1
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
            _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
            forward_iterator_tag, forward_iterator_tag)
@@ -1070,7 +1072,7 @@ __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 }
 
 template <class _BinaryPredicate, class _BidirectionalIterator1, class _BidirectionalIterator2>
-_BidirectionalIterator1
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1
 __find_end(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1,
            _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BinaryPredicate __pred,
            bidirectional_iterator_tag, bidirectional_iterator_tag)
@@ -1150,7 +1152,7 @@ __find_end(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
 }
 
 template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator1
 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
          _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
@@ -1162,7 +1164,7 @@ find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 }
 
 template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator1
 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
          _ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1188,7 +1190,7 @@ __find_first_of_ce(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 
 
 template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY  _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator1
 find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
               _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
@@ -1197,7 +1199,7 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 }
 
 template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY  _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator1
 find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
               _ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1210,7 +1212,7 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 // adjacent_find
 
 template <class _ForwardIterator, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
 {
@@ -1228,7 +1230,7 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicat
 }
 
 template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
 {
@@ -1239,7 +1241,7 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
 // count
 
 template <class _InputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 typename iterator_traits<_InputIterator>::difference_type
 count(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
 {
@@ -1253,7 +1255,7 @@ count(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
 // count_if
 
 template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 typename iterator_traits<_InputIterator>::difference_type
 count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 {
@@ -1267,7 +1269,7 @@ count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 // mismatch
 
 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 pair<_InputIterator1, _InputIterator2>
 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
          _InputIterator2 __first2, _BinaryPredicate __pred)
@@ -1279,7 +1281,7 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
 }
 
 template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 pair<_InputIterator1, _InputIterator2>
 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
 {
@@ -1290,7 +1292,7 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
 
 #if _LIBCPP_STD_VER > 11
 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 pair<_InputIterator1, _InputIterator2>
 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
          _InputIterator2 __first2, _InputIterator2 __last2,
@@ -1303,7 +1305,7 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
 }
 
 template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 pair<_InputIterator1, _InputIterator2>
 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
          _InputIterator2 __first2, _InputIterator2 __last2)
@@ -1317,7 +1319,7 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
 // equal
 
 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred)
 {
@@ -1328,7 +1330,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
 }
 
 template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
 {
@@ -1339,7 +1341,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
 
 #if _LIBCPP_STD_VER > 11
 template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 __equal(_InputIterator1 __first1, _InputIterator1 __last1,
         _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred,
@@ -1352,7 +1354,7 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1,
 }
 
 template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
         _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
@@ -1366,7 +1368,7 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
 }
 
 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 equal(_InputIterator1 __first1, _InputIterator1 __last1,
       _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred )
@@ -1378,7 +1380,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1,
 }
 
 template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 equal(_InputIterator1 __first1, _InputIterator1 __last1,
       _InputIterator2 __first2, _InputIterator2 __last2)
@@ -1394,17 +1396,18 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1,
 // is_permutation
 
 template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
                _ForwardIterator2 __first2, _BinaryPredicate __pred)
 {
-    // shorten sequences as much as possible by lopping of any equal parts
+//  shorten sequences as much as possible by lopping of any equal prefix
     for (; __first1 != __last1; ++__first1, (void) ++__first2)
         if (!__pred(*__first1, *__first2))
-            goto __not_done;
-    return true;
-__not_done:
-    // __first1 != __last1 && *__first1 != *__first2
+            break;
+    if (__first1 == __last1)
+        return true;
+
+//  __first1 != __last1 && *__first1 != *__first2
     typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
     _D1 __l1 = _VSTD::distance(__first1, __last1);
     if (__l1 == _D1(1))
@@ -1414,11 +1417,12 @@ __not_done:
     //    equal elements in [f2, l2)
     for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i)
     {
-        // Have we already counted the number of *__i in [f1, l1)?
-        for (_ForwardIterator1 __j = __first1; __j != __i; ++__j)
-            if (__pred(*__j, *__i))
-                goto __next_iter;
-        {
+    //  Have we already counted the number of *__i in [f1, l1)?
+        _ForwardIterator1 __match = __first1;
+        for (; __match != __i; ++__match)
+            if (__pred(*__match, *__i))
+                break;
+        if (__match == __i) {
             // Count number of *__i in [f2, l2)
             _D1 __c2 = 0;
             for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
@@ -1434,13 +1438,12 @@ __not_done:
             if (__c1 != __c2)
                 return false;
         }
-__next_iter:;
     }
     return true;
 }
 
 template<class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
                _ForwardIterator2 __first2)
@@ -1452,19 +1455,21 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 
 #if _LIBCPP_STD_VER > 11
 template<class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
                  _ForwardIterator2 __first2, _ForwardIterator2 __last2,
                  _BinaryPredicate __pred,
                  forward_iterator_tag, forward_iterator_tag )
 {
-    // shorten sequences as much as possible by lopping of any equal parts
+//  shorten sequences as much as possible by lopping of any equal prefix
     for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
         if (!__pred(*__first1, *__first2))
-            goto __not_done;
-    return __first1 == __last1 && __first2 == __last2;
-__not_done:
-    // __first1 != __last1 && __first2 != __last2 && *__first1 != *__first2
+            break;
+    if (__first1 == __last1)
+        return __first2 == __last2;
+    else if (__first2 == __last2)
+        return false;
+
     typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
     _D1 __l1 = _VSTD::distance(__first1, __last1);
 
@@ -1477,11 +1482,12 @@ __not_done:
     //    equal elements in [f2, l2)
     for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i)
     {
-        // Have we already counted the number of *__i in [f1, l1)?
-        for (_ForwardIterator1 __j = __first1; __j != __i; ++__j)
-            if (__pred(*__j, *__i))
-                goto __next_iter;
-        {
+    //  Have we already counted the number of *__i in [f1, l1)?
+        _ForwardIterator1 __match = __first1;
+        for (; __match != __i; ++__match)
+            if (__pred(*__match, *__i))
+                break;
+        if (__match == __i) {
             // Count number of *__i in [f2, l2)
             _D1 __c2 = 0;
             for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
@@ -1497,13 +1503,12 @@ __not_done:
             if (__c1 != __c2)
                 return false;
         }
-__next_iter:;
     }
     return true;
 }
 
 template<class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
                _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
                _BinaryPredicate __pred,
@@ -1517,7 +1522,7 @@ __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1
 }
 
 template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
                _ForwardIterator2 __first2, _ForwardIterator2 __last2,
@@ -1530,7 +1535,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 }
 
 template<class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
                _ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1545,91 +1550,10 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 #endif
 
 // search
-
-template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-pair<_ForwardIterator1, _ForwardIterator1>
-__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
-         _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
-         forward_iterator_tag, forward_iterator_tag)
-{
-    if (__first2 == __last2)
-        return make_pair(__first1, __first1);  // Everything matches an empty sequence
-    while (true)
-    {
-        // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks
-        while (true)
-        {
-            if (__first1 == __last1)  // return __last1 if no element matches *__first2
-                return make_pair(__last1, __last1);
-            if (__pred(*__first1, *__first2))
-                break;
-            ++__first1;
-        }
-        // *__first1 matches *__first2, now match elements after here
-        _ForwardIterator1 __m1 = __first1;
-        _ForwardIterator2 __m2 = __first2;
-        while (true)
-        {
-            if (++__m2 == __last2)  // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
-                return make_pair(__first1, __m1);
-            if (++__m1 == __last1)  // Otherwise if source exhaused, pattern not found
-                return make_pair(__last1, __last1);
-            if (!__pred(*__m1, *__m2))  // if there is a mismatch, restart with a new __first1
-            {
-                ++__first1;
-                break;
-            }  // else there is a match, check next elements
-        }
-    }
-}
-
-template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_RandomAccessIterator1, _RandomAccessIterator1>
-__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
-         _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
-           random_access_iterator_tag, random_access_iterator_tag)
-{
-    typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
-    typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
-    // Take advantage of knowing source and pattern lengths.  Stop short when source is smaller than pattern
-    const _D2 __len2 = __last2 - __first2;
-    if (__len2 == 0)
-        return make_pair(__first1, __first1);
-    const _D1 __len1 = __last1 - __first1;
-    if (__len1 < __len2)
-        return make_pair(__last1, __last1);
-    const _RandomAccessIterator1 __s = __last1 - (__len2 - 1);  // Start of pattern match can't go beyond here
-
-    while (true)
-    {
-        while (true)
-        {
-            if (__first1 == __s)
-                return make_pair(__last1, __last1);
-            if (__pred(*__first1, *__first2))
-                break;
-            ++__first1;
-        }
-
-        _RandomAccessIterator1 __m1 = __first1;
-        _RandomAccessIterator2 __m2 = __first2;
-         while (true)
-         {
-             if (++__m2 == __last2)
-                 return make_pair(__first1, __first1 + __len2);
-             ++__m1;          // no need to check range on __m1 because __s guarantees we have enough source
-             if (!__pred(*__m1, *__m2))
-             {
-                 ++__first1;
-                 break;
-             }
-         }
-    }
-}
+// __search is in <functional>
 
 template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator1
 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
        _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
@@ -1642,7 +1566,7 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 }
 
 template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator1
 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
        _ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1652,10 +1576,18 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
     return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
 }
 
+
+#if _LIBCPP_STD_VER > 14
+template <class _ForwardIterator, class _Searcher>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
+{ return __s(__f, __l).first; }
+#endif
+
 // search_n
 
 template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 __search_n(_ForwardIterator __first, _ForwardIterator __last,
            _Size __count, const _Tp& __value_, _BinaryPredicate __pred, forward_iterator_tag)
 {
@@ -1692,7 +1624,7 @@ __search_n(_ForwardIterator __first, _ForwardIterator __last,
 }
 
 template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp>
-_RandomAccessIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
 __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
            _Size __count, const _Tp& __value_, _BinaryPredicate __pred, random_access_iterator_tag)
 {
@@ -1732,7 +1664,7 @@ __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
 }
 
 template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 search_n(_ForwardIterator __first, _ForwardIterator __last,
          _Size __count, const _Tp& __value_, _BinaryPredicate __pred)
@@ -1743,7 +1675,7 @@ search_n(_ForwardIterator __first, _ForwardIterator __last,
 }
 
 template <class _ForwardIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)
 {
@@ -1776,7 +1708,7 @@ __unwrap_iter(move_iterator<_Tp*> __i)
 #if _LIBCPP_DEBUG_LEVEL < 2
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
 typename enable_if
 <
     is_trivially_copy_assignable<_Tp>::value,
@@ -1790,7 +1722,7 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
 #else
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
 typename enable_if
 <
     is_trivially_copy_assignable<_Tp>::value,
@@ -2023,7 +1955,7 @@ move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
 // transform
 
 template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
 {
@@ -2033,7 +1965,7 @@ transform(_InputIterator __first, _InputIterator __last, _OutputIterator __resul
 }
 
 template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
           _OutputIterator __result, _BinaryOperation __binary_op)
@@ -2046,7 +1978,7 @@ transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __f
 // replace
 
 template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
 {
@@ -2058,7 +1990,7 @@ replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_valu
 // replace_if
 
 template <class _ForwardIterator, class _Predicate, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
 {
@@ -2070,7 +2002,7 @@ replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
 // replace_copy
 
 template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
              const _Tp& __old_value, const _Tp& __new_value)
@@ -2086,7 +2018,7 @@ replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __re
 // replace_copy_if
 
 template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
                 _Predicate __pred, const _Tp& __new_value)
@@ -2102,7 +2034,7 @@ replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator _
 // fill_n
 
 template <class _OutputIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
 {
@@ -2111,24 +2043,8 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
     return __first;
 }
 
-template <class _Tp, class _Size, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_integral<_Tp>::value && sizeof(_Tp) == 1 &&
-    !is_same<_Tp, bool>::value &&
-    is_integral<_Up>::value && sizeof(_Up) == 1,
-    _Tp*
->::type
-__fill_n(_Tp* __first, _Size __n,_Up __value_)
-{
-    if (__n > 0)
-        _VSTD::memset(__first, (unsigned char)__value_, (size_t)(__n));
-    return __first + __n;
-}
-
 template <class _OutputIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
 {
@@ -2138,7 +2054,7 @@ fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
 // fill
 
 template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)
 {
@@ -2147,7 +2063,7 @@ __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, f
 }
 
 template <class _RandomAccessIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)
 {
@@ -2155,7 +2071,7 @@ __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& _
 }
 
 template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 {
@@ -2165,7 +2081,7 @@ fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 // generate
 
 template <class _ForwardIterator, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
 {
@@ -2176,7 +2092,7 @@ generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
 // generate_n
 
 template <class _OutputIterator, class _Size, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY  _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
 {
@@ -2190,7 +2106,7 @@ generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
 // remove
 
 template <class _ForwardIterator, class _Tp>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 {
     __first = _VSTD::find(__first, __last, __value_);
@@ -2212,7 +2128,7 @@ remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 // remove_if
 
 template <class _ForwardIterator, class _Predicate>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
 {
     __first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type>
@@ -2235,7 +2151,7 @@ remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
 // remove_copy
 
 template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_)
 {
@@ -2253,7 +2169,7 @@ remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __res
 // remove_copy_if
 
 template <class _InputIterator, class _OutputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
 {
@@ -2271,7 +2187,7 @@ remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __
 // unique
 
 template <class _ForwardIterator, class _BinaryPredicate>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
 {
     __first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type>
@@ -2290,7 +2206,7 @@ unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pre
 }
 
 template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 unique(_ForwardIterator __first, _ForwardIterator __last)
 {
@@ -2301,7 +2217,7 @@ unique(_ForwardIterator __first, _ForwardIterator __last)
 // unique_copy
 
 template <class _BinaryPredicate, class _InputIterator, class _OutputIterator>
-_OutputIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
 __unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
               input_iterator_tag, output_iterator_tag)
 {
@@ -2324,7 +2240,7 @@ __unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __r
 }
 
 template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator>
-_OutputIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
 __unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
               forward_iterator_tag, output_iterator_tag)
 {
@@ -2347,7 +2263,7 @@ __unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator
 }
 
 template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 __unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred,
               input_iterator_tag, forward_iterator_tag)
 {
@@ -2363,7 +2279,7 @@ __unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __
 }
 
 template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred)
 {
@@ -2374,7 +2290,7 @@ unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __res
 }
 
 template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
 {
@@ -2419,7 +2335,7 @@ reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
 // reverse_copy
 
 template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
 {
@@ -3303,7 +3219,7 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
 }
 
 template <class _InputIterator, class _Predicate>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
 {
     for (; __first != __last; ++__first)
@@ -3381,7 +3297,7 @@ partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
 
 template <class _InputIterator, class _OutputIterator1,
           class _OutputIterator2, class _Predicate>
-pair<_OutputIterator1, _OutputIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2>
 partition_copy(_InputIterator __first, _InputIterator __last,
                _OutputIterator1 __out_true, _OutputIterator2 __out_false,
                _Predicate __pred)
@@ -3405,7 +3321,7 @@ partition_copy(_InputIterator __first, _InputIterator __last,
 // partition_point
 
 template<class _ForwardIterator, class _Predicate>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
 {
     typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
@@ -3711,7 +3627,7 @@ stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate _
 // is_sorted_until
 
 template <class _ForwardIterator, class _Compare>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
 {
     if (__first != __last)
@@ -3728,7 +3644,7 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __co
 }
 
 template<class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
 {
@@ -3738,7 +3654,7 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
 // is_sorted
 
 template <class _ForwardIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
 {
@@ -3746,7 +3662,7 @@ is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
 }
 
 template<class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 is_sorted(_ForwardIterator __first, _ForwardIterator __last)
 {
@@ -4272,7 +4188,7 @@ _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&,
 // lower_bound
 
 template <class _Compare, class _ForwardIterator, class _Tp>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
 {
     typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
@@ -4294,7 +4210,7 @@ __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
 }
 
 template <class _ForwardIterator, class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
 {
@@ -4309,7 +4225,7 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
 }
 
 template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 {
@@ -4320,7 +4236,7 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
 // upper_bound
 
 template <class _Compare, class _ForwardIterator, class _Tp>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
 {
     typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
@@ -4342,7 +4258,7 @@ __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
 }
 
 template <class _ForwardIterator, class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
 {
@@ -4357,7 +4273,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
 }
 
 template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 {
@@ -4368,7 +4284,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
 // equal_range
 
 template <class _Compare, class _ForwardIterator, class _Tp>
-pair<_ForwardIterator, _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
 __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
 {
     typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
@@ -4402,7 +4318,7 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
 }
 
 template <class _ForwardIterator, class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 pair<_ForwardIterator, _ForwardIterator>
 equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
 {
@@ -4417,7 +4333,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
 }
 
 template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 pair<_ForwardIterator, _ForwardIterator>
 equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 {
@@ -4428,7 +4344,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
 // binary_search
 
 template <class _Compare, class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 __binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
 {
@@ -4437,7 +4353,7 @@ __binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __
 }
 
 template <class _ForwardIterator, class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
 {
@@ -4452,7 +4368,7 @@ binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
 }
 
 template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 {
@@ -4787,9 +4703,9 @@ __stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1
         ::new(__first2) value_type(_VSTD::move(*__first1));
         return;
     case 2:
-       __destruct_n __d(0);
+        __destruct_n __d(0);
         unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
-         if (__comp(*--__last1, *__first1))
+        if (__comp(*--__last1, *__first1))
         {
             ::new(__first2) value_type(_VSTD::move(*__last1));
             __d.__incr((value_type*)0);
@@ -4906,7 +4822,7 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
 // is_heap_until
 
 template <class _RandomAccessIterator, class _Compare>
-_RandomAccessIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
 is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
 {
     typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -4933,7 +4849,7 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
 }
 
 template<class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _RandomAccessIterator
 is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
 {
@@ -4943,7 +4859,7 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
 // is_heap
 
 template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
 {
@@ -4951,7 +4867,7 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __
 }
 
 template<class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
 {
@@ -5489,7 +5405,7 @@ nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomA
 // includes
 
 template <class _Compare, class _InputIterator1, class _InputIterator2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
            _Compare __comp)
 {
@@ -5504,7 +5420,7 @@ __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __
 }
 
 template <class _InputIterator1, class _InputIterator2, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
          _Compare __comp)
@@ -5520,7 +5436,7 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
 }
 
 template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
 {
@@ -5586,7 +5502,7 @@ set_union(_InputIterator1 __first1, _InputIterator1 __last1,
 // set_intersection
 
 template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_OutputIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
 __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
                    _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
 {
@@ -5609,7 +5525,7 @@ __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
 }
 
 template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
                  _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
@@ -5625,7 +5541,7 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
 }
 
 template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
                  _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
@@ -5751,7 +5667,7 @@ set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
 // lexicographical_compare
 
 template <class _Compare, class _InputIterator1, class _InputIterator2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
                           _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
 {
@@ -5766,7 +5682,7 @@ __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
 }
 
 template <class _InputIterator1, class _InputIterator2, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
                         _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
@@ -5782,7 +5698,7 @@ lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
 }
 
 template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
                         _InputIterator2 __first2, _InputIterator2 __last2)
diff --git lib/libcxx/include/any lib/libcxx/include/any
index d7161b0d6f4..9bd2f53c560 100644
--- lib/libcxx/include/any
+++ lib/libcxx/include/any
@@ -104,7 +104,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER > 14
 
-_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
 void __throw_bad_any_cast()
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
@@ -304,7 +304,7 @@ private:
         __any_imp::_Buffer __buf;
     };
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     void * __call(_Action __a, any * __other = nullptr,
                   type_info const * __info = nullptr,
                    const void* __fallback_info = nullptr) const
@@ -312,7 +312,7 @@ private:
         return __h(__a, this, __other, __info, __fallback_info);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     void * __call(_Action __a, any * __other = nullptr,
                   type_info const * __info = nullptr,
                   const void* __fallback_info = nullptr)
diff --git lib/libcxx/include/array lib/libcxx/include/array
index 4eb2fe6fc62..1e6a650198b 100644
--- lib/libcxx/include/array
+++ lib/libcxx/include/array
@@ -72,6 +72,9 @@ struct array
     const T* data() const noexcept;
 };
 
+  template <class T, class... U>
+    array(T, U...) -> array<T, 1 + sizeof...(U)>;
+
 template <class T, size_t N>
   bool operator==(const array<T,N>& x, const array<T,N>& y);
 template <class T, size_t N>
@@ -86,7 +89,7 @@ template <class T, size_t N>
   bool operator>=(const array<T,N>& x, const array<T,N>& y);
 
 template <class T, size_t N >
-  void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y)));
+  void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17
 
 template <class T> class tuple_size;
 template <size_t I, class T> class tuple_element;
@@ -108,6 +111,8 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
 #include <iterator>
 #include <algorithm>
 #include <stdexcept>
+#include <cstdlib> // for _LIBCPP_UNREACHABLE
+#include <__debug>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -117,6 +122,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+
 template <class _Tp, size_t _Size>
 struct _LIBCPP_TEMPLATE_VIS array
 {
@@ -134,31 +140,27 @@ struct _LIBCPP_TEMPLATE_VIS array
     typedef std::reverse_iterator<iterator>       reverse_iterator;
     typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
-    value_type __elems_[_Size > 0 ? _Size : 1];
+    _Tp __elems_[_Size];
 
     // No explicit construct/copy/destroy for aggregate type
-    _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
-        {_VSTD::fill_n(__elems_, _Size, __u);}
-    _LIBCPP_INLINE_VISIBILITY
-    void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
-        { __swap_dispatch((std::integral_constant<bool, _Size == 0>()), __a); }
-
-    _LIBCPP_INLINE_VISIBILITY
-    void __swap_dispatch(std::true_type, array&) {}
+    _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
+      _VSTD::fill_n(__elems_, _Size, __u);
+    }
 
     _LIBCPP_INLINE_VISIBILITY
-    void __swap_dispatch(std::false_type, array& __a)
-        { _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+    void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+      std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
+    }
 
     // iterators:
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-    iterator begin() _NOEXCEPT {return iterator(__elems_);}
+    iterator begin() _NOEXCEPT {return iterator(data());}
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-    const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
+    const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-    iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
+    iterator end() _NOEXCEPT {return iterator(data() + _Size);}
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-    const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
+    const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
     reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
@@ -184,7 +186,7 @@ struct _LIBCPP_TEMPLATE_VIS array
     _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
     _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
-    _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
+    _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; }
 
     // element access:
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
@@ -197,8 +199,8 @@ struct _LIBCPP_TEMPLATE_VIS array
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front()             {return __elems_[0];}
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
-    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back()              {return __elems_[_Size > 0 ? _Size-1 : 0];}
-    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const  {return __elems_[_Size > 0 ? _Size-1 : 0];}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back()              {return __elems_[_Size - 1];}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const  {return __elems_[_Size - 1];}
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
     value_type* data() _NOEXCEPT {return __elems_;}
@@ -206,6 +208,7 @@ struct _LIBCPP_TEMPLATE_VIS array
     const value_type* data() const _NOEXCEPT {return __elems_;}
 };
 
+
 template <class _Tp, size_t _Size>
 _LIBCPP_CONSTEXPR_AFTER_CXX14
 typename array<_Tp, _Size>::reference
@@ -227,12 +230,147 @@ array<_Tp, _Size>::at(size_type __n) const
     return __elems_[__n];
 }
 
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
+{
+    // types:
+    typedef array __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;
+
+    typedef typename conditional<is_const<_Tp>::value, const char,
+                                char>::type _CharType;
+
+    struct  _ArrayInStructT { _Tp __data_[1]; };
+    _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
+
+    // No explicit construct/copy/destroy for aggregate type
+    _LIBCPP_INLINE_VISIBILITY void fill(const value_type&) {
+      static_assert(!is_const<_Tp>::value,
+                    "cannot fill zero-sized array of type 'const T'");
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(array&) _NOEXCEPT {
+      static_assert(!is_const<_Tp>::value,
+                    "cannot swap zero-sized array of type 'const T'");
+    }
+
+    // iterators:
+    _LIBCPP_INLINE_VISIBILITY
+    iterator begin() _NOEXCEPT {return iterator(data());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator end() _NOEXCEPT {return iterator(data());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const _NOEXCEPT {return const_iterator(data());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT {return begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const _NOEXCEPT {return end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+    // capacity:
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; }
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;}
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
+
+    // element access:
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator[](size_type) {
+      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
+      _LIBCPP_UNREACHABLE();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    const_reference operator[](size_type) const {
+      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
+      _LIBCPP_UNREACHABLE();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference at(size_type) {
+      __throw_out_of_range("array<T, 0>::at");
+      _LIBCPP_UNREACHABLE();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference at(size_type) const {
+      __throw_out_of_range("array<T, 0>::at");
+      _LIBCPP_UNREACHABLE();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference front() {
+      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
+      _LIBCPP_UNREACHABLE();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference front() const {
+      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
+      _LIBCPP_UNREACHABLE();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference back() {
+      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
+      _LIBCPP_UNREACHABLE();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference back() const {
+      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
+      _LIBCPP_UNREACHABLE();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);}
+    _LIBCPP_INLINE_VISIBILITY
+    const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);}
+};
+
+
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _Tp, class... _Args,
+         class = typename enable_if<(is_same_v<_Tp, _Args> && ...), void>::type
+         >
+array(_Tp, _Args...)
+  -> array<_Tp, 1 + sizeof...(_Args)>;
+#endif
+
 template <class _Tp, size_t _Size>
 inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
 {
-    return _VSTD::equal(__x.__elems_, __x.__elems_ + _Size, __y.__elems_);
+    return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
 }
 
 template <class _Tp, size_t _Size>
@@ -248,7 +386,8 @@ inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
 {
-    return _VSTD::lexicographical_compare(__x.__elems_, __x.__elems_ + _Size, __y.__elems_, __y.__elems_ + _Size);
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
+                                          __y.begin(), __y.end());
 }
 
 template <class _Tp, size_t _Size>
diff --git lib/libcxx/include/atomic lib/libcxx/include/atomic
index f55e28ff5e9..809f78a06d3 100644
--- lib/libcxx/include/atomic
+++ lib/libcxx/include/atomic
@@ -555,6 +555,9 @@ void atomic_signal_fence(memory_order m) noexcept;
 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
 #error <atomic> is not implemented
 #endif
+#ifdef kill_dependency
+#error C++ standard library is incompatible with <stdatomic.h>
+#endif
 
 #if _LIBCPP_STD_VER > 14
 # define __cpp_lib_atomic_is_always_lock_free 201603L
@@ -695,7 +698,7 @@ static inline void __c11_atomic_store(_Atomic(_Tp)* __a,  _Tp __val,
 }
 
 template <typename _Tp>
-static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
+static inline _Tp __c11_atomic_load(const volatile _Atomic(_Tp)* __a,
                                     memory_order __order) {
   _Tp __ret;
   __atomic_load(&__a->__a_value, &__ret,
@@ -704,7 +707,7 @@ static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
 }
 
 template <typename _Tp>
-static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) {
+static inline _Tp __c11_atomic_load(const _Atomic(_Tp)* __a, memory_order __order) {
   _Tp __ret;
   __atomic_load(&__a->__a_value, &__ret,
                 __gcc_atomic::__to_gcc_order(__order));
@@ -1741,7 +1744,7 @@ typedef struct atomic_flag
     atomic_flag() _NOEXCEPT : __a_() {}
 #endif // _LIBCPP_CXX03_LANG
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
     atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
 
 #ifndef _LIBCPP_CXX03_LANG
diff --git lib/libcxx/include/cfloat lib/libcxx/include/cfloat
index 176fa9de3ce..0abe84bf175 100644
--- lib/libcxx/include/cfloat
+++ lib/libcxx/include/cfloat
@@ -20,11 +20,18 @@ Macros:
     FLT_EVAL_METHOD     // C99
     FLT_RADIX
 
+    FLT_HAS_SUBNORM     // C11
+    DBL_HAS_SUBNORM     // C11
+    LDBL_HAS_SUBNORM    // C11
+
     FLT_MANT_DIG
     DBL_MANT_DIG
     LDBL_MANT_DIG
 
     DECIMAL_DIG         // C99
+    FLT_DECIMAL_DIG     // C11
+    DBL_DECIMAL_DIG     // C11
+    LDBL_DECIMAL_DIG    // C11
 
     FLT_DIG
     DBL_DIG
@@ -58,6 +65,9 @@ Macros:
     DBL_MIN
     LDBL_MIN
 
+    FLT_TRUE_MIN        // C11
+    DBL_TRUE_MIN        // C11
+    LDBL_TRUE_MIN       // C11
 */
 
 #include <__config>
diff --git lib/libcxx/include/charconv lib/libcxx/include/charconv
new file mode 100644
index 00000000000..7cb790e1bee
--- /dev/null
+++ lib/libcxx/include/charconv
@@ -0,0 +1,610 @@
+// -*- C++ -*-
+//===------------------------------ charconv ------------------------------===//
+//
+//                     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_CHARCONV
+#define _LIBCPP_CHARCONV
+
+/*
+    charconv synopsis
+
+namespace std {
+
+  // floating-point format for primitive numerical conversion
+  enum class chars_format {
+    scientific = unspecified,
+    fixed = unspecified,
+    hex = unspecified,
+    general = fixed | scientific
+  };
+
+  // 23.20.2, primitive numerical output conversion
+  struct to_chars_result {
+    char* ptr;
+    errc ec;
+  };
+
+  to_chars_result to_chars(char* first, char* last, see below value,
+                           int base = 10);
+
+  to_chars_result to_chars(char* first, char* last, float value);
+  to_chars_result to_chars(char* first, char* last, double value);
+  to_chars_result to_chars(char* first, char* last, long double value);
+
+  to_chars_result to_chars(char* first, char* last, float value,
+                           chars_format fmt);
+  to_chars_result to_chars(char* first, char* last, double value,
+                           chars_format fmt);
+  to_chars_result to_chars(char* first, char* last, long double value,
+                           chars_format fmt);
+
+  to_chars_result to_chars(char* first, char* last, float value,
+                           chars_format fmt, int precision);
+  to_chars_result to_chars(char* first, char* last, double value,
+                           chars_format fmt, int precision);
+  to_chars_result to_chars(char* first, char* last, long double value,
+                           chars_format fmt, int precision);
+
+  // 23.20.3, primitive numerical input conversion
+  struct from_chars_result {
+    const char* ptr;
+    errc ec;
+  };
+
+  from_chars_result from_chars(const char* first, const char* last,
+                               see below& value, int base = 10);
+
+  from_chars_result from_chars(const char* first, const char* last,
+                               float& value,
+                               chars_format fmt = chars_format::general);
+  from_chars_result from_chars(const char* first, const char* last,
+                               double& value,
+                               chars_format fmt = chars_format::general);
+  from_chars_result from_chars(const char* first, const char* last,
+                               long double& value,
+                               chars_format fmt = chars_format::general);
+
+} // namespace std
+
+*/
+
+#include <__errc>
+#include <type_traits>
+#include <limits>
+#include <stdint.h>
+#include <string.h>
+#include <math.h>
+
+#include <__debug>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 11
+
+enum class _LIBCPP_ENUM_VIS chars_format
+{
+    scientific = 0x1,
+    fixed = 0x2,
+    hex = 0x4,
+    general = fixed | scientific
+};
+
+struct _LIBCPP_TYPE_VIS to_chars_result
+{
+    char* ptr;
+    errc ec;
+};
+
+struct _LIBCPP_TYPE_VIS from_chars_result
+{
+    const char* ptr;
+    errc ec;
+};
+
+void to_chars(char*, char*, bool, int = 10) = delete;
+void from_chars(const char*, const char*, bool, int = 10) = delete;
+
+namespace __itoa
+{
+
+static constexpr uint64_t __pow10_64[] = {
+    UINT64_C(0),
+    UINT64_C(10),
+    UINT64_C(100),
+    UINT64_C(1000),
+    UINT64_C(10000),
+    UINT64_C(100000),
+    UINT64_C(1000000),
+    UINT64_C(10000000),
+    UINT64_C(100000000),
+    UINT64_C(1000000000),
+    UINT64_C(10000000000),
+    UINT64_C(100000000000),
+    UINT64_C(1000000000000),
+    UINT64_C(10000000000000),
+    UINT64_C(100000000000000),
+    UINT64_C(1000000000000000),
+    UINT64_C(10000000000000000),
+    UINT64_C(100000000000000000),
+    UINT64_C(1000000000000000000),
+    UINT64_C(10000000000000000000),
+};
+
+static constexpr uint32_t __pow10_32[] = {
+    UINT32_C(0),          UINT32_C(10),       UINT32_C(100),
+    UINT32_C(1000),       UINT32_C(10000),    UINT32_C(100000),
+    UINT32_C(1000000),    UINT32_C(10000000), UINT32_C(100000000),
+    UINT32_C(1000000000),
+};
+
+_LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer);
+_LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer);
+
+template <typename _Tp, typename = void>
+struct _LIBCPP_HIDDEN __traits_base
+{
+    using type = uint64_t;
+
+#if !defined(_LIBCPP_COMPILER_MSVC)
+    static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
+    {
+        auto __t = (64 - __builtin_clzll(__v | 1)) * 1233 >> 12;
+        return __t - (__v < __pow10_64[__t]) + 1;
+    }
+#endif
+
+    static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
+    {
+        return __u64toa(__v, __p);
+    }
+
+    static _LIBCPP_INLINE_VISIBILITY auto& __pow() { return __pow10_64; }
+};
+
+template <typename _Tp>
+struct _LIBCPP_HIDDEN
+    __traits_base<_Tp, decltype(void(uint32_t{declval<_Tp>()}))>
+{
+    using type = uint32_t;
+
+#if !defined(_LIBCPP_COMPILER_MSVC)
+    static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
+    {
+        auto __t = (32 - __builtin_clz(__v | 1)) * 1233 >> 12;
+        return __t - (__v < __pow10_32[__t]) + 1;
+    }
+#endif
+
+    static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
+    {
+        return __u32toa(__v, __p);
+    }
+
+    static _LIBCPP_INLINE_VISIBILITY auto& __pow() { return __pow10_32; }
+};
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
+{
+    auto __c = __a * __b;
+    __r = __c;
+    return __c > (numeric_limits<unsigned char>::max)();
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
+{
+    auto __c = __a * __b;
+    __r = __c;
+    return __c > (numeric_limits<unsigned short>::max)();
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
+{
+    static_assert(is_unsigned<_Tp>::value, "");
+#if !defined(_LIBCPP_COMPILER_MSVC)
+    return __builtin_mul_overflow(__a, __b, &__r);
+#else
+    bool __did = __b && ((numeric_limits<_Tp>::max)() / __b) < __a;
+    __r = __a * __b;
+    return __did;
+#endif
+}
+
+template <typename _Tp, typename _Up>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
+{
+    return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);
+}
+
+template <typename _Tp>
+struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
+{
+    static constexpr int digits = numeric_limits<_Tp>::digits10 + 1;
+    using __traits_base<_Tp>::__pow;
+    using typename __traits_base<_Tp>::type;
+
+    // precondition: at least one non-zero character available
+    static _LIBCPP_INLINE_VISIBILITY char const*
+    __read(char const* __p, char const* __ep, type& __a, type& __b)
+    {
+        type __cprod[digits];
+        int __j = digits - 1;
+        int __i = digits;
+        do
+        {
+            if (!('0' <= *__p && *__p <= '9'))
+                break;
+            __cprod[--__i] = *__p++ - '0';
+        } while (__p != __ep && __i != 0);
+
+        __a = __inner_product(__cprod + __i + 1, __cprod + __j, __pow() + 1,
+                              __cprod[__i]);
+        if (__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))
+            --__p;
+        return __p;
+    }
+
+    template <typename _It1, typename _It2, class _Up>
+    static _LIBCPP_INLINE_VISIBILITY _Up
+    __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
+    {
+        for (; __first1 < __last1; ++__first1, ++__first2)
+            __init = __init + *__first1 * *__first2;
+        return __init;
+    }
+};
+
+}  // namespace __itoa
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _Tp
+__complement(_Tp __x)
+{
+    static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
+    return _Tp(~__x + 1);
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY auto
+__to_unsigned(_Tp __x)
+{
+    return static_cast<make_unsigned_t<_Tp>>(__x);
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
+{
+    auto __x = __to_unsigned(__value);
+    if (__value < 0 && __first != __last)
+    {
+        *__first++ = '-';
+        __x = __complement(__x);
+    }
+
+    return __to_chars_itoa(__first, __last, __x, false_type());
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
+{
+    using __tx = __itoa::__traits<_Tp>;
+    auto __diff = __last - __first;
+
+#if !defined(_LIBCPP_COMPILER_MSVC)
+    if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
+        return {__tx::__convert(__value, __first), {}};
+    else
+        return {__last, errc::value_too_large};
+#else
+    if (__tx::digits <= __diff)
+        return {__tx::__convert(__value, __first), {}};
+    else
+    {
+        char __buf[__tx::digits];
+        auto __p = __tx::__convert(__value, __buf);
+        auto __len = __p - __buf;
+        if (__len <= __diff)
+        {
+            memcpy(__first, __buf, __len);
+            return {__first + __len, {}};
+        }
+        else
+            return {__last, errc::value_too_large};
+    }
+#endif
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
+                    true_type)
+{
+    auto __x = __to_unsigned(__value);
+    if (__value < 0 && __first != __last)
+    {
+        *__first++ = '-';
+        __x = __complement(__x);
+    }
+
+    return __to_chars_integral(__first, __last, __x, __base, false_type());
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
+                    false_type)
+{
+    if (__base == 10)
+        return __to_chars_itoa(__first, __last, __value, false_type());
+
+    auto __p = __last;
+    while (__p != __first)
+    {
+        auto __c = __value % __base;
+        __value /= __base;
+        *--__p = "0123456789abcdefghijklmnopqrstuvwxyz"[__c];
+        if (__value == 0)
+            break;
+    }
+
+    auto __len = __last - __p;
+    if (__value != 0 || !__len)
+        return {__last, errc::value_too_large};
+    else
+    {
+        memmove(__first, __p, __len);
+        return {__first + __len, {}};
+    }
+}
+
+template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+to_chars(char* __first, char* __last, _Tp __value)
+{
+    return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>());
+}
+
+template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
+inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+to_chars(char* __first, char* __last, _Tp __value, int __base)
+{
+    _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
+    return __to_chars_integral(__first, __last, __value, __base,
+                               is_signed<_Tp>());
+}
+
+template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
+{
+    using __tl = numeric_limits<_Tp>;
+    decltype(__to_unsigned(__value)) __x;
+
+    bool __neg = (__first != __last && *__first == '-');
+    auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...);
+    switch (__r.ec)
+    {
+    case errc::invalid_argument:
+        return {__first, __r.ec};
+    case errc::result_out_of_range:
+        return __r;
+    default:
+        break;
+    }
+
+    if (__neg)
+    {
+        if (__x <= __complement(__to_unsigned(__tl::min())))
+        {
+            __x = __complement(__x);
+            memcpy(&__value, &__x, sizeof(__x));
+            return __r;
+        }
+    }
+    else
+    {
+        if (__x <= (__tl::max)())
+        {
+            __value = __x;
+            return __r;
+        }
+    }
+
+    return {__r.ptr, errc::result_out_of_range};
+}
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY bool
+__in_pattern(_Tp __c)
+{
+    return '0' <= __c && __c <= '9';
+}
+
+struct _LIBCPP_HIDDEN __in_pattern_result
+{
+    bool __ok;
+    int __val;
+
+    explicit _LIBCPP_INLINE_VISIBILITY operator bool() const { return __ok; }
+};
+
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY __in_pattern_result
+__in_pattern(_Tp __c, int __base)
+{
+    if (__base <= 10)
+        return {'0' <= __c && __c < '0' + __base, __c - '0'};
+    else if (__in_pattern(__c))
+        return {true, __c - '0'};
+    else if ('a' <= __c && __c < 'a' + __base - 10)
+        return {true, __c - 'a' + 10};
+    else
+        return {'A' <= __c && __c < 'A' + __base - 10, __c - 'A' + 10};
+}
+
+template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
+                         _Ts... __args)
+{
+    auto __find_non_zero = [](_It __first, _It __last) {
+        for (; __first != __last; ++__first)
+            if (*__first != '0')
+                break;
+        return __first;
+    };
+
+    auto __p = __find_non_zero(__first, __last);
+    if (__p == __last || !__in_pattern(*__p, __args...))
+    {
+        if (__p == __first)
+            return {__first, errc::invalid_argument};
+        else
+        {
+            __value = 0;
+            return {__p, {}};
+        }
+    }
+
+    auto __r = __f(__p, __last, __value, __args...);
+    if (__r.ec == errc::result_out_of_range)
+    {
+        for (; __r.ptr != __last; ++__r.ptr)
+        {
+            if (!__in_pattern(*__r.ptr, __args...))
+                break;
+        }
+    }
+
+    return __r;
+}
+
+template <typename _Tp, enable_if_t<is_unsigned<_Tp>::value, int> = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
+{
+    using __tx = __itoa::__traits<_Tp>;
+    using __output_type = typename __tx::type;
+
+    return __subject_seq_combinator(
+        __first, __last, __value,
+        [](const char* __first, const char* __last,
+           _Tp& __value) -> from_chars_result {
+            __output_type __a, __b;
+            auto __p = __tx::__read(__first, __last, __a, __b);
+            if (__p == __last || !__in_pattern(*__p))
+            {
+                __output_type __m = (numeric_limits<_Tp>::max)();
+                if (__m >= __a && __m - __a >= __b)
+                {
+                    __value = __a + __b;
+                    return {__p, {}};
+                }
+            }
+            return {__p, errc::result_out_of_range};
+        });
+}
+
+template <typename _Tp, enable_if_t<is_signed<_Tp>::value, int> = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
+{
+    using __t = decltype(__to_unsigned(__value));
+    return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
+}
+
+template <typename _Tp, enable_if_t<is_unsigned<_Tp>::value, int> = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
+                      int __base)
+{
+    if (__base == 10)
+        return __from_chars_atoi(__first, __last, __value);
+
+    return __subject_seq_combinator(
+        __first, __last, __value,
+        [](const char* __p, const char* __last, _Tp& __value,
+           int __base) -> from_chars_result {
+            using __tl = numeric_limits<_Tp>;
+            auto __digits = __tl::digits / log2f(float(__base));
+            _Tp __a = __in_pattern(*__p++, __base).__val, __b = 0;
+
+            for (int __i = 1; __p != __last; ++__i, ++__p)
+            {
+                if (auto __c = __in_pattern(*__p, __base))
+                {
+                    if (__i < __digits - 1)
+                        __a = __a * __base + __c.__val;
+                    else
+                    {
+                        if (!__itoa::__mul_overflowed(__a, __base, __a))
+                            ++__p;
+                        __b = __c.__val;
+                        break;
+                    }
+                }
+                else
+                    break;
+            }
+
+            if (__p == __last || !__in_pattern(*__p, __base))
+            {
+                if ((__tl::max)() - __a >= __b)
+                {
+                    __value = __a + __b;
+                    return {__p, {}};
+                }
+            }
+            return {__p, errc::result_out_of_range};
+        },
+        __base);
+}
+
+template <typename _Tp, enable_if_t<is_signed<_Tp>::value, int> = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
+                      int __base)
+{
+    using __t = decltype(__to_unsigned(__value));
+    return __sign_combinator(__first, __last, __value,
+                             __from_chars_integral<__t>, __base);
+}
+
+template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+from_chars(const char* __first, const char* __last, _Tp& __value)
+{
+    return __from_chars_atoi(__first, __last, __value);
+}
+
+template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
+inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
+{
+    _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
+    return __from_chars_integral(__first, __last, __value, __base);
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CHARCONV
diff --git lib/libcxx/include/chrono lib/libcxx/include/chrono
index 809f773b6c6..f6a6f4b2434 100644
--- lib/libcxx/include/chrono
+++ lib/libcxx/include/chrono
@@ -147,6 +147,11 @@ template <class Clock, class Duration1, class Duration2>
 
 namespace chrono {
 
+
+template<class T> struct is_clock;  // C++20
+template<class T> inline constexpr bool is_clock_v = is_clock<T>::value;   // C++20
+
+
 // duration arithmetic
 template <class Rep1, class Period1, class Rep2, class Period2>
   constexpr
@@ -204,6 +209,8 @@ template <class ToDuration, class Rep, class Period>
 template <class ToDuration, class Rep, class Period>
     constexpr ToDuration round(const duration<Rep, Period>& d);    // C++17
 
+// duration I/O is elsewhere
+
 // time_point arithmetic (all constexpr in C++14)
 template <class Clock, class Duration1, class Rep2, class Period2>
   time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
@@ -251,6 +258,7 @@ template <class ToDuration, class Clock, class Duration>
 
 template <class Rep, class Period>
     constexpr duration<Rep, Period> abs(duration<Rep, Period> d);  // C++17
+
 // Clocks
 
 class system_clock
@@ -267,6 +275,28 @@ public:
     static time_point from_time_t(time_t __t) noexcept;
 };
 
+template <class Duration>
+  using sys_time  = time_point<system_clock, Duration>; // C++20
+using sys_seconds = sys_time<seconds>;                  // C++20
+using sys_days    = sys_time<days>;                     // C++20
+
+class utc_clock;                                        // C++20
+
+template <class Duration>
+  using utc_time  = time_point<utc_clock, Duration>;    // C++20
+using utc_seconds = utc_time<seconds>;                  // C++20
+
+class tai_clock;                                        // C++20
+
+template <class Duration>
+  using tai_time  = time_point<tai_clock, Duration>;    // C++20
+using tai_seconds = tai_time<seconds>;                  // C++20
+
+class file_clock;                                       // C++20
+
+template<class Duration>
+  using file_time = time_point<file_clock, Duration>;   // C++20
+
 class steady_clock
 {
 public:
@@ -281,8 +311,466 @@ public:
 
 typedef steady_clock high_resolution_clock;
 
+// 25.7.8, local time           // C++20
+struct local_t {};
+template<class Duration>
+  using local_time  = time_point<local_t, Duration>;
+using local_seconds = local_time<seconds>;
+using local_days    = local_time<days>;
+
+// 25.7.9, time_point conversions template<class DestClock, class SourceClock>    // C++20
+struct clock_time_conversion;
+
+template<class DestClock, class SourceClock, class Duration>
+  auto clock_cast(const time_point<SourceClock, Duration>& t);
+  
+// 25.8.2, class last_spec    // C++20
+struct last_spec;
+
+// 25.8.3, class day          // C++20
+
+class day;
+constexpr bool operator==(const day& x, const day& y) noexcept;
+constexpr bool operator!=(const day& x, const day& y) noexcept;
+constexpr bool operator< (const day& x, const day& y) noexcept;
+constexpr bool operator> (const day& x, const day& y) noexcept;
+constexpr bool operator<=(const day& x, const day& y) noexcept;
+constexpr bool operator>=(const day& x, const day& y) noexcept;
+constexpr day  operator+(const day&  x, const days& y) noexcept;
+constexpr day  operator+(const days& x, const day&  y) noexcept;
+constexpr day  operator-(const day&  x, const days& y) noexcept;
+constexpr days operator-(const day&  x, const day&  y) noexcept;
+
+// 25.8.4, class month    // C++20
+class month;
+constexpr bool operator==(const month& x, const month& y) noexcept;
+constexpr bool operator!=(const month& x, const month& y) noexcept;
+constexpr bool operator< (const month& x, const month& y) noexcept;
+constexpr bool operator> (const month& x, const month& y) noexcept;
+constexpr bool operator<=(const month& x, const month& y) noexcept;
+constexpr bool operator>=(const month& x, const month& y) noexcept;
+constexpr month  operator+(const month&  x, const months& y) noexcept;
+constexpr month  operator+(const months& x,  const month& y) noexcept;
+constexpr month  operator-(const month&  x, const months& y) noexcept;
+constexpr months operator-(const month&  x,  const month& y) noexcept;
+
+// 25.8.5, class year    // C++20
+class year;
+constexpr bool operator==(const year& x, const year& y) noexcept;
+constexpr bool operator!=(const year& x, const year& y) noexcept;
+constexpr bool operator< (const year& x, const year& y) noexcept;
+constexpr bool operator> (const year& x, const year& y) noexcept;
+constexpr bool operator<=(const year& x, const year& y) noexcept;
+constexpr bool operator>=(const year& x, const year& y) noexcept;
+constexpr year  operator+(const year&  x, const years& y) noexcept;
+constexpr year  operator+(const years& x, const year&  y) noexcept;
+constexpr year  operator-(const year&  x, const years& y) noexcept;
+constexpr years operator-(const year&  x, const year&  y) noexcept;
+
+// 25.8.6, class weekday    // C++20
+class weekday;
+
+constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
+constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
+constexpr weekday operator+(const weekday& x, const days&    y) noexcept;
+constexpr weekday operator+(const days&    x, const weekday& y) noexcept;
+constexpr weekday operator-(const weekday& x, const days&    y) noexcept;
+constexpr days    operator-(const weekday& x, const weekday& y) noexcept;
+
+// 25.8.7, class weekday_indexed    // C++20
+
+class weekday_indexed;
+constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
+constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
+
+// 25.8.8, class weekday_last    // C++20
+class weekday_last;
+
+constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
+constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
+
+// 25.8.9, class month_day    // C++20
+class month_day;
+
+constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
+constexpr bool operator!=(const month_day& x, const month_day& y) noexcept;
+constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
+constexpr bool operator> (const month_day& x, const month_day& y) noexcept;
+constexpr bool operator<=(const month_day& x, const month_day& y) noexcept;
+constexpr bool operator>=(const month_day& x, const month_day& y) noexcept;
+
+
+// 25.8.10, class month_day_last    // C++20
+class month_day_last;
+
+constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;
+constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;
+
+// 25.8.11, class month_weekday    // C++20
+class month_weekday;
+
+constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
+constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept;
+
+// 25.8.12, class month_weekday_last    // C++20
+class month_weekday_last;
+
+constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
+constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept;
+
+
+// 25.8.13, class year_month    // C++20
+class year_month;
+
+constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
+constexpr bool operator!=(const year_month& x, const year_month& y) noexcept;
+constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
+constexpr bool operator> (const year_month& x, const year_month& y) noexcept;
+constexpr bool operator<=(const year_month& x, const year_month& y) noexcept;
+constexpr bool operator>=(const year_month& x, const year_month& y) noexcept;
+
+constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
+constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
+constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
+constexpr months operator-(const year_month& x, const year_month& y) noexcept;
+constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
+constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
+constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
+
+// 25.8.14, class year_month_day class    // C++20
+year_month_day;
+
+constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept;
+constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept;
+
+constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
+constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
+constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
+constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
+constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
+constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
+
+
+// 25.8.15, class year_month_day_last    // C++20
+class year_month_day_last;
+
+constexpr bool operator==(const year_month_day_last& x,
+                          const year_month_day_last& y) noexcept;
+constexpr bool operator!=(const year_month_day_last& x,
+                          const year_month_day_last& y) noexcept;
+constexpr bool operator< (const year_month_day_last& x,
+                          const year_month_day_last& y) noexcept;
+constexpr bool operator> (const year_month_day_last& x,
+                          const year_month_day_last& y) noexcept;
+constexpr bool operator<=(const year_month_day_last& x,
+                          const year_month_day_last& y) noexcept;
+constexpr bool operator>=(const year_month_day_last& x,
+                          const year_month_day_last& y) noexcept;
+
+constexpr year_month_day_last
+  operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
+constexpr year_month_day_last
+  operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
+constexpr year_month_day_last
+  operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
+constexpr year_month_day_last
+  operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
+constexpr year_month_day_last
+  operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
+constexpr year_month_day_last
+  operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
+
+// 25.8.16, class year_month_weekday    // C++20
+class year_month_weekday;
+
+constexpr bool operator==(const year_month_weekday& x,
+                          const year_month_weekday& y) noexcept;
+constexpr bool operator!=(const year_month_weekday& x,
+                          const year_month_weekday& y) noexcept;
+
+constexpr year_month_weekday
+  operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
+constexpr year_month_weekday
+  operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
+constexpr year_month_weekday
+  operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
+constexpr year_month_weekday
+  operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
+constexpr year_month_weekday
+  operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
+constexpr year_month_weekday
+  operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
+
+// 25.8.17, class year_month_weekday_last    // C++20
+class year_month_weekday_last;
+
+constexpr bool operator==(const year_month_weekday_last& x,
+                          const year_month_weekday_last& y) noexcept;
+constexpr bool operator!=(const year_month_weekday_last& x,
+                          const year_month_weekday_last& y) noexcept;
+constexpr year_month_weekday_last
+  operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
+constexpr year_month_weekday_last
+  operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
+constexpr year_month_weekday_last
+  operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
+constexpr year_month_weekday_last
+  operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
+constexpr year_month_weekday_last
+  operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
+constexpr year_month_weekday_last
+  operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
+  
+// 25.8.18, civil calendar conventional syntax operators    // C++20
+constexpr year_month
+  operator/(const year& y, const month& m) noexcept;
+constexpr year_month
+  operator/(const year& y, int m) noexcept;
+constexpr month_day
+  operator/(const month& m, const day& d) noexcept;
+constexpr month_day
+  operator/(const month& m, int d) noexcept;
+constexpr month_day
+  operator/(int m, const day& d) noexcept;
+constexpr month_day
+  operator/(const day& d, const month& m) noexcept;
+constexpr month_day
+  operator/(const day& d, int m) noexcept;
+constexpr month_day_last
+  operator/(const month& m, last_spec) noexcept;
+constexpr month_day_last
+  operator/(int m, last_spec) noexcept;
+constexpr month_day_last
+  operator/(last_spec, const month& m) noexcept;
+constexpr month_day_last
+  operator/(last_spec, int m) noexcept;
+constexpr month_weekday
+  operator/(const month& m, const weekday_indexed& wdi) noexcept;
+constexpr month_weekday
+  operator/(int m, const weekday_indexed& wdi) noexcept;
+constexpr month_weekday
+  operator/(const weekday_indexed& wdi, const month& m) noexcept;
+constexpr month_weekday
+  operator/(const weekday_indexed& wdi, int m) noexcept;
+constexpr month_weekday_last
+  operator/(const month& m, const weekday_last& wdl) noexcept;
+constexpr month_weekday_last
+  operator/(int m, const weekday_last& wdl) noexcept;
+constexpr month_weekday_last
+  operator/(const weekday_last& wdl, const month& m) noexcept;
+constexpr month_weekday_last
+  operator/(const weekday_last& wdl, int m) noexcept;
+constexpr year_month_day
+  operator/(const year_month& ym, const day& d) noexcept;
+constexpr year_month_day
+  operator/(const year_month& ym, int d) noexcept;
+constexpr year_month_day
+  operator/(const year& y, const month_day& md) noexcept;
+constexpr year_month_day
+  operator/(int y, const month_day& md) noexcept;
+constexpr year_month_day
+  operator/(const month_day& md, const year& y) noexcept;
+constexpr year_month_day
+  operator/(const month_day& md, int y) noexcept;
+constexpr year_month_day_last
+  operator/(const year_month& ym, last_spec) noexcept;
+constexpr year_month_day_last
+  operator/(const year& y, const month_day_last& mdl) noexcept;
+constexpr year_month_day_last
+  operator/(int y, const month_day_last& mdl) noexcept;
+constexpr year_month_day_last
+  operator/(const month_day_last& mdl, const year& y) noexcept;
+constexpr year_month_day_last
+  operator/(const month_day_last& mdl, int y) noexcept;
+constexpr year_month_weekday
+  operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
+constexpr year_month_weekday
+  operator/(const year& y, const month_weekday& mwd) noexcept;
+constexpr year_month_weekday
+  operator/(int y, const month_weekday& mwd) noexcept;
+constexpr year_month_weekday
+  operator/(const month_weekday& mwd, const year& y) noexcept;
+constexpr year_month_weekday
+  operator/(const month_weekday& mwd, int y) noexcept;
+constexpr year_month_weekday_last
+  operator/(const year_month& ym, const weekday_last& wdl) noexcept;
+constexpr year_month_weekday_last
+  operator/(const year& y, const month_weekday_last& mwdl) noexcept;
+constexpr year_month_weekday_last
+  operator/(int y, const month_weekday_last& mwdl) noexcept;
+constexpr year_month_weekday_last
+  operator/(const month_weekday_last& mwdl, const year& y) noexcept;
+constexpr year_month_weekday_last
+  operator/(const month_weekday_last& mwdl, int y) noexcept;  
+
+// 25.9, class template time_of_day    // C++20
+template<class Duration> class time_of_day;
+
+template<> class time_of_day<hours>;
+template<> class time_of_day<minutes>;
+template<> class time_of_day<seconds>;
+template<class Rep, class Period> class time_of_day<duration<Rep, Period>>;
+
+// 25.10.2, time zone database     // C++20
+struct tzdb;
+class tzdb_list;
+
+// 25.10.2.3, time zone database access    // C++20
+const tzdb& get_tzdb();
+tzdb_list& get_tzdb_list();
+const time_zone* locate_zone(string_view tz_name);
+const time_zone* current_zone();
+
+// 25.10.2.4, remote time zone database support    // C++20
+const tzdb& reload_tzdb();
+string remote_version();
+
+// 25.10.3, exception classes    // C++20
+class nonexistent_local_time;
+class ambiguous_local_time;
+
+// 25.10.4, information classes    // C++20
+struct sys_info;
+struct local_info;
+    
+// 25.10.5, class time_zone    // C++20
+enum class choose {earliest, latest};
+class time_zone;
+bool operator==(const time_zone& x, const time_zone& y) noexcept;
+bool operator!=(const time_zone& x, const time_zone& y) noexcept;
+bool operator<(const time_zone& x, const time_zone& y) noexcept;
+bool operator>(const time_zone& x, const time_zone& y) noexcept;
+bool operator<=(const time_zone& x, const time_zone& y) noexcept;
+bool operator>=(const time_zone& x, const time_zone& y) noexcept;
+  
+// 25.10.6, class template zoned_traits    // C++20
+template<class T> struct zoned_traits;
+
+// 25.10.7, class template zoned_time    // C++20
+template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time;
+using zoned_seconds = zoned_time<seconds>;
+
+template<class Duration1, class Duration2, class TimeZonePtr>
+  bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
+                  const zoned_time<Duration2, TimeZonePtr>& y);
+template<class Duration1, class Duration2, class TimeZonePtr>
+  bool operator!=(const zoned_time<Duration1, TimeZonePtr>& x,
+                  const zoned_time<Duration2, TimeZonePtr>& y);
+
+// 25.10.8, leap second support    // C++20
+class leap;
+
+bool operator==(const leap& x, const leap& y);
+bool operator!=(const leap& x, const leap& y);
+bool operator< (const leap& x, const leap& y);
+bool operator> (const leap& x, const leap& y);
+bool operator<=(const leap& x, const leap& y);
+bool operator>=(const leap& x, const leap& y);
+template<class Duration>
+  bool operator==(const leap& x, const sys_time<Duration>& y);
+template<class Duration>
+  bool operator==(const sys_time<Duration>& x, const leap& y);
+template<class Duration>
+  bool operator!=(const leap& x, const sys_time<Duration>& y);
+template<class Duration>
+  bool operator!=(const sys_time<Duration>& x, const leap& y);
+template<class Duration>
+  bool operator< (const leap& x, const sys_time<Duration>& y);
+template<class Duration>
+  bool operator< (const sys_time<Duration>& x, const leap& y);
+template<class Duration>
+  bool operator> (const leap& x, const sys_time<Duration>& y);
+template<class Duration>
+  bool operator> (const sys_time<Duration>& x, const leap& y);
+template<class Duration>
+  bool operator<=(const leap& x, const sys_time<Duration>& y);
+template<class Duration>
+  bool operator<=(const sys_time<Duration>& x, const leap& y);
+template<class Duration>
+  bool operator>=(const leap& x, const sys_time<Duration>& y);
+template<class Duration>
+  bool operator>=(const sys_time<Duration>& x, const leap& y);
+
+// 25.10.9, class link    // C++20
+class link;
+bool operator==(const link& x, const link& y);
+bool operator!=(const link& x, const link& y);
+bool operator< (const link& x, const link& y);
+bool operator> (const link& x, const link& y);
+bool operator<=(const link& x, const link& y);
+bool operator>=(const link& x, const link& y);
+
+// 25.11, formatting    // C++20
+template<class charT, class Streamable>
+  basic_string<charT>
+    format(const charT* fmt, const Streamable& s);
+
+template<class charT, class Streamable>
+  basic_string<charT>
+    format(const locale& loc, const charT* fmt, const Streamable& s);
+
+template<class charT, class traits, class Alloc, class Streamable>
+  basic_string<charT, traits, Alloc>
+    format(const basic_string<charT, traits, Alloc>& fmt, const Streamable& s);
+
+template<class charT, class traits, class Alloc, class Streamable>
+  basic_string<charT, traits, Alloc>
+    format(const locale& loc, const basic_string<charT, traits, Alloc>& fmt,
+           const Streamable& s);            
+
+// 25.12, parsing    // C++20
+template<class charT, class traits, class Alloc, class Parsable>
+unspecified
+    parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp);
+
+template<class charT, class traits, class Alloc, class Parsable>
+unspecified
+    parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
+          basic_string<charT, traits, Alloc>& abbrev);
+
+template<class charT, class traits, class Alloc, class Parsable>
+unspecified
+    parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
+          minutes& offset);
+
+template<class charT, class traits, class Alloc, class Parsable>
+unspecified
+    parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
+          basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
+
+inline constexpr last_spec last{};       // C++20
+inline constexpr chrono::weekday                        Sunday{0};    // C++20
+inline constexpr chrono::weekday                        Monday{1};    // C++20
+inline constexpr chrono::weekday                        Tuesday{2};   // C++20
+inline constexpr chrono::weekday                        Wednesday{3}; // C++20
+inline constexpr chrono::weekday                        Thursday{4};  // C++20
+inline constexpr chrono::weekday                        Friday{5};    // C++20
+inline constexpr chrono::weekday                        Saturday{6};  // C++20
+
+inline constexpr chrono::month                          January{1};   // C++20
+inline constexpr chrono::month                          February{2};  // C++20
+inline constexpr chrono::month                          March{3};     // C++20
+inline constexpr chrono::month                          April{4};     // C++20
+inline constexpr chrono::month                          May{5};       // C++20
+inline constexpr chrono::month                          June{6};      // C++20
+inline constexpr chrono::month                          July{7};      // C++20
+inline constexpr chrono::month                          August{8};    // C++20
+inline constexpr chrono::month                          September{9}; // C++20
+inline constexpr chrono::month                          October{10};  // C++20
+inline constexpr chrono::month                          November{11}; // C++20
+inline constexpr chrono::month                          December{12}; // C++20
 }  // chrono
 
+inline namespace literals {
+  inline namespace chrono_literals {
 constexpr chrono::hours                                 operator ""h(unsigned long long); // C++14
 constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
 constexpr chrono::minutes                               operator ""min(unsigned long long); // C++14
@@ -295,6 +783,10 @@ constexpr chrono::microseconds                          operator ""us(unsigned l
 constexpr chrono::duration<unspecified , micro>         operator ""us(long double); // C++14
 constexpr chrono::nanoseconds                           operator ""ns(unsigned long long); // C++14
 constexpr chrono::duration<unspecified , nano>          operator ""ns(long double); // C++14
+constexpr chrono::day                                   operator ""d(unsigned long long d) noexcept; // C++20
+constexpr chrono::year                                  operator ""y(unsigned long long y) noexcept; // C++20
+}  // chrono_literals
+}  // literals
 
 }  // std
 */
diff --git lib/libcxx/include/cmath lib/libcxx/include/cmath
index 917928a1f42..ffb1c46c7b6 100644
--- lib/libcxx/include/cmath
+++ lib/libcxx/include/cmath
@@ -547,7 +547,7 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
 #endif
 
 template <class _A1>
-_LIBCPP_ALWAYS_INLINE
+_LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
 __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 {
@@ -559,7 +559,7 @@ __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 }
 
 template <class _A1>
-_LIBCPP_ALWAYS_INLINE
+_LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
 __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 {
@@ -567,7 +567,7 @@ __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 }
 
 template <class _A1>
-_LIBCPP_ALWAYS_INLINE
+_LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
 __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 {
@@ -579,7 +579,7 @@ __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 }
 
 template <class _A1>
-_LIBCPP_ALWAYS_INLINE
+_LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
 __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 {
@@ -587,7 +587,7 @@ __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 }
 
 template <class _A1>
-_LIBCPP_ALWAYS_INLINE
+_LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
 __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 {
@@ -599,7 +599,7 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 }
 
 template <class _A1>
-_LIBCPP_ALWAYS_INLINE
+_LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
 __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
 {
diff --git lib/libcxx/include/codecvt lib/libcxx/include/codecvt
index 46f56acff71..5eb9d154911 100644
--- lib/libcxx/include/codecvt
+++ lib/libcxx/include/codecvt
@@ -86,7 +86,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -121,7 +121,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -156,7 +156,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -186,11 +186,11 @@ class _LIBCPP_TEMPLATE_VIS codecvt_utf8
     : public __codecvt_utf8<_Elem>
 {
 public:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt_utf8(size_t __refs = 0)
         : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     ~codecvt_utf8() {}
 };
 
@@ -209,7 +209,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -244,7 +244,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -279,7 +279,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -314,7 +314,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -349,7 +349,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -384,7 +384,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -414,11 +414,11 @@ class _LIBCPP_TEMPLATE_VIS codecvt_utf16
     : public __codecvt_utf16<_Elem, _Mode & little_endian>
 {
 public:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt_utf16(size_t __refs = 0)
         : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     ~codecvt_utf16() {}
 };
 
@@ -437,7 +437,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -472,7 +472,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -507,7 +507,7 @@ public:
     typedef char      extern_type;
     typedef mbstate_t state_type;
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
                             codecvt_mode _Mode)
         : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
@@ -537,11 +537,11 @@ class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16
     : public __codecvt_utf8_utf16<_Elem>
 {
 public:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     explicit codecvt_utf8_utf16(size_t __refs = 0)
         : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     ~codecvt_utf8_utf16() {}
 };
 
diff --git lib/libcxx/include/compare lib/libcxx/include/compare
new file mode 100644
index 00000000000..07f88f09cb3
--- /dev/null
+++ lib/libcxx/include/compare
@@ -0,0 +1,679 @@
+// -*- C++ -*-
+//===-------------------------- compare -----------------------------------===//
+//
+//                     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_COMPARE
+#define _LIBCPP_COMPARE
+
+/*
+    compare synopsis
+
+namespace std {
+  // [cmp.categories], comparison category types
+  class weak_equality;
+  class strong_equality;
+  class partial_ordering;
+  class weak_ordering;
+  class strong_ordering;
+
+  // named comparison functions
+  constexpr bool is_eq  (weak_equality cmp) noexcept    { return cmp == 0; }
+  constexpr bool is_neq (weak_equality cmp) noexcept    { return cmp != 0; }
+  constexpr bool is_lt  (partial_ordering cmp) noexcept { return cmp < 0; }
+  constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
+  constexpr bool is_gt  (partial_ordering cmp) noexcept { return cmp > 0; }
+  constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
+
+  // [cmp.common], common comparison category type
+  template<class... Ts>
+  struct common_comparison_category {
+    using type = see below;
+  };
+  template<class... Ts>
+    using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
+
+  // [cmp.alg], comparison algorithms
+  template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
+  template<class T> constexpr weak_ordering weak_order(const T& a, const T& b);
+  template<class T> constexpr partial_ordering partial_order(const T& a, const T& b);
+  template<class T> constexpr strong_equality strong_equal(const T& a, const T& b);
+  template<class T> constexpr weak_equality weak_equal(const T& a, const T& b);
+}
+*/
+
+#include <__config>
+#include <type_traits>
+#include <array>
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+// exposition only
+enum class _LIBCPP_ENUM_VIS _EqResult : unsigned char {
+  __zero = 0,
+  __equal = __zero,
+  __equiv = __equal,
+  __nonequal = 1,
+  __nonequiv = __nonequal
+};
+
+enum class _LIBCPP_ENUM_VIS _OrdResult : signed char {
+  __less = -1,
+  __greater = 1
+};
+
+enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {
+  __unordered = -127
+};
+
+struct _CmpUnspecifiedType;
+using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();
+
+class  weak_equality {
+  _LIBCPP_INLINE_VISIBILITY
+  constexpr explicit weak_equality(_EqResult __val) noexcept : __value_(__val) {}
+
+public:
+  static const weak_equality equivalent;
+  static const weak_equality nonequivalent;
+
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept;
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+  _LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept;
+#endif
+
+private:
+  _EqResult __value_;
+};
+
+_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::equivalent(_EqResult::__equiv);
+_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::nonequivalent(_EqResult::__nonequiv);
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ == _EqResult::__zero;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept {
+  return __v.__value_ == _EqResult::__zero;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ != _EqResult::__zero;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept {
+  return __v.__value_ != _EqResult::__zero;
+}
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept {
+  return __v;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept {
+  return __v;
+}
+#endif
+
+class strong_equality {
+  _LIBCPP_INLINE_VISIBILITY
+  explicit constexpr strong_equality(_EqResult __val) noexcept : __value_(__val) {}
+
+public:
+  static const strong_equality equal;
+  static const strong_equality nonequal;
+  static const strong_equality equivalent;
+  static const strong_equality nonequivalent;
+
+  // conversion
+  _LIBCPP_INLINE_VISIBILITY constexpr operator weak_equality() const noexcept {
+    return __value_ == _EqResult::__zero ? weak_equality::equivalent
+          : weak_equality::nonequivalent;
+  }
+
+  // comparisons
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept;
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+  _LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept;
+#endif
+private:
+  _EqResult __value_;
+};
+
+_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equal(_EqResult::__equal);
+_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequal(_EqResult::__nonequal);
+_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equivalent(_EqResult::__equiv);
+_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequivalent(_EqResult::__nonequiv);
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ == _EqResult::__zero;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept {
+  return __v.__value_ == _EqResult::__zero;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ != _EqResult::__zero;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept {
+  return __v.__value_ != _EqResult::__zero;
+}
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+_LIBCPP_INLINE_VISIBILITY
+constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept {
+  return __v;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept {
+  return __v;
+}
+#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+
+class partial_ordering {
+  using _ValueT = signed char;
+
+  _LIBCPP_INLINE_VISIBILITY
+  explicit constexpr partial_ordering(_EqResult __v) noexcept
+      : __value_(_ValueT(__v)) {}
+
+  _LIBCPP_INLINE_VISIBILITY
+  explicit constexpr partial_ordering(_OrdResult __v) noexcept
+      : __value_(_ValueT(__v)) {}
+
+  _LIBCPP_INLINE_VISIBILITY
+  explicit constexpr partial_ordering(_NCmpResult __v) noexcept
+      : __value_(_ValueT(__v)) {}
+
+  constexpr bool __is_ordered() const noexcept {
+    return __value_ != _ValueT(_NCmpResult::__unordered);
+  }
+public:
+  // valid values
+  static const partial_ordering less;
+  static const partial_ordering equivalent;
+  static const partial_ordering greater;
+  static const partial_ordering unordered;
+
+  // conversion
+  constexpr operator weak_equality() const noexcept {
+    return __value_ == 0 ? weak_equality::equivalent : weak_equality::nonequivalent;
+  }
+
+  // comparisons
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+  _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+#endif
+
+private:
+  _ValueT __value_;
+};
+
+_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
+_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv);
+_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
+_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ == 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ < 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ <= 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ > 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ >= 0;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+  return __v.__is_ordered() && 0 == __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+  return __v.__is_ordered() && 0 < __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+  return __v.__is_ordered() && 0 <= __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+  return __v.__is_ordered() && 0 > __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+  return __v.__is_ordered() && 0 >= __v.__value_;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return !__v.__is_ordered() || __v.__value_ != 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+  return !__v.__is_ordered() || __v.__value_ != 0;
+}
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+_LIBCPP_INLINE_VISIBILITY
+constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+  return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
+}
+#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+
+class weak_ordering {
+  using _ValueT = signed char;
+
+  _LIBCPP_INLINE_VISIBILITY
+  explicit constexpr weak_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
+  _LIBCPP_INLINE_VISIBILITY
+  explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
+
+public:
+  static const weak_ordering less;
+  static const weak_ordering equivalent;
+  static const weak_ordering greater;
+
+  // conversions
+  _LIBCPP_INLINE_VISIBILITY
+  constexpr operator weak_equality() const noexcept {
+    return __value_ == 0 ? weak_equality::equivalent
+                         : weak_equality::nonequivalent;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  constexpr operator partial_ordering() const noexcept {
+    return __value_ == 0 ? partial_ordering::equivalent
+        : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
+  }
+
+  // comparisons
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+  _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
+#endif
+
+private:
+  _ValueT __value_;
+};
+
+_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::less(_OrdResult::__less);
+_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv);
+_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ == 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ != 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ < 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ <= 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ > 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ >= 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+  return 0 == __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+  return 0 != __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+  return 0 < __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+  return 0 <= __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+  return 0 > __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+  return 0 >= __v.__value_;
+}
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+_LIBCPP_INLINE_VISIBILITY
+constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+  return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
+}
+#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+
+class strong_ordering {
+  using _ValueT = signed char;
+
+  _LIBCPP_INLINE_VISIBILITY
+  explicit constexpr strong_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
+  _LIBCPP_INLINE_VISIBILITY
+  explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
+
+public:
+  static const strong_ordering less;
+  static const strong_ordering equal;
+  static const strong_ordering equivalent;
+  static const strong_ordering greater;
+
+  // conversions
+  _LIBCPP_INLINE_VISIBILITY
+  constexpr operator weak_equality() const noexcept {
+    return __value_ == 0 ? weak_equality::equivalent
+                         : weak_equality::nonequivalent;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  constexpr operator strong_equality() const noexcept {
+    return __value_ == 0 ? strong_equality::equal
+                         : strong_equality::nonequal;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  constexpr operator partial_ordering() const noexcept {
+    return __value_ == 0 ? partial_ordering::equivalent
+        : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  constexpr operator weak_ordering() const noexcept {
+    return __value_ == 0 ? weak_ordering::equivalent
+        : (__value_ < 0 ? weak_ordering::less : weak_ordering::greater);
+  }
+
+  // comparisons
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+  _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
+  _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
+#endif
+
+private:
+  _ValueT __value_;
+};
+
+_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::less(_OrdResult::__less);
+_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equal(_EqResult::__equal);
+_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv);
+_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ == 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ != 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ < 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ <= 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ > 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__value_ >= 0;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+  return 0 == __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+  return 0 != __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+  return 0 < __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+  return 0 <= __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+  return 0 > __v.__value_;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+  return 0 >= __v.__value_;
+}
+
+#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+_LIBCPP_INLINE_VISIBILITY
+constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v;
+}
+_LIBCPP_INLINE_VISIBILITY
+constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+  return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
+}
+#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+
+// named comparison functions
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool is_eq(weak_equality __cmp) noexcept    { return __cmp == 0; }
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool is_neq(weak_equality __cmp) noexcept    { return __cmp != 0; }
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool is_lt(partial_ordering __cmp) noexcept { return __cmp < 0; }
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool is_lteq(partial_ordering __cmp) noexcept { return __cmp <= 0; }
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool is_gt(partial_ordering __cmp) noexcept { return __cmp > 0; }
+
+_LIBCPP_INLINE_VISIBILITY
+constexpr bool is_gteq(partial_ordering __cmp) noexcept { return __cmp >= 0; }
+
+namespace __comp_detail {
+
+enum _ClassifyCompCategory : unsigned{
+  _None,
+  _WeakEq,
+  _StrongEq,
+  _PartialOrd,
+  _WeakOrd,
+  _StrongOrd,
+  _CCC_Size
+};
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+constexpr _ClassifyCompCategory __type_to_enum() noexcept {
+  if (is_same_v<_Tp, weak_equality>)
+    return _WeakEq;
+  if (is_same_v<_Tp, strong_equality>)
+    return _StrongEq;
+  if (is_same_v<_Tp, partial_ordering>)
+    return _PartialOrd;
+  if (is_same_v<_Tp, weak_ordering>)
+    return _WeakOrd;
+  if (is_same_v<_Tp, strong_ordering>)
+    return _StrongOrd;
+  return _None;
+}
+
+template <size_t _Size>
+constexpr _ClassifyCompCategory
+__compute_comp_type(std::array<_ClassifyCompCategory, _Size> __types) {
+  std::array<int, _CCC_Size> __seen = {};
+  for (auto __type : __types)
+    ++__seen[__type];
+  if (__seen[_None])
+    return _None;
+  if (__seen[_WeakEq])
+    return _WeakEq;
+  if (__seen[_StrongEq] && (__seen[_PartialOrd] || __seen[_WeakOrd]))
+    return _WeakEq;
+  if (__seen[_StrongEq])
+    return _StrongEq;
+  if (__seen[_PartialOrd])
+    return _PartialOrd;
+  if (__seen[_WeakOrd])
+    return _WeakOrd;
+  return _StrongOrd;
+}
+
+template <class ..._Ts>
+constexpr auto __get_comp_type() {
+  using _CCC = _ClassifyCompCategory;
+  constexpr array<_CCC, sizeof...(_Ts)> __type_kinds{{__comp_detail::__type_to_enum<_Ts>()...}};
+  constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
+      : __compute_comp_type(__type_kinds);
+  if constexpr (_Cat == _None)
+    return void();
+  else if constexpr (_Cat == _WeakEq)
+    return weak_equality::equivalent;
+  else if constexpr (_Cat == _StrongEq)
+    return strong_equality::equivalent;
+  else if constexpr (_Cat == _PartialOrd)
+    return partial_ordering::equivalent;
+  else if constexpr (_Cat == _WeakOrd)
+    return weak_ordering::equivalent;
+  else if constexpr (_Cat == _StrongOrd)
+    return strong_ordering::equivalent;
+  else
+    static_assert(_Cat != _Cat, "unhandled case");
+}
+} // namespace __comp_detail
+
+// [cmp.common], common comparison category type
+template<class... _Ts>
+struct _LIBCPP_TEMPLATE_VIS common_comparison_category {
+  using type = decltype(__comp_detail::__get_comp_type<_Ts...>());
+};
+
+template<class... _Ts>
+using common_comparison_category_t = typename common_comparison_category<_Ts...>::type;
+
+// [cmp.alg], comparison algorithms
+// TODO: unimplemented
+template<class _Tp> constexpr strong_ordering strong_order(const _Tp& __lhs, const _Tp& __rhs);
+template<class _Tp> constexpr weak_ordering weak_order(const _Tp& __lhs, const _Tp& __rhs);
+template<class _Tp> constexpr partial_ordering partial_order(const _Tp& __lhs, const _Tp& __rhs);
+template<class _Tp> constexpr strong_equality strong_equal(const _Tp& __lhs, const _Tp& __rhs);
+template<class _Tp> constexpr weak_equality weak_equal(const _Tp& __lhs, const _Tp& __rhs);
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_COMPARE
diff --git lib/libcxx/include/complex lib/libcxx/include/complex
index 41a47cfba47..d692ee31920 100644
--- lib/libcxx/include/complex
+++ lib/libcxx/include/complex
@@ -203,7 +203,7 @@ template<class T>    complex<T>           proj(const complex<T>&);
 template<Integral T> complex<double>      proj(T);
                      complex<float>       proj(float);
 
-template<class T> complex<T> polar(const T&, const T& = 0);
+template<class T> complex<T> polar(const T&, const T& = T());
 
 // 26.3.8 transcendentals:
 template<class T> complex<T> acos(const complex<T>&);
@@ -991,7 +991,7 @@ proj(_Tp __re)
 
 template<class _Tp>
 complex<_Tp>
-polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
+polar(const _Tp& __rho, const _Tp& __theta = _Tp())
 {
     if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
         return complex<_Tp>(_Tp(NAN), _Tp(NAN));
@@ -1125,6 +1125,17 @@ pow(const _Tp& __x, const complex<_Up>& __y)
     return _VSTD::pow(result_type(__x), result_type(__y));
 }
 
+// __sqr, computes pow(x, 2)
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+__sqr(const complex<_Tp>& __x)
+{
+    return complex<_Tp>((__x.real() - __x.imag()) * (__x.real() + __x.imag()),
+                        _Tp(2) * __x.real() * __x.imag());
+}
+
 // asinh
 
 template<class _Tp>
@@ -1150,7 +1161,7 @@ asinh(const complex<_Tp>& __x)
     }
     if (__libcpp_isinf_or_builtin(__x.imag()))
         return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
-    complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
+    complex<_Tp> __z = log(__x + sqrt(__sqr(__x) + _Tp(1)));
     return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
 }
 
@@ -1184,7 +1195,7 @@ acosh(const complex<_Tp>& __x)
     }
     if (__libcpp_isinf_or_builtin(__x.imag()))
         return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
-    complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
+    complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
     return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
 }
 
@@ -1318,7 +1329,7 @@ acos(const complex<_Tp>& __x)
         return complex<_Tp>(__pi/_Tp(2), -__x.imag());
     if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
         return complex<_Tp>(__pi/_Tp(2), -__x.imag());
-    complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
+    complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
     if (signbit(__x.imag()))
         return complex<_Tp>(abs(__z.imag()), abs(__z.real()));
     return complex<_Tp>(abs(__z.imag()), -abs(__z.real()));
diff --git lib/libcxx/include/cstdlib lib/libcxx/include/cstdlib
index 78c428403c3..00c604e6762 100644
--- lib/libcxx/include/cstdlib
+++ lib/libcxx/include/cstdlib
@@ -151,11 +151,11 @@ using ::mbtowc;
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
diff --git lib/libcxx/include/ctime lib/libcxx/include/ctime
index da9e3290bbb..8264fe33b96 100644
--- lib/libcxx/include/ctime
+++ lib/libcxx/include/ctime
@@ -18,7 +18,8 @@ Macros:
 
     NULL
     CLOCKS_PER_SEC
-
+    TIME_UTC // C++17
+    
 namespace std
 {
 
@@ -28,7 +29,8 @@ Types:
     size_t
     time_t
     tm
-
+    timespec // C++17
+    
 clock_t clock();
 double difftime(time_t time1, time_t time0);
 time_t mktime(tm* timeptr);
@@ -39,7 +41,7 @@ tm*    gmtime(const time_t* timer);
 tm* localtime(const time_t* timer);
 size_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
                 const tm* restrict timeptr);
-
+int timespec_get( struct timespec *ts, int base); // C++17
 }  // std
 
 */
@@ -57,6 +59,9 @@ using ::clock_t;
 using ::size_t;
 using ::time_t;
 using ::tm;
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+using ::timespec;
+#endif
 using ::clock;
 using ::difftime;
 using ::mktime;
@@ -68,6 +73,9 @@ using ::gmtime;
 using ::localtime;
 #endif
 using ::strftime;
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
+using ::timespec_get;
+#endif
 
 _LIBCPP_END_NAMESPACE_STD
 
diff --git lib/libcxx/include/deque lib/libcxx/include/deque
index 08cb295408b..bfbd3a5ef54 100644
--- lib/libcxx/include/deque
+++ lib/libcxx/include/deque
@@ -128,6 +128,10 @@ public:
     void clear() noexcept;
 };
 
+template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+   deque(InputIterator, InputIterator, Allocator = Allocator())
+   -> deque<typename iterator_traits<InputIterator>::value_type, Allocator>;
+
 template <class T, class Allocator>
     bool operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
 template <class T, class Allocator>
@@ -921,13 +925,14 @@ class __deque_base
 {
     __deque_base(const __deque_base& __c);
     __deque_base& operator=(const __deque_base& __c);
-protected:
-    typedef _Tp                                      value_type;
+public:
     typedef _Allocator                               allocator_type;
     typedef allocator_traits<allocator_type>         __alloc_traits;
+    typedef typename __alloc_traits::size_type       size_type;
+protected:
+    typedef _Tp                                      value_type;
     typedef value_type&                              reference;
     typedef const value_type&                        const_reference;
-    typedef typename __alloc_traits::size_type       size_type;
     typedef typename __alloc_traits::difference_type difference_type;
     typedef typename __alloc_traits::pointer         pointer;
     typedef typename __alloc_traits::const_pointer   const_pointer;
@@ -946,6 +951,7 @@ protected:
     typedef __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer,
                              difference_type>    const_iterator;
 
+protected:
     __map __map_;
     size_type __start_;
     __compressed_pair<size_type, allocator_type> __size_;
@@ -1461,6 +1467,23 @@ private:
     void __move_assign(deque& __c, false_type);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _InputIterator,
+         class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
+         class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+         >
+deque(_InputIterator, _InputIterator)
+  -> deque<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+
+template<class _InputIterator,
+         class _Alloc,
+         class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+         >
+deque(_InputIterator, _InputIterator, _Alloc)
+  -> deque<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+#endif
+
+
 template <class _Tp, class _Allocator>
 deque<_Tp, _Allocator>::deque(size_type __n)
 {
diff --git lib/libcxx/include/exception lib/libcxx/include/exception
index 79bd6ac2ae3..b517486b5a8 100644
--- lib/libcxx/include/exception
+++ lib/libcxx/include/exception
@@ -259,7 +259,7 @@ struct __throw_with_nested;
 
 template <class _Tp, class _Up>
 struct __throw_with_nested<_Tp, _Up, true> {
-    _LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
+    _LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
 #ifndef _LIBCPP_CXX03_LANG
     __do_throw(_Tp&& __t)
 #else
@@ -272,7 +272,7 @@ struct __throw_with_nested<_Tp, _Up, true> {
 
 template <class _Tp, class _Up>
 struct __throw_with_nested<_Tp, _Up, false> {
-    _LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
+    _LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
 #ifndef _LIBCPP_CXX03_LANG
     __do_throw(_Tp&& __t)
 #else
diff --git lib/libcxx/include/experimental/__config lib/libcxx/include/experimental/__config
index 37f88c166dd..c6f17762022 100644
--- lib/libcxx/include/experimental/__config
+++ lib/libcxx/include/experimental/__config
@@ -52,6 +52,23 @@
 
 #define _VSTD_CORO _VSTD_EXPERIMENTAL::coroutines_v1
 
-#define _VSTD_FS ::std::experimental::filesystem::v1
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
+    _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
+    } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+    _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+    } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
+
+// TODO: support more targets
+#if defined(__AVX__)
+#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
+#else
+#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
+#endif
 
 #endif
diff --git lib/libcxx/include/experimental/algorithm lib/libcxx/include/experimental/algorithm
index a6a28f07181..eb3bad6ef98 100644
--- lib/libcxx/include/experimental/algorithm
+++ lib/libcxx/include/experimental/algorithm
@@ -23,11 +23,8 @@ 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);
+
+// sample removed because it's now part of C++17
 
 } // namespace fundamentals_v1
 } // namespace experimental
@@ -56,16 +53,6 @@ _LIBCPP_INLINE_VISIBILITY
 _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
 { return __s(__f, __l).first; }
 
-
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
-          class _UniformRandomNumberGenerator>
-inline _LIBCPP_INLINE_VISIBILITY
-_SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
-                       _SampleIterator __output_iter, _Distance __n,
-                       _UniformRandomNumberGenerator &&__g) {
-  return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
-}
-
 _LIBCPP_END_NAMESPACE_LFTS
 
 _LIBCPP_POP_MACROS
diff --git lib/libcxx/include/experimental/any lib/libcxx/include/experimental/any
index 083a2909033..1dcdd0f25ec 100644
--- lib/libcxx/include/experimental/any
+++ lib/libcxx/include/experimental/any
@@ -8,585 +8,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP_EXPERIMENTAL_ANY
-#define _LIBCPP_EXPERIMENTAL_ANY
-
-/*
-   experimental/any synopsis
-
-namespace std {
-namespace experimental {
-inline namespace fundamentals_v1 {
-
-  class bad_any_cast : public bad_cast
-  {
-  public:
-    virtual const char* what() const noexcept;
-  };
-
-  class any
-  {
-  public:
-
-    // 6.3.1 any construct/destruct
-    any() noexcept;
-
-    any(const any& other);
-    any(any&& other) noexcept;
-
-    template <class ValueType>
-      any(ValueType&& value);
-
-    ~any();
-
-    // 6.3.2 any assignments
-    any& operator=(const any& rhs);
-    any& operator=(any&& rhs) noexcept;
-
-    template <class ValueType>
-      any& operator=(ValueType&& rhs);
-
-    // 6.3.3 any modifiers
-    void clear() noexcept;
-    void swap(any& rhs) noexcept;
-
-    // 6.3.4 any observers
-    bool empty() const noexcept;
-    const type_info& type() const noexcept;
-  };
-
-   // 6.4 Non-member functions
-  void swap(any& x, any& y) noexcept;
-
-  template<class ValueType>
-    ValueType any_cast(const any& operand);
-  template<class ValueType>
-    ValueType any_cast(any& operand);
-  template<class ValueType>
-    ValueType any_cast(any&& operand);
-
-  template<class ValueType>
-    const ValueType* any_cast(const any* operand) noexcept;
-  template<class ValueType>
-    ValueType* any_cast(any* operand) noexcept;
-
-} // namespace fundamentals_v1
-} // namespace experimental
-} // namespace std
-
-*/
-
-#include <experimental/__config>
-#include <memory>
-#include <new>
-#include <typeinfo>
-#include <type_traits>
-#include <cstdlib>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_LFTS
-
-class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
-{
-public:
-    virtual const char* what() const _NOEXCEPT;
-};
-
-#if _LIBCPP_STD_VER > 11                                            // C++ > 11
-
-_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
-_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-void __throw_bad_any_cast()
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
-    throw bad_any_cast();
-#else
-    _VSTD::abort();
-#endif
-}
-
-// Forward declarations
-class any;
-
-template <class _ValueType>
-typename add_pointer<typename add_const<_ValueType>::type>::type
-_LIBCPP_INLINE_VISIBILITY
-any_cast(any const *) _NOEXCEPT;
-
-template <class _ValueType>
-typename add_pointer<_ValueType>::type
-_LIBCPP_INLINE_VISIBILITY
-any_cast(any *) _NOEXCEPT;
-
-namespace __any_imp
-{
-  typedef typename aligned_storage<3*sizeof(void*), alignment_of<void*>::value>::type
-    _Buffer;
-
-  template <class _Tp>
-  struct _IsSmallObject
-    : public integral_constant<bool
-        , sizeof(_Tp) <= sizeof(_Buffer)
-          && alignment_of<_Buffer>::value
-             % alignment_of<_Tp>::value == 0
-          && is_nothrow_move_constructible<_Tp>::value
-        >
-  {};
-
-  enum class _Action
-  {
-    _Destroy,
-    _Copy,
-    _Move,
-    _Get,
-    _TypeInfo
-  };
-
-  template <class _Tp>
-  struct _SmallHandler;
-
-  template <class _Tp>
-  struct _LargeHandler;
-
-  template <class _Tp>
-  using _Handler = typename conditional<_IsSmallObject<_Tp>::value
-                                      , _SmallHandler<_Tp>
-                                      , _LargeHandler<_Tp>
-                                    >::type;
-  template <class _ValueType>
-  using _EnableIfNotAny = typename
-    enable_if<
-      !is_same<typename decay<_ValueType>::type, any>::value
-    >::type;
-
-} // namespace __any_imp
-
-class any
-{
-public:
-  // 6.3.1 any construct/destruct
-  _LIBCPP_INLINE_VISIBILITY
-  any() _NOEXCEPT : __h(nullptr) {}
-
-  _LIBCPP_INLINE_VISIBILITY
-  any(any const & __other) : __h(nullptr)
-  {
-    if (__other.__h) __other.__call(_Action::_Copy, this);
-  }
-
-  _LIBCPP_INLINE_VISIBILITY
-  any(any && __other) _NOEXCEPT : __h(nullptr)
-  {
-    if (__other.__h) __other.__call(_Action::_Move, this);
-  }
-
-  template <
-      class _ValueType
-    , class = __any_imp::_EnableIfNotAny<_ValueType>
-    >
-  _LIBCPP_INLINE_VISIBILITY
-  any(_ValueType && __value);
-
-  _LIBCPP_INLINE_VISIBILITY
-  ~any()
-  {
-    this->clear();
-  }
-
-  // 6.3.2 any assignments
-  _LIBCPP_INLINE_VISIBILITY
-  any & operator=(any const & __rhs)
-  {
-    any(__rhs).swap(*this);
-    return *this;
-  }
-
-  _LIBCPP_INLINE_VISIBILITY
-  any & operator=(any && __rhs) _NOEXCEPT
-  {
-    any(_VSTD::move(__rhs)).swap(*this);
-    return *this;
-  }
-
-  template <
-      class _ValueType
-    , class = __any_imp::_EnableIfNotAny<_ValueType>
-    >
-  _LIBCPP_INLINE_VISIBILITY
-  any & operator=(_ValueType && __rhs);
-
-  // 6.3.3 any modifiers
-  _LIBCPP_INLINE_VISIBILITY
-  void clear() _NOEXCEPT
-  {
-    if (__h) this->__call(_Action::_Destroy);
-  }
-
-  _LIBCPP_INLINE_VISIBILITY
-  void swap(any & __rhs) _NOEXCEPT;
-
-  // 6.3.4 any observers
-  _LIBCPP_INLINE_VISIBILITY
-  bool empty() const _NOEXCEPT
-  {
-    return __h == nullptr;
-  }
-
-#if !defined(_LIBCPP_NO_RTTI)
-  _LIBCPP_INLINE_VISIBILITY
-  const type_info & type() const _NOEXCEPT
-  {
-    if (__h) {
-        return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
-    } else {
-        return typeid(void);
-    }
-  }
-#endif
-
-private:
-    typedef __any_imp::_Action _Action;
-
-    typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *);
-
-    union _Storage
-    {
-        void *  __ptr;
-        __any_imp::_Buffer __buf;
-    };
-
-    _LIBCPP_ALWAYS_INLINE
-    void * __call(_Action __a, any * __other = nullptr,
-                  type_info const * __info = nullptr) const
-    {
-        return __h(__a, this, __other, __info);
-    }
-
-    _LIBCPP_ALWAYS_INLINE
-    void * __call(_Action __a, any * __other = nullptr,
-                  type_info const * __info = nullptr)
-    {
-        return __h(__a, this, __other, __info);
-    }
-
-    template <class>
-    friend struct __any_imp::_SmallHandler;
-    template <class>
-    friend struct __any_imp::_LargeHandler;
-
-    template <class _ValueType>
-    friend typename add_pointer<typename add_const<_ValueType>::type>::type
-    any_cast(any const *) _NOEXCEPT;
-
-    template <class _ValueType>
-    friend typename add_pointer<_ValueType>::type
-    any_cast(any *) _NOEXCEPT;
-
-    _HandleFuncPtr __h;
-    _Storage __s;
-};
-
-namespace __any_imp
-{
-
-  template <class _Tp>
-  struct _LIBCPP_TEMPLATE_VIS _SmallHandler
-  {
-     _LIBCPP_INLINE_VISIBILITY
-     static void* __handle(_Action __act, any const * __this, any * __other,
-                           type_info const * __info)
-     {
-        switch (__act)
-        {
-        case _Action::_Destroy:
-          __destroy(const_cast<any &>(*__this));
-          return nullptr;
-        case _Action::_Copy:
-            __copy(*__this, *__other);
-            return nullptr;
-        case _Action::_Move:
-          __move(const_cast<any &>(*__this), *__other);
-          return nullptr;
-        case _Action::_Get:
-            return __get(const_cast<any &>(*__this), __info);
-        case _Action::_TypeInfo:
-          return __type_info();
-        }
-    }
-
-    template <class _Up>
-    _LIBCPP_INLINE_VISIBILITY
-    static void __create(any & __dest, _Up && __v)
-    {
-        ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v));
-        __dest.__h = &_SmallHandler::__handle;
-    }
-
-  private:
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void __destroy(any & __this)
-    {
-        _Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
-        __value.~_Tp();
-        __this.__h = nullptr;
-    }
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void __copy(any const & __this, any & __dest)
-    {
-        _SmallHandler::__create(__dest, *static_cast<_Tp const *>(
-            static_cast<void const *>(&__this.__s.__buf)));
-    }
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void __move(any & __this, any & __dest)
-    {
-        _SmallHandler::__create(__dest, _VSTD::move(
-            *static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
-        __destroy(__this);
-    }
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void* __get(any & __this, type_info const * __info)
-    {
-#if !defined(_LIBCPP_NO_RTTI)
-        if (typeid(_Tp) == *__info) {
-            return static_cast<void*>(&__this.__s.__buf);
-        }
-        return nullptr;
-#else
-        return static_cast<void*>(&__this.__s.__buf);
-#endif
-    }
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void* __type_info()
-    {
-#if !defined(_LIBCPP_NO_RTTI)
-        return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
-#else
-        return nullptr;
-#endif
-    }
-  };
-
-  template <class _Tp>
-  struct _LIBCPP_TEMPLATE_VIS _LargeHandler
-  {
-    _LIBCPP_INLINE_VISIBILITY
-    static void* __handle(_Action __act, any const * __this, any * __other,
-                          type_info const * __info)
-    {
-        switch (__act)
-        {
-        case _Action::_Destroy:
-          __destroy(const_cast<any &>(*__this));
-          return nullptr;
-        case _Action::_Copy:
-          __copy(*__this, *__other);
-          return nullptr;
-        case _Action::_Move:
-          __move(const_cast<any &>(*__this), *__other);
-          return nullptr;
-        case _Action::_Get:
-            return __get(const_cast<any &>(*__this), __info);
-        case _Action::_TypeInfo:
-          return __type_info();
-        }
-    }
-
-    template <class _Up>
-    _LIBCPP_INLINE_VISIBILITY
-    static void __create(any & __dest, _Up && __v)
-    {
-        typedef allocator<_Tp> _Alloc;
-        typedef __allocator_destructor<_Alloc> _Dp;
-        _Alloc __a;
-        unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-        ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v));
-        __dest.__s.__ptr = __hold.release();
-        __dest.__h = &_LargeHandler::__handle;
-    }
-
-  private:
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void __destroy(any & __this)
-    {
-        delete static_cast<_Tp*>(__this.__s.__ptr);
-        __this.__h = nullptr;
-    }
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void __copy(any const & __this, any & __dest)
-    {
-        _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
-    }
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void __move(any & __this, any & __dest)
-    {
-      __dest.__s.__ptr = __this.__s.__ptr;
-      __dest.__h = &_LargeHandler::__handle;
-      __this.__h = nullptr;
-    }
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void* __get(any & __this, type_info const * __info)
-    {
-#if !defined(_LIBCPP_NO_RTTI)
-        if (typeid(_Tp) == *__info) {
-            return static_cast<void*>(__this.__s.__ptr);
-        }
-        return nullptr;
-#else
-        return static_cast<void*>(__this.__s.__ptr);
-#endif
-    }
-
-    _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
-    static void* __type_info()
-    {
-#if !defined(_LIBCPP_NO_RTTI)
-        return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
-#else
-        return nullptr;
-#endif
-    }
-  };
-
-} // namespace __any_imp
-
-
-template <class _ValueType, class>
-any::any(_ValueType && __v) : __h(nullptr)
-{
-  typedef typename decay<_ValueType>::type _Tp;
-  static_assert(is_copy_constructible<_Tp>::value,
-                "_ValueType must be CopyConstructible.");
-  typedef __any_imp::_Handler<_Tp> _HandlerType;
-  _HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v));
-}
-
-template <class _ValueType, class>
-any & any::operator=(_ValueType && __v)
-{
-  typedef typename decay<_ValueType>::type _Tp;
-  static_assert(is_copy_constructible<_Tp>::value,
-                "_ValueType must be CopyConstructible.");
-  any(_VSTD::forward<_ValueType>(__v)).swap(*this);
-  return *this;
-}
-
-inline
-void any::swap(any & __rhs) _NOEXCEPT
-{
-    if (__h && __rhs.__h) {
-        any __tmp;
-        __rhs.__call(_Action::_Move, &__tmp);
-        this->__call(_Action::_Move, &__rhs);
-        __tmp.__call(_Action::_Move, this);
-    }
-    else if (__h) {
-        this->__call(_Action::_Move, &__rhs);
-    }
-    else if (__rhs.__h) {
-        __rhs.__call(_Action::_Move, this);
-    }
-}
-
-// 6.4 Non-member functions
-
-inline _LIBCPP_INLINE_VISIBILITY
-void swap(any & __lhs, any & __rhs) _NOEXCEPT
-{
-    __lhs.swap(__rhs);
-}
-
-template <class _ValueType>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-_ValueType any_cast(any const & __v)
-{
-    static_assert(
-        is_reference<_ValueType>::value
-        || is_copy_constructible<_ValueType>::value,
-        "_ValueType is required to be a reference or a CopyConstructible type.");
-    typedef typename add_const<typename remove_reference<_ValueType>::type>::type
-            _Tp;
-    _Tp * __tmp = any_cast<_Tp>(&__v);
-    if (__tmp == nullptr)
-        __throw_bad_any_cast();
-    return *__tmp;
-}
-
-template <class _ValueType>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-_ValueType any_cast(any & __v)
-{
-    static_assert(
-        is_reference<_ValueType>::value
-        || is_copy_constructible<_ValueType>::value,
-        "_ValueType is required to be a reference or a CopyConstructible type.");
-    typedef typename remove_reference<_ValueType>::type _Tp;
-    _Tp * __tmp = any_cast<_Tp>(&__v);
-    if (__tmp == nullptr)
-        __throw_bad_any_cast();
-    return *__tmp;
-}
-
-template <class _ValueType>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-_ValueType any_cast(any && __v)
-{
-    static_assert(
-        is_reference<_ValueType>::value
-        || is_copy_constructible<_ValueType>::value,
-        "_ValueType is required to be a reference or a CopyConstructible type.");
-    typedef typename remove_reference<_ValueType>::type _Tp;
-    _Tp * __tmp = any_cast<_Tp>(&__v);
-    if (__tmp == nullptr)
-        __throw_bad_any_cast();
-    return *__tmp;
-}
-
-template <class _ValueType>
-inline
-typename add_pointer<typename add_const<_ValueType>::type>::type
-any_cast(any const * __any) _NOEXCEPT
-{
-    static_assert(!is_reference<_ValueType>::value,
-                  "_ValueType may not be a reference.");
-    return any_cast<_ValueType>(const_cast<any *>(__any));
-}
-
-template <class _ValueType>
-typename add_pointer<_ValueType>::type
-any_cast(any * __any) _NOEXCEPT
-{
-    using __any_imp::_Action;
-    static_assert(!is_reference<_ValueType>::value,
-                  "_ValueType may not be a reference.");
-    typedef typename add_pointer<_ValueType>::type _ReturnType;
-    if (__any && __any->__h) {
-
-        return static_cast<_ReturnType>(
-            __any->__call(_Action::_Get, nullptr,
-#if !defined(_LIBCPP_NO_RTTI)
-                &typeid(_ValueType)
-#else
-                nullptr
-#endif
-        ));
-
-    }
-    return nullptr;
-}
-
-#endif // _LIBCPP_STD_VER > 11
-
-_LIBCPP_END_NAMESPACE_LFTS
-
-#endif // _LIBCPP_EXPERIMENTAL_ANY
+#error "<experimental/any> has been removed. Use <any> instead."
diff --git lib/libcxx/include/experimental/chrono lib/libcxx/include/experimental/chrono
index ca9e5f852ea..591cf7160c1 100644
--- lib/libcxx/include/experimental/chrono
+++ lib/libcxx/include/experimental/chrono
@@ -8,52 +8,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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 */
+#error "<experimental/chrono> has been removed. Use <chrono> instead."
diff --git lib/libcxx/include/experimental/coroutine lib/libcxx/include/experimental/coroutine
index ce795ad452c..1eb224a535a 100644
--- lib/libcxx/include/experimental/coroutine
+++ lib/libcxx/include/experimental/coroutine
@@ -93,28 +93,28 @@ class _LIBCPP_TEMPLATE_VIS coroutine_handle;
 template <>
 class _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
 public:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR coroutine_handle() _NOEXCEPT : __handle_(nullptr) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR coroutine_handle(nullptr_t) _NOEXCEPT : __handle_(nullptr) {}
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     coroutine_handle& operator=(nullptr_t) _NOEXCEPT {
         __handle_ = nullptr;
         return *this;
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR void* address() const _NOEXCEPT { return __handle_; }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return __handle_; }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     void operator()() { resume(); }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     void resume() {
       _LIBCPP_ASSERT(__is_suspended(),
                      "resume() can only be called on suspended coroutines");
@@ -123,14 +123,14 @@ public:
       __builtin_coro_resume(__handle_);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     void destroy() {
       _LIBCPP_ASSERT(__is_suspended(),
                      "destroy() can only be called on suspended coroutines");
       __builtin_coro_destroy(__handle_);
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     bool done() const {
       _LIBCPP_ASSERT(__is_suspended(),
                      "done() can only be called on suspended coroutines");
@@ -138,7 +138,7 @@ public:
     }
 
 public:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     static coroutine_handle from_address(void* __addr) _NOEXCEPT {
         coroutine_handle __tmp;
         __tmp.__handle_ = __addr;
@@ -146,7 +146,7 @@ public:
     }
 
     // FIXME: Should from_address(nullptr) be allowed?
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
       return coroutine_handle(nullptr);
     }
@@ -169,27 +169,27 @@ private:
 };
 
 // 18.11.2.7 comparison operators:
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
     return __x.address() == __y.address();
 }
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 bool operator!=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
     return !(__x == __y);
 }
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 bool operator<(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
     return less<void*>()(__x.address(), __y.address());
 }
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 bool operator>(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
     return __y < __x;
 }
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 bool operator<=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
     return !(__x > __y);
 }
-inline _LIBCPP_ALWAYS_INLINE
+inline _LIBCPP_INLINE_VISIBILITY
 bool operator>=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
     return !(__x < __y);
 }
@@ -202,8 +202,8 @@ public:
     // 18.11.2.1 construct/reset
     using coroutine_handle<>::coroutine_handle;
 #else
-    _LIBCPP_ALWAYS_INLINE coroutine_handle() _NOEXCEPT : _Base() {}
-    _LIBCPP_ALWAYS_INLINE coroutine_handle(nullptr_t) _NOEXCEPT : _Base(nullptr) {}
+    _LIBCPP_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT : _Base() {}
+    _LIBCPP_INLINE_VISIBILITY coroutine_handle(nullptr_t) _NOEXCEPT : _Base(nullptr) {}
 #endif
     _LIBCPP_INLINE_VISIBILITY
     coroutine_handle& operator=(nullptr_t) _NOEXCEPT {
@@ -213,12 +213,12 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     _Promise& promise() const {
-        return *reinterpret_cast<_Promise*>(
+        return *static_cast<_Promise*>(
             __builtin_coro_promise(this->__handle_, __alignof(_Promise), false));
     }
 
 public:
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     static coroutine_handle from_address(void* __addr) _NOEXCEPT {
         coroutine_handle __tmp;
         __tmp.__handle_ = __addr;
@@ -229,7 +229,7 @@ public:
     // the deleted _Promise* overload doesn't make from_address(nullptr)
     // ambiguous.
     // FIXME: should from_address work with nullptr?
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
       return coroutine_handle(nullptr);
     }
@@ -248,7 +248,7 @@ public:
         "pointers to the coroutine's promise type; use 'from_promise' instead");
     }
 
-    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_INLINE_VISIBILITY
     static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
         typedef typename remove_cv<_Promise>::type _RawPromise;
         coroutine_handle __tmp;
@@ -259,21 +259,61 @@ public:
     }
 };
 
+#if __has_builtin(__builtin_coro_noop)
+struct noop_coroutine_promise {};
+
+template <>
+class _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise>
+    : public coroutine_handle<> {
+  using _Base = coroutine_handle<>;
+  using _Promise = noop_coroutine_promise;
+public:
+
+  _LIBCPP_INLINE_VISIBILITY
+  _Promise& promise() const {
+    return *static_cast<_Promise*>(
+      __builtin_coro_promise(this->__handle_, __alignof(_Promise), false));
+  }
+
+  _LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return true; }
+  _LIBCPP_CONSTEXPR bool done() const _NOEXCEPT { return false; }
+
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 void operator()() const _NOEXCEPT {}
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 void resume() const _NOEXCEPT {}
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 void destroy() const _NOEXCEPT {}
+
+private:
+  _LIBCPP_INLINE_VISIBILITY
+  friend coroutine_handle<noop_coroutine_promise> noop_coroutine() _NOEXCEPT;
+
+  _LIBCPP_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT {
+    this->__handle_ = __builtin_coro_noop();
+  }
+};
+
+using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
+
+inline _LIBCPP_INLINE_VISIBILITY
+noop_coroutine_handle noop_coroutine() _NOEXCEPT {
+  return noop_coroutine_handle();
+}
+#endif // __has_builtin(__builtin_coro_noop)
+
 struct _LIBCPP_TYPE_VIS suspend_never {
-  _LIBCPP_ALWAYS_INLINE
+  _LIBCPP_INLINE_VISIBILITY
   bool await_ready() const _NOEXCEPT { return true; }
-  _LIBCPP_ALWAYS_INLINE
+  _LIBCPP_INLINE_VISIBILITY
   void await_suspend(coroutine_handle<>) const _NOEXCEPT {}
-  _LIBCPP_ALWAYS_INLINE
+  _LIBCPP_INLINE_VISIBILITY
   void await_resume() const _NOEXCEPT {}
 };
 
 struct _LIBCPP_TYPE_VIS suspend_always {
-  _LIBCPP_ALWAYS_INLINE
+  _LIBCPP_INLINE_VISIBILITY
   bool await_ready() const _NOEXCEPT { return false; }
-  _LIBCPP_ALWAYS_INLINE
+  _LIBCPP_INLINE_VISIBILITY
   void await_suspend(coroutine_handle<>) const _NOEXCEPT {}
-  _LIBCPP_ALWAYS_INLINE
+  _LIBCPP_INLINE_VISIBILITY
   void await_resume() const _NOEXCEPT {}
 };
 
diff --git lib/libcxx/include/experimental/dynarray lib/libcxx/include/experimental/dynarray
index 16193317ad2..a60c87c3f97 100644
--- lib/libcxx/include/experimental/dynarray
+++ lib/libcxx/include/experimental/dynarray
@@ -133,19 +133,20 @@ public:
 private:
     size_t                  __size_;
     value_type *            __base_;
-    _LIBCPP_ALWAYS_INLINE dynarray () noexcept :  __size_(0), __base_(nullptr) {}
+    _LIBCPP_INLINE_VISIBILITY dynarray () noexcept :  __size_(0), __base_(nullptr) {}
     
-    static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
-    {
-        if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count )
+    static inline _LIBCPP_INLINE_VISIBILITY
+    value_type* __allocate(size_t __count) {
+        if (numeric_limits<size_t>::max() / sizeof (value_type) <= __count)
             __throw_bad_array_length();
 
-        return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
+        return static_cast<value_type *>(
+            _VSTD::__libcpp_allocate(sizeof(value_type) * __count, __alignof(value_type)));
     }
 
-    static inline _LIBCPP_INLINE_VISIBILITY void __deallocate_value( value_type* __ptr ) noexcept
-    {
-        _VSTD::__libcpp_deallocate (static_cast<void *> (__ptr));
+    static inline _LIBCPP_INLINE_VISIBILITY
+    void __deallocate_value(value_type* __ptr ) noexcept {
+        _VSTD::__libcpp_deallocate(static_cast<void *>(__ptr), __alignof(value_type));
     }
 
 public:
diff --git lib/libcxx/include/experimental/filesystem lib/libcxx/include/experimental/filesystem
index 674490f6038..28d8dcf4fc1 100644
--- lib/libcxx/include/experimental/filesystem
+++ lib/libcxx/include/experimental/filesystem
@@ -16,24 +16,25 @@
 
     class path;
 
-    void swap(path& lhs, path& rhs) _NOEXCEPT;
-    size_t hash_value(const path& p) _NOEXCEPT;
+    void swap(path& lhs, path& rhs) noexcept;
+    size_t hash_value(const path& p) noexcept;
 
-    bool operator==(const path& lhs, const path& rhs) _NOEXCEPT;
-    bool operator!=(const path& lhs, const path& rhs) _NOEXCEPT;
-    bool operator< (const path& lhs, const path& rhs) _NOEXCEPT;
-    bool operator<=(const path& lhs, const path& rhs) _NOEXCEPT;
-    bool operator> (const path& lhs, const path& rhs) _NOEXCEPT;
-    bool operator>=(const path& lhs, const path& rhs) _NOEXCEPT;
+    bool operator==(const path& lhs, const path& rhs) noexcept;
+    bool operator!=(const path& lhs, const path& rhs) noexcept;
+    bool operator< (const path& lhs, const path& rhs) noexcept;
+    bool operator<=(const path& lhs, const path& rhs) noexcept;
+    bool operator> (const path& lhs, const path& rhs) noexcept;
+    bool operator>=(const path& lhs, const path& rhs) noexcept;
 
     path operator/ (const path& lhs, const path& rhs);
 
+    // fs.path.io operators are friends of path.
     template <class charT, class traits>
-    basic_ostream<charT, traits>&
+    friend basic_ostream<charT, traits>&
     operator<<(basic_ostream<charT, traits>& os, const path& p);
 
     template <class charT, class traits>
-    basic_istream<charT, traits>&
+    friend basic_istream<charT, traits>&
     operator>>(basic_istream<charT, traits>& is, path& p);
 
     template <class Source>
@@ -67,6 +68,7 @@
 
     enum class file_type;
     enum class perms;
+    enum class perm_options;
     enum class copy_options;
     enum class directory_options;
 
@@ -74,11 +76,11 @@
 
     // operational functions
 
-    path absolute(const path& p, const path& base=current_path());
+    path absolute(const path& p);
+    path absolute(const path& p, error_code &ec);
 
-    path canonical(const path& p, const path& base = current_path());
+    path canonical(const path& p);
     path canonical(const path& p, error_code& ec);
-    path canonical(const path& p, const path& base, error_code& ec);
 
     void copy(const path& from, const path& to);
     void copy(const path& from, const path& to, error_code& ec);
@@ -87,2054 +89,169 @@
                    error_code& ec);
 
     bool copy_file(const path& from, const path& to);
-    bool copy_file(const path& from, const path& to, error_code& ec) _NOEXCEPT;
+    bool copy_file(const path& from, const path& to, error_code& ec);
     bool copy_file(const path& from, const path& to, copy_options option);
     bool copy_file(const path& from, const path& to, copy_options option,
-                           error_code& ec) _NOEXCEPT;
+                           error_code& ec);
 
     void copy_symlink(const path& existing_symlink, const path& new_symlink);
     void copy_symlink(const path& existing_symlink, const path& new_symlink,
-                              error_code& ec) _NOEXCEPT;
+                              error_code& ec) noexcept;
 
     bool create_directories(const path& p);
-    bool create_directories(const path& p, error_code& ec) _NOEXCEPT;
+    bool create_directories(const path& p, error_code& ec);
 
     bool create_directory(const path& p);
-    bool create_directory(const path& p, error_code& ec) _NOEXCEPT;
+    bool create_directory(const path& p, error_code& ec) noexcept;
 
     bool create_directory(const path& p, const path& attributes);
     bool create_directory(const path& p, const path& attributes,
-                                  error_code& ec) _NOEXCEPT;
+                                  error_code& ec) noexcept;
 
     void create_directory_symlink(const path& to, const path& new_symlink);
     void create_directory_symlink(const path& to, const path& new_symlink,
-                                          error_code& ec) _NOEXCEPT;
+                                          error_code& ec) noexcept;
 
     void create_hard_link(const path& to, const path& new_hard_link);
     void create_hard_link(const path& to, const path& new_hard_link,
-                                  error_code& ec) _NOEXCEPT;
+                                  error_code& ec) noexcept;
 
     void create_symlink(const path& to, const path& new_symlink);
     void create_symlink(const path& to, const path& new_symlink,
-                                error_code& ec) _NOEXCEPT;
+                                error_code& ec) noexcept;
 
     path current_path();
     path current_path(error_code& ec);
     void current_path(const path& p);
-    void current_path(const path& p, error_code& ec) _NOEXCEPT;
+    void current_path(const path& p, error_code& ec) noexcept;
 
-    bool exists(file_status s) _NOEXCEPT;
+    bool exists(file_status s) noexcept;
     bool exists(const path& p);
-    bool exists(const path& p, error_code& ec) _NOEXCEPT;
+    bool exists(const path& p, error_code& ec) noexcept;
 
     bool equivalent(const path& p1, const path& p2);
-    bool equivalent(const path& p1, const path& p2, error_code& ec) _NOEXCEPT;
+    bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
 
     uintmax_t    file_size(const path& p);
-    uintmax_t    file_size(const path& p, error_code& ec) _NOEXCEPT;
+    uintmax_t    file_size(const path& p, error_code& ec) noexcept;
 
     uintmax_t    hard_link_count(const path& p);
-    uintmax_t    hard_link_count(const path& p, error_code& ec) _NOEXCEPT;
+    uintmax_t    hard_link_count(const path& p, error_code& ec) noexcept;
 
-    bool is_block_file(file_status s) _NOEXCEPT;
+    bool is_block_file(file_status s) noexcept;
     bool is_block_file(const path& p);
-    bool is_block_file(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_block_file(const path& p, error_code& ec) noexcept;
 
-    bool is_character_file(file_status s) _NOEXCEPT;
+    bool is_character_file(file_status s) noexcept;
     bool is_character_file(const path& p);
-    bool is_character_file(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_character_file(const path& p, error_code& ec) noexcept;
 
-    bool is_directory(file_status s) _NOEXCEPT;
+    bool is_directory(file_status s) noexcept;
     bool is_directory(const path& p);
-    bool is_directory(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_directory(const path& p, error_code& ec) noexcept;
 
     bool is_empty(const path& p);
-    bool is_empty(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_empty(const path& p, error_code& ec) noexcept;
 
-    bool is_fifo(file_status s) _NOEXCEPT;
+    bool is_fifo(file_status s) noexcept;
     bool is_fifo(const path& p);
-    bool is_fifo(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_fifo(const path& p, error_code& ec) noexcept;
 
-    bool is_other(file_status s) _NOEXCEPT;
+    bool is_other(file_status s) noexcept;
     bool is_other(const path& p);
-    bool is_other(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_other(const path& p, error_code& ec) noexcept;
 
-    bool is_regular_file(file_status s) _NOEXCEPT;
+    bool is_regular_file(file_status s) noexcept;
     bool is_regular_file(const path& p);
-    bool is_regular_file(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_regular_file(const path& p, error_code& ec) noexcept;
 
-    bool is_socket(file_status s) _NOEXCEPT;
+    bool is_socket(file_status s) noexcept;
     bool is_socket(const path& p);
-    bool is_socket(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_socket(const path& p, error_code& ec) noexcept;
 
-    bool is_symlink(file_status s) _NOEXCEPT;
+    bool is_symlink(file_status s) noexcept;
     bool is_symlink(const path& p);
-    bool is_symlink(const path& p, error_code& ec) _NOEXCEPT;
+    bool is_symlink(const path& p, error_code& ec) noexcept;
 
     file_time_type  last_write_time(const path& p);
-    file_time_type  last_write_time(const path& p, error_code& ec) _NOEXCEPT;
+    file_time_type  last_write_time(const path& p, error_code& ec) noexcept;
     void last_write_time(const path& p, file_time_type new_time);
     void last_write_time(const path& p, file_time_type new_time,
-                                 error_code& ec) _NOEXCEPT;
+                                 error_code& ec) noexcept;
 
-    void permissions(const path& p, perms prms);
-    void permissions(const path& p, perms prms, error_code& ec) _NOEXCEPT;
+    void permissions(const path& p, perms prms,
+                     perm_options opts=perm_options::replace);
+    void permissions(const path& p, perms prms, error_code& ec) noexcept;
+    void permissions(const path& p, perms prms, perm_options opts,
+                     error_code& ec);
+
+    path proximate(const path& p, error_code& ec);
+    path proximate(const path& p, const path& base = current_path());
+    path proximate(const path& p, const path& base, error_code &ec);
 
     path read_symlink(const path& p);
     path read_symlink(const path& p, error_code& ec);
 
+    path relative(const path& p, error_code& ec);
+    path relative(const path& p, const path& base=current_path());
+    path relative(const path& p, const path& base, error_code& ec);
+
     bool remove(const path& p);
-    bool remove(const path& p, error_code& ec) _NOEXCEPT;
+    bool remove(const path& p, error_code& ec) noexcept;
 
     uintmax_t    remove_all(const path& p);
-    uintmax_t    remove_all(const path& p, error_code& ec) _NOEXCEPT;
+    uintmax_t    remove_all(const path& p, error_code& ec);
 
     void rename(const path& from, const path& to);
-    void rename(const path& from, const path& to, error_code& ec) _NOEXCEPT;
+    void rename(const path& from, const path& to, error_code& ec) noexcept;
 
     void resize_file(const path& p, uintmax_t size);
-    void resize_file(const path& p, uintmax_t size, error_code& ec) _NOEXCEPT;
+    void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
 
     space_info   space(const path& p);
-    space_info   space(const path& p, error_code& ec) _NOEXCEPT;
+    space_info   space(const path& p, error_code& ec) noexcept;
 
     file_status  status(const path& p);
-    file_status  status(const path& p, error_code& ec) _NOEXCEPT;
+    file_status  status(const path& p, error_code& ec) noexcept;
 
-    bool status_known(file_status s) _NOEXCEPT;
+    bool status_known(file_status s) noexcept;
 
     file_status  symlink_status(const path& p);
-    file_status  symlink_status(const path& p, error_code& ec) _NOEXCEPT;
-
-    path system_complete(const path& p);
-    path system_complete(const path& p, error_code& ec);
+    file_status  symlink_status(const path& p, error_code& ec) noexcept;
 
     path temp_directory_path();
     path temp_directory_path(error_code& ec);
 
+    path weakly_canonical(path const& p);
+    path weakly_canonical(path const& p, error_code& ec);
+
+
 } } } }  // namespaces std::experimental::filesystem::v1
 
 */
 
 #include <experimental/__config>
-#include <cstddef>
-#include <chrono>
-#include <iterator>
-#include <iosfwd>
-#include <locale>
-#include <memory>
-#include <stack>
-#include <string>
-#include <system_error>
-#include <utility>
-#include <iomanip> // for quoted
-#include <string_view>
-
-#include <__debug>
+#include <filesystem>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#ifndef _LIBCPP_CXX03_LANG
+
 #define __cpp_lib_experimental_filesystem 201406
 
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
 
-typedef chrono::time_point<std::chrono::system_clock>  file_time_type;
-
-struct _LIBCPP_TYPE_VIS space_info
-{
-  uintmax_t capacity;
-  uintmax_t free;
-  uintmax_t available;
-};
-
-enum class _LIBCPP_ENUM_VIS file_type : signed char
-{
-    none       = 0,
-    not_found  = -1,
-    regular    = 1,
-    directory  = 2,
-    symlink    = 3,
-    block      = 4,
-    character  = 5,
-    fifo       = 6,
-    socket     = 7,
-    unknown    = 8
-};
-
-enum class _LIBCPP_ENUM_VIS perms : unsigned
-{
-    none         = 0,
-
-    owner_read   = 0400,
-    owner_write  = 0200,
-    owner_exec   = 0100,
-    owner_all    = 0700,
-
-    group_read   = 040,
-    group_write  = 020,
-    group_exec   = 010,
-    group_all    = 070,
-
-    others_read  = 04,
-    others_write = 02,
-    others_exec  = 01,
-    others_all   = 07,
-
-    all          = 0777,
-
-    set_uid      = 04000,
-    set_gid      = 02000,
-    sticky_bit   = 01000,
-    mask         = 07777,
-    unknown      = 0xFFFF,
-
-    add_perms        = 0x10000,
-    remove_perms     = 0x20000,
-    symlink_nofollow = 0x40000
-};
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR perms operator&(perms _LHS, perms _RHS)
-{ return static_cast<perms>(static_cast<unsigned>(_LHS) & static_cast<unsigned>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR perms operator|(perms _LHS, perms _RHS)
-{ return static_cast<perms>(static_cast<unsigned>(_LHS) | static_cast<unsigned>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR perms operator^(perms _LHS, perms _RHS)
-{ return static_cast<perms>(static_cast<unsigned>(_LHS) ^ static_cast<unsigned>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR perms operator~(perms _LHS)
-{ return static_cast<perms>(~static_cast<unsigned>(_LHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline perms& operator&=(perms& _LHS, perms _RHS)
-{ return _LHS = _LHS & _RHS; }
-
-_LIBCPP_INLINE_VISIBILITY
-inline perms& operator|=(perms& _LHS, perms _RHS)
-{ return _LHS = _LHS | _RHS; }
-
-_LIBCPP_INLINE_VISIBILITY
-inline perms& operator^=(perms& _LHS, perms _RHS)
-{ return _LHS = _LHS ^ _RHS; }
-
-enum class _LIBCPP_ENUM_VIS copy_options : unsigned short
-{
-    none               = 0,
-    skip_existing      = 1,
-    overwrite_existing = 2,
-    update_existing    = 4,
-    recursive          = 8,
-    copy_symlinks      = 16,
-    skip_symlinks      = 32,
-    directories_only   = 64,
-    create_symlinks    = 128,
-    create_hard_links  = 256,
-    __in_recursive_copy = 512,
-};
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR copy_options operator&(copy_options _LHS, copy_options _RHS)
-{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) & static_cast<unsigned short>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR copy_options operator|(copy_options _LHS, copy_options _RHS)
-{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) | static_cast<unsigned short>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR copy_options operator^(copy_options _LHS, copy_options _RHS)
-{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^ static_cast<unsigned short>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR copy_options operator~(copy_options _LHS)
-{ return static_cast<copy_options>(~static_cast<unsigned short>(_LHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS)
-{ return _LHS = _LHS & _RHS; }
-
-_LIBCPP_INLINE_VISIBILITY
-inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS)
-{ return _LHS = _LHS | _RHS; }
-
-_LIBCPP_INLINE_VISIBILITY
-inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS)
-{ return _LHS = _LHS ^ _RHS; }
-
-
-enum class _LIBCPP_ENUM_VIS directory_options : unsigned char
-{
-    none                     = 0,
-    follow_directory_symlink = 1,
-    skip_permission_denied   = 2
-};
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR directory_options operator&(directory_options _LHS, directory_options _RHS)
-{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) & static_cast<unsigned char>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR directory_options operator|(directory_options _LHS, directory_options _RHS)
-{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) | static_cast<unsigned char>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR directory_options operator^(directory_options _LHS, directory_options _RHS)
-{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^ static_cast<unsigned char>(_RHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline _LIBCPP_CONSTEXPR directory_options operator~(directory_options _LHS)
-{ return static_cast<directory_options>(~static_cast<unsigned char>(_LHS)); }
-
-_LIBCPP_INLINE_VISIBILITY
-inline directory_options& operator&=(directory_options& _LHS, directory_options _RHS)
-{ return _LHS = _LHS & _RHS; }
-
-_LIBCPP_INLINE_VISIBILITY
-inline directory_options& operator|=(directory_options& _LHS, directory_options _RHS)
-{ return _LHS = _LHS | _RHS; }
-
-_LIBCPP_INLINE_VISIBILITY
-inline directory_options& operator^=(directory_options& _LHS, directory_options _RHS)
-{ return _LHS = _LHS ^ _RHS; }
-
-
-class _LIBCPP_TYPE_VIS file_status
-{
-public:
-    // constructors
-    _LIBCPP_INLINE_VISIBILITY
-    file_status() _NOEXCEPT : file_status(file_type::none) {}
-    _LIBCPP_INLINE_VISIBILITY
-    explicit file_status(file_type __ft,
-                         perms __prms = perms::unknown) _NOEXCEPT
-      : __ft_(__ft), __prms_(__prms)
-    {}
-
-    file_status(const file_status&) _NOEXCEPT = default;
-    file_status(file_status&&) _NOEXCEPT = default;
-
-    _LIBCPP_INLINE_VISIBILITY
-    ~file_status() {}
-
-    file_status& operator=(const file_status&) _NOEXCEPT = default;
-    file_status& operator=(file_status&&) _NOEXCEPT = default;
-
-    // observers
-    _LIBCPP_ALWAYS_INLINE
-    file_type type() const _NOEXCEPT {
-        return __ft_;
-    }
-
-    _LIBCPP_ALWAYS_INLINE
-    perms permissions() const _NOEXCEPT {
-        return __prms_;
-    }
-
-    // modifiers
-    _LIBCPP_ALWAYS_INLINE
-    void type(file_type __ft) _NOEXCEPT {
-        __ft_ = __ft;
-    }
-
-    _LIBCPP_ALWAYS_INLINE
-    void permissions(perms __p) _NOEXCEPT {
-        __prms_ = __p;
-    }
-private:
-    file_type __ft_;
-    perms __prms_;
-};
-
-class _LIBCPP_TYPE_VIS directory_entry;
-
-template <class _Tp> struct __can_convert_char {
-  static const bool value = false;
-};
-template <class _Tp> struct __can_convert_char<const _Tp>
-    : public __can_convert_char<_Tp> {
-};
-template <> struct __can_convert_char<char> {
-    static const bool value = true;
-    using __char_type = char;
-};
-template <> struct __can_convert_char<wchar_t>  {
-    static const bool value = true;
-    using __char_type = wchar_t;
-};
-template <> struct __can_convert_char<char16_t> {
-    static const bool value = true;
-    using __char_type = char16_t;
-};
-template <> struct __can_convert_char<char32_t> {
-    static const bool value = true;
-    using __char_type = char32_t;
-};
-
-template <class _ECharT>
-typename enable_if<__can_convert_char<_ECharT>::value, bool>::type
-__is_separator(_ECharT __e) {
-    return __e == _ECharT('/');
-};
-
-struct _NullSentinal {};
-
-template <class _Tp>
-using _Void = void;
-
-template <class _Tp, class = void>
-struct __is_pathable_string : public false_type {};
-
-template <class _ECharT, class _Traits, class _Alloc>
-struct __is_pathable_string<basic_string<_ECharT, _Traits, _Alloc>,
-                            _Void<typename __can_convert_char<_ECharT>::__char_type>>
-: public __can_convert_char<_ECharT>
-{
-    using _Str = basic_string<_ECharT, _Traits, _Alloc>;
-    using _Base = __can_convert_char<_ECharT>;
-    static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
-    static _ECharT const* __range_end(_Str const& __s) { return __s.data() + __s.length(); }
-    static _ECharT __first_or_null(_Str const& __s) {
-        return __s.empty() ? _ECharT{} : __s[0];
-    }
-};
-
-
-template <class _ECharT, class _Traits>
-struct __is_pathable_string<basic_string_view<_ECharT, _Traits>,
-                            _Void<typename __can_convert_char<_ECharT>::__char_type>>
-: public __can_convert_char<_ECharT>
-{
-    using _Str = basic_string_view<_ECharT, _Traits>;
-    using _Base = __can_convert_char<_ECharT>;
-    static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
-    static _ECharT const* __range_end(_Str const& __s) { return __s.data() + __s.length(); }
-    static _ECharT __first_or_null(_Str const& __s) {
-        return __s.empty() ? _ECharT{} : __s[0];
-    }
-};
-
-template <class _Source,
-          class _DS = typename decay<_Source>::type,
-          class _UnqualPtrType = typename remove_const<
-              typename remove_pointer<_DS>::type>::type,
-          bool _IsCharPtr = is_pointer<_DS>::value &&
-                            __can_convert_char<_UnqualPtrType>::value
-        >
-struct __is_pathable_char_array : false_type {};
-
-template <class _Source, class _ECharT, class _UPtr>
-struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
-        : __can_convert_char<typename remove_const<_ECharT>::type>
-{
-  using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;
-
-  static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
-  static _ECharT const* __range_end(const _ECharT* __b)
-  {
-      using _Iter = const _ECharT*;
-      const _ECharT __sentinal = _ECharT{};
-      _Iter __e = __b;
-      for (; *__e != __sentinal; ++__e)
-          ;
-      return __e;
-  }
-
-  static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }
-};
-
-template <class _Iter, bool _IsIt = __is_input_iterator<_Iter>::value, class = void>
-struct __is_pathable_iter : false_type {};
-
-template <class _Iter>
-struct __is_pathable_iter<_Iter, true,
-        _Void<typename __can_convert_char<typename iterator_traits<_Iter>::value_type>::__char_type>>
-        : __can_convert_char<typename iterator_traits<_Iter>::value_type>
-{
-  using _ECharT = typename iterator_traits<_Iter>::value_type;
-  using _Base = __can_convert_char<_ECharT>;
-
-  static _Iter         __range_begin(_Iter __b) { return __b; }
-  static _NullSentinal __range_end(_Iter)       { return _NullSentinal{}; }
-
-  static _ECharT __first_or_null(_Iter __b) { return *__b; }
-};
-
-template <class _Tp, bool _IsStringT =  __is_pathable_string<_Tp>::value,
-                     bool _IsCharIterT = __is_pathable_char_array<_Tp>::value,
-                     bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value
-         >
-struct __is_pathable : false_type {
-  static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false");
-};
-
-template <class _Tp>
-struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {};
-
-
-template <class _Tp>
-struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {};
-
-
-template <class _Tp>
-struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};
-
-
-template <class _ECharT>
-struct _PathCVT {
-    static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible");
-
-    typedef __narrow_to_utf8<sizeof(_ECharT)*__CHAR_BIT__> _Narrower;
-
-    static void __append_range(string& __dest, _ECharT const* __b, _ECharT const* __e)  {
-        _Narrower()(back_inserter(__dest), __b, __e);
-    }
-
-    template <class _Iter>
-    static void __append_range(string& __dest, _Iter __b, _Iter __e) {
-        static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
-        if (__b == __e) return;
-        basic_string<_ECharT> __tmp(__b, __e);
-        _Narrower()(back_inserter(__dest), __tmp.data(),
-                    __tmp.data() + __tmp.length());
-    }
-
-    template <class _Iter>
-    static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
-        static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
-        const _ECharT __sentinal = _ECharT{};
-        if (*__b == __sentinal) return;
-        basic_string<_ECharT> __tmp;
-        for (; *__b != __sentinal; ++__b)
-            __tmp.push_back(*__b);
-        _Narrower()(back_inserter(__dest), __tmp.data(),
-                    __tmp.data() + __tmp.length());
-    }
-
-    template <class _Source>
-    static void __append_source(string& __dest, _Source const& __s)
-    {
-        using _Traits = __is_pathable<_Source>;
-        __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s));
-    }
-};
-
-template <>
-struct _PathCVT<char> {
-
-    template <class _Iter>
-    static typename enable_if<
-        __is_exactly_input_iterator<_Iter>::value
-    >::type __append_range(string& __dest, _Iter __b, _Iter __e) {
-        for (; __b != __e; ++__b)
-            __dest.push_back(*__b);
-    }
-
-    template <class _Iter>
-    static typename enable_if<
-        __is_forward_iterator<_Iter>::value
-    >::type __append_range(string& __dest, _Iter __b, _Iter __e) {
-        __dest.__append_forward_unsafe(__b, __e);
-    }
-
-    template <class _Iter>
-    static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
-        const char __sentinal = char{};
-        for (; *__b != __sentinal; ++__b)
-            __dest.push_back(*__b);
-    }
-
-    template <class _Source>
-    static void __append_source(string& __dest, _Source const& __s)
-    {
-        using _Traits = __is_pathable<_Source>;
-        __append_range(__dest, _Traits::__range_begin(__s),
-                               _Traits::__range_end(__s));
-    }
-};
-
-
-class _LIBCPP_TYPE_VIS path
-{
-    template <class _SourceOrIter, class _Tp = path&>
-    using _EnableIfPathable = typename
-        enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type;
-
-    template <class _Tp>
-    using _SourceChar = typename __is_pathable<_Tp>::__char_type;
-
-    template <class _Tp>
-    using _SourceCVT = _PathCVT<_SourceChar<_Tp>>;
-
-public:
-    typedef char value_type;
-    typedef basic_string<value_type> string_type;
-    typedef _VSTD::string_view __string_view;
-    static _LIBCPP_CONSTEXPR value_type preferred_separator = '/';
-
-    // constructors and destructor
-    _LIBCPP_INLINE_VISIBILITY path() _NOEXCEPT {}
-    _LIBCPP_INLINE_VISIBILITY path(const path& __p)      : __pn_(__p.__pn_) {}
-    _LIBCPP_INLINE_VISIBILITY path(path&& __p) _NOEXCEPT : __pn_(_VSTD::move(__p.__pn_)) {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    path(string_type&& __s) _NOEXCEPT : __pn_(_VSTD::move(__s)) {}
-
-    template <
-        class _Source,
-        class = _EnableIfPathable<_Source, void>
-        >
-    path(const _Source& __src) {
-        _SourceCVT<_Source>::__append_source(__pn_, __src);
-    }
-
-    template <class _InputIt>
-    path(_InputIt __first, _InputIt __last) {
-        typedef typename iterator_traits<_InputIt>::value_type _ItVal;
-        _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
-    }
-
-    // TODO Implement locale conversions.
-    template <class _Source,
-              class = _EnableIfPathable<_Source, void>
-             >
-        path(const _Source& __src, const locale& __loc);
-    template <class _InputIt>
-        path(_InputIt __first, _InputIt _last, const locale& __loc);
-
-    _LIBCPP_INLINE_VISIBILITY
-    ~path() = default;
-
-    // assignments
-    _LIBCPP_INLINE_VISIBILITY
-    path& operator=(const path& __p) {
-        __pn_ = __p.__pn_;
-        return *this;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    path& operator=(path&& __p) _NOEXCEPT {
-        __pn_ = _VSTD::move(__p.__pn_);
-        return *this;
-    }
-
-    template <class = void>
-    _LIBCPP_INLINE_VISIBILITY
-    path& operator=(string_type&& __s) _NOEXCEPT {
-        __pn_ = _VSTD::move(__s);
-        return *this;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    path& assign(string_type&& __s) _NOEXCEPT {
-        __pn_ = _VSTD::move(__s);
-        return *this;
-    }
-
-    template <class _Source>
-    _LIBCPP_INLINE_VISIBILITY
-    _EnableIfPathable<_Source>
-    operator=(const _Source& __src)
-    { return this->assign(__src); }
-
-
-    template <class _Source>
-    _EnableIfPathable<_Source>
-    assign(const _Source& __src) {
-        __pn_.clear();
-        _SourceCVT<_Source>::__append_source(__pn_, __src);
-        return *this;
-    }
-
-    template <class _InputIt>
-    path& assign(_InputIt __first, _InputIt __last) {
-        typedef typename iterator_traits<_InputIt>::value_type _ItVal;
-        __pn_.clear();
-        _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
-        return *this;
-    }
-
-private:
-    template <class _ECharT>
-    void __append_sep_if_needed(_ECharT __first_or_null) {
-        const _ECharT __null_val = {};
-        bool __append_sep = !empty()                       &&
-                            !__is_separator(__pn_.back())  &&
-                            __first_or_null != __null_val  && // non-empty
-                            !__is_separator(__first_or_null);
-        if (__append_sep)
-            __pn_ += preferred_separator;
-    }
-
-public:
-    // appends
-    path& operator/=(const path& __p) {
-        _LIBCPP_ASSERT(!__p.has_root_name(),
-                      "cannot append to a path with a root name");
-        __append_sep_if_needed(__p.empty() ? char{} : __p.__pn_[0]);
-        __pn_ += __p.native();
-        return *this;
-    }
-
-    template <class _Source>
-    _LIBCPP_INLINE_VISIBILITY
-    _EnableIfPathable<_Source>
-    operator/=(const _Source& __src) {
-        return this->append(__src);
-    }
-
-    template <class _Source>
-    _EnableIfPathable<_Source>
-    append(const _Source& __src) {
-        using _Traits = __is_pathable<_Source>;
-        using _CVT = _PathCVT<_SourceChar<_Source>>;
-        __append_sep_if_needed(_Traits::__first_or_null(__src));
-        _CVT::__append_source(__pn_, __src);
-        return *this;
-    }
-
-    template <class _InputIt>
-    path& append(_InputIt __first, _InputIt __last) {
-        typedef typename iterator_traits<_InputIt>::value_type _ItVal;
-        static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
-        using _CVT = _PathCVT<_ItVal>;
-        if (__first != __last) {
-            __append_sep_if_needed(*__first);
-            _CVT::__append_range(__pn_, __first, __last);
-        }
-        return *this;
-    }
-
-    // concatenation
-    _LIBCPP_INLINE_VISIBILITY
-    path& operator+=(const path& __x) {
-        __pn_ += __x.__pn_;
-        return *this;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    path& operator+=(const string_type& __x) {
-        __pn_ += __x;
-        return *this;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    path& operator+=(__string_view __x) {
-        __pn_ += __x;
-        return *this;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    path& operator+=(const value_type* __x) {
-        __pn_ += __x;
-        return *this;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    path& operator+=(value_type __x) {
-        __pn_ += __x;
-        return *this;
-    }
-
-    template <class _ECharT>
-    typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
-    operator+=(_ECharT __x)
-    {
-        basic_string<_ECharT> __tmp;
-        __tmp += __x;
-        _PathCVT<_ECharT>::__append_source(__pn_, __tmp);
-        return *this;
-    }
-
-    template <class _Source>
-    _EnableIfPathable<_Source>
-    operator+=(const _Source& __x) {
-       return this->concat(__x);
-    }
-
-    template <class _Source>
-    _EnableIfPathable<_Source>
-    concat(const _Source& __x) {
-         _SourceCVT<_Source>::__append_source(__pn_, __x);
-        return *this;
-    }
-
-    template <class _InputIt>
-    path& concat(_InputIt __first, _InputIt __last) {
-        typedef typename iterator_traits<_InputIt>::value_type _ItVal;
-        _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
-        return *this;
-    }
-
-    // modifiers
-    _LIBCPP_INLINE_VISIBILITY
-    void clear() _NOEXCEPT {
-        __pn_.clear();
-    }
-
-    path& make_preferred() { return *this; }
-
-    _LIBCPP_INLINE_VISIBILITY
-    path& remove_filename() {
-      if (__pn_.size() == __root_path_raw().size())
-        clear();
-      else
-        __pn_ = __parent_path();
-      return *this;
-    }
-
-    path& replace_filename(const path& __replacement) {
-        remove_filename();
-        return (*this /= __replacement);
-    }
-
-    path& replace_extension(const path& __replacement = path());
-
-    _LIBCPP_INLINE_VISIBILITY
-    void  swap(path& __rhs) _NOEXCEPT {
-        __pn_.swap(__rhs.__pn_);
-    }
-
-    // native format observers
-    _LIBCPP_INLINE_VISIBILITY
-    const string_type& native() const _NOEXCEPT {
-        return __pn_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    const value_type* c_str() const _NOEXCEPT { return __pn_.c_str(); }
-
-    _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_;  }
-
-    template <class _ECharT, class _Traits = char_traits<_ECharT>,
-              class _Allocator = allocator<_ECharT> >
-    basic_string<_ECharT, _Traits, _Allocator>
-    string(const _Allocator& __a = _Allocator()) const {
-        using _CVT = __widen_from_utf8<sizeof(_ECharT)*__CHAR_BIT__>;
-        using _Str = basic_string<_ECharT, _Traits, _Allocator>;
-        _Str __s(__a);
-        __s.reserve(__pn_.size());
-        _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
-        return __s;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY std::string    string()    const { return __pn_; }
-    _LIBCPP_INLINE_VISIBILITY std::wstring   wstring()   const { return string<wchar_t>(); }
-    _LIBCPP_INLINE_VISIBILITY std::string    u8string()  const { return __pn_; }
-    _LIBCPP_INLINE_VISIBILITY std::u16string u16string() const { return string<char16_t>(); }
-    _LIBCPP_INLINE_VISIBILITY std::u32string u32string() const { return string<char32_t>(); }
-
-    // generic format observers
-    template <class _ECharT, class _Traits = char_traits<_ECharT>,
-              class _Allocator = allocator<_ECharT>
-    >
-    basic_string<_ECharT, _Traits, _Allocator>
-    generic_string(const _Allocator& __a = _Allocator()) const {
-        return string<_ECharT, _Traits, _Allocator>(__a);
-    }
-
-    std::string    generic_string()    const { return __pn_; }
-    std::wstring   generic_wstring()   const { return string<wchar_t>(); }
-    std::string    generic_u8string()  const { return __pn_; }
-    std::u16string generic_u16string() const { return string<char16_t>(); }
-    std::u32string generic_u32string() const { return string<char32_t>(); }
-
-private:
-    int __compare(__string_view) const;
-    __string_view __root_name() const;
-    __string_view __root_directory() const;
-    __string_view __root_path_raw() const;
-    __string_view __relative_path() const;
-    __string_view __parent_path() const;
-    __string_view __filename() const;
-    __string_view __stem() const;
-    __string_view __extension() const;
-
-public:
-    // compare
-    _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const _NOEXCEPT { return __compare(__p.__pn_);}
-    _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { return __compare(__s); }
-    _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const { return __compare(__s); }
-    _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const  { return __compare(__s); }
-
-    // decomposition
-    _LIBCPP_INLINE_VISIBILITY path root_name()      const { return  string_type(__root_name()); }
-    _LIBCPP_INLINE_VISIBILITY path root_directory() const { return  string_type(__root_directory()); }
-    _LIBCPP_INLINE_VISIBILITY path root_path()      const { return root_name().append(string_type(__root_directory())); }
-    _LIBCPP_INLINE_VISIBILITY path relative_path()  const { return string_type(__relative_path()); }
-    _LIBCPP_INLINE_VISIBILITY path parent_path()    const { return string_type(__parent_path()); }
-    _LIBCPP_INLINE_VISIBILITY path filename()       const { return string_type(__filename()); }
-    _LIBCPP_INLINE_VISIBILITY path stem()           const { return string_type(__stem());}
-    _LIBCPP_INLINE_VISIBILITY path extension()      const { return string_type(__extension()); }
-
-    // query
-    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
-    bool empty() const _NOEXCEPT { return __pn_.empty(); }
-
-    _LIBCPP_INLINE_VISIBILITY bool has_root_name()      const { return !__root_name().empty(); }
-    _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { return !__root_directory().empty(); }
-    _LIBCPP_INLINE_VISIBILITY bool has_root_path()      const { return !__root_path_raw().empty(); }
-    _LIBCPP_INLINE_VISIBILITY bool has_relative_path()  const { return !__relative_path().empty(); }
-    _LIBCPP_INLINE_VISIBILITY bool has_parent_path()    const { return !__parent_path().empty(); }
-    _LIBCPP_INLINE_VISIBILITY bool has_filename()       const { return !__filename().empty(); }
-    _LIBCPP_INLINE_VISIBILITY bool has_stem()           const { return !__stem().empty(); }
-    _LIBCPP_INLINE_VISIBILITY bool has_extension()      const { return !__extension().empty(); }
-
-    _LIBCPP_INLINE_VISIBILITY bool is_absolute()        const { return has_root_directory(); }
-    _LIBCPP_INLINE_VISIBILITY bool is_relative()        const { return !is_absolute(); }
-
-    // iterators
-    class _LIBCPP_TYPE_VIS iterator;
-    typedef iterator const_iterator;
-
-    iterator begin() const;
-    iterator end() const;
-
-private:
-    inline _LIBCPP_INLINE_VISIBILITY
-    path& __assign_view(__string_view const& __s) noexcept { __pn_ = string_type(__s); return *this; }
-    string_type __pn_;
-};
-
-inline _LIBCPP_ALWAYS_INLINE
-void swap(path& __lhs, path& __rhs) _NOEXCEPT {
-    __lhs.swap(__rhs);
-}
-
-_LIBCPP_FUNC_VIS
-size_t hash_value(const path& __p) _NOEXCEPT;
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator==(const path& __lhs, const path& __rhs) _NOEXCEPT
-{ return __lhs.compare(__rhs) == 0; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator!=(const path& __lhs, const path& __rhs) _NOEXCEPT
-{ return __lhs.compare(__rhs) != 0; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator<(const path& __lhs, const path& __rhs) _NOEXCEPT
-{ return __lhs.compare(__rhs) < 0; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator<=(const path& __lhs, const path& __rhs) _NOEXCEPT
-{ return __lhs.compare(__rhs) <= 0; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator>(const path& __lhs, const path& __rhs) _NOEXCEPT
-{ return __lhs.compare(__rhs) > 0; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator>=(const path& __lhs, const path& __rhs) _NOEXCEPT
-{ return __lhs.compare(__rhs) >= 0; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-path operator/(const path& __lhs, const path& __rhs) {
-    return path(__lhs) /= __rhs;
-}
-
-template <class _CharT, class _Traits>
-_LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_same<_CharT, char>::value &&
-                   is_same<_Traits, char_traits<char>>::value,
-                   basic_ostream<_CharT, _Traits>&
->::type
-operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
-    __os << std::__quoted(__p.native());
-    return __os;
-}
-
-template <class _CharT, class _Traits>
-_LIBCPP_INLINE_VISIBILITY
-typename enable_if<!is_same<_CharT, char>::value ||
-                   !is_same<_Traits, char_traits<char>>::value,
-                   basic_ostream<_CharT, _Traits>&
->::type
-operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
-    __os << std::__quoted(__p.string<_CharT, _Traits>());
-    return __os;
-}
-
-template <class _CharT, class _Traits>
-_LIBCPP_INLINE_VISIBILITY
-basic_istream<_CharT, _Traits>&
-operator>>(basic_istream<_CharT, _Traits>& __is, path& __p)
-{
-    basic_string<_CharT, _Traits> __tmp;
-    __is >> __quoted(__tmp);
-    __p = __tmp;
-    return __is;
-}
-
-template <class _Source>
-_LIBCPP_INLINE_VISIBILITY
-typename enable_if<__is_pathable<_Source>::value, path>::type
-u8path(const _Source& __s){
-    static_assert(is_same<typename __is_pathable<_Source>::__char_type, char>::value,
-        "u8path(Source const&) requires Source have a character type of type 'char'");
-    return path(__s);
-}
-
-template <class _InputIt>
-_LIBCPP_INLINE_VISIBILITY
-typename enable_if<__is_pathable<_InputIt>::value, path>::type
-u8path(_InputIt __f, _InputIt __l) {
-    static_assert(is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
-        "u8path(Iter, Iter) requires Iter have a value_type of type 'char'");
-    return path(__f, __l);
-}
-
-class _LIBCPP_TYPE_VIS path::iterator
-{
-public:
-    typedef bidirectional_iterator_tag iterator_category;
-
-    typedef path                       value_type;
-    typedef std::ptrdiff_t             difference_type;
-    typedef const path*                pointer;
-    typedef const path&                reference;
-
-    typedef void __stashing_iterator_tag; // See reverse_iterator and __is_stashing_iterator
-public:
-    _LIBCPP_INLINE_VISIBILITY
-    iterator() : __stashed_elem_(), __path_ptr_(nullptr),
-                 __entry_(), __state_(__singular) {}
-
-    iterator(const iterator&) = default;
-    ~iterator() = default;
-
-    iterator& operator=(const iterator&) = default;
-
-    _LIBCPP_INLINE_VISIBILITY
-    reference operator*() const {
-        return __stashed_elem_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    pointer operator->() const {
-        return &__stashed_elem_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    iterator& operator++() {
-        _LIBCPP_ASSERT(__state_ != __singular,
-                       "attempting to increment a singular iterator");
-        _LIBCPP_ASSERT(__state_ != __at_end,
-                      "attempting to increment the end iterator");
-        return __increment();
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    iterator operator++(int) {
-        iterator __it(*this);
-        this->operator++();
-        return __it;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    iterator& operator--() {
-        _LIBCPP_ASSERT(__state_ != __singular,
-                       "attempting to decrement a singular iterator");
-        _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(),
-                       "attempting to decrement the begin iterator");
-        return __decrement();
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    iterator operator--(int) {
-        iterator __it(*this);
-        this->operator--();
-        return __it;
-    }
-
-private:
-    friend class path;
-
-    static constexpr unsigned char __singular = 0;
-    static constexpr unsigned char __at_end = 6;
-
-    inline _LIBCPP_INLINE_VISIBILITY
-    friend bool operator==(const iterator&, const iterator&);
-
-    iterator& __increment();
-    iterator& __decrement();
-
-    path __stashed_elem_;
-    const path* __path_ptr_;
-    path::__string_view __entry_;
-    unsigned char __state_;
-};
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator==(const path::iterator& __lhs, const path::iterator& __rhs) {
-    return __lhs.__path_ptr_ == __rhs.__path_ptr_ &&
-           __lhs.__entry_.data() == __rhs.__entry_.data();
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator!=(const path::iterator& __lhs, const path::iterator& __rhs) {
-    return !(__lhs == __rhs);
-}
-
-class _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error
-{
-public:
-    _LIBCPP_INLINE_VISIBILITY
-    filesystem_error(const string& __what, error_code __ec)
-        : system_error(__ec, __what),
-          __paths_(make_shared<_Storage>(path(), path()))
-    {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    filesystem_error(const string& __what, const path& __p1, error_code __ec)
-        : system_error(__ec, __what),
-        __paths_(make_shared<_Storage>(__p1, path()))
-    {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    filesystem_error(const string& __what, const path& __p1, const path& __p2,
-                     error_code __ec)
-        : system_error(__ec, __what),
-          __paths_(make_shared<_Storage>(__p1, __p2))
-    {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    const path& path1() const _NOEXCEPT {
-        return __paths_->first;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    const path& path2() const _NOEXCEPT {
-        return __paths_->second;
-    }
-
-    ~filesystem_error() override; // key function
-
-    // TODO(ericwf): Create a custom error message.
-    //const char* what() const _NOEXCEPT;
-
-private:
-    typedef pair<path, path> _Storage;
-    shared_ptr<_Storage> __paths_;
-};
-
-template <class... _Args>
-_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
-#ifndef _LIBCPP_NO_EXCEPTIONS
-void __throw_filesystem_error(_Args && ...__args)
-{
-    throw filesystem_error(std::forward<_Args>(__args)...);
-}
-#else
-void __throw_filesystem_error(_Args&&...)
-{
-    _VSTD::abort();
-}
-#endif
+using namespace _VSTD_FS;
 
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
 
-// operational functions
-
-_LIBCPP_FUNC_VIS
-path __canonical(const path&, const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __copy(const path& __from, const path& __to, copy_options __opt,
-        error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-bool __copy_file(const path& __from, const path& __to, copy_options __opt,
-        error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __copy_symlink(const path& __existing_symlink, const path& __new_symlink,
-        error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-bool __create_directories(const path& p, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-bool __create_directory(const path& p, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-bool __create_directory(const path& p, const path & attributes,
-        error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __create_directory_symlink(const path& __to, const path& __new_symlink,
-        error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __create_hard_link(const path& __to, const path& __new_hard_link,
-        error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __create_symlink(const path& __to, const path& __new_symlink,
-        error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-path __current_path(error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __current_path(const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-bool __equivalent(const path&, const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-uintmax_t __file_size(const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-uintmax_t __hard_link_count(const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-bool __fs_is_empty(const path& p, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-file_time_type __last_write_time(const path& p, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __last_write_time(const path& p, file_time_type new_time,
-        error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __permissions(const path& p, perms prms, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-path __read_symlink(const path& p, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-bool __remove(const path& p, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-uintmax_t __remove_all(const path& p, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __rename(const path& from, const path& to, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-void __resize_file(const path& p, uintmax_t size, error_code *ec=nullptr);
-_LIBCPP_FUNC_VIS
-space_info __space(const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-file_status __status(const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-file_status __symlink_status(const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-path __system_complete(const path&, error_code *__ec=nullptr);
-_LIBCPP_FUNC_VIS
-path __temp_directory_path(error_code *__ec=nullptr);
-
-inline _LIBCPP_INLINE_VISIBILITY
-path current_path() {
-    return __current_path();
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path current_path(error_code& __ec) {
-    return __current_path(&__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void current_path(const path& __p) {
-    __current_path(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void current_path(const path& __p, error_code& __ec) _NOEXCEPT {
-    __current_path(__p, &__ec);
-}
-
-_LIBCPP_FUNC_VIS
-path absolute(const path&, const path& __p2 = current_path());
-
-inline _LIBCPP_INLINE_VISIBILITY
-path canonical(const path& __p, const path& __base = current_path()) {
-    return __canonical(__p, __base);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path canonical(const path& __p, error_code& __ec) {
-    path __base = __current_path(&__ec);
-    if (__ec) return {};
-    return __canonical(__p, __base, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path canonical(const path& __p, const path& __base, error_code& __ec) {
-    return __canonical(__p, __base, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void copy(const path& __from, const path& __to) {
-    __copy(__from, __to, copy_options::none);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void copy(const path& __from, const path& __to, error_code& __ec) {
-    __copy(__from, __to, copy_options::none, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void copy(const path& __from, const path& __to, copy_options __opt) {
-    __copy(__from, __to, __opt);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void copy(const path& __from, const path& __to,
-          copy_options __opt, error_code& __ec) {
-    __copy(__from, __to, __opt, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool copy_file(const path& __from, const path& __to) {
-    return __copy_file(__from, __to, copy_options::none);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool copy_file(const path& __from, const path& __to, error_code& __ec) _NOEXCEPT {
-    return __copy_file(__from, __to, copy_options::none, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool copy_file(const path& __from, const path& __to, copy_options __opt) {
-    return __copy_file(__from, __to, __opt);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool copy_file(const path& __from, const path& __to,
-               copy_options __opt, error_code& __ec) _NOEXCEPT {
-    return __copy_file(__from, __to, __opt, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void copy_symlink(const path& __existing, const path& __new) {
-    __copy_symlink(__existing, __new);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void copy_symlink(const path& __ext, const path& __new, error_code& __ec) _NOEXCEPT {
-    __copy_symlink(__ext, __new, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool create_directories(const path& __p) {
-    return __create_directories(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool create_directories(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __create_directories(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool create_directory(const path& __p) {
-    return __create_directory(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool create_directory(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __create_directory(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool create_directory(const path& __p, const path& __attrs) {
-    return __create_directory(__p, __attrs);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool create_directory(const path& __p, const path& __attrs, error_code& __ec) _NOEXCEPT {
-    return __create_directory(__p, __attrs, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void create_directory_symlink(const path& __to, const path& __new) {
-    __create_directory_symlink(__to, __new);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void create_directory_symlink(const path& __to, const path& __new,
-                              error_code& __ec) _NOEXCEPT {
-    __create_directory_symlink(__to, __new, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void create_hard_link(const path& __to, const path& __new) {
-    __create_hard_link(__to, __new);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void create_hard_link(const path& __to, const path& __new, error_code& __ec) _NOEXCEPT {
-    __create_hard_link(__to, __new, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void create_symlink(const path& __to, const path& __new) {
-    __create_symlink(__to, __new);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void create_symlink(const path& __to, const path& __new, error_code& __ec) _NOEXCEPT {
-    return __create_symlink(__to, __new, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool status_known(file_status __s) _NOEXCEPT {
-    return __s.type() != file_type::none;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool exists(file_status __s) _NOEXCEPT {
-    return status_known(__s) && __s.type() != file_type::not_found;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool exists(const path& __p) {
-    return exists(__status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool exists(const path& __p, error_code& __ec) _NOEXCEPT {
-    auto __s = __status(__p, &__ec);
-    if (status_known(__s)) __ec.clear();
-    return exists(__s);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool equivalent(const path& __p1, const path& __p2) {
-    return __equivalent(__p1, __p2);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool equivalent(const path& __p1, const path& __p2, error_code& __ec) _NOEXCEPT {
-    return __equivalent(__p1, __p2, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-uintmax_t file_size(const path& __p) {
-    return __file_size(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-uintmax_t file_size(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __file_size(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-uintmax_t hard_link_count(const path& __p) {
-    return __hard_link_count(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-uintmax_t hard_link_count(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __hard_link_count(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_block_file(file_status __s) _NOEXCEPT {
-    return __s.type() == file_type::block;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_block_file(const path& __p) {
-    return is_block_file(__status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_block_file(const path& __p, error_code& __ec) _NOEXCEPT {
-    return is_block_file(__status(__p, &__ec));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_character_file(file_status __s) _NOEXCEPT {
-    return __s.type() == file_type::character;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_character_file(const path& __p) {
-    return is_character_file(__status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_character_file(const path& __p, error_code& __ec) _NOEXCEPT {
-    return is_character_file(__status(__p, &__ec));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_directory(file_status __s) _NOEXCEPT {
-    return __s.type() == file_type::directory;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_directory(const path& __p) {
-    return is_directory(__status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_directory(const path& __p, error_code& __ec) _NOEXCEPT {
-    return is_directory(__status(__p, &__ec));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_empty(const path& __p) {
-    return __fs_is_empty(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_empty(const path& __p, error_code& __ec) {
-    return __fs_is_empty(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_fifo(file_status __s) _NOEXCEPT {
-    return __s.type() == file_type::fifo;
-}
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_fifo(const path& __p) {
-    return is_fifo(__status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_fifo(const path& __p, error_code& __ec) _NOEXCEPT {
-    return is_fifo(__status(__p, &__ec));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_regular_file(file_status __s) _NOEXCEPT {
-    return __s.type() == file_type::regular;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_regular_file(const path& __p) {
-    return is_regular_file(__status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_regular_file(const path& __p, error_code& __ec) _NOEXCEPT {
-    return is_regular_file(__status(__p, &__ec));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_socket(file_status __s) _NOEXCEPT {
-    return __s.type() == file_type::socket;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_socket(const path& __p) {
-    return is_socket(__status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_socket(const path& __p, error_code& __ec) _NOEXCEPT {
-    return is_socket(__status(__p, &__ec));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_symlink(file_status __s) _NOEXCEPT {
-    return __s.type() == file_type::symlink;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_symlink(const path& __p) {
-    return is_symlink(__symlink_status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_symlink(const path& __p, error_code& __ec) _NOEXCEPT {
-    return is_symlink(__symlink_status(__p, &__ec));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_other(file_status __s) _NOEXCEPT {
-    return exists(__s)
-        && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_other(const path& __p) {
-    return is_other(__status(__p));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool is_other(const path& __p, error_code& __ec) _NOEXCEPT {
-    return is_other(__status(__p, &__ec));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-file_time_type last_write_time(const path& __p) {
-    return __last_write_time(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-file_time_type last_write_time(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __last_write_time(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void last_write_time(const path& __p, file_time_type __t) {
-    __last_write_time(__p, __t);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void last_write_time(const path& __p, file_time_type __t, error_code& __ec) _NOEXCEPT {
-    __last_write_time(__p, __t, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void permissions(const path& __p, perms __prms) {
-    __permissions(__p, __prms);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void permissions(const path& __p, perms __prms, error_code& __ec)  {
-    __permissions(__p, __prms, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path read_symlink(const path& __p) {
-    return __read_symlink(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path read_symlink(const path& __p, error_code& __ec) {
-    return __read_symlink(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool remove(const path& __p) {
-    return __remove(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool remove(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __remove(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-uintmax_t remove_all(const path& __p) {
-    return __remove_all(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-uintmax_t remove_all(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __remove_all(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void rename(const path& __from, const path& __to) {
-    return __rename(__from, __to);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void rename(const path& __from, const path& __to, error_code& __ec) _NOEXCEPT {
-    return __rename(__from, __to, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void resize_file(const path& __p, uintmax_t __ns) {
-    return __resize_file(__p, __ns);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) _NOEXCEPT {
-    return __resize_file(__p, __ns, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-space_info space(const path& __p) {
-    return __space(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-space_info space(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __space(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-file_status status(const path& __p) {
-    return __status(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-file_status status(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __status(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-file_status symlink_status(const path& __p) {
-    return __symlink_status(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-file_status symlink_status(const path& __p, error_code& __ec) _NOEXCEPT {
-    return __symlink_status(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path system_complete(const path& __p) {
-    return __system_complete(__p);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path system_complete(const path& __p, error_code& __ec) {
-    return __system_complete(__p, &__ec);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path temp_directory_path() {
-    return __temp_directory_path();
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-path temp_directory_path(error_code& __ec) {
-    return __temp_directory_path(&__ec);
-}
-
-
-class directory_entry
-{
-    typedef _VSTD_FS::path _Path;
-
-public:
-    // constructors and destructors
-    directory_entry() _NOEXCEPT = default;
-    directory_entry(directory_entry const&) = default;
-    directory_entry(directory_entry&&) _NOEXCEPT = default;
-
-    _LIBCPP_INLINE_VISIBILITY
-    explicit directory_entry(_Path const& __p) : __p_(__p) {}
-
-    ~directory_entry() {}
-
-    directory_entry& operator=(directory_entry const&) = default;
-    directory_entry& operator=(directory_entry&&) _NOEXCEPT = default;
-
-    _LIBCPP_INLINE_VISIBILITY
-    void assign(_Path const& __p) {
-        __p_ = __p;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    void replace_filename(_Path const& __p) {
-        __p_ = __p_.parent_path() / __p;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    _Path const& path() const _NOEXCEPT {
-        return __p_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    operator const _Path&() const _NOEXCEPT {
-        return __p_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    file_status status() const {
-        return _VSTD_FS::status(__p_);
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    file_status status(error_code& __ec) const _NOEXCEPT {
-        return _VSTD_FS::status(__p_, __ec);
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    file_status symlink_status() const {
-        return _VSTD_FS::symlink_status(__p_);
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    file_status symlink_status(error_code& __ec) const _NOEXCEPT {
-        return _VSTD_FS::symlink_status(__p_, __ec);
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    bool operator< (directory_entry const& __rhs) const _NOEXCEPT {
-        return __p_ < __rhs.__p_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    bool operator==(directory_entry const& __rhs) const _NOEXCEPT {
-        return __p_ == __rhs.__p_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    bool operator!=(directory_entry const& __rhs) const _NOEXCEPT {
-        return __p_ != __rhs.__p_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    bool operator<=(directory_entry const& __rhs) const _NOEXCEPT {
-        return __p_ <= __rhs.__p_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    bool operator> (directory_entry const& __rhs) const _NOEXCEPT {
-        return __p_ > __rhs.__p_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    bool operator>=(directory_entry const& __rhs) const _NOEXCEPT {
-        return __p_ >= __rhs.__p_;
-    }
-private:
-    _Path __p_;
-};
-
-
-class directory_iterator;
-class recursive_directory_iterator;
-class __dir_stream;
-
-class __dir_element_proxy {
-public:
-
-    inline _LIBCPP_INLINE_VISIBILITY
-    directory_entry operator*() { return _VSTD::move(__elem_); }
-
-private:
-    friend class directory_iterator;
-    friend class recursive_directory_iterator;
-    explicit __dir_element_proxy(directory_entry const& __e) : __elem_(__e) {}
-    __dir_element_proxy(__dir_element_proxy&& __o) : __elem_(_VSTD::move(__o.__elem_)) {}
-    directory_entry __elem_;
-};
-
-class directory_iterator
-{
-public:
-    typedef directory_entry value_type;
-    typedef ptrdiff_t difference_type;
-    typedef value_type const* pointer;
-    typedef value_type const& reference;
-    typedef input_iterator_tag iterator_category;
-
-public:
-    //ctor & dtor
-    directory_iterator() _NOEXCEPT
-    { }
-
-    explicit directory_iterator(const path& __p)
-        : directory_iterator(__p, nullptr)
-    { }
-
-    directory_iterator(const path& __p, directory_options __opts)
-        : directory_iterator(__p, nullptr, __opts)
-    { }
-
-    directory_iterator(const path& __p, error_code& __ec)
-        : directory_iterator(__p, &__ec)
-    { }
-
-    directory_iterator(const path& __p, directory_options __opts,
-                       error_code& __ec)
-        : directory_iterator(__p, &__ec, __opts)
-    { }
-
-    directory_iterator(const directory_iterator&) = default;
-    directory_iterator(directory_iterator&&) = default;
-    directory_iterator& operator=(const directory_iterator&) = default;
-
-    directory_iterator& operator=(directory_iterator&& __o) _NOEXCEPT {
-        // non-default implementation provided to support self-move assign.
-        if (this != &__o) {
-            __imp_ = _VSTD::move(__o.__imp_);
-        }
-        return *this;
-    }
-
-    ~directory_iterator() = default;
-
-    const directory_entry& operator*() const {
-        _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced");
-        return __dereference();
-    }
-
-    const directory_entry* operator->() const
-    { return &**this; }
-
-    directory_iterator& operator++()
-    { return __increment(); }
-
-    __dir_element_proxy operator++(int) {
-        __dir_element_proxy __p(**this);
-        __increment();
-        return __p;
-    }
-
-    directory_iterator& increment(error_code& __ec)
-    { return __increment(&__ec); }
-
-private:
-    inline _LIBCPP_INLINE_VISIBILITY
-    friend bool operator==(const directory_iterator& __lhs,
-                           const directory_iterator& __rhs) _NOEXCEPT;
-
-    // construct the dir_stream
-    _LIBCPP_FUNC_VIS
-    directory_iterator(const path&, error_code *,
-                       directory_options = directory_options::none);
-
-    _LIBCPP_FUNC_VIS
-    directory_iterator& __increment(error_code * __ec = nullptr);
-
-    _LIBCPP_FUNC_VIS
-    const directory_entry& __dereference() const;
-
-private:
-    shared_ptr<__dir_stream> __imp_;
-};
-
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator==(const directory_iterator& __lhs,
-                const directory_iterator& __rhs) _NOEXCEPT {
-    return __lhs.__imp_ == __rhs.__imp_;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator!=(const directory_iterator& __lhs,
-                const directory_iterator& __rhs) _NOEXCEPT {
-    return !(__lhs == __rhs);
-}
-
-// enable directory_iterator range-based for statements
-inline _LIBCPP_INLINE_VISIBILITY
-directory_iterator begin(directory_iterator __iter) _NOEXCEPT {
-    return __iter;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-directory_iterator end(const directory_iterator&) _NOEXCEPT {
-    return directory_iterator();
-}
-
-class recursive_directory_iterator {
-public:
-    using value_type = directory_entry;
-    using difference_type = std::ptrdiff_t;
-    using pointer = directory_entry const *;
-    using reference = directory_entry const &;
-    using iterator_category = std::input_iterator_tag;
-
-public:
-    // constructors and destructor
-    _LIBCPP_INLINE_VISIBILITY
-    recursive_directory_iterator()  _NOEXCEPT
-        : __rec_(false)
-    {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    explicit recursive_directory_iterator(const path& __p,
-                directory_options __xoptions = directory_options::none)
-        : recursive_directory_iterator(__p, __xoptions,  nullptr)
-    { }
-
-    _LIBCPP_INLINE_VISIBILITY
-    recursive_directory_iterator(const path& __p,
-        directory_options __xoptions, error_code& __ec)
-        : recursive_directory_iterator(__p, __xoptions, &__ec)
-    { }
-
-    _LIBCPP_INLINE_VISIBILITY
-    recursive_directory_iterator(const path& __p, error_code& __ec)
-        : recursive_directory_iterator(__p, directory_options::none,  &__ec)
-    { }
-
-    recursive_directory_iterator(const recursive_directory_iterator&) = default;
-    recursive_directory_iterator(recursive_directory_iterator&&) = default;
-
-    recursive_directory_iterator &
-    operator=(const recursive_directory_iterator&) = default;
-
-    _LIBCPP_INLINE_VISIBILITY
-    recursive_directory_iterator &
-    operator=(recursive_directory_iterator&& __o) noexcept {
-        // non-default implementation provided to support self-move assign.
-        if (this != &__o) {
-            __imp_ = _VSTD::move(__o.__imp_);
-            __rec_ = __o.__rec_;
-        }
-        return *this;
-    }
-
-    ~recursive_directory_iterator() = default;
-
-    _LIBCPP_INLINE_VISIBILITY
-    const directory_entry& operator*() const
-    { return __dereference(); }
-
-    _LIBCPP_INLINE_VISIBILITY
-    const directory_entry* operator->() const
-    { return &__dereference(); }
-
-    recursive_directory_iterator& operator++()
-    { return __increment(); }
-
-    _LIBCPP_INLINE_VISIBILITY
-    __dir_element_proxy operator++(int) {
-        __dir_element_proxy __p(**this);
-        __increment();
-        return __p;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY
-    recursive_directory_iterator& increment(error_code& __ec)
-    { return __increment(&__ec); }
-
-    _LIBCPP_FUNC_VIS directory_options options() const;
-    _LIBCPP_FUNC_VIS int  depth() const;
-
-    _LIBCPP_INLINE_VISIBILITY
-    void pop() { __pop(); }
-
-    _LIBCPP_INLINE_VISIBILITY
-    void pop(error_code& __ec)
-    { __pop(&__ec); }
-
-    _LIBCPP_INLINE_VISIBILITY
-    bool recursion_pending() const
-    { return __rec_; }
-
-    _LIBCPP_INLINE_VISIBILITY
-    void disable_recursion_pending()
-    { __rec_ = false; }
-
-private:
-    recursive_directory_iterator(const path& __p, directory_options __opt,
-                                 error_code *__ec);
-
-    _LIBCPP_FUNC_VIS
-    const directory_entry& __dereference() const;
-
-    _LIBCPP_FUNC_VIS
-    bool __try_recursion(error_code* __ec);
-
-    _LIBCPP_FUNC_VIS
-    void __advance(error_code* __ec=nullptr);
-
-    _LIBCPP_FUNC_VIS
-    recursive_directory_iterator& __increment(error_code *__ec=nullptr);
-
-    _LIBCPP_FUNC_VIS
-    void __pop(error_code* __ec=nullptr);
-
-    inline _LIBCPP_INLINE_VISIBILITY
-    friend bool operator==(const recursive_directory_iterator&,
-                           const recursive_directory_iterator&) _NOEXCEPT;
-
-    struct __shared_imp;
-    shared_ptr<__shared_imp> __imp_;
-    bool __rec_;
-};                                     // class recursive_directory_iterator
-
-
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator==(const recursive_directory_iterator& __lhs,
-                const recursive_directory_iterator& __rhs) _NOEXCEPT
-{
-    return __lhs.__imp_ == __rhs.__imp_;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-inline bool operator!=(const recursive_directory_iterator& __lhs,
-                        const recursive_directory_iterator& __rhs) _NOEXCEPT
-{
-    return !(__lhs == __rhs);
-}
-// enable recursive_directory_iterator range-based for statements
-inline _LIBCPP_INLINE_VISIBILITY
-recursive_directory_iterator begin(recursive_directory_iterator __iter) _NOEXCEPT {
-    return __iter;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-recursive_directory_iterator end(const recursive_directory_iterator&) _NOEXCEPT {
-    return recursive_directory_iterator();
-}
+#endif // !_LIBCPP_CXX03_LANG
 
-_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
+_LIBCPP_POP_MACROS
 
 #endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM
diff --git lib/libcxx/include/experimental/functional lib/libcxx/include/experimental/functional
index a136cbb57c8..f63dfb07bb0 100644
--- lib/libcxx/include/experimental/functional
+++ lib/libcxx/include/experimental/functional
@@ -241,8 +241,8 @@ public:
     operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
     {
         static_assert ( std::is_same<
-                typename std::decay<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
-                typename std::decay<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
+                typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
+                typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
                     >::value,
                 "Corpus and Pattern iterators must point to the same type" );
 
@@ -394,8 +394,8 @@ public:
     operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
     {
         static_assert ( std::is_same<
-                typename std::decay<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
-                typename std::decay<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
+                typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
+                typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
                     >::value,
                 "Corpus and Pattern iterators must point to the same type" );
 
diff --git lib/libcxx/include/experimental/memory_resource lib/libcxx/include/experimental/memory_resource
index d101f3e0811..221ce5b8eac 100644
--- lib/libcxx/include/experimental/memory_resource
+++ lib/libcxx/include/experimental/memory_resource
@@ -71,7 +71,7 @@ namespace pmr {
 #include <memory>
 #include <new>
 #include <stdexcept>
-#include <tuple>
+#include <__tuple>
 #include <type_traits>
 #include <utility>
 #include <cstddef>
@@ -96,7 +96,7 @@ size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
 }
 
 // 8.5, memory.resource
-class _LIBCPP_TEMPLATE_VIS memory_resource
+class _LIBCPP_TYPE_VIS memory_resource
 {
     static const size_t __max_align = alignof(max_align_t);
 
@@ -206,7 +206,7 @@ public:
     void construct(_Tp* __p, _Ts &&... __args)
     {
         _VSTD_LFTS::__lfts_user_alloc_construct(
-            __p, resource(), _VSTD::forward<_Ts>(__args)...
+            __p, *this, _VSTD::forward<_Ts>(__args)...
           );
     }
 
@@ -218,14 +218,14 @@ public:
         ::new ((void*)__p) pair<_T1, _T2>(piecewise_construct
           , __transform_tuple(
               typename __lfts_uses_alloc_ctor<
-                  _T1, memory_resource*, _Args1...
+                  _T1, polymorphic_allocator&, _Args1...
               >::type()
             , _VSTD::move(__x)
             , typename __make_tuple_indices<sizeof...(_Args1)>::type{}
           )
           , __transform_tuple(
               typename __lfts_uses_alloc_ctor<
-                  _T2, memory_resource*, _Args2...
+                  _T2, polymorphic_allocator&, _Args2...
               >::type()
             , _VSTD::move(__y)
             , typename __make_tuple_indices<sizeof...(_Args2)>::type{}
@@ -289,23 +289,23 @@ private:
 
     template <class ..._Args, size_t ..._Idx>
     _LIBCPP_INLINE_VISIBILITY
-    tuple<allocator_arg_t const&, memory_resource*, _Args&&...>
+    tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>
     __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
-                      __tuple_indices<_Idx...>) const
+                      __tuple_indices<_Idx...>)
     {
-        using _Tup = tuple<allocator_arg_t const&, memory_resource*, _Args&&...>;
-        return _Tup(allocator_arg, resource(),
+        using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>;
+        return _Tup(allocator_arg, *this,
                     _VSTD::get<_Idx>(_VSTD::move(__t))...);
     }
 
     template <class ..._Args, size_t ..._Idx>
     _LIBCPP_INLINE_VISIBILITY
-    tuple<_Args&&..., memory_resource*>
+    tuple<_Args&&..., polymorphic_allocator&>
     __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
-                      __tuple_indices<_Idx...>) const
+                      __tuple_indices<_Idx...>)
     {
-        using _Tup = tuple<_Args&&..., memory_resource*>;
-        return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource());
+        using _Tup = tuple<_Args&&..., polymorphic_allocator&>;
+        return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., *this);
     }
 
     _LIBCPP_INLINE_VISIBILITY
diff --git lib/libcxx/include/experimental/numeric lib/libcxx/include/experimental/numeric
index d784c08f0fe..14a664011b5 100644
--- lib/libcxx/include/experimental/numeric
+++ lib/libcxx/include/experimental/numeric
@@ -8,112 +8,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
-#define _LIBCPP_EXPERIMENTAL_NUMERIC
-/*
-    experimental/numeric synopsis
-
-// C++1z
-namespace std {
-namespace experimental {
-inline namespace fundamentals_v2 {
-
-  // 13.1.2, Greatest common divisor
-  template<class M, class N>
-  constexpr common_type_t<M,N> gcd(M m, N n);
-
-  // 13.1.3, Least common multiple
-  template<class M, class N>
-  constexpr common_type_t<M,N> lcm(M m, N n);
-
-} // namespace fundamentals_v2
-} // namespace experimental
-} // namespace std
-
- */
-
-#include <experimental/__config>
-#include <numeric>
-#include <type_traits>              // is_integral
-#include <limits>                   // numeric_limits
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-#if _LIBCPP_STD_VER > 11
-
-_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
-
-template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __abs;
-
-template <typename _Result, typename _Source>
-struct __abs<_Result, _Source, true> {
-    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-    _Result operator()(_Source __t) const noexcept
-    {
-    if (__t >= 0) return __t;
-    if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
-    return -__t;
-    }
-};
-
-template <typename _Result, typename _Source>
-struct __abs<_Result, _Source, false> {
-    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-    _Result operator()(_Source __t) const noexcept { return __t; }
-};
-
-
-template<class _Tp>
-_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
-inline _Tp __gcd(_Tp __m, _Tp __n)
-{
-    static_assert((!is_signed<_Tp>::value), "" );
-    return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n);
-}
-
-
-template<class _Tp, class _Up>
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-common_type_t<_Tp,_Up>
-gcd(_Tp __m, _Up __n)
-{
-    static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
-    static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" );
-    static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
-    using _Rp = common_type_t<_Tp,_Up>;
-    using _Wp = make_unsigned_t<_Rp>;
-    return static_cast<_Rp>(_VSTD_LFTS_V2::__gcd(
-      static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
-      static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
-}
-
-template<class _Tp, class _Up>
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-common_type_t<_Tp,_Up>
-lcm(_Tp __m, _Up __n)
-{
-    static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
-    static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" );
-    static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" );
-    if (__m == 0 || __n == 0)
-        return 0;
-
-    using _Rp = common_type_t<_Tp,_Up>;
-    _Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n);
-    _Rp __val2 = __abs<_Rp, _Up>()(__n);
-    _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
-    return __val1 * __val2;
-}
-
-_LIBCPP_END_NAMESPACE_LFTS_V2
-
-#endif /* _LIBCPP_STD_VER > 11 */
-
-_LIBCPP_POP_MACROS
-
-#endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */
+#error "<experimental/numeric> has been removed. Use <numeric> instead."
diff --git lib/libcxx/include/experimental/optional lib/libcxx/include/experimental/optional
index b251748fbf3..d68cefdf6c1 100644
--- lib/libcxx/include/experimental/optional
+++ lib/libcxx/include/experimental/optional
@@ -8,915 +8,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
-#define _LIBCPP_EXPERIMENTAL_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>
-#if _LIBCPP_STD_VER > 11
-#include <initializer_list>
-#include <type_traits>
-#include <new>
-#include <__functional_base>
-#include <__debug>
-#endif
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-
-_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
-class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 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
-
-_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((void*)_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((void*)_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((void*)_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((void*)_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((void*)_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((void*)_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((void*)_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((void*)_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((void*)_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((void*)_VSTD::addressof(__opt.__val_))
-                    value_type(_VSTD::move(this->__val_));
-                this->__val_.~value_type();
-            }
-            else
-            {
-                ::new((void*)_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");
-#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
-        return __builtin_addressof(this->__val_);
-#else
-        return __operator_arrow(__has_operator_addressof<value_type>{});
-#endif
-    }
-
-    _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_NORETURN _LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_NO_EXCEPTIONS
-_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-#endif
- constexpr void __throw_bad_optional_access() const
- {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw bad_optional_access();
-#else
-        _VSTD::abort();
-#endif
- }
-
-    _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-    constexpr value_type const& value() const
-    {
-        if (!this->__engaged_)
-            __throw_bad_optional_access();
-        return this->__val_;
-    }
-
-    _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-    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>&) 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>&) 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_TEMPLATE_VIS 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
-
-_LIBCPP_POP_MACROS
-
-#endif  // _LIBCPP_EXPERIMENTAL_OPTIONAL
+#error "<experimental/optional> has been removed. Use <optional> instead."
diff --git lib/libcxx/include/experimental/propagate_const lib/libcxx/include/experimental/propagate_const
index e7f7e9fc683..188548596b8 100644
--- lib/libcxx/include/experimental/propagate_const
+++ lib/libcxx/include/experimental/propagate_const
@@ -463,8 +463,7 @@ template <class _Tp>
 _LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
 {
-  using _VSTD::swap;
-  swap(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
+  __pc1.swap(__pc2);
 }
 
 template <class _Tp>
diff --git lib/libcxx/include/experimental/ratio lib/libcxx/include/experimental/ratio
index 757f24e0861..9c2bf2e4624 100644
--- lib/libcxx/include/experimental/ratio
+++ lib/libcxx/include/experimental/ratio
@@ -8,70 +8,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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
+#error "<experimental/ratio> has been removed. Use <ratio> instead."
diff --git lib/libcxx/include/experimental/simd lib/libcxx/include/experimental/simd
new file mode 100644
index 00000000000..6580443f7b0
--- /dev/null
+++ lib/libcxx/include/experimental/simd
@@ -0,0 +1,1570 @@
+// -*- C++ -*-
+//===------------------------------- simd ---------------------------------===//
+//
+//                     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_SIMD
+#define _LIBCPP_EXPERIMENTAL_SIMD
+
+/*
+    experimental/simd synopsis
+
+namespace std::experimental {
+
+inline namespace parallelism_v2 {
+
+namespace simd_abi {
+
+struct scalar {};
+template <int N> struct fixed_size {};
+template <typename T> inline constexpr int max_fixed_size = implementation-defined;
+template <typename T> using compatible = implementation-defined;
+template <typename T> using native = implementation-defined;
+
+} // simd_abi
+
+struct element_aligned_tag {};
+struct vector_aligned_tag {};
+template <size_t> struct overaligned_tag {};
+inline constexpr element_aligned_tag element_aligned{};
+inline constexpr vector_aligned_tag vector_aligned{};
+template <size_t N> inline constexpr overaligned_tag<N> overaligned{};
+
+// traits [simd.traits]
+template <class T> struct is_abi_tag;
+template <class T> inline constexpr bool is_abi_tag_v = is_abi_tag<T>::value;
+
+template <class T> struct is_simd;
+template <class T> inline constexpr bool is_simd_v = is_simd<T>::value;
+
+template <class T> struct is_simd_mask;
+template <class T> inline constexpr bool is_simd_mask_v = is_simd_mask<T>::value;
+
+template <class T> struct is_simd_flag_type;
+template <class T> inline constexpr bool is_simd_flag_type_v = is_simd_flag_type<T>::value;
+
+template <class T, size_t N> struct abi_for_size { using type = see below; };
+template <class T, size_t N> using abi_for_size_t = typename abi_for_size<T, N>::type;
+
+template <class T, class Abi = simd_abi::compatible<T>> struct simd_size;
+template <class T, class Abi = simd_abi::compatible<T>>
+inline constexpr size_t simd_size_v = simd_size<T, Abi>::value;
+
+template <class T, class U = typename T::value_type> struct memory_alignment;
+template <class T, class U = typename T::value_type>
+inline constexpr size_t memory_alignment_v = memory_alignment<T, U>::value;
+
+// class template simd [simd.class]
+template <class T, class Abi = simd_abi::compatible<T>> class simd;
+template <class T> using native_simd = simd<T, simd_abi::native<T>>;
+template <class T, int N> using fixed_size_simd = simd<T, simd_abi::fixed_size<N>>;
+
+// class template simd_mask [simd.mask.class]
+template <class T, class Abi = simd_abi::compatible<T>> class simd_mask;
+template <class T> using native_simd_mask = simd_mask<T, simd_abi::native<T>>;
+template <class T, int N> using fixed_size_simd_mask = simd_mask<T, simd_abi::fixed_size<N>>;
+
+// casts [simd.casts]
+template <class T, class U, class Abi> see below simd_cast(const simd<U, Abi>&);
+template <class T, class U, class Abi> see below static_simd_cast(const simd<U, Abi>&);
+
+template <class T, class Abi>
+fixed_size_simd<T, simd_size_v<T, Abi>> to_fixed_size(const simd<T, Abi>&) noexcept;
+template <class T, class Abi>
+fixed_size_simd_mask<T, simd_size_v<T, Abi>> to_fixed_size(const simd_mask<T, Abi>&) noexcept;
+template <class T, size_t N> native_simd<T> to_native(const fixed_size_simd<T, N>&) noexcept;
+template <class T, size_t N>
+native_simd_mask<T> to_native(const fixed_size_simd_mask<T, N>> &) noexcept;
+template <class T, size_t N> simd<T> to_compatible(const fixed_size_simd<T, N>&) noexcept;
+template <class T, size_t N> simd_mask<T> to_compatible(const fixed_size_simd_mask<T, N>&) noexcept;
+
+template <size_t... Sizes, class T, class Abi>
+tuple<simd<T, abi_for_size_t<Sizes>>...> split(const simd<T, Abi>&);
+template <size_t... Sizes, class T, class Abi>
+tuple<simd_mask<T, abi_for_size_t<Sizes>>...> split(const simd_mask<T, Abi>&);
+template <class V, class Abi>
+array<V, simd_size_v<typename V::value_type, Abi> / V::size()> split(
+const simd<typename V::value_type, Abi>&);
+template <class V, class Abi>
+array<V, simd_size_v<typename V::value_type, Abi> / V::size()> split(
+const simd_mask<typename V::value_type, Abi>&);
+
+template <class T, class... Abis>
+simd<T, abi_for_size_t<T, (simd_size_v<T, Abis> + ...)>> concat(const simd<T, Abis>&...);
+template <class T, class... Abis>
+simd_mask<T, abi_for_size_t<T, (simd_size_v<T, Abis> + ...)>> concat(const simd_mask<T, Abis>&...);
+
+// reductions [simd.mask.reductions]
+template <class T, class Abi> bool all_of(const simd_mask<T, Abi>&) noexcept;
+template <class T, class Abi> bool any_of(const simd_mask<T, Abi>&) noexcept;
+template <class T, class Abi> bool none_of(const simd_mask<T, Abi>&) noexcept;
+template <class T, class Abi> bool some_of(const simd_mask<T, Abi>&) noexcept;
+template <class T, class Abi> int popcount(const simd_mask<T, Abi>&) noexcept;
+template <class T, class Abi> int find_first_set(const simd_mask<T, Abi>&);
+template <class T, class Abi> int find_last_set(const simd_mask<T, Abi>&);
+
+bool all_of(see below) noexcept;
+bool any_of(see below) noexcept;
+bool none_of(see below) noexcept;
+bool some_of(see below) noexcept;
+int popcount(see below) noexcept;
+int find_first_set(see below) noexcept;
+int find_last_set(see below) noexcept;
+
+// masked assignment [simd.whereexpr]
+template <class M, class T> class const_where_expression;
+template <class M, class T> class where_expression;
+
+// masked assignment [simd.mask.where]
+template <class T> struct nodeduce { using type = T; }; // exposition only
+
+template <class T> using nodeduce_t = typename nodeduce<T>::type; // exposition only
+
+template <class T, class Abi>
+where_expression<simd_mask<T, Abi>, simd<T, Abi>>
+where(const typename simd<T, Abi>::mask_type&, simd<T, Abi>&) noexcept;
+
+template <class T, class Abi>
+const_where_expression<simd_mask<T, Abi>, const simd<T, Abi>>
+where(const typename simd<T, Abi>::mask_type&, const simd<T, Abi>&) noexcept;
+
+template <class T, class Abi>
+where_expression<simd_mask<T, Abi>, simd_mask<T, Abi>>
+where(const nodeduce_t<simd_mask<T, Abi>>&, simd_mask<T, Abi>&) noexcept;
+
+template <class T, class Abi>
+const_where_expression<simd_mask<T, Abi>, const simd_mask<T, Abi>>
+where(const nodeduce_t<simd_mask<T, Abi>>&, const simd_mask<T, Abi>&) noexcept;
+
+template <class T> where_expression<bool, T> where(see below k, T& d) noexcept;
+
+template <class T>
+const_where_expression<bool, const T> where(see below k, const T& d) noexcept;
+
+// reductions [simd.reductions]
+template <class T, class Abi, class BinaryOperation = std::plus<>>
+T reduce(const simd<T, Abi>&, BinaryOperation = BinaryOperation());
+
+template <class M, class V, class BinaryOperation>
+typename V::value_type reduce(const const_where_expression<M, V>& x,
+typename V::value_type neutral_element, BinaryOperation binary_op);
+
+template <class M, class V>
+typename V::value_type reduce(const const_where_expression<M, V>& x, plus<> binary_op = plus<>());
+
+template <class M, class V>
+typename V::value_type reduce(const const_where_expression<M, V>& x, multiplies<> binary_op);
+
+template <class M, class V>
+typename V::value_type reduce(const const_where_expression<M, V>& x, bit_and<> binary_op);
+
+template <class M, class V>
+typename V::value_type reduce(const const_where_expression<M, V>& x, bit_or<> binary_op);
+
+template <class M, class V>
+typename V::value_type reduce(const const_where_expression<M, V>& x, bit_xor<> binary_op);
+
+template <class T, class Abi> T hmin(const simd<T, Abi>&);
+template <class M, class V> T hmin(const const_where_expression<M, V>&);
+template <class T, class Abi> T hmax(const simd<T, Abi>&);
+template <class M, class V> T hmax(const const_where_expression<M, V>&);
+
+// algorithms [simd.alg]
+template <class T, class Abi> simd<T, Abi> min(const simd<T, Abi>&, const simd<T, Abi>&) noexcept;
+
+template <class T, class Abi> simd<T, Abi> max(const simd<T, Abi>&, const simd<T, Abi>&) noexcept;
+
+template <class T, class Abi>
+std::pair<simd<T, Abi>, simd<T, Abi>> minmax(const simd<T, Abi>&, const simd<T, Abi>&) noexcept;
+
+template <class T, class Abi>
+simd<T, Abi> clamp(const simd<T, Abi>& v, const simd<T, Abi>& lo, const simd<T, Abi>& hi);
+
+// [simd.whereexpr]
+template <class M, class T>
+class const_where_expression {
+  const M& mask; // exposition only
+  T& data; // exposition only
+public:
+  const_where_expression(const const_where_expression&) = delete;
+  const_where_expression& operator=(const const_where_expression&) = delete;
+  remove_const_t<T> operator-() const &&;
+  template <class U, class Flags> void copy_to(U* mem, Flags f) const &&;
+};
+
+template <class M, class T>
+class where_expression : public const_where_expression<M, T> {
+public:
+  where_expression(const where_expression&) = delete;
+  where_expression& operator=(const where_expression&) = delete;
+  template <class U> void operator=(U&& x);
+  template <class U> void operator+=(U&& x);
+  template <class U> void operator-=(U&& x);
+  template <class U> void operator*=(U&& x);
+  template <class U> void operator/=(U&& x);
+  template <class U> void operator%=(U&& x);
+  template <class U> void operator&=(U&& x);
+  template <class U> void operator|=(U&& x);
+  template <class U> void operator^=(U&& x);
+  template <class U> void operator<<=(U&& x);
+  template <class U> void operator>>=(U&& x);
+  void operator++();
+  void operator++(int);
+  void operator--();
+  void operator--(int);
+  template <class U, class Flags> void copy_from(const U* mem, Flags);
+};
+
+// [simd.class]
+template <class T, class Abi> class simd {
+public:
+  using value_type = T;
+  using reference = see below;
+  using mask_type = simd_mask<T, Abi>;
+
+  using abi_type = Abi;
+  static constexpr size_t size() noexcept;
+  simd() = default;
+
+  // implicit type conversion constructor
+  template <class U> simd(const simd<U, simd_abi::fixed_size<size()>>&);
+
+  // implicit broadcast constructor (see below for constraints)
+  template <class U> simd(U&& value);
+
+  // generator constructor (see below for constraints)
+  template <class G> explicit simd(G&& gen);
+
+  // load constructor
+  template <class U, class Flags> simd(const U* mem, Flags f);
+
+  // loads [simd.load]
+  template <class U, class Flags> void copy_from(const U* mem, Flags f);
+
+  // stores [simd.store]
+  template <class U, class Flags> void copy_to(U* mem, Flags f) const;
+
+  // scalar access [simd.subscr]
+  reference operator[](size_t);
+  value_type operator[](size_t) const;
+
+  // unary operators [simd.unary]
+  simd& operator++();
+  simd operator++(int);
+  simd& operator--();
+  simd operator--(int);
+  mask_type operator!() const;
+  simd operator~() const; // see below
+  simd operator+() const;
+  simd operator-() const;
+
+  // binary operators [simd.binary]
+  friend simd operator+ (const simd&, const simd&);
+  friend simd operator- (const simd&, const simd&);
+  friend simd operator* (const simd&, const simd&);
+  friend simd operator/ (const simd&, const simd&);
+  friend simd operator% (const simd&, const simd&);
+  friend simd operator& (const simd&, const simd&);
+  friend simd operator| (const simd&, const simd&);
+  friend simd operator^ (const simd&, const simd&);
+  friend simd operator<<(const simd&, const simd&);
+  friend simd operator>>(const simd&, const simd&);
+  friend simd operator<<(const simd&, int);
+  friend simd operator>>(const simd&, int);
+
+  // compound assignment [simd.cassign]
+  friend simd& operator+= (simd&, const simd&);
+  friend simd& operator-= (simd&, const simd&);
+  friend simd& operator*= (simd&, const simd&);
+  friend simd& operator/= (simd&, const simd&);
+  friend simd& operator%= (simd&, const simd&);
+
+  friend simd& operator&= (simd&, const simd&);
+  friend simd& operator|= (simd&, const simd&);
+  friend simd& operator^= (simd&, const simd&);
+  friend simd& operator<<=(simd&, const simd&);
+  friend simd& operator>>=(simd&, const simd&);
+  friend simd& operator<<=(simd&, int);
+  friend simd& operator>>=(simd&, int);
+
+  // compares [simd.comparison]
+  friend mask_type operator==(const simd&, const simd&);
+  friend mask_type operator!=(const simd&, const simd&);
+  friend mask_type operator>=(const simd&, const simd&);
+  friend mask_type operator<=(const simd&, const simd&);
+  friend mask_type operator> (const simd&, const simd&);
+  friend mask_type operator< (const simd&, const simd&);
+};
+
+// [simd.math]
+template <class Abi> using scharv = simd<signed char, Abi>; // exposition only
+template <class Abi> using shortv = simd<short, Abi>; // exposition only
+template <class Abi> using intv = simd<int, Abi>; // exposition only
+template <class Abi> using longv = simd<long int, Abi>; // exposition only
+template <class Abi> using llongv = simd<long long int, Abi>; // exposition only
+template <class Abi> using floatv = simd<float, Abi>; // exposition only
+template <class Abi> using doublev = simd<double, Abi>; // exposition only
+template <class Abi> using ldoublev = simd<long double, Abi>; // exposition only
+template <class T, class V> using samesize = fixed_size_simd<T, V::size()>; // exposition only
+
+template <class Abi> floatv<Abi> acos(floatv<Abi> x);
+template <class Abi> doublev<Abi> acos(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> acos(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> asin(floatv<Abi> x);
+template <class Abi> doublev<Abi> asin(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> asin(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> atan(floatv<Abi> x);
+template <class Abi> doublev<Abi> atan(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> atan(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> atan2(floatv<Abi> y, floatv<Abi> x);
+template <class Abi> doublev<Abi> atan2(doublev<Abi> y, doublev<Abi> x);
+template <class Abi> ldoublev<Abi> atan2(ldoublev<Abi> y, ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> cos(floatv<Abi> x);
+template <class Abi> doublev<Abi> cos(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> cos(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> sin(floatv<Abi> x);
+template <class Abi> doublev<Abi> sin(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> sin(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> tan(floatv<Abi> x);
+template <class Abi> doublev<Abi> tan(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> tan(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> acosh(floatv<Abi> x);
+template <class Abi> doublev<Abi> acosh(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> acosh(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> asinh(floatv<Abi> x);
+template <class Abi> doublev<Abi> asinh(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> asinh(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> atanh(floatv<Abi> x);
+template <class Abi> doublev<Abi> atanh(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> atanh(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> cosh(floatv<Abi> x);
+template <class Abi> doublev<Abi> cosh(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> cosh(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> sinh(floatv<Abi> x);
+template <class Abi> doublev<Abi> sinh(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> sinh(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> tanh(floatv<Abi> x);
+template <class Abi> doublev<Abi> tanh(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> tanh(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> exp(floatv<Abi> x);
+template <class Abi> doublev<Abi> exp(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> exp(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> exp2(floatv<Abi> x);
+template <class Abi> doublev<Abi> exp2(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> exp2(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> expm1(floatv<Abi> x);
+template <class Abi> doublev<Abi> expm1(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> expm1(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> frexp(floatv<Abi> value, samesize<int, floatv<Abi>>* exp);
+template <class Abi> doublev<Abi> frexp(doublev<Abi> value, samesize<int, doublev<Abi>>* exp);
+template <class Abi> ldoublev<Abi> frexp(ldoublev<Abi> value, samesize<int, ldoublev<Abi>>* exp);
+
+template <class Abi> samesize<int, floatv<Abi>> ilogb(floatv<Abi> x);
+template <class Abi> samesize<int, doublev<Abi>> ilogb(doublev<Abi> x);
+template <class Abi> samesize<int, ldoublev<Abi>> ilogb(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> ldexp(floatv<Abi> x, samesize<int, floatv<Abi>> exp);
+template <class Abi> doublev<Abi> ldexp(doublev<Abi> x, samesize<int, doublev<Abi>> exp);
+template <class Abi> ldoublev<Abi> ldexp(ldoublev<Abi> x, samesize<int, ldoublev<Abi>> exp);
+
+template <class Abi> floatv<Abi> log(floatv<Abi> x);
+template <class Abi> doublev<Abi> log(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> log(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> log10(floatv<Abi> x);
+template <class Abi> doublev<Abi> log10(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> log10(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> log1p(floatv<Abi> x);
+template <class Abi> doublev<Abi> log1p(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> log1p(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> log2(floatv<Abi> x);
+template <class Abi> doublev<Abi> log2(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> log2(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> logb(floatv<Abi> x);
+template <class Abi> doublev<Abi> logb(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> logb(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> modf(floatv<Abi> value, floatv<Abi>* iptr);
+template <class Abi> doublev<Abi> modf(doublev<Abi> value, doublev<Abi>* iptr);
+template <class Abi> ldoublev<Abi> modf(ldoublev<Abi> value, ldoublev<Abi>* iptr);
+
+template <class Abi> floatv<Abi> scalbn(floatv<Abi> x, samesize<int, floatv<Abi>> n);
+template <class Abi> doublev<Abi> scalbn(doublev<Abi> x, samesize<int, doublev<Abi>> n);
+template <class Abi> ldoublev<Abi> scalbn(ldoublev<Abi> x, samesize<int, ldoublev<Abi>> n);
+template <class Abi> floatv<Abi> scalbln(floatv<Abi> x, samesize<long int, floatv<Abi>> n);
+template <class Abi> doublev<Abi> scalbln(doublev<Abi> x, samesize<long int, doublev<Abi>> n);
+template <class Abi> ldoublev<Abi> scalbln(ldoublev<Abi> x, samesize<long int, ldoublev<Abi>> n);
+
+template <class Abi> floatv<Abi> cbrt(floatv<Abi> x);
+template <class Abi> doublev<Abi> cbrt(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> cbrt(ldoublev<Abi> x);
+
+template <class Abi> scharv<Abi> abs(scharv<Abi> j);
+template <class Abi> shortv<Abi> abs(shortv<Abi> j);
+template <class Abi> intv<Abi> abs(intv<Abi> j);
+template <class Abi> longv<Abi> abs(longv<Abi> j);
+template <class Abi> llongv<Abi> abs(llongv<Abi> j);
+template <class Abi> floatv<Abi> abs(floatv<Abi> j);
+template <class Abi> doublev<Abi> abs(doublev<Abi> j);
+template <class Abi> ldoublev<Abi> abs(ldoublev<Abi> j);
+
+template <class Abi> floatv<Abi> hypot(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> floatv<Abi> hypot(floatv<Abi> x, floatv<Abi> y, floatv<Abi> z);
+template <class Abi> doublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y, doublev<Abi> z);
+template <class Abi> ldoublev<Abi> hypot(ldoublev<Abi> x, ldoublev<Abi> y, ldoublev<Abi> z);
+
+template <class Abi> floatv<Abi> pow(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> pow(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> pow(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> floatv<Abi> sqrt(floatv<Abi> x);
+template <class Abi> doublev<Abi> sqrt(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> sqrt(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> erf(floatv<Abi> x);
+template <class Abi> doublev<Abi> erf(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> erf(ldoublev<Abi> x);
+template <class Abi> floatv<Abi> erfc(floatv<Abi> x);
+template <class Abi> doublev<Abi> erfc(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> erfc(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> lgamma(floatv<Abi> x);
+template <class Abi> doublev<Abi> lgamma(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> lgamma(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> tgamma(floatv<Abi> x);
+template <class Abi> doublev<Abi> tgamma(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> tgamma(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> ceil(floatv<Abi> x);
+template <class Abi> doublev<Abi> ceil(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> ceil(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> floor(floatv<Abi> x);
+template <class Abi> doublev<Abi> floor(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> floor(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> nearbyint(floatv<Abi> x);
+template <class Abi> doublev<Abi> nearbyint(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> nearbyint(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> rint(floatv<Abi> x);
+template <class Abi> doublev<Abi> rint(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> rint(ldoublev<Abi> x);
+
+template <class Abi> samesize<long int, floatv<Abi>> lrint(floatv<Abi> x);
+template <class Abi> samesize<long int, doublev<Abi>> lrint(doublev<Abi> x);
+template <class Abi> samesize<long int, ldoublev<Abi>> lrint(ldoublev<Abi> x);
+template <class Abi> samesize<long long int, floatv<Abi>> llrint(floatv<Abi> x);
+template <class Abi> samesize<long long int, doublev<Abi>> llrint(doublev<Abi> x);
+template <class Abi> samesize<long long int, ldoublev<Abi>> llrint(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> round(floatv<Abi> x);
+template <class Abi> doublev<Abi> round(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> round(ldoublev<Abi> x);
+template <class Abi> samesize<long int, floatv<Abi>> lround(floatv<Abi> x);
+template <class Abi> samesize<long int, doublev<Abi>> lround(doublev<Abi> x);
+template <class Abi> samesize<long int, ldoublev<Abi>> lround(ldoublev<Abi> x);
+template <class Abi> samesize<long long int, floatv<Abi>> llround(floatv<Abi> x);
+template <class Abi> samesize<long long int, doublev<Abi>> llround(doublev<Abi> x);
+template <class Abi> samesize<long long int, ldoublev<Abi>> llround(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> trunc(floatv<Abi> x);
+template <class Abi> doublev<Abi> trunc(doublev<Abi> x);
+template <class Abi> ldoublev<Abi> trunc(ldoublev<Abi> x);
+
+template <class Abi> floatv<Abi> fmod(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> fmod(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> fmod(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> floatv<Abi> remainder(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> remainder(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> remainder(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> floatv<Abi> remquo(floatv<Abi> x, floatv<Abi> y, samesize<int, floatv<Abi>>* quo);
+template <class Abi> doublev<Abi> remquo(doublev<Abi> x, doublev<Abi> y, samesize<int, doublev<Abi>>* quo);
+template <class Abi> ldoublev<Abi> remquo(ldoublev<Abi> x, ldoublev<Abi> y, samesize<int, ldoublev<Abi>>* quo);
+
+template <class Abi> floatv<Abi> copysign(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> copysign(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> copysign(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> doublev<Abi> nan(const char* tagp);
+template <class Abi> floatv<Abi> nanf(const char* tagp);
+template <class Abi> ldoublev<Abi> nanl(const char* tagp);
+
+template <class Abi> floatv<Abi> nextafter(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> nextafter(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> nextafter(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> floatv<Abi> nexttoward(floatv<Abi> x, ldoublev<Abi> y);
+template <class Abi> doublev<Abi> nexttoward(doublev<Abi> x, ldoublev<Abi> y);
+template <class Abi> ldoublev<Abi> nexttoward(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> floatv<Abi> fdim(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> fdim(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> fdim(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> floatv<Abi> fmax(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> fmax(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> fmax(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> floatv<Abi> fmin(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> doublev<Abi> fmin(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> ldoublev<Abi> fmin(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> floatv<Abi> fma(floatv<Abi> x, floatv<Abi> y, floatv<Abi> z);
+template <class Abi> doublev<Abi> fma(doublev<Abi> x, doublev<Abi> y, doublev<Abi> z);
+template <class Abi> ldoublev<Abi> fma(ldoublev<Abi> x, ldoublev<Abi> y, ldoublev<Abi> z);
+
+template <class Abi> samesize<int, floatv<Abi>> fpclassify(floatv<Abi> x);
+template <class Abi> samesize<int, doublev<Abi>> fpclassify(doublev<Abi> x);
+template <class Abi> samesize<int, ldoublev<Abi>> fpclassify(ldoublev<Abi> x);
+
+template <class Abi> simd_mask<float, Abi> isfinite(floatv<Abi> x);
+template <class Abi> simd_mask<double, Abi> isfinite(doublev<Abi> x);
+template <class Abi> simd_mask<long double, Abi> isfinite(ldoublev<Abi> x);
+
+template <class Abi> simd_mask<float, Abi> isinf(floatv<Abi> x);
+template <class Abi> simd_mask<double, Abi> isinf(doublev<Abi> x);
+template <class Abi> simd_mask<long double, Abi> isinf(ldoublev<Abi> x);
+
+template <class Abi> simd_mask<float, Abi> isnan(floatv<Abi> x);
+template <class Abi> simd_mask<double, Abi> isnan(doublev<Abi> x);
+template <class Abi> simd_mask<long double, Abi> isnan(ldoublev<Abi> x);
+
+template <class Abi> simd_mask<float, Abi> isnormal(floatv<Abi> x);
+template <class Abi> simd_mask<double, Abi> isnormal(doublev<Abi> x);
+template <class Abi> simd_mask<long double, Abi> isnormal(ldoublev<Abi> x);
+
+template <class Abi> simd_mask<float, Abi> signbit(floatv<Abi> x);
+template <class Abi> simd_mask<double, Abi> signbit(doublev<Abi> x);
+template <class Abi> simd_mask<long double, Abi> signbit(ldoublev<Abi> x);
+
+template <class Abi> simd_mask<float, Abi> isgreater(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> simd_mask<double, Abi> isgreater(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> simd_mask<long double, Abi> isgreater(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> simd_mask<float, Abi> isgreaterequal(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> simd_mask<double, Abi> isgreaterequal(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> simd_mask<long double, Abi> isgreaterequal(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> simd_mask<float, Abi> isless(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> simd_mask<double, Abi> isless(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> simd_mask<long double, Abi> isless(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> simd_mask<float, Abi> islessequal(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> simd_mask<double, Abi> islessequal(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> simd_mask<long double, Abi> islessequal(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> simd_mask<float, Abi> islessgreater(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> simd_mask<double, Abi> islessgreater(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> simd_mask<long double, Abi> islessgreater(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class Abi> simd_mask<float, Abi> isunordered(floatv<Abi> x, floatv<Abi> y);
+template <class Abi> simd_mask<double, Abi> isunordered(doublev<Abi> x, doublev<Abi> y);
+template <class Abi> simd_mask<long double, Abi> isunordered(ldoublev<Abi> x, ldoublev<Abi> y);
+
+template <class V> struct simd_div_t { V quot, rem; };
+template <class Abi> simd_div_t<scharv<Abi>> div(scharv<Abi> numer, scharv<Abi> denom);
+template <class Abi> simd_div_t<shortv<Abi>> div(shortv<Abi> numer, shortv<Abi> denom);
+template <class Abi> simd_div_t<intv<Abi>> div(intv<Abi> numer, intv<Abi> denom);
+template <class Abi> simd_div_t<longv<Abi>> div(longv<Abi> numer, longv<Abi> denom);
+template <class Abi> simd_div_t<llongv<Abi>> div(llongv<Abi> numer, llongv<Abi> denom);
+
+// [simd.mask.class]
+template <class T, class Abi>
+class simd_mask {
+public:
+  using value_type = bool;
+  using reference = see below;
+  using simd_type = simd<T, Abi>;
+  using abi_type = Abi;
+  static constexpr size_t size() noexcept;
+  simd_mask() = default;
+
+  // broadcast constructor
+  explicit simd_mask(value_type) noexcept;
+
+  // implicit type conversion constructor
+  template <class U> simd_mask(const simd_mask<U, simd_abi::fixed_size<size()>>&) noexcept;
+
+  // load constructor
+  template <class Flags> simd_mask(const value_type* mem, Flags);
+
+  // loads [simd.mask.copy]
+  template <class Flags> void copy_from(const value_type* mem, Flags);
+  template <class Flags> void copy_to(value_type* mem, Flags) const;
+
+  // scalar access [simd.mask.subscr]
+  reference operator[](size_t);
+  value_type operator[](size_t) const;
+
+  // unary operators [simd.mask.unary]
+  simd_mask operator!() const noexcept;
+
+  // simd_mask binary operators [simd.mask.binary]
+  friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator& (const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator| (const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator^ (const simd_mask&, const simd_mask&) noexcept;
+
+  // simd_mask compound assignment [simd.mask.cassign]
+  friend simd_mask& operator&=(simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask& operator|=(simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask& operator^=(simd_mask&, const simd_mask&) noexcept;
+
+  // simd_mask compares [simd.mask.comparison]
+  friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept;
+};
+
+} // parallelism_v2
+} // std::experimental
+
+*/
+
+#include <experimental/__config>
+#include <algorithm>
+#include <array>
+#include <cstddef>
+#include <functional>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
+
+#if _LIBCPP_STD_VER >= 17
+
+enum class _StorageKind {
+  _Scalar,
+  _Array,
+  _VecExt,
+};
+
+template <_StorageKind __kind, int _Np>
+struct __simd_abi {};
+
+template <class _Tp, class _Abi>
+class __simd_storage {};
+
+template <class _Tp, int __num_element>
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> {
+  std::array<_Tp, __num_element> __storage_;
+
+  template <class, class>
+  friend struct simd;
+
+  template <class, class>
+  friend struct simd_mask;
+
+public:
+  _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
+  void __set(size_t __index, _Tp __val) noexcept {
+    __storage_[__index] = __val;
+  }
+};
+
+template <class _Tp>
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> {
+  _Tp __storage_;
+
+  template <class, class>
+  friend struct simd;
+
+  template <class, class>
+  friend struct simd_mask;
+
+public:
+  _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; };
+  void __set(size_t __index, _Tp __val) noexcept {
+    (&__storage_)[__index] = __val;
+  }
+};
+
+#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
+constexpr size_t __floor_pow_of_2(size_t __val) {
+  return ((__val - 1) & __val) == 0 ? __val
+                                    : __floor_pow_of_2((__val - 1) & __val);
+}
+
+constexpr size_t __ceil_pow_of_2(size_t __val) {
+  return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1;
+}
+
+template <class _Tp, size_t __bytes>
+struct __vec_ext_traits {
+#if !defined(_LIBCPP_COMPILER_CLANG)
+  typedef _Tp type __attribute__((vector_size(__ceil_pow_of_2(__bytes))));
+#endif
+};
+
+#if defined(_LIBCPP_COMPILER_CLANG)
+#define _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT)                        \
+  template <>                                                                  \
+  struct __vec_ext_traits<_TYPE, sizeof(_TYPE) * _NUM_ELEMENT> {               \
+    using type =                                                               \
+        _TYPE __attribute__((vector_size(sizeof(_TYPE) * _NUM_ELEMENT)));      \
+  }
+
+#define _LIBCPP_SPECIALIZE_VEC_EXT_32(_TYPE)                                   \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 1);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 2);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 3);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 4);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 5);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 6);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 7);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 8);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 9);                                        \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 10);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 11);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 12);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 13);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 14);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 15);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 16);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 17);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 18);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 19);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 20);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 21);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 22);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 23);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 24);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 25);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 26);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 27);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 28);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 29);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 30);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 31);                                       \
+  _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 32);
+
+_LIBCPP_SPECIALIZE_VEC_EXT_32(char);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(char16_t);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(char32_t);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(wchar_t);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed char);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed short);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed int);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long long);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned char);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned short);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned int);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long long);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(float);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(double);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(long double);
+
+#undef _LIBCPP_SPECIALIZE_VEC_EXT_32
+#undef _LIBCPP_SPECIALIZE_VEC_EXT
+#endif
+
+template <class _Tp, int __num_element>
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_VecExt, __num_element>> {
+  using _StorageType =
+      typename __vec_ext_traits<_Tp, sizeof(_Tp) * __num_element>::type;
+
+  _StorageType __storage_;
+
+  template <class, class>
+  friend struct simd;
+
+  template <class, class>
+  friend struct simd_mask;
+
+public:
+  _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
+  void __set(size_t __index, _Tp __val) noexcept {
+    __storage_[__index] = __val;
+  }
+};
+
+#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
+template <class _Vp, class _Tp, class _Abi>
+class __simd_reference {
+  static_assert(std::is_same<_Vp, _Tp>::value, "");
+
+  template <class, class>
+  friend struct simd;
+
+  template <class, class>
+  friend struct simd_mask;
+
+  __simd_storage<_Tp, _Abi>* __ptr_;
+  size_t __index_;
+
+  __simd_reference(__simd_storage<_Tp, _Abi>* __ptr, size_t __index)
+      : __ptr_(__ptr), __index_(__index) {}
+
+  __simd_reference(const __simd_reference&) = default;
+
+public:
+  __simd_reference() = delete;
+  __simd_reference& operator=(const __simd_reference&) = delete;
+
+  operator _Vp() const { return __ptr_->__get(__index_); }
+
+  __simd_reference operator=(_Vp __value) && {
+    __ptr_->__set(__index_, __value);
+    return *this;
+  }
+
+  __simd_reference operator++() && {
+    return std::move(*this) = __ptr_->__get(__index_) + 1;
+  }
+
+  _Vp operator++(int) && {
+    auto __val = __ptr_->__get(__index_);
+    __ptr_->__set(__index_, __val + 1);
+    return __val;
+  }
+
+  __simd_reference operator--() && {
+    return std::move(*this) = __ptr_->__get(__index_) - 1;
+  }
+
+  _Vp operator--(int) && {
+    auto __val = __ptr_->__get(__index_);
+    __ptr_->__set(__index_, __val - 1);
+    return __val;
+  }
+
+  __simd_reference operator+=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) + __value;
+  }
+
+  __simd_reference operator-=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) - __value;
+  }
+
+  __simd_reference operator*=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) * __value;
+  }
+
+  __simd_reference operator/=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) / __value;
+  }
+
+  __simd_reference operator%=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) % __value;
+  }
+
+  __simd_reference operator>>=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) >> __value;
+  }
+
+  __simd_reference operator<<=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) << __value;
+  }
+
+  __simd_reference operator&=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) & __value;
+  }
+
+  __simd_reference operator|=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) | __value;
+  }
+
+  __simd_reference operator^=(_Vp __value) && {
+    return std::move(*this) = __ptr_->__get(__index_) ^ __value;
+  }
+};
+
+template <class _To, class _From>
+constexpr decltype(_To{std::declval<_From>()}, true)
+__is_non_narrowing_convertible_impl(_From) {
+  return true;
+}
+
+template <class _To>
+constexpr bool __is_non_narrowing_convertible_impl(...) {
+  return false;
+}
+
+template <class _From, class _To>
+constexpr typename std::enable_if<std::is_arithmetic<_To>::value &&
+                                      std::is_arithmetic<_From>::value,
+                                  bool>::type
+__is_non_narrowing_arithmetic_convertible() {
+  return __is_non_narrowing_convertible_impl<_To>(_From{});
+}
+
+template <class _From, class _To>
+constexpr typename std::enable_if<!(std::is_arithmetic<_To>::value &&
+                                    std::is_arithmetic<_From>::value),
+                                  bool>::type
+__is_non_narrowing_arithmetic_convertible() {
+  return false;
+}
+
+template <class _Tp>
+constexpr _Tp __variadic_sum() {
+  return _Tp{};
+}
+
+template <class _Tp, class _Up, class... _Args>
+constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) {
+  return static_cast<_Tp>(__first) + __variadic_sum<_Tp>(__rest...);
+}
+
+template <class _Tp>
+struct __nodeduce {
+  using type = _Tp;
+};
+
+template <class _Tp>
+constexpr bool __vectorizable() {
+  return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value &&
+         !std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value;
+}
+
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI
+
+using scalar = __simd_abi<_StorageKind::_Scalar, 1>;
+
+template <int _Np>
+using fixed_size = __simd_abi<_StorageKind::_Array, _Np>;
+
+template <class _Tp>
+_LIBCPP_INLINE_VAR constexpr size_t max_fixed_size = 32;
+
+template <class _Tp>
+using compatible = fixed_size<16 / sizeof(_Tp)>;
+
+#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
+template <class _Tp>
+using native = __simd_abi<_StorageKind::_VecExt,
+                          _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
+#else
+template <class _Tp>
+using native =
+    fixed_size<_Tp, _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
+#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
+
+template <class _Tp, class _Abi = simd_abi::compatible<_Tp>>
+class simd;
+template <class _Tp, class _Abi = simd_abi::compatible<_Tp>>
+class simd_mask;
+
+struct element_aligned_tag {};
+struct vector_aligned_tag {};
+template <size_t>
+struct overaligned_tag {};
+_LIBCPP_INLINE_VAR constexpr element_aligned_tag element_aligned{};
+_LIBCPP_INLINE_VAR constexpr vector_aligned_tag vector_aligned{};
+template <size_t _Np>
+_LIBCPP_INLINE_VAR constexpr overaligned_tag<_Np> overaligned{};
+
+// traits [simd.traits]
+template <class _Tp>
+struct is_abi_tag : std::integral_constant<bool, false> {};
+
+template <_StorageKind __kind, int _Np>
+struct is_abi_tag<__simd_abi<__kind, _Np>>
+    : std::integral_constant<bool, true> {};
+
+template <class _Tp>
+struct is_simd : std::integral_constant<bool, false> {};
+
+template <class _Tp, class _Abi>
+struct is_simd<simd<_Tp, _Abi>> : std::integral_constant<bool, true> {};
+
+template <class _Tp>
+struct is_simd_mask : std::integral_constant<bool, false> {};
+
+template <class _Tp, class _Abi>
+struct is_simd_mask<simd_mask<_Tp, _Abi>> : std::integral_constant<bool, true> {
+};
+
+template <class _Tp>
+struct is_simd_flag_type : std::integral_constant<bool, false> {};
+
+template <>
+struct is_simd_flag_type<element_aligned_tag>
+    : std::integral_constant<bool, true> {};
+
+template <>
+struct is_simd_flag_type<vector_aligned_tag>
+    : std::integral_constant<bool, true> {};
+
+template <size_t _Align>
+struct is_simd_flag_type<overaligned_tag<_Align>>
+    : std::integral_constant<bool, true> {};
+
+template <class _Tp>
+_LIBCPP_INLINE_VAR constexpr bool is_abi_tag_v = is_abi_tag<_Tp>::value;
+template <class _Tp>
+_LIBCPP_INLINE_VAR constexpr bool is_simd_v = is_simd<_Tp>::value;
+template <class _Tp>
+_LIBCPP_INLINE_VAR constexpr bool is_simd_mask_v = is_simd_mask<_Tp>::value;
+template <class _Tp>
+_LIBCPP_INLINE_VAR constexpr bool is_simd_flag_type_v =
+    is_simd_flag_type<_Tp>::value;
+template <class _Tp, size_t _Np>
+struct abi_for_size {
+  using type = simd_abi::fixed_size<_Np>;
+};
+template <class _Tp, size_t _Np>
+using abi_for_size_t = typename abi_for_size<_Tp, _Np>::type;
+
+template <class _Tp, class _Abi = simd_abi::compatible<_Tp>>
+struct simd_size;
+
+template <class _Tp, _StorageKind __kind, int _Np>
+struct simd_size<_Tp, __simd_abi<__kind, _Np>>
+    : std::integral_constant<size_t, _Np> {
+  static_assert(
+      std::is_arithmetic<_Tp>::value &&
+          !std::is_same<typename std::remove_const<_Tp>::type, bool>::value,
+      "Element type should be vectorizable");
+};
+
+// TODO: implement it.
+template <class _Tp, class _Up = typename _Tp::value_type>
+struct memory_alignment;
+
+template <class _Tp, class _Abi = simd_abi::compatible<_Tp>>
+_LIBCPP_INLINE_VAR constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value;
+
+template <class _Tp, class _Up = typename _Tp::value_type>
+_LIBCPP_INLINE_VAR constexpr size_t memory_alignment_v =
+    memory_alignment<_Tp, _Up>::value;
+
+// class template simd [simd.class]
+template <class _Tp>
+using native_simd = simd<_Tp, simd_abi::native<_Tp>>;
+template <class _Tp, int _Np>
+using fixed_size_simd = simd<_Tp, simd_abi::fixed_size<_Np>>;
+
+// class template simd_mask [simd.mask.class]
+template <class _Tp>
+using native_simd_mask = simd_mask<_Tp, simd_abi::native<_Tp>>;
+
+template <class _Tp, int _Np>
+using fixed_size_simd_mask = simd_mask<_Tp, simd_abi::fixed_size<_Np>>;
+
+// casts [simd.casts]
+template <class _Tp>
+struct __static_simd_cast_traits {
+  template <class _Up, class _Abi>
+  static simd<_Tp, _Abi> __apply(const simd<_Up, _Abi>& __v);
+};
+
+template <class _Tp, class _NewAbi>
+struct __static_simd_cast_traits<simd<_Tp, _NewAbi>> {
+  template <class _Up, class _Abi>
+  static typename std::enable_if<simd<_Up, _Abi>::size() ==
+                                     simd<_Tp, _NewAbi>::size(),
+                                 simd<_Tp, _NewAbi>>::type
+  __apply(const simd<_Up, _Abi>& __v);
+};
+
+template <class _Tp>
+struct __simd_cast_traits {
+  template <class _Up, class _Abi>
+  static typename std::enable_if<
+      __is_non_narrowing_arithmetic_convertible<_Up, _Tp>(),
+      simd<_Tp, _Abi>>::type
+  __apply(const simd<_Up, _Abi>& __v);
+};
+
+template <class _Tp, class _NewAbi>
+struct __simd_cast_traits<simd<_Tp, _NewAbi>> {
+  template <class _Up, class _Abi>
+  static typename std::enable_if<
+      __is_non_narrowing_arithmetic_convertible<_Up, _Tp>() &&
+          simd<_Up, _Abi>::size() == simd<_Tp, _NewAbi>::size(),
+      simd<_Tp, _NewAbi>>::type
+  __apply(const simd<_Up, _Abi>& __v);
+};
+
+template <class _Tp, class _Up, class _Abi>
+auto simd_cast(const simd<_Up, _Abi>& __v)
+    -> decltype(__simd_cast_traits<_Tp>::__apply(__v)) {
+  return __simd_cast_traits<_Tp>::__apply(__v);
+}
+
+template <class _Tp, class _Up, class _Abi>
+auto static_simd_cast(const simd<_Up, _Abi>& __v)
+    -> decltype(__static_simd_cast_traits<_Tp>::__apply(__v)) {
+  return __static_simd_cast_traits<_Tp>::__apply(__v);
+}
+
+template <class _Tp, class _Abi>
+fixed_size_simd<_Tp, simd_size<_Tp, _Abi>::value>
+to_fixed_size(const simd<_Tp, _Abi>&) noexcept;
+
+template <class _Tp, class _Abi>
+fixed_size_simd_mask<_Tp, simd_size<_Tp, _Abi>::value>
+to_fixed_size(const simd_mask<_Tp, _Abi>&) noexcept;
+
+template <class _Tp, size_t _Np>
+native_simd<_Tp> to_native(const fixed_size_simd<_Tp, _Np>&) noexcept;
+
+template <class _Tp, size_t _Np>
+native_simd_mask<_Tp> to_native(const fixed_size_simd_mask<_Tp, _Np>&) noexcept;
+
+template <class _Tp, size_t _Np>
+simd<_Tp> to_compatible(const fixed_size_simd<_Tp, _Np>&) noexcept;
+
+template <class _Tp, size_t _Np>
+simd_mask<_Tp> to_compatible(const fixed_size_simd_mask<_Tp, _Np>&) noexcept;
+
+template <size_t... __sizes, class _Tp, class _Abi>
+tuple<simd<_Tp, abi_for_size_t<_Tp, __sizes>>...> split(const simd<_Tp, _Abi>&);
+
+template <size_t... __sizes, class _Tp, class _Abi>
+tuple<simd_mask<_Tp, abi_for_size_t<_Tp, __sizes>>...>
+split(const simd_mask<_Tp, _Abi>&);
+
+template <class _SimdType, class _Abi>
+array<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value /
+                     _SimdType::size()>
+split(const simd<typename _SimdType::value_type, _Abi>&);
+
+template <class _SimdType, class _Abi>
+array<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value /
+                     _SimdType::size()>
+split(const simd_mask<typename _SimdType::value_type, _Abi>&);
+
+template <class _Tp, class... _Abis>
+simd<_Tp, abi_for_size_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...)>>
+concat(const simd<_Tp, _Abis>&...);
+
+template <class _Tp, class... _Abis>
+simd_mask<_Tp,
+          abi_for_size_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...)>>
+concat(const simd_mask<_Tp, _Abis>&...);
+
+// reductions [simd.mask.reductions]
+template <class _Tp, class _Abi>
+bool all_of(const simd_mask<_Tp, _Abi>&) noexcept;
+template <class _Tp, class _Abi>
+bool any_of(const simd_mask<_Tp, _Abi>&) noexcept;
+template <class _Tp, class _Abi>
+bool none_of(const simd_mask<_Tp, _Abi>&) noexcept;
+template <class _Tp, class _Abi>
+bool some_of(const simd_mask<_Tp, _Abi>&) noexcept;
+template <class _Tp, class _Abi>
+int popcount(const simd_mask<_Tp, _Abi>&) noexcept;
+template <class _Tp, class _Abi>
+int find_first_set(const simd_mask<_Tp, _Abi>&);
+template <class _Tp, class _Abi>
+int find_last_set(const simd_mask<_Tp, _Abi>&);
+bool all_of(bool) noexcept;
+bool any_of(bool) noexcept;
+bool none_of(bool) noexcept;
+bool some_of(bool) noexcept;
+int popcount(bool) noexcept;
+int find_first_set(bool) noexcept;
+int find_last_set(bool) noexcept;
+
+// masked assignment [simd.whereexpr]
+template <class _MaskType, class _Tp>
+class const_where_expression;
+template <class _MaskType, class _Tp>
+class where_expression;
+
+// masked assignment [simd.mask.where]
+template <class _Tp, class _Abi>
+where_expression<simd_mask<_Tp, _Abi>, simd<_Tp, _Abi>>
+where(const typename simd<_Tp, _Abi>::mask_type&, simd<_Tp, _Abi>&) noexcept;
+
+template <class _Tp, class _Abi>
+const_where_expression<simd_mask<_Tp, _Abi>, const simd<_Tp, _Abi>>
+where(const typename simd<_Tp, _Abi>::mask_type&,
+      const simd<_Tp, _Abi>&) noexcept;
+
+template <class _Tp, class _Abi>
+where_expression<simd_mask<_Tp, _Abi>, simd_mask<_Tp, _Abi>>
+where(const typename __nodeduce<simd_mask<_Tp, _Abi>>::type&,
+      simd_mask<_Tp, _Abi>&) noexcept;
+
+template <class _Tp, class _Abi>
+const_where_expression<simd_mask<_Tp, _Abi>, const simd_mask<_Tp, _Abi>>
+where(const typename __nodeduce<simd_mask<_Tp, _Abi>>::type&,
+      const simd_mask<_Tp, _Abi>&) noexcept;
+
+template <class _Tp>
+where_expression<bool, _Tp> where(bool, _Tp&) noexcept;
+
+template <class _Tp>
+const_where_expression<bool, const _Tp> where(bool, const _Tp&) noexcept;
+
+// reductions [simd.reductions]
+template <class _Tp, class _Abi, class _BinaryOp = std::plus<_Tp>>
+_Tp reduce(const simd<_Tp, _Abi>&, _BinaryOp = _BinaryOp());
+
+template <class _MaskType, class _SimdType, class _BinaryOp>
+typename _SimdType::value_type
+reduce(const const_where_expression<_MaskType, _SimdType>&,
+       typename _SimdType::value_type neutral_element, _BinaryOp binary_op);
+
+template <class _MaskType, class _SimdType>
+typename _SimdType::value_type
+reduce(const const_where_expression<_MaskType, _SimdType>&,
+       plus<typename _SimdType::value_type> binary_op = {});
+
+template <class _MaskType, class _SimdType>
+typename _SimdType::value_type
+reduce(const const_where_expression<_MaskType, _SimdType>&,
+       multiplies<typename _SimdType::value_type> binary_op);
+
+template <class _MaskType, class _SimdType>
+typename _SimdType::value_type
+reduce(const const_where_expression<_MaskType, _SimdType>&,
+       bit_and<typename _SimdType::value_type> binary_op);
+
+template <class _MaskType, class _SimdType>
+typename _SimdType::value_type
+reduce(const const_where_expression<_MaskType, _SimdType>&,
+       bit_or<typename _SimdType::value_type> binary_op);
+
+template <class _MaskType, class _SimdType>
+typename _SimdType::value_type
+reduce(const const_where_expression<_MaskType, _SimdType>&,
+       bit_xor<typename _SimdType::value_type> binary_op);
+
+template <class _Tp, class _Abi>
+_Tp hmin(const simd<_Tp, _Abi>&);
+template <class _MaskType, class _SimdType>
+typename _SimdType::value_type
+hmin(const const_where_expression<_MaskType, _SimdType>&);
+template <class _Tp, class _Abi>
+_Tp hmax(const simd<_Tp, _Abi>&);
+template <class _MaskType, class _SimdType>
+typename _SimdType::value_type
+hmax(const const_where_expression<_MaskType, _SimdType>&);
+
+// algorithms [simd.alg]
+template <class _Tp, class _Abi>
+simd<_Tp, _Abi> min(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept;
+
+template <class _Tp, class _Abi>
+simd<_Tp, _Abi> max(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept;
+
+template <class _Tp, class _Abi>
+std::pair<simd<_Tp, _Abi>, simd<_Tp, _Abi>>
+minmax(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept;
+
+template <class _Tp, class _Abi>
+simd<_Tp, _Abi> clamp(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&,
+                      const simd<_Tp, _Abi>&);
+
+// [simd.whereexpr]
+// TODO implement where expressions.
+template <class _MaskType, class _Tp>
+class const_where_expression {
+public:
+  const_where_expression(const const_where_expression&) = delete;
+  const_where_expression& operator=(const const_where_expression&) = delete;
+  typename remove_const<_Tp>::type operator-() const&&;
+  template <class _Up, class _Flags>
+  void copy_to(_Up*, _Flags) const&&;
+};
+
+template <class _MaskType, class _Tp>
+class where_expression : public const_where_expression<_MaskType, _Tp> {
+public:
+  where_expression(const where_expression&) = delete;
+  where_expression& operator=(const where_expression&) = delete;
+  template <class _Up>
+  void operator=(_Up&&);
+  template <class _Up>
+  void operator+=(_Up&&);
+  template <class _Up>
+  void operator-=(_Up&&);
+  template <class _Up>
+  void operator*=(_Up&&);
+  template <class _Up>
+  void operator/=(_Up&&);
+  template <class _Up>
+  void operator%=(_Up&&);
+  template <class _Up>
+  void operator&=(_Up&&);
+  template <class _Up>
+  void operator|=(_Up&&);
+  template <class _Up>
+  void operator^=(_Up&&);
+  template <class _Up>
+  void operator<<=(_Up&&);
+  template <class _Up>
+  void operator>>=(_Up&&);
+  void operator++();
+  void operator++(int);
+  void operator--();
+  void operator--(int);
+  template <class _Up, class _Flags>
+  void copy_from(const _Up*, _Flags);
+};
+
+// [simd.class]
+// TODO: implement simd
+template <class _Tp, class _Abi>
+class simd {
+public:
+  using value_type = _Tp;
+  using reference = __simd_reference<_Tp, _Tp, _Abi>;
+  using mask_type = simd_mask<_Tp, _Abi>;
+  using abi_type = _Abi;
+
+  simd() = default;
+  simd(const simd&) = default;
+  simd& operator=(const simd&) = default;
+
+  static constexpr size_t size() noexcept {
+    return simd_size<_Tp, _Abi>::value;
+  }
+
+private:
+  __simd_storage<_Tp, _Abi> __s_;
+
+  template <class _Up>
+  static constexpr bool __can_broadcast() {
+    return (std::is_arithmetic<_Up>::value &&
+            __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()) ||
+           (!std::is_arithmetic<_Up>::value &&
+            std::is_convertible<_Up, _Tp>::value) ||
+           std::is_same<typename std::remove_const<_Up>::type, int>::value ||
+           (std::is_same<typename std::remove_const<_Up>::type,
+                         unsigned int>::value &&
+            std::is_unsigned<_Tp>::value);
+  }
+
+  template <class _Generator, size_t... __indicies>
+  static constexpr decltype(
+      std::forward_as_tuple(std::declval<_Generator>()(
+          std::integral_constant<size_t, __indicies>())...),
+      bool())
+  __can_generate(std::index_sequence<__indicies...>) {
+    return !__variadic_sum<bool>(
+        !__can_broadcast<decltype(std::declval<_Generator>()(
+            std::integral_constant<size_t, __indicies>()))>()...);
+  }
+
+  template <class _Generator>
+  static bool __can_generate(...) {
+    return false;
+  }
+
+  template <class _Generator, size_t... __indicies>
+  void __generator_init(_Generator&& __g, std::index_sequence<__indicies...>) {
+    int __not_used[]{((*this)[__indicies] =
+                          __g(std::integral_constant<size_t, __indicies>()),
+                      0)...};
+    (void)__not_used;
+  }
+
+public:
+  // implicit type conversion constructor
+  template <class _Up,
+            class = typename std::enable_if<
+                std::is_same<_Abi, simd_abi::fixed_size<size()>>::value &&
+                __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()>::type>
+  simd(const simd<_Up, simd_abi::fixed_size<size()>>& __v) {
+    for (size_t __i = 0; __i < size(); __i++) {
+      (*this)[__i] = static_cast<_Tp>(__v[__i]);
+    }
+  }
+
+  // implicit broadcast constructor
+  template <class _Up,
+            class = typename std::enable_if<__can_broadcast<_Up>()>::type>
+  simd(_Up&& __rv) {
+    auto __v = static_cast<_Tp>(__rv);
+    for (size_t __i = 0; __i < size(); __i++) {
+      (*this)[__i] = __v;
+    }
+  }
+
+  // generator constructor
+  template <class _Generator,
+            int = typename std::enable_if<
+                __can_generate<_Generator>(std::make_index_sequence<size()>()),
+                int>::type()>
+  explicit simd(_Generator&& __g) {
+    __generator_init(std::forward<_Generator>(__g),
+                     std::make_index_sequence<size()>());
+  }
+
+  // load constructor
+  template <
+      class _Up, class _Flags,
+      class = typename std::enable_if<__vectorizable<_Up>()>::type,
+      class = typename std::enable_if<is_simd_flag_type<_Flags>::value>::type>
+  simd(const _Up* __buffer, _Flags) {
+    // TODO: optimize for overaligned flags
+    for (size_t __i = 0; __i < size(); __i++) {
+      (*this)[__i] = static_cast<_Tp>(__buffer[__i]);
+    }
+  }
+
+  // loads [simd.load]
+  template <class _Up, class _Flags>
+  typename std::enable_if<__vectorizable<_Up>() &&
+                          is_simd_flag_type<_Flags>::value>::type
+  copy_from(const _Up* __buffer, _Flags) {
+    *this = simd(__buffer, _Flags());
+  }
+
+  // stores [simd.store]
+  template <class _Up, class _Flags>
+  typename std::enable_if<__vectorizable<_Up>() &&
+                          is_simd_flag_type<_Flags>::value>::type
+  copy_to(_Up* __buffer, _Flags) const {
+    // TODO: optimize for overaligned flags
+    for (size_t __i = 0; __i < size(); __i++) {
+      __buffer[__i] = static_cast<_Up>((*this)[__i]);
+    }
+  }
+
+  // scalar access [simd.subscr]
+  reference operator[](size_t __i) { return reference(&__s_, __i); }
+
+  value_type operator[](size_t __i) const { return __s_.__get(__i); }
+
+  // unary operators [simd.unary]
+  simd& operator++();
+  simd operator++(int);
+  simd& operator--();
+  simd operator--(int);
+  mask_type operator!() const;
+  simd operator~() const;
+  simd operator+() const;
+  simd operator-() const;
+
+  // binary operators [simd.binary]
+  friend simd operator+(const simd&, const simd&);
+  friend simd operator-(const simd&, const simd&);
+  friend simd operator*(const simd&, const simd&);
+  friend simd operator/(const simd&, const simd&);
+  friend simd operator%(const simd&, const simd&);
+  friend simd operator&(const simd&, const simd&);
+  friend simd operator|(const simd&, const simd&);
+  friend simd operator^(const simd&, const simd&);
+  friend simd operator<<(const simd&, const simd&);
+  friend simd operator>>(const simd&, const simd&);
+  friend simd operator<<(const simd&, int);
+  friend simd operator>>(const simd&, int);
+
+  // compound assignment [simd.cassign]
+  friend simd& operator+=(simd&, const simd&);
+  friend simd& operator-=(simd&, const simd&);
+  friend simd& operator*=(simd&, const simd&);
+  friend simd& operator/=(simd&, const simd&);
+  friend simd& operator%=(simd&, const simd&);
+
+  friend simd& operator&=(simd&, const simd&);
+  friend simd& operator|=(simd&, const simd&);
+  friend simd& operator^=(simd&, const simd&);
+  friend simd& operator<<=(simd&, const simd&);
+  friend simd& operator>>=(simd&, const simd&);
+  friend simd& operator<<=(simd&, int);
+  friend simd& operator>>=(simd&, int);
+
+  // compares [simd.comparison]
+  friend mask_type operator==(const simd&, const simd&);
+  friend mask_type operator!=(const simd&, const simd&);
+  friend mask_type operator>=(const simd&, const simd&);
+  friend mask_type operator<=(const simd&, const simd&);
+  friend mask_type operator>(const simd&, const simd&);
+  friend mask_type operator<(const simd&, const simd&);
+};
+
+// [simd.mask.class]
+template <class _Tp, class _Abi>
+// TODO: implement simd_mask
+class simd_mask {
+public:
+  using value_type = bool;
+  // TODO: this is strawman implementation. Turn it into a proxy type.
+  using reference = bool&;
+  using simd_type = simd<_Tp, _Abi>;
+  using abi_type = _Abi;
+  static constexpr size_t size() noexcept;
+  simd_mask() = default;
+
+  // broadcast constructor
+  explicit simd_mask(value_type) noexcept;
+
+  // implicit type conversion constructor
+  template <class _Up>
+  simd_mask(const simd_mask<_Up, simd_abi::fixed_size<size()>>&) noexcept;
+
+  // load constructor
+  template <class _Flags>
+  simd_mask(const value_type*, _Flags);
+
+  // loads [simd.mask.copy]
+  template <class _Flags>
+  void copy_from(const value_type*, _Flags);
+  template <class _Flags>
+  void copy_to(value_type*, _Flags) const;
+
+  // scalar access [simd.mask.subscr]
+  reference operator[](size_t);
+  value_type operator[](size_t) const;
+
+  // unary operators [simd.mask.unary]
+  simd_mask operator!() const noexcept;
+
+  // simd_mask binary operators [simd.mask.binary]
+  friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator&(const simd_mask&, const simd_mask&)noexcept;
+  friend simd_mask operator|(const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator^(const simd_mask&, const simd_mask&) noexcept;
+
+  // simd_mask compound assignment [simd.mask.cassign]
+  friend simd_mask& operator&=(simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask& operator|=(simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask& operator^=(simd_mask&, const simd_mask&) noexcept;
+
+  // simd_mask compares [simd.mask.comparison]
+  friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept;
+  friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept;
+};
+
+#endif // _LIBCPP_STD_VER >= 17
+
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
+
+#endif /* _LIBCPP_EXPERIMENTAL_SIMD */
diff --git lib/libcxx/include/experimental/string_view lib/libcxx/include/experimental/string_view
index da104f9a121..f13bff54d53 100644
--- lib/libcxx/include/experimental/string_view
+++ lib/libcxx/include/experimental/string_view
@@ -8,811 +8,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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 <stdexcept>
-#include <iomanip>
-
-#include <__debug>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-_LIBCPP_BEGIN_NAMESPACE_LFTS
-
-    template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
-    class _LIBCPP_TEMPLATE_VIS 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): received 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())
-                : 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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(): received 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_TEMPLATE_VIS 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
-
-_LIBCPP_POP_MACROS
-
-#endif // _LIBCPP_LFTS_STRING_VIEW
+#error "<experimental/string_view> has been removed. Use <string_view> instead."
diff --git lib/libcxx/include/experimental/system_error lib/libcxx/include/experimental/system_error
index 2ec23854461..7937357fa14 100644
--- lib/libcxx/include/experimental/system_error
+++ lib/libcxx/include/experimental/system_error
@@ -8,56 +8,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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 */
+#error "<experimental/system_error> has been removed. Use <system_error> instead."
diff --git lib/libcxx/include/experimental/tuple lib/libcxx/include/experimental/tuple
index e00d2ec1a92..1f37a6293ba 100644
--- lib/libcxx/include/experimental/tuple
+++ lib/libcxx/include/experimental/tuple
@@ -8,75 +8,4 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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
-_LIBCPP_CONSTEXPR_AFTER_CXX11
-decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
-                                  integer_sequence<size_t, _Id...>) {
-    return _VSTD::__invoke_constexpr(
-        _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 */
+#error "<experimental/tuple> has been removed. Use <tuple> instead."
diff --git lib/libcxx/include/experimental/type_traits lib/libcxx/include/experimental/type_traits
index 3a7593620a7..afe491567ce 100644
--- lib/libcxx/include/experimental/type_traits
+++ lib/libcxx/include/experimental/type_traits
@@ -21,146 +21,6 @@ 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...)>;
@@ -172,14 +32,6 @@ inline namespace fundamentals_v1 {
   template <class T>
     using raw_invocation_type_t = typename raw_invocation_type<T>::type;
 
-  // 3.3.3, Logical operator traits
-  template<class... B> struct conjunction;
-  template<class... B> constexpr bool conjunction_v = conjunction<B...>::value;
-  template<class... B> struct disjunction;
-  template<class... B> constexpr bool disjunction_v = disjunction<B...>::value;
-  template<class B> struct negation;
-  template<class B> constexpr bool negation_v = negation<B>::value;
-
   // 3.3.4, Detection idiom
   template <class...> using void_t = void;
 
@@ -229,215 +81,6 @@ inline namespace fundamentals_v1 {
 
 _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>
@@ -459,24 +102,6 @@ template <class _Tp>
 using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
 */
 
-// 3.3.3, Logical operator traits
-template <class...> using void_t = void;
-
-template <class... _Args>
-struct conjunction : _VSTD::__and_<_Args...> {};
-template <class... _Args>
-_LIBCPP_CONSTEXPR bool conjunction_v = conjunction<_Args...>::value;
-
-template <class... _Args>
-struct disjunction : _VSTD::__or_<_Args...> {};
-template <class... _Args>
-_LIBCPP_CONSTEXPR bool disjunction_v = disjunction<_Args...>::value;
-
-template <class _Tp>
-struct negation : _VSTD::__not_<_Tp> {};
-template<class _Tp>
-_LIBCPP_CONSTEXPR bool negation_v = negation<_Tp>::value;
-
 // 3.3.4, Detection idiom
 template <class...> using void_t = void;
 
diff --git lib/libcxx/include/filesystem lib/libcxx/include/filesystem
new file mode 100644
index 00000000000..aa1d7180072
--- /dev/null
+++ lib/libcxx/include/filesystem
@@ -0,0 +1,2682 @@
+// -*- C++ -*-
+//===--------------------------- filesystem -------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP_FILESYSTEM
+#define _LIBCPP_FILESYSTEM
+/*
+    filesystem synopsis
+
+    namespace std { namespace filesystem {
+
+    class path;
+
+    void swap(path& lhs, path& rhs) noexcept;
+    size_t hash_value(const path& p) noexcept;
+
+    bool operator==(const path& lhs, const path& rhs) noexcept;
+    bool operator!=(const path& lhs, const path& rhs) noexcept;
+    bool operator< (const path& lhs, const path& rhs) noexcept;
+    bool operator<=(const path& lhs, const path& rhs) noexcept;
+    bool operator> (const path& lhs, const path& rhs) noexcept;
+    bool operator>=(const path& lhs, const path& rhs) noexcept;
+
+    path operator/ (const path& lhs, const path& rhs);
+
+    // fs.path.io operators are friends of path.
+    template <class charT, class traits>
+    friend basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os, const path& p);
+
+    template <class charT, class traits>
+    friend basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is, path& p);
+
+    template <class Source>
+      path u8path(const Source& source);
+    template <class InputIterator>
+      path u8path(InputIterator first, InputIterator last);
+
+    class filesystem_error;
+    class directory_entry;
+
+    class directory_iterator;
+
+    // enable directory_iterator range-based for statements
+    directory_iterator begin(directory_iterator iter) noexcept;
+    directory_iterator end(const directory_iterator&) noexcept;
+
+    class recursive_directory_iterator;
+
+    // enable recursive_directory_iterator range-based for statements
+    recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept;
+    recursive_directory_iterator end(const recursive_directory_iterator&) noexcept;
+
+    class file_status;
+
+    struct space_info
+    {
+      uintmax_t capacity;
+      uintmax_t free;
+      uintmax_t available;
+    };
+
+    enum class file_type;
+    enum class perms;
+    enum class perm_options;
+    enum class copy_options;
+    enum class directory_options;
+
+    typedef chrono::time_point<trivial-clock>  file_time_type;
+
+    // operational functions
+
+    path absolute(const path& p);
+    path absolute(const path& p, error_code &ec);
+
+    path canonical(const path& p);
+    path canonical(const path& p, error_code& ec);
+
+    void copy(const path& from, const path& to);
+    void copy(const path& from, const path& to, error_code& ec);
+    void copy(const path& from, const path& to, copy_options options);
+    void copy(const path& from, const path& to, copy_options options,
+                   error_code& ec);
+
+    bool copy_file(const path& from, const path& to);
+    bool copy_file(const path& from, const path& to, error_code& ec);
+    bool copy_file(const path& from, const path& to, copy_options option);
+    bool copy_file(const path& from, const path& to, copy_options option,
+                           error_code& ec);
+
+    void copy_symlink(const path& existing_symlink, const path& new_symlink);
+    void copy_symlink(const path& existing_symlink, const path& new_symlink,
+                              error_code& ec) noexcept;
+
+    bool create_directories(const path& p);
+    bool create_directories(const path& p, error_code& ec);
+
+    bool create_directory(const path& p);
+    bool create_directory(const path& p, error_code& ec) noexcept;
+
+    bool create_directory(const path& p, const path& attributes);
+    bool create_directory(const path& p, const path& attributes,
+                                  error_code& ec) noexcept;
+
+    void create_directory_symlink(const path& to, const path& new_symlink);
+    void create_directory_symlink(const path& to, const path& new_symlink,
+                                          error_code& ec) noexcept;
+
+    void create_hard_link(const path& to, const path& new_hard_link);
+    void create_hard_link(const path& to, const path& new_hard_link,
+                                  error_code& ec) noexcept;
+
+    void create_symlink(const path& to, const path& new_symlink);
+    void create_symlink(const path& to, const path& new_symlink,
+                                error_code& ec) noexcept;
+
+    path current_path();
+    path current_path(error_code& ec);
+    void current_path(const path& p);
+    void current_path(const path& p, error_code& ec) noexcept;
+
+    bool exists(file_status s) noexcept;
+    bool exists(const path& p);
+    bool exists(const path& p, error_code& ec) noexcept;
+
+    bool equivalent(const path& p1, const path& p2);
+    bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
+
+    uintmax_t    file_size(const path& p);
+    uintmax_t    file_size(const path& p, error_code& ec) noexcept;
+
+    uintmax_t    hard_link_count(const path& p);
+    uintmax_t    hard_link_count(const path& p, error_code& ec) noexcept;
+
+    bool is_block_file(file_status s) noexcept;
+    bool is_block_file(const path& p);
+    bool is_block_file(const path& p, error_code& ec) noexcept;
+
+    bool is_character_file(file_status s) noexcept;
+    bool is_character_file(const path& p);
+    bool is_character_file(const path& p, error_code& ec) noexcept;
+
+    bool is_directory(file_status s) noexcept;
+    bool is_directory(const path& p);
+    bool is_directory(const path& p, error_code& ec) noexcept;
+
+    bool is_empty(const path& p);
+    bool is_empty(const path& p, error_code& ec) noexcept;
+
+    bool is_fifo(file_status s) noexcept;
+    bool is_fifo(const path& p);
+    bool is_fifo(const path& p, error_code& ec) noexcept;
+
+    bool is_other(file_status s) noexcept;
+    bool is_other(const path& p);
+    bool is_other(const path& p, error_code& ec) noexcept;
+
+    bool is_regular_file(file_status s) noexcept;
+    bool is_regular_file(const path& p);
+    bool is_regular_file(const path& p, error_code& ec) noexcept;
+
+    bool is_socket(file_status s) noexcept;
+    bool is_socket(const path& p);
+    bool is_socket(const path& p, error_code& ec) noexcept;
+
+    bool is_symlink(file_status s) noexcept;
+    bool is_symlink(const path& p);
+    bool is_symlink(const path& p, error_code& ec) noexcept;
+
+    file_time_type  last_write_time(const path& p);
+    file_time_type  last_write_time(const path& p, error_code& ec) noexcept;
+    void last_write_time(const path& p, file_time_type new_time);
+    void last_write_time(const path& p, file_time_type new_time,
+                                 error_code& ec) noexcept;
+
+    void permissions(const path& p, perms prms,
+                     perm_options opts=perm_options::replace);
+    void permissions(const path& p, perms prms, error_code& ec) noexcept;
+    void permissions(const path& p, perms prms, perm_options opts,
+                     error_code& ec);
+
+    path proximate(const path& p, error_code& ec);
+    path proximate(const path& p, const path& base = current_path());
+    path proximate(const path& p, const path& base, error_code &ec);
+
+    path read_symlink(const path& p);
+    path read_symlink(const path& p, error_code& ec);
+
+    path relative(const path& p, error_code& ec);
+    path relative(const path& p, const path& base=current_path());
+    path relative(const path& p, const path& base, error_code& ec);
+
+    bool remove(const path& p);
+    bool remove(const path& p, error_code& ec) noexcept;
+
+    uintmax_t    remove_all(const path& p);
+    uintmax_t    remove_all(const path& p, error_code& ec);
+
+    void rename(const path& from, const path& to);
+    void rename(const path& from, const path& to, error_code& ec) noexcept;
+
+    void resize_file(const path& p, uintmax_t size);
+    void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
+
+    space_info   space(const path& p);
+    space_info   space(const path& p, error_code& ec) noexcept;
+
+    file_status  status(const path& p);
+    file_status  status(const path& p, error_code& ec) noexcept;
+
+    bool status_known(file_status s) noexcept;
+
+    file_status  symlink_status(const path& p);
+    file_status  symlink_status(const path& p, error_code& ec) noexcept;
+
+    path temp_directory_path();
+    path temp_directory_path(error_code& ec);
+
+    path weakly_canonical(path const& p);
+    path weakly_canonical(path const& p, error_code& ec);
+
+
+} }  // namespaces std::filesystem
+
+*/
+
+#include <__config>
+#include <cstddef>
+#include <cstdlib>
+#include <chrono>
+#include <iterator>
+#include <iosfwd>
+#include <locale>
+#include <memory>
+#include <stack>
+#include <string>
+#include <system_error>
+#include <utility>
+#include <iomanip> // for quoted
+#include <string_view>
+
+#include <__debug>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#ifndef _LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER >= 17
+#define __cpp_lib_filesystem 201703
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+
+struct _FilesystemClock {
+#if !defined(_LIBCPP_HAS_NO_INT128)
+  typedef __int128_t rep;
+  typedef nano period;
+#else
+  typedef long long rep;
+  typedef nano period;
+#endif
+
+  typedef chrono::duration<rep, period> duration;
+  typedef chrono::time_point<_FilesystemClock> time_point;
+
+  static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
+
+  _LIBCPP_FUNC_VIS static time_point now() noexcept;
+
+  _LIBCPP_INLINE_VISIBILITY
+  static time_t to_time_t(const time_point& __t) noexcept {
+    typedef chrono::duration<rep> __secs;
+    return time_t(
+        chrono::duration_cast<__secs>(__t.time_since_epoch()).count());
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  static time_point from_time_t(time_t __t) noexcept {
+    typedef chrono::duration<rep> __secs;
+    return time_point(__secs(__t));
+  }
+};
+
+typedef chrono::time_point<_FilesystemClock> file_time_type;
+
+struct _LIBCPP_TYPE_VIS space_info {
+  uintmax_t capacity;
+  uintmax_t free;
+  uintmax_t available;
+};
+
+enum class _LIBCPP_ENUM_VIS file_type : signed char {
+  none = 0,
+  not_found = -1,
+  regular = 1,
+  directory = 2,
+  symlink = 3,
+  block = 4,
+  character = 5,
+  fifo = 6,
+  socket = 7,
+  unknown = 8
+};
+
+enum class _LIBCPP_ENUM_VIS perms : unsigned {
+  none = 0,
+
+  owner_read = 0400,
+  owner_write = 0200,
+  owner_exec = 0100,
+  owner_all = 0700,
+
+  group_read = 040,
+  group_write = 020,
+  group_exec = 010,
+  group_all = 070,
+
+  others_read = 04,
+  others_write = 02,
+  others_exec = 01,
+  others_all = 07,
+
+  all = 0777,
+
+  set_uid = 04000,
+  set_gid = 02000,
+  sticky_bit = 01000,
+  mask = 07777,
+  unknown = 0xFFFF,
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perms operator&(perms _LHS, perms _RHS) {
+  return static_cast<perms>(static_cast<unsigned>(_LHS) &
+                            static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perms operator|(perms _LHS, perms _RHS) {
+  return static_cast<perms>(static_cast<unsigned>(_LHS) |
+                            static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perms operator^(perms _LHS, perms _RHS) {
+  return static_cast<perms>(static_cast<unsigned>(_LHS) ^
+                            static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perms operator~(perms _LHS) {
+  return static_cast<perms>(~static_cast<unsigned>(_LHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; }
+
+_LIBCPP_INLINE_VISIBILITY
+inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; }
+
+_LIBCPP_INLINE_VISIBILITY
+inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; }
+
+enum class _LIBCPP_ENUM_VIS perm_options : unsigned char {
+  replace = 1,
+  add = 2,
+  remove = 4,
+  nofollow = 8
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) {
+  return static_cast<perm_options>(static_cast<unsigned>(_LHS) &
+                                   static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) {
+  return static_cast<perm_options>(static_cast<unsigned>(_LHS) |
+                                   static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) {
+  return static_cast<perm_options>(static_cast<unsigned>(_LHS) ^
+                                   static_cast<unsigned>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr perm_options operator~(perm_options _LHS) {
+  return static_cast<perm_options>(~static_cast<unsigned>(_LHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) {
+  return _LHS = _LHS & _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) {
+  return _LHS = _LHS | _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) {
+  return _LHS = _LHS ^ _RHS;
+}
+
+enum class _LIBCPP_ENUM_VIS copy_options : unsigned short {
+  none = 0,
+  skip_existing = 1,
+  overwrite_existing = 2,
+  update_existing = 4,
+  recursive = 8,
+  copy_symlinks = 16,
+  skip_symlinks = 32,
+  directories_only = 64,
+  create_symlinks = 128,
+  create_hard_links = 256,
+  __in_recursive_copy = 512,
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) {
+  return static_cast<copy_options>(static_cast<unsigned short>(_LHS) &
+                                   static_cast<unsigned short>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) {
+  return static_cast<copy_options>(static_cast<unsigned short>(_LHS) |
+                                   static_cast<unsigned short>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) {
+  return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^
+                                   static_cast<unsigned short>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr copy_options operator~(copy_options _LHS) {
+  return static_cast<copy_options>(~static_cast<unsigned short>(_LHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) {
+  return _LHS = _LHS & _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) {
+  return _LHS = _LHS | _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) {
+  return _LHS = _LHS ^ _RHS;
+}
+
+enum class _LIBCPP_ENUM_VIS directory_options : unsigned char {
+  none = 0,
+  follow_directory_symlink = 1,
+  skip_permission_denied = 2
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr directory_options operator&(directory_options _LHS,
+                                             directory_options _RHS) {
+  return static_cast<directory_options>(static_cast<unsigned char>(_LHS) &
+                                        static_cast<unsigned char>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr directory_options operator|(directory_options _LHS,
+                                             directory_options _RHS) {
+  return static_cast<directory_options>(static_cast<unsigned char>(_LHS) |
+                                        static_cast<unsigned char>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr directory_options operator^(directory_options _LHS,
+                                             directory_options _RHS) {
+  return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^
+                                        static_cast<unsigned char>(_RHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr directory_options operator~(directory_options _LHS) {
+  return static_cast<directory_options>(~static_cast<unsigned char>(_LHS));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline directory_options& operator&=(directory_options& _LHS,
+                                     directory_options _RHS) {
+  return _LHS = _LHS & _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline directory_options& operator|=(directory_options& _LHS,
+                                     directory_options _RHS) {
+  return _LHS = _LHS | _RHS;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+inline directory_options& operator^=(directory_options& _LHS,
+                                     directory_options _RHS) {
+  return _LHS = _LHS ^ _RHS;
+}
+
+class _LIBCPP_TYPE_VIS file_status {
+public:
+  // constructors
+  _LIBCPP_INLINE_VISIBILITY
+  file_status() noexcept : file_status(file_type::none) {}
+  _LIBCPP_INLINE_VISIBILITY
+  explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept
+      : __ft_(__ft),
+        __prms_(__prms) {}
+
+  file_status(const file_status&) noexcept = default;
+  file_status(file_status&&) noexcept = default;
+
+  _LIBCPP_INLINE_VISIBILITY
+  ~file_status() {}
+
+  file_status& operator=(const file_status&) noexcept = default;
+  file_status& operator=(file_status&&) noexcept = default;
+
+  // observers
+  _LIBCPP_INLINE_VISIBILITY
+  file_type type() const noexcept { return __ft_; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  perms permissions() const noexcept { return __prms_; }
+
+  // modifiers
+  _LIBCPP_INLINE_VISIBILITY
+  void type(file_type __ft) noexcept { __ft_ = __ft; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  void permissions(perms __p) noexcept { __prms_ = __p; }
+
+private:
+  file_type __ft_;
+  perms __prms_;
+};
+
+class _LIBCPP_TYPE_VIS directory_entry;
+
+template <class _Tp>
+struct __can_convert_char {
+  static const bool value = false;
+};
+template <class _Tp>
+struct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {};
+template <>
+struct __can_convert_char<char> {
+  static const bool value = true;
+  using __char_type = char;
+};
+template <>
+struct __can_convert_char<wchar_t> {
+  static const bool value = true;
+  using __char_type = wchar_t;
+};
+template <>
+struct __can_convert_char<char16_t> {
+  static const bool value = true;
+  using __char_type = char16_t;
+};
+template <>
+struct __can_convert_char<char32_t> {
+  static const bool value = true;
+  using __char_type = char32_t;
+};
+
+template <class _ECharT>
+typename enable_if<__can_convert_char<_ECharT>::value, bool>::type
+__is_separator(_ECharT __e) {
+  return __e == _ECharT('/');
+};
+
+struct _NullSentinal {};
+
+template <class _Tp>
+using _Void = void;
+
+template <class _Tp, class = void>
+struct __is_pathable_string : public false_type {};
+
+template <class _ECharT, class _Traits, class _Alloc>
+struct __is_pathable_string<
+    basic_string<_ECharT, _Traits, _Alloc>,
+    _Void<typename __can_convert_char<_ECharT>::__char_type> >
+    : public __can_convert_char<_ECharT> {
+  using _Str = basic_string<_ECharT, _Traits, _Alloc>;
+  using _Base = __can_convert_char<_ECharT>;
+  static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
+  static _ECharT const* __range_end(_Str const& __s) {
+    return __s.data() + __s.length();
+  }
+  static _ECharT __first_or_null(_Str const& __s) {
+    return __s.empty() ? _ECharT{} : __s[0];
+  }
+};
+
+template <class _ECharT, class _Traits>
+struct __is_pathable_string<
+    basic_string_view<_ECharT, _Traits>,
+    _Void<typename __can_convert_char<_ECharT>::__char_type> >
+    : public __can_convert_char<_ECharT> {
+  using _Str = basic_string_view<_ECharT, _Traits>;
+  using _Base = __can_convert_char<_ECharT>;
+  static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
+  static _ECharT const* __range_end(_Str const& __s) {
+    return __s.data() + __s.length();
+  }
+  static _ECharT __first_or_null(_Str const& __s) {
+    return __s.empty() ? _ECharT{} : __s[0];
+  }
+};
+
+template <class _Source, class _DS = typename decay<_Source>::type,
+          class _UnqualPtrType =
+              typename remove_const<typename remove_pointer<_DS>::type>::type,
+          bool _IsCharPtr = is_pointer<_DS>::value&&
+              __can_convert_char<_UnqualPtrType>::value>
+struct __is_pathable_char_array : false_type {};
+
+template <class _Source, class _ECharT, class _UPtr>
+struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
+    : __can_convert_char<typename remove_const<_ECharT>::type> {
+  using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;
+
+  static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
+  static _ECharT const* __range_end(const _ECharT* __b) {
+    using _Iter = const _ECharT*;
+    const _ECharT __sentinal = _ECharT{};
+    _Iter __e = __b;
+    for (; *__e != __sentinal; ++__e)
+      ;
+    return __e;
+  }
+
+  static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }
+};
+
+template <class _Iter, bool _IsIt = __is_input_iterator<_Iter>::value,
+          class = void>
+struct __is_pathable_iter : false_type {};
+
+template <class _Iter>
+struct __is_pathable_iter<
+    _Iter, true,
+    _Void<typename __can_convert_char<
+        typename iterator_traits<_Iter>::value_type>::__char_type> >
+    : __can_convert_char<typename iterator_traits<_Iter>::value_type> {
+  using _ECharT = typename iterator_traits<_Iter>::value_type;
+  using _Base = __can_convert_char<_ECharT>;
+
+  static _Iter __range_begin(_Iter __b) { return __b; }
+  static _NullSentinal __range_end(_Iter) { return _NullSentinal{}; }
+
+  static _ECharT __first_or_null(_Iter __b) { return *__b; }
+};
+
+template <class _Tp, bool _IsStringT = __is_pathable_string<_Tp>::value,
+          bool _IsCharIterT = __is_pathable_char_array<_Tp>::value,
+          bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value>
+struct __is_pathable : false_type {
+  static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false");
+};
+
+template <class _Tp>
+struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {};
+
+template <class _Tp>
+struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {
+};
+
+template <class _Tp>
+struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};
+
+template <class _ECharT>
+struct _PathCVT {
+  static_assert(__can_convert_char<_ECharT>::value,
+                "Char type not convertible");
+
+  typedef __narrow_to_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Narrower;
+
+  static void __append_range(string& __dest, _ECharT const* __b,
+                             _ECharT const* __e) {
+    _Narrower()(back_inserter(__dest), __b, __e);
+  }
+
+  template <class _Iter>
+  static void __append_range(string& __dest, _Iter __b, _Iter __e) {
+    static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
+    if (__b == __e)
+      return;
+    basic_string<_ECharT> __tmp(__b, __e);
+    _Narrower()(back_inserter(__dest), __tmp.data(),
+                __tmp.data() + __tmp.length());
+  }
+
+  template <class _Iter>
+  static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
+    static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
+    const _ECharT __sentinal = _ECharT{};
+    if (*__b == __sentinal)
+      return;
+    basic_string<_ECharT> __tmp;
+    for (; *__b != __sentinal; ++__b)
+      __tmp.push_back(*__b);
+    _Narrower()(back_inserter(__dest), __tmp.data(),
+                __tmp.data() + __tmp.length());
+  }
+
+  template <class _Source>
+  static void __append_source(string& __dest, _Source const& __s) {
+    using _Traits = __is_pathable<_Source>;
+    __append_range(__dest, _Traits::__range_begin(__s),
+                   _Traits::__range_end(__s));
+  }
+};
+
+template <>
+struct _PathCVT<char> {
+
+  template <class _Iter>
+  static typename enable_if<__is_exactly_input_iterator<_Iter>::value>::type
+  __append_range(string& __dest, _Iter __b, _Iter __e) {
+    for (; __b != __e; ++__b)
+      __dest.push_back(*__b);
+  }
+
+  template <class _Iter>
+  static typename enable_if<__is_forward_iterator<_Iter>::value>::type
+  __append_range(string& __dest, _Iter __b, _Iter __e) {
+    __dest.__append_forward_unsafe(__b, __e);
+  }
+
+  template <class _Iter>
+  static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
+    const char __sentinal = char{};
+    for (; *__b != __sentinal; ++__b)
+      __dest.push_back(*__b);
+  }
+
+  template <class _Source>
+  static void __append_source(string& __dest, _Source const& __s) {
+    using _Traits = __is_pathable<_Source>;
+    __append_range(__dest, _Traits::__range_begin(__s),
+                   _Traits::__range_end(__s));
+  }
+};
+
+class _LIBCPP_TYPE_VIS path {
+  template <class _SourceOrIter, class _Tp = path&>
+  using _EnableIfPathable =
+      typename enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type;
+
+  template <class _Tp>
+  using _SourceChar = typename __is_pathable<_Tp>::__char_type;
+
+  template <class _Tp>
+  using _SourceCVT = _PathCVT<_SourceChar<_Tp> >;
+
+public:
+  typedef char value_type;
+  typedef basic_string<value_type> string_type;
+  typedef _VSTD::string_view __string_view;
+  static constexpr value_type preferred_separator = '/';
+
+  enum class _LIBCPP_ENUM_VIS format : unsigned char {
+    auto_format,
+    native_format,
+    generic_format
+  };
+
+  // constructors and destructor
+  _LIBCPP_INLINE_VISIBILITY path() noexcept {}
+  _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {}
+  _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept
+      : __pn_(_VSTD::move(__p.__pn_)) {}
+
+  _LIBCPP_INLINE_VISIBILITY
+  path(string_type&& __s, format = format::auto_format) noexcept
+      : __pn_(_VSTD::move(__s)) {}
+
+  template <class _Source, class = _EnableIfPathable<_Source, void> >
+  path(const _Source& __src, format = format::auto_format) {
+    _SourceCVT<_Source>::__append_source(__pn_, __src);
+  }
+
+  template <class _InputIt>
+  path(_InputIt __first, _InputIt __last, format = format::auto_format) {
+    typedef typename iterator_traits<_InputIt>::value_type _ItVal;
+    _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
+  }
+
+  // TODO Implement locale conversions.
+  template <class _Source, class = _EnableIfPathable<_Source, void> >
+  path(const _Source& __src, const locale& __loc, format = format::auto_format);
+  template <class _InputIt>
+  path(_InputIt __first, _InputIt _last, const locale& __loc,
+       format = format::auto_format);
+
+  _LIBCPP_INLINE_VISIBILITY
+  ~path() = default;
+
+  // assignments
+  _LIBCPP_INLINE_VISIBILITY
+  path& operator=(const path& __p) {
+    __pn_ = __p.__pn_;
+    return *this;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  path& operator=(path&& __p) noexcept {
+    __pn_ = _VSTD::move(__p.__pn_);
+    return *this;
+  }
+
+  template <class = void>
+  _LIBCPP_INLINE_VISIBILITY path& operator=(string_type&& __s) noexcept {
+    __pn_ = _VSTD::move(__s);
+    return *this;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  path& assign(string_type&& __s) noexcept {
+    __pn_ = _VSTD::move(__s);
+    return *this;
+  }
+
+  template <class _Source>
+  _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
+  operator=(const _Source& __src) {
+    return this->assign(__src);
+  }
+
+  template <class _Source>
+  _EnableIfPathable<_Source> assign(const _Source& __src) {
+    __pn_.clear();
+    _SourceCVT<_Source>::__append_source(__pn_, __src);
+    return *this;
+  }
+
+  template <class _InputIt>
+  path& assign(_InputIt __first, _InputIt __last) {
+    typedef typename iterator_traits<_InputIt>::value_type _ItVal;
+    __pn_.clear();
+    _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
+    return *this;
+  }
+
+private:
+  template <class _ECharT>
+  static bool __source_is_absolute(_ECharT __first_or_null) {
+    return __is_separator(__first_or_null);
+  }
+
+public:
+  // appends
+  path& operator/=(const path& __p) {
+    if (__p.is_absolute()) {
+      __pn_ = __p.__pn_;
+      return *this;
+    }
+    if (has_filename())
+      __pn_ += preferred_separator;
+    __pn_ += __p.native();
+    return *this;
+  }
+
+  // FIXME: Use _LIBCPP_DIAGNOSE_WARNING to produce a diagnostic when __src
+  // is known at compile time to be "/' since the user almost certainly intended
+  // to append a separator instead of overwriting the path with "/"
+  template <class _Source>
+  _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
+  operator/=(const _Source& __src) {
+    return this->append(__src);
+  }
+
+  template <class _Source>
+  _EnableIfPathable<_Source> append(const _Source& __src) {
+    using _Traits = __is_pathable<_Source>;
+    using _CVT = _PathCVT<_SourceChar<_Source> >;
+    if (__source_is_absolute(_Traits::__first_or_null(__src)))
+      __pn_.clear();
+    else if (has_filename())
+      __pn_ += preferred_separator;
+    _CVT::__append_source(__pn_, __src);
+    return *this;
+  }
+
+  template <class _InputIt>
+  path& append(_InputIt __first, _InputIt __last) {
+    typedef typename iterator_traits<_InputIt>::value_type _ItVal;
+    static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
+    using _CVT = _PathCVT<_ItVal>;
+    if (__first != __last && __source_is_absolute(*__first))
+      __pn_.clear();
+    else if (has_filename())
+      __pn_ += preferred_separator;
+    _CVT::__append_range(__pn_, __first, __last);
+    return *this;
+  }
+
+  // concatenation
+  _LIBCPP_INLINE_VISIBILITY
+  path& operator+=(const path& __x) {
+    __pn_ += __x.__pn_;
+    return *this;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  path& operator+=(const string_type& __x) {
+    __pn_ += __x;
+    return *this;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  path& operator+=(__string_view __x) {
+    __pn_ += __x;
+    return *this;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  path& operator+=(const value_type* __x) {
+    __pn_ += __x;
+    return *this;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  path& operator+=(value_type __x) {
+    __pn_ += __x;
+    return *this;
+  }
+
+  template <class _ECharT>
+  typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
+  operator+=(_ECharT __x) {
+    basic_string<_ECharT> __tmp;
+    __tmp += __x;
+    _PathCVT<_ECharT>::__append_source(__pn_, __tmp);
+    return *this;
+  }
+
+  template <class _Source>
+  _EnableIfPathable<_Source> operator+=(const _Source& __x) {
+    return this->concat(__x);
+  }
+
+  template <class _Source>
+  _EnableIfPathable<_Source> concat(const _Source& __x) {
+    _SourceCVT<_Source>::__append_source(__pn_, __x);
+    return *this;
+  }
+
+  template <class _InputIt>
+  path& concat(_InputIt __first, _InputIt __last) {
+    typedef typename iterator_traits<_InputIt>::value_type _ItVal;
+    _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
+    return *this;
+  }
+
+  // modifiers
+  _LIBCPP_INLINE_VISIBILITY
+  void clear() noexcept { __pn_.clear(); }
+
+  path& make_preferred() { return *this; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  path& remove_filename() {
+    auto __fname = __filename();
+    if (!__fname.empty())
+      __pn_.erase(__fname.data() - __pn_.data());
+    return *this;
+  }
+
+  path& replace_filename(const path& __replacement) {
+    remove_filename();
+    return (*this /= __replacement);
+  }
+
+  path& replace_extension(const path& __replacement = path());
+
+  _LIBCPP_INLINE_VISIBILITY
+  void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
+
+  // private helper to allow reserving memory in the path
+  _LIBCPP_INLINE_VISIBILITY
+  void __reserve(size_t __s) { __pn_.reserve(__s); }
+
+  // native format observers
+  _LIBCPP_INLINE_VISIBILITY
+  const string_type& native() const noexcept { return __pn_; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  const value_type* c_str() const noexcept { return __pn_.c_str(); }
+
+  _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; }
+
+  template <class _ECharT, class _Traits = char_traits<_ECharT>,
+            class _Allocator = allocator<_ECharT> >
+  basic_string<_ECharT, _Traits, _Allocator>
+  string(const _Allocator& __a = _Allocator()) const {
+    using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;
+    using _Str = basic_string<_ECharT, _Traits, _Allocator>;
+    _Str __s(__a);
+    __s.reserve(__pn_.size());
+    _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
+    return __s;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; }
+  _LIBCPP_INLINE_VISIBILITY std::wstring wstring() const {
+    return string<wchar_t>();
+  }
+  _LIBCPP_INLINE_VISIBILITY std::string u8string() const { return __pn_; }
+  _LIBCPP_INLINE_VISIBILITY std::u16string u16string() const {
+    return string<char16_t>();
+  }
+  _LIBCPP_INLINE_VISIBILITY std::u32string u32string() const {
+    return string<char32_t>();
+  }
+
+  // generic format observers
+  template <class _ECharT, class _Traits = char_traits<_ECharT>,
+            class _Allocator = allocator<_ECharT> >
+  basic_string<_ECharT, _Traits, _Allocator>
+  generic_string(const _Allocator& __a = _Allocator()) const {
+    return string<_ECharT, _Traits, _Allocator>(__a);
+  }
+
+  std::string generic_string() const { return __pn_; }
+  std::wstring generic_wstring() const { return string<wchar_t>(); }
+  std::string generic_u8string() const { return __pn_; }
+  std::u16string generic_u16string() const { return string<char16_t>(); }
+  std::u32string generic_u32string() const { return string<char32_t>(); }
+
+private:
+  int __compare(__string_view) const;
+  __string_view __root_name() const;
+  __string_view __root_directory() const;
+  __string_view __root_path_raw() const;
+  __string_view __relative_path() const;
+  __string_view __parent_path() const;
+  __string_view __filename() const;
+  __string_view __stem() const;
+  __string_view __extension() const;
+
+public:
+  // compare
+  _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept {
+    return __compare(__p.__pn_);
+  }
+  _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const {
+    return __compare(__s);
+  }
+  _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const {
+    return __compare(__s);
+  }
+  _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const {
+    return __compare(__s);
+  }
+
+  // decomposition
+  _LIBCPP_INLINE_VISIBILITY path root_name() const {
+    return string_type(__root_name());
+  }
+  _LIBCPP_INLINE_VISIBILITY path root_directory() const {
+    return string_type(__root_directory());
+  }
+  _LIBCPP_INLINE_VISIBILITY path root_path() const {
+    return root_name().append(string_type(__root_directory()));
+  }
+  _LIBCPP_INLINE_VISIBILITY path relative_path() const {
+    return string_type(__relative_path());
+  }
+  _LIBCPP_INLINE_VISIBILITY path parent_path() const {
+    return string_type(__parent_path());
+  }
+  _LIBCPP_INLINE_VISIBILITY path filename() const {
+    return string_type(__filename());
+  }
+  _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); }
+  _LIBCPP_INLINE_VISIBILITY path extension() const {
+    return string_type(__extension());
+  }
+
+  // query
+  _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool
+  empty() const noexcept {
+    return __pn_.empty();
+  }
+
+  _LIBCPP_INLINE_VISIBILITY bool has_root_name() const {
+    return !__root_name().empty();
+  }
+  _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const {
+    return !__root_directory().empty();
+  }
+  _LIBCPP_INLINE_VISIBILITY bool has_root_path() const {
+    return !__root_path_raw().empty();
+  }
+  _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const {
+    return !__relative_path().empty();
+  }
+  _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const {
+    return !__parent_path().empty();
+  }
+  _LIBCPP_INLINE_VISIBILITY bool has_filename() const {
+    return !__filename().empty();
+  }
+  _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); }
+  _LIBCPP_INLINE_VISIBILITY bool has_extension() const {
+    return !__extension().empty();
+  }
+
+  _LIBCPP_INLINE_VISIBILITY bool is_absolute() const {
+    return has_root_directory();
+  }
+  _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); }
+
+  // relative paths
+  path lexically_normal() const;
+  path lexically_relative(const path& __base) const;
+
+  _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const {
+    path __result = this->lexically_relative(__base);
+    if (__result.native().empty())
+      return *this;
+    return __result;
+  }
+
+  // iterators
+  class _LIBCPP_TYPE_VIS iterator;
+  typedef iterator const_iterator;
+
+  iterator begin() const;
+  iterator end() const;
+
+  template <class _CharT, class _Traits>
+  _LIBCPP_INLINE_VISIBILITY friend
+      typename enable_if<is_same<_CharT, char>::value &&
+                             is_same<_Traits, char_traits<char> >::value,
+                         basic_ostream<_CharT, _Traits>&>::type
+      operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
+    __os << std::__quoted(__p.native());
+    return __os;
+  }
+
+  template <class _CharT, class _Traits>
+  _LIBCPP_INLINE_VISIBILITY friend
+      typename enable_if<!is_same<_CharT, char>::value ||
+                             !is_same<_Traits, char_traits<char> >::value,
+                         basic_ostream<_CharT, _Traits>&>::type
+      operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
+    __os << std::__quoted(__p.string<_CharT, _Traits>());
+    return __os;
+  }
+
+  template <class _CharT, class _Traits>
+  _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>&
+  operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) {
+    basic_string<_CharT, _Traits> __tmp;
+    __is >> __quoted(__tmp);
+    __p = __tmp;
+    return __is;
+  }
+
+private:
+  inline _LIBCPP_INLINE_VISIBILITY path&
+  __assign_view(__string_view const& __s) noexcept {
+    __pn_ = string_type(__s);
+    return *this;
+  }
+  string_type __pn_;
+};
+
+inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept {
+  __lhs.swap(__rhs);
+}
+
+_LIBCPP_FUNC_VIS
+size_t hash_value(const path& __p) noexcept;
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs,
+                                                 const path& __rhs) noexcept {
+  return __lhs.compare(__rhs) == 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs,
+                                                 const path& __rhs) noexcept {
+  return __lhs.compare(__rhs) != 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs,
+                                                const path& __rhs) noexcept {
+  return __lhs.compare(__rhs) < 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs,
+                                                 const path& __rhs) noexcept {
+  return __lhs.compare(__rhs) <= 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs,
+                                                const path& __rhs) noexcept {
+  return __lhs.compare(__rhs) > 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs,
+                                                 const path& __rhs) noexcept {
+  return __lhs.compare(__rhs) >= 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
+                                                const path& __rhs) {
+  path __result(__lhs);
+  __result /= __rhs;
+  return __result;
+}
+
+template <class _Source>
+_LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_pathable<_Source>::value, path>::type
+    u8path(const _Source& __s) {
+  static_assert(
+      is_same<typename __is_pathable<_Source>::__char_type, char>::value,
+      "u8path(Source const&) requires Source have a character type of type "
+      "'char'");
+  return path(__s);
+}
+
+template <class _InputIt>
+_LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_pathable<_InputIt>::value, path>::type
+    u8path(_InputIt __f, _InputIt __l) {
+  static_assert(
+      is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
+      "u8path(Iter, Iter) requires Iter have a value_type of type 'char'");
+  return path(__f, __l);
+}
+
+class _LIBCPP_TYPE_VIS path::iterator {
+public:
+  enum _ParserState : unsigned char {
+    _Singular,
+    _BeforeBegin,
+    _InRootName,
+    _InRootDir,
+    _InFilenames,
+    _InTrailingSep,
+    _AtEnd
+  };
+
+public:
+  typedef bidirectional_iterator_tag iterator_category;
+
+  typedef path value_type;
+  typedef std::ptrdiff_t difference_type;
+  typedef const path* pointer;
+  typedef const path& reference;
+
+  typedef void
+      __stashing_iterator_tag; // See reverse_iterator and __is_stashing_iterator
+
+public:
+  _LIBCPP_INLINE_VISIBILITY
+  iterator()
+      : __stashed_elem_(), __path_ptr_(nullptr), __entry_(),
+        __state_(_Singular) {}
+
+  iterator(const iterator&) = default;
+  ~iterator() = default;
+
+  iterator& operator=(const iterator&) = default;
+
+  _LIBCPP_INLINE_VISIBILITY
+  reference operator*() const { return __stashed_elem_; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  pointer operator->() const { return &__stashed_elem_; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  iterator& operator++() {
+    _LIBCPP_ASSERT(__state_ != _Singular,
+                   "attempting to increment a singular iterator");
+    _LIBCPP_ASSERT(__state_ != _AtEnd,
+                   "attempting to increment the end iterator");
+    return __increment();
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  iterator operator++(int) {
+    iterator __it(*this);
+    this->operator++();
+    return __it;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  iterator& operator--() {
+    _LIBCPP_ASSERT(__state_ != _Singular,
+                   "attempting to decrement a singular iterator");
+    _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(),
+                   "attempting to decrement the begin iterator");
+    return __decrement();
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  iterator operator--(int) {
+    iterator __it(*this);
+    this->operator--();
+    return __it;
+  }
+
+private:
+  friend class path;
+
+  inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&,
+                                                          const iterator&);
+
+  iterator& __increment();
+  iterator& __decrement();
+
+  path __stashed_elem_;
+  const path* __path_ptr_;
+  path::__string_view __entry_;
+  _ParserState __state_;
+};
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path::iterator& __lhs,
+                                                 const path::iterator& __rhs) {
+  return __lhs.__path_ptr_ == __rhs.__path_ptr_ &&
+         __lhs.__entry_.data() == __rhs.__entry_.data();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs,
+                                                 const path::iterator& __rhs) {
+  return !(__lhs == __rhs);
+}
+
+class _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error {
+public:
+  _LIBCPP_INLINE_VISIBILITY
+  filesystem_error(const string& __what, error_code __ec)
+      : system_error(__ec, __what),
+        __storage_(make_shared<_Storage>(path(), path())) {
+    __create_what(0);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  filesystem_error(const string& __what, const path& __p1, error_code __ec)
+      : system_error(__ec, __what),
+        __storage_(make_shared<_Storage>(__p1, path())) {
+    __create_what(1);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  filesystem_error(const string& __what, const path& __p1, const path& __p2,
+                   error_code __ec)
+      : system_error(__ec, __what),
+        __storage_(make_shared<_Storage>(__p1, __p2)) {
+    __create_what(2);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  const path& path1() const noexcept { return __storage_->__p1_; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  const path& path2() const noexcept { return __storage_->__p2_; }
+
+  ~filesystem_error() override; // key function
+
+  _LIBCPP_INLINE_VISIBILITY
+  const char* what() const noexcept override {
+    return __storage_->__what_.c_str();
+  }
+
+  _LIBCPP_FUNC_VIS
+  void __create_what(int __num_paths);
+
+private:
+  struct _Storage {
+    _LIBCPP_INLINE_VISIBILITY
+    _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {}
+
+    path __p1_;
+    path __p2_;
+    string __what_;
+  };
+  shared_ptr<_Storage> __storage_;
+};
+
+template <class... _Args>
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    void
+    __throw_filesystem_error(_Args&&... __args) {
+  throw filesystem_error(std::forward<_Args>(__args)...);
+}
+#else
+    void
+    __throw_filesystem_error(_Args&&...) {
+  _VSTD::abort();
+}
+#endif
+
+// operational functions
+
+_LIBCPP_FUNC_VIS
+path __absolute(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+path __canonical(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __copy(const path& __from, const path& __to, copy_options __opt,
+            error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+bool __copy_file(const path& __from, const path& __to, copy_options __opt,
+                 error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __copy_symlink(const path& __existing_symlink, const path& __new_symlink,
+                    error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+bool __create_directories(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+bool __create_directory(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+bool __create_directory(const path& p, const path& attributes,
+                        error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __create_directory_symlink(const path& __to, const path& __new_symlink,
+                                error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __create_hard_link(const path& __to, const path& __new_hard_link,
+                        error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __create_symlink(const path& __to, const path& __new_symlink,
+                      error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+path __current_path(error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __current_path(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+bool __equivalent(const path&, const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+uintmax_t __file_size(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+bool __fs_is_empty(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+file_time_type __last_write_time(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __last_write_time(const path& p, file_time_type new_time,
+                       error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __permissions(const path&, perms, perm_options, error_code* = nullptr);
+_LIBCPP_FUNC_VIS
+path __read_symlink(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+bool __remove(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+uintmax_t __remove_all(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __rename(const path& from, const path& to, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+void __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS
+space_info __space(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+file_status __status(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+file_status __symlink_status(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+path __system_complete(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+path __temp_directory_path(error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS
+path __weakly_canonical(path const& __p, error_code* __ec = nullptr);
+
+inline _LIBCPP_INLINE_VISIBILITY path current_path() {
+  return __current_path();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) {
+  return __current_path(&__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) {
+  __current_path(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p,
+                                                   error_code& __ec) noexcept {
+  __current_path(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) {
+  return __absolute(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p,
+                                               error_code& __ec) {
+  return __absolute(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) {
+  return __canonical(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p,
+                                                error_code& __ec) {
+  return __canonical(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from,
+                                           const path& __to) {
+  __copy(__from, __to, copy_options::none);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to,
+                                           error_code& __ec) {
+  __copy(__from, __to, copy_options::none, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to,
+                                           copy_options __opt) {
+  __copy(__from, __to, __opt);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to,
+                                           copy_options __opt,
+                                           error_code& __ec) {
+  __copy(__from, __to, __opt, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from,
+                                                const path& __to) {
+  return __copy_file(__from, __to, copy_options::none);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+copy_file(const path& __from, const path& __to, error_code& __ec) {
+  return __copy_file(__from, __to, copy_options::none, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+copy_file(const path& __from, const path& __to, copy_options __opt) {
+  return __copy_file(__from, __to, __opt);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from,
+                                                const path& __to,
+                                                copy_options __opt,
+                                                error_code& __ec) {
+  return __copy_file(__from, __to, __opt, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __existing,
+                                                   const path& __new) {
+  __copy_symlink(__existing, __new);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+copy_symlink(const path& __ext, const path& __new, error_code& __ec) noexcept {
+  __copy_symlink(__ext, __new, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) {
+  return __create_directories(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p,
+                                                         error_code& __ec) {
+  return __create_directories(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) {
+  return __create_directory(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+create_directory(const path& __p, error_code& __ec) noexcept {
+  return __create_directory(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p,
+                                                       const path& __attrs) {
+  return __create_directory(__p, __attrs);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+create_directory(const path& __p, const path& __attrs,
+                 error_code& __ec) noexcept {
+  return __create_directory(__p, __attrs, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+create_directory_symlink(const path& __to, const path& __new) {
+  __create_directory_symlink(__to, __new);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+create_directory_symlink(const path& __to, const path& __new,
+                         error_code& __ec) noexcept {
+  __create_directory_symlink(__to, __new, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __to,
+                                                       const path& __new) {
+  __create_hard_link(__to, __new);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+create_hard_link(const path& __to, const path& __new,
+                 error_code& __ec) noexcept {
+  __create_hard_link(__to, __new, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __to,
+                                                     const path& __new) {
+  __create_symlink(__to, __new);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+create_symlink(const path& __to, const path& __new, error_code& __ec) noexcept {
+  return __create_symlink(__to, __new, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept {
+  return __s.type() != file_type::none;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept {
+  return status_known(__s) && __s.type() != file_type::not_found;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) {
+  return exists(__status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p,
+                                             error_code& __ec) noexcept {
+  auto __s = __status(__p, &__ec);
+  if (status_known(__s))
+    __ec.clear();
+  return exists(__s);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1,
+                                                 const path& __p2) {
+  return __equivalent(__p1, __p2);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept {
+  return __equivalent(__p1, __p2, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) {
+  return __file_size(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY uintmax_t
+file_size(const path& __p, error_code& __ec) noexcept {
+  return __file_size(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) {
+  return __hard_link_count(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY uintmax_t
+hard_link_count(const path& __p, error_code& __ec) noexcept {
+  return __hard_link_count(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept {
+  return __s.type() == file_type::block;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) {
+  return is_block_file(__status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p,
+                                                    error_code& __ec) noexcept {
+  return is_block_file(__status(__p, &__ec));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+is_character_file(file_status __s) noexcept {
+  return __s.type() == file_type::character;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) {
+  return is_character_file(__status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+is_character_file(const path& __p, error_code& __ec) noexcept {
+  return is_character_file(__status(__p, &__ec));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept {
+  return __s.type() == file_type::directory;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) {
+  return is_directory(__status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p,
+                                                   error_code& __ec) noexcept {
+  return is_directory(__status(__p, &__ec));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) {
+  return __fs_is_empty(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p,
+                                               error_code& __ec) {
+  return __fs_is_empty(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept {
+  return __s.type() == file_type::fifo;
+}
+inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) {
+  return is_fifo(__status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p,
+                                              error_code& __ec) noexcept {
+  return is_fifo(__status(__p, &__ec));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+is_regular_file(file_status __s) noexcept {
+  return __s.type() == file_type::regular;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) {
+  return is_regular_file(__status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool
+is_regular_file(const path& __p, error_code& __ec) noexcept {
+  return is_regular_file(__status(__p, &__ec));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept {
+  return __s.type() == file_type::socket;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) {
+  return is_socket(__status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p,
+                                                error_code& __ec) noexcept {
+  return is_socket(__status(__p, &__ec));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept {
+  return __s.type() == file_type::symlink;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) {
+  return is_symlink(__symlink_status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p,
+                                                 error_code& __ec) noexcept {
+  return is_symlink(__symlink_status(__p, &__ec));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept {
+  return exists(__s) && !is_regular_file(__s) && !is_directory(__s) &&
+         !is_symlink(__s);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) {
+  return is_other(__status(__p));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p,
+                                               error_code& __ec) noexcept {
+  return is_other(__status(__p, &__ec));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY file_time_type
+last_write_time(const path& __p) {
+  return __last_write_time(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY file_time_type
+last_write_time(const path& __p, error_code& __ec) noexcept {
+  return __last_write_time(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p,
+                                                      file_time_type __t) {
+  __last_write_time(__p, __t);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+last_write_time(const path& __p, file_time_type __t,
+                error_code& __ec) noexcept {
+  __last_write_time(__p, __t, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+permissions(const path& __p, perms __prms,
+            perm_options __opts = perm_options::replace) {
+  __permissions(__p, __prms, __opts);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms,
+                                                  error_code& __ec) noexcept {
+  __permissions(__p, __prms, perm_options::replace, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms,
+                                                  perm_options __opts,
+                                                  error_code& __ec) {
+  __permissions(__p, __prms, __opts, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p,
+                                                const path& __base,
+                                                error_code& __ec) {
+  path __tmp = __weakly_canonical(__p, &__ec);
+  if (__ec)
+    return {};
+  path __tmp_base = __weakly_canonical(__base, &__ec);
+  if (__ec)
+    return {};
+  return __tmp.lexically_proximate(__tmp_base);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p,
+                                                error_code& __ec) {
+  return proximate(__p, current_path(), __ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path
+proximate(const path& __p, const path& __base = current_path()) {
+  return __weakly_canonical(__p).lexically_proximate(
+      __weakly_canonical(__base));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) {
+  return __read_symlink(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p,
+                                                   error_code& __ec) {
+  return __read_symlink(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p,
+                                               const path& __base,
+                                               error_code& __ec) {
+  path __tmp = __weakly_canonical(__p, &__ec);
+  if (__ec)
+    return path();
+  path __tmpbase = __weakly_canonical(__base, &__ec);
+  if (__ec)
+    return path();
+  return __tmp.lexically_relative(__tmpbase);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p,
+                                               error_code& __ec) {
+  return relative(__p, current_path(), __ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path
+relative(const path& __p, const path& __base = current_path()) {
+  return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) {
+  return __remove(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p,
+                                             error_code& __ec) noexcept {
+  return __remove(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) {
+  return __remove_all(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p,
+                                                      error_code& __ec) {
+  return __remove_all(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from,
+                                             const path& __to) {
+  return __rename(__from, __to);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+rename(const path& __from, const path& __to, error_code& __ec) noexcept {
+  return __rename(__from, __to, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p,
+                                                  uintmax_t __ns) {
+  return __resize_file(__p, __ns);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void
+resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept {
+  return __resize_file(__p, __ns, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) {
+  return __space(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p,
+                                                  error_code& __ec) noexcept {
+  return __space(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) {
+  return __status(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p,
+                                                    error_code& __ec) noexcept {
+  return __status(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) {
+  return __symlink_status(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY file_status
+symlink_status(const path& __p, error_code& __ec) noexcept {
+  return __symlink_status(__p, &__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() {
+  return __temp_directory_path();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) {
+  return __temp_directory_path(&__ec);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) {
+  return __weakly_canonical(__p);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p,
+                                                       error_code& __ec) {
+  return __weakly_canonical(__p, &__ec);
+}
+
+class directory_iterator;
+class recursive_directory_iterator;
+class __dir_stream;
+
+class directory_entry {
+  typedef _VSTD_FS::path _Path;
+
+public:
+  // constructors and destructors
+  directory_entry() noexcept = default;
+  directory_entry(directory_entry const&) = default;
+  directory_entry(directory_entry&&) noexcept = default;
+
+  _LIBCPP_INLINE_VISIBILITY
+  explicit directory_entry(_Path const& __p) : __p_(__p) {
+    error_code __ec;
+    __refresh(&__ec);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  directory_entry(_Path const& __p, error_code& __ec) : __p_(__p) {
+    __refresh(&__ec);
+  }
+
+  ~directory_entry() {}
+
+  directory_entry& operator=(directory_entry const&) = default;
+  directory_entry& operator=(directory_entry&&) noexcept = default;
+
+  _LIBCPP_INLINE_VISIBILITY
+  void assign(_Path const& __p) {
+    __p_ = __p;
+    error_code __ec;
+    __refresh(&__ec);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  void assign(_Path const& __p, error_code& __ec) {
+    __p_ = __p;
+    __refresh(&__ec);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  void replace_filename(_Path const& __p) {
+    __p_.replace_filename(__p);
+    error_code __ec;
+    __refresh(&__ec);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  void replace_filename(_Path const& __p, error_code& __ec) {
+    __p_ = __p_.parent_path() / __p;
+    __refresh(&__ec);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  void refresh() { __refresh(); }
+
+  _LIBCPP_INLINE_VISIBILITY
+  void refresh(error_code& __ec) noexcept { __refresh(&__ec); }
+
+  _LIBCPP_INLINE_VISIBILITY
+  _Path const& path() const noexcept { return __p_; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  operator const _Path&() const noexcept { return __p_; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool exists() const { return _VSTD_FS::exists(file_status{__get_ft()}); }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool exists(error_code& __ec) const noexcept {
+    return _VSTD_FS::exists(file_status{__get_ft(&__ec)});
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_block_file() const { return __get_ft() == file_type::block; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_block_file(error_code& __ec) const noexcept {
+    return __get_ft(&__ec) == file_type::block;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_character_file() const { return __get_ft() == file_type::character; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_character_file(error_code& __ec) const noexcept {
+    return __get_ft(&__ec) == file_type::character;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_directory() const { return __get_ft() == file_type::directory; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_directory(error_code& __ec) const noexcept {
+    return __get_ft(&__ec) == file_type::directory;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_fifo() const { return __get_ft() == file_type::fifo; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_fifo(error_code& __ec) const noexcept {
+    return __get_ft(&__ec) == file_type::fifo;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_other() const { return _VSTD_FS::is_other(file_status{__get_ft()}); }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_other(error_code& __ec) const noexcept {
+    return _VSTD_FS::is_other(file_status{__get_ft(&__ec)});
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_regular_file() const { return __get_ft() == file_type::regular; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_regular_file(error_code& __ec) const noexcept {
+    return __get_ft(&__ec) == file_type::regular;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_socket() const { return __get_ft() == file_type::socket; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_socket(error_code& __ec) const noexcept {
+    return __get_ft(&__ec) == file_type::socket;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_symlink() const { return __get_sym_ft() == file_type::symlink; }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool is_symlink(error_code& __ec) const noexcept {
+    return __get_sym_ft(&__ec) == file_type::symlink;
+  }
+  _LIBCPP_INLINE_VISIBILITY
+  uintmax_t file_size() const { return __get_size(); }
+
+  _LIBCPP_INLINE_VISIBILITY
+  uintmax_t file_size(error_code& __ec) const noexcept {
+    return __get_size(&__ec);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  uintmax_t hard_link_count() const { return __get_nlink(); }
+
+  _LIBCPP_INLINE_VISIBILITY
+  uintmax_t hard_link_count(error_code& __ec) const noexcept {
+    return __get_nlink(&__ec);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  file_time_type last_write_time() const { return __get_write_time(); }
+
+  _LIBCPP_INLINE_VISIBILITY
+  file_time_type last_write_time(error_code& __ec) const noexcept {
+    return __get_write_time(&__ec);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  file_status status() const { return __get_status(); }
+
+  _LIBCPP_INLINE_VISIBILITY
+  file_status status(error_code& __ec) const noexcept {
+    return __get_status(&__ec);
+  }
+
+ &n