diff --git a/AUTHORS b/AUTHORS
index f5cac4a6f7294..2a60562617d80 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -247,4 +247,5 @@ a license to everyone to use it as detailed in LICENSE.)
 * Andrey Burov <burik666@gmail.com>
 * Holland Schutte <hgschutte1@gmail.com>
 * Kerby Geffrard <kerby.geffrard@gmail.com>
-
+* cynecx <me@cynecx.net>
+* Chris Gibson <cgibson@mrvoxel.com>
diff --git a/ChangeLog.markdown b/ChangeLog.markdown
index 46c8184cd6034..4fbcf75d08a1e 100644
--- a/ChangeLog.markdown
+++ b/ChangeLog.markdown
@@ -381,6 +381,7 @@ v1.34.8: 9/9/2015
  - Update emrun to latest, which improves unit test run automation with emrun.
  - Added support for LZ4 compressing file packages, used with the -s LZ4=1 linker flag. (#3754)
  - Fixed noisy build warning on "unexpected number of arguments in call to strtold" (#3760)
+ - Added new linker flag --separate-asm that splits the asm.js module and the handwritten JS functions to separate files.
  - Full list of changes:
     - Emscripten: https://github.com/kripken/emscripten/compare/1.34.7...1.34.8
     - Emscripten-LLVM: no changes.
diff --git a/embuilder.py b/embuilder.py
index e5227d0b8d761..6ac56fd998c11 100755
--- a/embuilder.py
+++ b/embuilder.py
@@ -34,6 +34,7 @@
         libcxxabi
         gl
         native_optimizer
+        binaryen
         bullet
         freetype
         libpng
@@ -81,7 +82,7 @@ def build_port(port_name, lib_name, params):
 if operation == 'build':
   tasks = sys.argv[2:]
   if 'ALL' in tasks:
-    tasks = ['libc', 'libc-mt', 'dlmalloc', 'dlmalloc_threadsafe', 'pthreads', 'libcxx', 'libcxx_noexcept', 'libcxxabi', 'gl', 'bullet', 'freetype', 'libpng', 'ogg', 'sdl2', 'sdl2-image', 'sdl2-ttf', 'sdl2-net', 'vorbis', 'zlib']
+    tasks = ['libc', 'libc-mt', 'dlmalloc', 'dlmalloc_threadsafe', 'pthreads', 'libcxx', 'libcxx_noexcept', 'libcxxabi', 'gl', 'binaryen', 'bullet', 'freetype', 'libpng', 'ogg', 'sdl2', 'sdl2-image', 'sdl2-ttf', 'sdl2-net', 'vorbis', 'zlib']
     if os.environ.get('EMSCRIPTEN_NATIVE_OPTIMIZER'):
       print 'Skipping building of native-optimizer since environment variable EMSCRIPTEN_NATIVE_OPTIMIZER is present and set to point to a prebuilt native optimizer path.'
     elif hasattr(shared, 'EMSCRIPTEN_NATIVE_OPTIMIZER'):
diff --git a/emcc.py b/emcc.py
index 11aa60efe46ab..297b9db809b98 100755
--- a/emcc.py
+++ b/emcc.py
@@ -482,6 +482,24 @@ def validate_arg_level(level_string, max_level, err_msg):
         raise Exception(err_msg)
       return level
 
+    def detect_fixed_language_mode(args):
+      check_next = False
+      for item in args:
+        if check_next:
+          if item in ("c++", "c"):
+            return True
+          else:
+            check_next = False
+        if item.startswith("-x"):
+          lmode = item[2:] if len(item) > 2 else None
+          if lmode in ("c++", "c"):
+            return True
+          else:
+            check_next = True
+            continue
+      return False
+
+    has_fixed_language_mode = detect_fixed_language_mode(newargs)
     should_exit = False
 
     for i in range(len(newargs)):
@@ -822,8 +840,13 @@ def validate_arg_level(level_string, max_level, err_msg):
               logging.error(arg + ': Unknown format, not a static library!')
             exit(1)
         else:
-          logging.error(arg + ": Input file has an unknown suffix, don't know what to do with it!")
-          exit(1)
+          if has_fixed_language_mode:
+            newargs[i] = ''
+            input_files.append((i, arg))
+            has_source_inputs = True
+          else:
+            logging.error(arg + ": Input file has an unknown suffix, don't know what to do with it!")
+            exit(1)
       elif arg.startswith('-L'):
         lib_dirs.append(arg[2:])
         newargs[i] = ''
@@ -1219,19 +1242,22 @@ def get_bitcode_args(input_files):
       logging.debug(('just preprocessor ' if '-E' in newargs else 'just dependencies: ') + ' '.join(cmd))
       exit(subprocess.call(cmd))
 
+    def compile_source_file(i, input_file):
+      logging.debug('compiling source file: ' + input_file)
+      output_file = get_bitcode_file(input_file)
+      temp_files.append((i, output_file))
+      args = get_bitcode_args([input_file]) + ['-emit-llvm', '-c', '-o', output_file]
+      logging.debug("running: " + ' '.join(args))
+      execute(args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
+      if not os.path.exists(output_file):
+        logging.error('compiler frontend failed to generate LLVM bitcode, halting')
+        sys.exit(1)
+
     # First, generate LLVM bitcode. For each input file, we get base.o with bitcode
     for i, input_file in input_files:
       file_ending = filename_type_ending(input_file)
       if file_ending.endswith(SOURCE_ENDINGS):
-        logging.debug('compiling source file: ' + input_file)
-        output_file = get_bitcode_file(input_file)
-        temp_files.append((i, output_file))
-        args = get_bitcode_args([input_file]) + ['-emit-llvm', '-c', '-o', output_file]
-        logging.debug("running: " + ' '.join(args))
-        execute(args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
-        if not os.path.exists(output_file):
-          logging.error('compiler frontend failed to generate LLVM bitcode, halting')
-          sys.exit(1)
+        compile_source_file(i, input_file)
       else: # bitcode
         if file_ending.endswith(BITCODE_ENDINGS):
           logging.debug('using bitcode file: ' + input_file)
@@ -1246,8 +1272,11 @@ def get_bitcode_args(input_files):
             shared.Building.llvm_as(input_file, temp_file)
             temp_files.append((i, temp_file))
         else:
-          logging.error(input_file + ': Unknown file suffix when compiling to LLVM bitcode!')
-          sys.exit(1)
+          if has_fixed_language_mode:
+            compile_source_file(i, input_file)
+          else:
+            logging.error(input_file + ': Unknown file suffix when compiling to LLVM bitcode!')
+            sys.exit(1)
 
     log_time('bitcodeize inputs')
 
diff --git a/emrun b/emrun
index 6cb3db8addd3b..396cdfdff4df2 100755
--- a/emrun
+++ b/emrun
@@ -243,6 +243,10 @@ user_pref("extensions.getAddons.cache.lastUpdate", 4102437600);
 user_pref("media.gmp-eme-adobe.lastUpdate", 4102437600);
 user_pref("media.gmp-gmpopenh264.lastUpdate", 4102437600);
 user_pref("datareporting.healthreport.nextDataSubmissionTime", 4102437600439);
+// Detect directly when executing if asm.js does not validate by throwing an error.
+user_pref("javascript.options.throw_on_asmjs_validation_failure", true);
+// Throw errors on all JS engine warnings for "strict" mode execution.
+user_pref("javascript.options.werror", true);
 ''')
   f.close()
   logv('create_emrun_safe_firefox_profile: Created new Firefox profile "' + temp_firefox_profile_dir + '"')
@@ -442,13 +446,26 @@ class HTTPHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
       else:
         # Manually implement directory listing support.
         return self.list_directory(path)
-    ctype = self.guess_type(path)
+
     try:
       f = open(path, 'rb')
     except IOError:
       self.send_error(404, "File not found: " + path)
       return None
     self.send_response(200)
+    guess_file_type = path
+    # All files of type x.gz are served as gzip-compressed, which means the browser will transparently decode the file before passing the uncompressed bytes to the JS page.
+    # Note: In a slightly silly manner, detect files ending with "gz" and not ".gz", since both Unity and UE4 generate multiple files with .jsgz, .datagz, .memgz, .symbolsgz suffixes and so on,
+    #       so everything goes.
+    # Note 2: If the JS application would like to receive the actual bits of a gzipped file, instead of having the browser decompress it immediately, then it can't use the suffix .gz when using emrun.
+    #         To work around, one can use the suffix .gzip instead.
+    if self.headers.has_key('Accept-Encoding') and 'gzip' in self.headers['Accept-Encoding'] and path.lower().endswith('gz'):
+      self.send_header('Content-Encoding', 'gzip')
+      logv('Serving ' + path + ' as gzip-compressed.')
+      guess_file_type = guess_file_type[:-2]
+      if guess_file_type.endswith('.'): guess_file_type = guess_file_type[:-1]
+
+    ctype = self.guess_type(guess_file_type)
     self.send_header("Content-type", ctype)
     fs = os.fstat(f.fileno())
     self.send_header("Content-Length", str(fs[6]))
@@ -1103,7 +1120,10 @@ def main():
   url = 'http://' + server_root + ':' + str(options.port)+'/'+url
   
   os.chdir(serve_dir)
-  logv('Web server root directory: ' + os.path.abspath('.'))
+  if options.no_browser:
+    logi('Web server root directory: ' + os.path.abspath('.'))
+  else:
+    logv('Web server root directory: ' + os.path.abspath('.'))
 
   if options.android:
     if not options.no_browser:
@@ -1236,6 +1256,8 @@ def main():
     # For Android automation, we execute adb, so this process does not represent a browser and no point killing it.
     if options.android:
       browser_process = None
+  else:
+    logi('Now listening at http://localhost:' + str(options.port) + '/')
 
   if browser_process:
     premature_quit_code = browser_process.poll()
diff --git a/emscripten-version.txt b/emscripten-version.txt
index fdd5c62a3bd55..dd62092ad711e 100644
--- a/emscripten-version.txt
+++ b/emscripten-version.txt
@@ -1,2 +1,2 @@
-"1.36.3"
+"1.36.4"
 
diff --git a/site/build/text/docs/api_reference/emscripten.h.txt b/site/build/text/docs/api_reference/emscripten.h.txt
index e4bf2f16c3431..1df8e81c3acda 100644
--- a/site/build/text/docs/api_reference/emscripten.h.txt
+++ b/site/build/text/docs/api_reference/emscripten.h.txt
@@ -911,7 +911,7 @@ int emscripten_async_wget2_data(const char* url, const char* requesttype, cons
         callbacks, untouched by the API itself. This may be used by a
         callback to identify the associated call.
 
-      * **int free** (*const*) -- Tells the runtime whether to free
+      * **free** (*int*) -- Tells the runtime whether to free
         the returned buffer after "onload" is complete. If "false"
         freeing the buffer is the receiver's responsibility.
 
@@ -1076,7 +1076,7 @@ void emscripten_idb_async_store(const char *db_name, const char *file_id, void*
         callbacks, untouched by the API itself. This may be used by a
         callback to identify the associated call.
 
-      * **onload** (*em_async_wget_onload_func*) --
+      * **onload** (*em_arg_callback_func*) --
 
         Callback on successful load of the URL into the buffer. The
         callback function parameter values are:
@@ -1119,7 +1119,7 @@ void emscripten_idb_async_delete(const char *db_name, const char *file_id, voi
 
         * *(void*)* : Equal to "arg" (user defined data).
 
-void emscripten_idb_async_exists(const char *db_name, const char *file_id, void* arg, em_arg_callback_func oncheck, em_arg_callback_func onerror)
+void emscripten_idb_async_exists(const char *db_name, const char *file_id, void* arg, em_idb_exists_func oncheck, em_arg_callback_func onerror)
 
    Checks if data with a certain ID exists in the local IndexedDB
    storage asynchronously.
@@ -1136,7 +1136,7 @@ void emscripten_idb_async_exists(const char *db_name, const char *file_id, voi
         callbacks, untouched by the API itself. This may be used by a
         callback to identify the associated call.
 
-      * **oncheck** (*em_arg_callback_func*) --
+      * **oncheck** (*em_idb_exists_func*) --
 
         Callback on successful check, with arguments
 
@@ -1652,7 +1652,7 @@ em_socket_error_callback
 Functions
 ---------
 
-void emscripten_set_socket_error_callback(void *userData, em_socket_error_callback *callback)
+void emscripten_set_socket_error_callback(void *userData, em_socket_error_callback callback)
 
    Triggered by a "WebSocket" error.
 
@@ -1662,7 +1662,7 @@ void emscripten_set_socket_error_callback(void *userData, em_socket_error_callb
       * **userData** (*void**) -- Arbitrary user data to be passed
         to the callback.
 
-      * **callback** (*em_socket_error_callback**) -- Pointer to a
+      * **callback** (*em_socket_error_callback*) -- Pointer to a
         callback function. The callback returns a file descriptor,
         error code and message, and the arbitrary "userData" passed to
         this function.
diff --git a/site/build/text/docs/api_reference/html5.h.txt b/site/build/text/docs/api_reference/html5.h.txt
index 2879d27a57cb8..4707e163e051d 100644
--- a/site/build/text/docs/api_reference/html5.h.txt
+++ b/site/build/text/docs/api_reference/html5.h.txt
@@ -2717,7 +2717,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_create_context(const char *tar
         which to initialize the WebGL context. If 0 is passed, the
         element specified by "Module.canvas" will be used.
 
-      * **attributes** (*EmscriptenWebGLContextAttributes**) -- The
+      * **attributes** (*const EmscriptenWebGLContextAttributes**) -- The
         attributes of the requested context version.
 
    Returns:
diff --git a/site/source/docs/api_reference/emscripten.h.rst b/site/source/docs/api_reference/emscripten.h.rst
index c453506db4f3a..c43e1edf1b11a 100644
--- a/site/source/docs/api_reference/emscripten.h.rst
+++ b/site/source/docs/api_reference/emscripten.h.rst
@@ -550,8 +550,8 @@ Functions
 	:param param: Request parameters for POST requests (see ``requesttype``). The parameters are specified in the same way as they would be in the URL for an equivalent GET request: e.g. ``key=value&key2=value2``.
 	:type param: const char*
 	:param void* arg: User-defined data that is passed to the callbacks, untouched by the API itself. This may be used by a callback to identify the associated call.
-	:param const int free: Tells the runtime whether to free the returned buffer after ``onload`` is complete. If ``false`` freeing the buffer is the receiver's responsibility.
-	:type free: const int
+	:param int free: Tells the runtime whether to free the returned buffer after ``onload`` is complete. If ``false`` freeing the buffer is the receiver's responsibility.
+	:type free: int
 	:param em_async_wget2_data_onload_func onload: Callback on successful load of the file. The callback function parameter values are:
 	
 		- *(void*)* : Equal to ``arg`` (user defined data).
@@ -637,7 +637,7 @@ Emscripten Asynchronous IndexedDB API
 	:param ptr: A pointer to the data to store.
 	:param num: How many bytes to store.
 	:param void* arg: User-defined data that is passed to the callbacks, untouched by the API itself. This may be used by a callback to identify the associated call.
-	:param em_async_wget_onload_func onload: Callback on successful load of the URL into the buffer. The callback function parameter values are:	
+	:param em_arg_callback_func onload: Callback on successful load of the URL into the buffer. The callback function parameter values are:
 	
 		- *(void*)* : Equal to ``arg`` (user defined data).
 	
@@ -662,7 +662,7 @@ Emscripten Asynchronous IndexedDB API
 	
 		- *(void*)* : Equal to ``arg`` (user defined data).
 
-.. c:function:: void emscripten_idb_async_exists(const char *db_name, const char *file_id, void* arg, em_arg_callback_func oncheck, em_arg_callback_func onerror)
+.. c:function:: void emscripten_idb_async_exists(const char *db_name, const char *file_id, void* arg, em_idb_exists_func oncheck, em_arg_callback_func onerror)
 		 
 	Checks if data with a certain ID exists in the local IndexedDB storage asynchronously.
 	
@@ -671,7 +671,7 @@ Emscripten Asynchronous IndexedDB API
 	:param db_name: The IndexedDB database.
 	:param file_id: The identifier of the data.
 	:param void* arg: User-defined data that is passed to the callbacks, untouched by the API itself. This may be used by a callback to identify the associated call.
-	:param em_arg_callback_func oncheck: Callback on successful check, with arguments
+	:param em_idb_exists_func oncheck: Callback on successful check, with arguments
 
 		- *(void*)* : Equal to ``arg`` (user defined data).
 		- *int* : Whether the file exists or not.
@@ -998,14 +998,14 @@ Callback functions
 Functions
 ---------
 
-.. c:function:: void emscripten_set_socket_error_callback(void *userData, em_socket_error_callback *callback)
+.. c:function:: void emscripten_set_socket_error_callback(void *userData, em_socket_error_callback callback)
 
 	Triggered by a ``WebSocket`` error. 
 	
 	See :ref:`emscripten-api-reference-sockets` for more information.
 	
 	:param void* userData: Arbitrary user data to be passed to the callback.
-	:param em_socket_error_callback* callback: Pointer to a callback function. The callback returns a file descriptor, error code and message, and the arbitrary ``userData`` passed to this function.
+	:param em_socket_error_callback callback: Pointer to a callback function. The callback returns a file descriptor, error code and message, and the arbitrary ``userData`` passed to this function.
 
 
 .. c:function:: void emscripten_set_socket_open_callback(void *userData, em_socket_callback callback)
diff --git a/site/source/docs/api_reference/html5.h.rst b/site/source/docs/api_reference/html5.h.rst
index 6da3a8b91fecf..d3a8e5a179956 100644
--- a/site/source/docs/api_reference/html5.h.rst
+++ b/site/source/docs/api_reference/html5.h.rst
@@ -1977,7 +1977,7 @@ Functions
 	:param target: The DOM canvas element in which to initialize the WebGL context. If 0 is passed, the element specified by ``Module.canvas`` will be used.
 	:type target: const char*
 	:param attributes: The attributes of the requested context version.
-	:type attributes: EmscriptenWebGLContextAttributes*
+	:type attributes: const EmscriptenWebGLContextAttributes*
 	:returns: On success, a strictly positive value that represents a handle to the created context. On failure, a negative number that can be cast to an |EMSCRIPTEN_RESULT| field to get the reason why the context creation failed.
 	:rtype: |EMSCRIPTEN_WEBGL_CONTEXT_HANDLE|
 
diff --git a/site/source/docs/api_reference/trace.h.rst b/site/source/docs/api_reference/trace.h.rst
index a1026ab6f756a..a42730516ba26 100644
--- a/site/source/docs/api_reference/trace.h.rst
+++ b/site/source/docs/api_reference/trace.h.rst
@@ -404,7 +404,7 @@ Functions
 .. c:function:: void emscripten_trace_record_allocation(const void *address, int32_t size)
 
    :param address: Memory address which has been allocated.
-   :type address: void*
+   :type address: const void*
    :param size: Size of the memory block allocated.
    :type size: int32_t
    :rtype: void
@@ -417,9 +417,9 @@ Functions
 .. c:function:: void emscripten_trace_record_reallocation(const void *old_address, const void *new_address, int32_t size)
 
    :param old_address: Old address of the memory block which has been reallocated.
-   :type old_address: void*
+   :type old_address: const void*
    :param new_address: New address of the memory block which has been reallocated.
-   :type new_address: void*
+   :type new_address: const void*
    :param size: New size of the memory block reallocated.
    :type size: int32_t
    :rtype: void
@@ -432,7 +432,7 @@ Functions
 .. c:function:: void emscripten_trace_record_free(const void *address)
 
    :param address: Memory address which is being freed.
-   :type address: void*
+   :type address: const void*
    :rtype: void
 
    This must be called for each and every ``free`` operation. The best place
@@ -446,7 +446,7 @@ Functions
 .. c:function:: void emscripten_trace_annotate_address_type(const void *address, const char *type)
 
    :param address: Memory address which should be annotated.
-   :type address: void*
+   :type address: const void*
    :param type: The name of the data type being allocated.
    :type type: const char*
    :rtype: void
@@ -458,7 +458,7 @@ Functions
 .. c:function:: void emscripten_trace_associate_storage_size(const void *address, int32_t size)
 
    :param address: Memory address which should be annotated.
-   :type address: void*
+   :type address: const void*
    :param size: Size of the memory associated with this allocation.
    :type type: int32_t
    :rtype: void
diff --git a/src/cpuprofiler.js b/src/cpuprofiler.js
index 5521b2d16e7c3..88c4b4cc182db 100644
--- a/src/cpuprofiler.js
+++ b/src/cpuprofiler.js
@@ -43,8 +43,11 @@ var emscriptenCpuProfiler = {
   fpsCounter: function fpsCounter() {
     // Record the new frame time sample, and prune the history to 120 most recent frames.
     var now = performance.now();
-    this.fpsCounterTicks.push(now);
-    if (this.fpsCounterTicks.length > 120) this.fpsCounterTicks = this.fpsCounterTicks.slice(this.fpsCounterTicks.length - 120, this.fpsCounterTicks.length);
+    if (this.fpsCounterTicks.length < 120) this.fpsCounterTicks.push(now);
+    else {
+      for (var i = 0; i < this.fpsCounterTicks.length-1; ++i) this.fpsCounterTicks[i] = this.fpsCounterTicks[i+1];
+      this.fpsCounterTicks[this.fpsCounterTicks.length-1] = now;
+    }
   
     if (now - this.fpsCounterLastPrint > 2000) {
       var fps = ((this.fpsCounterTicks.length - 1) * 1000.0 / (this.fpsCounterTicks[this.fpsCounterTicks.length - 1] - this.fpsCounterTicks[0]));
@@ -83,6 +86,7 @@ var emscriptenCpuProfiler = {
 
   // Creates a new section. Call once at startup.
   createSection: function createSection(number, name, drawColor) {
+    while (this.sections.length <= number) this.sections.push(null); // Keep an array structure.
     var sect = this.sections[number];
     if (!sect) {
       sect = {
@@ -124,7 +128,7 @@ var emscriptenCpuProfiler = {
   frameEnd: function frameEnd() {
     // Aggregate total times spent in each section to memory store to wait until the next stats UI redraw period.
     var totalTimeInSections = 0;
-    for (var i in this.sections) {
+    for(var i = 0; i < this.sections.length; ++i) {
       var sect = this.sections[i];
       sect.frametimes[this.currentHistogramX] = sect.accumulatedTime;
       totalTimeInSections += sect.accumulatedTime;
@@ -153,9 +157,12 @@ var emscriptenCpuProfiler = {
     // you can manually create this beforehand.
     cpuprofiler = document.getElementById('cpuprofiler');
     if (!cpuprofiler) {
-      var div = document.createElement("div");
+      var div = document.getElementById('cpuprofiler_container'); // Users can provide a container element where to place this if desired.
+      if (!div) {
+        div = document.createElement("div");
+        document.body.appendChild(div);
+      }      
       div.innerHTML = "<div style='border: 2px solid black; padding: 2px;'><button style='display:inline;' onclick='Module.noExitRuntime=false;Module.exit();'>Halt</button><span id='fpsResult'></span><canvas style='border: 1px solid black; margin-left:auto; margin-right:auto; display: block;' id='cpuprofiler_canvas' width='800px' height='200'></canvas><div id='cpuprofiler'></div>";
-      document.body.appendChild(div);
       cpuprofiler = document.getElementById('cpuprofiler');
     }
     
@@ -205,7 +212,7 @@ var emscriptenCpuProfiler = {
     y -= h;
     this.drawContext.fillStyle = "#0000BB";
     this.drawContext.fillRect(x, y, 1, h);
-    for (var i in this.sections) {
+    for(var i = 0; i < this.sections.length; ++i) {
       var sect = this.sections[i];
       var h = sect.frametimes[x] * scale;
       y -= h;
diff --git a/src/library.js b/src/library.js
index 9917fc79862f1..7b21ac415b687 100644
--- a/src/library.js
+++ b/src/library.js
@@ -3992,8 +3992,10 @@ LibraryManager.library = {
     return 0; // we cannot succeed
   },
 
+  _Unwind_RaiseException__deps: ['__cxa_throw'],
   _Unwind_RaiseException: function(ex) {
-    abort('Unwind_RaiseException');
+    Module.printErr('Warning: _Unwind_RaiseException is not correctly implemented');
+    return ___cxa_throw(ex, 0, 0);
   },
 
   _Unwind_DeleteException: function(ex) {
diff --git a/src/library_gl.js b/src/library_gl.js
index 347987ff649af..3e6d4f0b34f50 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1065,45 +1065,55 @@ var LibraryGL = {
         numChannels = 2;
         break;
       case 0x1907 /* GL_RGB */:
+      case 0x8C40 /* GL_SRGB_EXT */:
 #if USE_WEBGL2
       case 0x8D98 /* GL_RGB_INTEGER */:
 #endif
-      case 0x8C40 /* GL_SRGB_EXT */:
         numChannels = 3;
         break;
       case 0x1908 /* GL_RGBA */:
+      case 0x8C42 /* GL_SRGB_ALPHA_EXT */:
 #if USE_WEBGL2
       case 0x8D99 /* GL_RGBA_INTEGER */:
 #endif
-      case 0x8C42 /* GL_SRGB_ALPHA_EXT */:
         numChannels = 4;
         break;
       default:
         GL.recordError(0x0500); // GL_INVALID_ENUM
 #if GL_ASSERTIONS
-        Module.printErr('GL_INVALID_ENUM due to unknown format in getTexPixelData, type: ' + type + ', format: ' + format);
+        Module.printErr('GL_INVALID_ENUM due to unknown format in glTex[Sub]Image/glReadPixels, format: ' + format);
 #endif
-        return {
-          pixels: null,
-          internalFormat: 0x0
-        };
+        return null;
     }
     switch (type) {
       case 0x1401 /* GL_UNSIGNED_BYTE */:
+#if USE_WEBGL2
+      case 0x1400 /* GL_BYTE */:
+#endif
         sizePerPixel = numChannels*1;
         break;
       case 0x1403 /* GL_UNSIGNED_SHORT */:
+      case 0x8D61 /* GL_HALF_FLOAT_OES */:
 #if USE_WEBGL2
       case 0x140B /* GL_HALF_FLOAT */:
+      case 0x1402 /* GL_SHORT */:
 #endif
-      case 0x8D61 /* GL_HALF_FLOAT_OES */:
         sizePerPixel = numChannels*2;
         break;
       case 0x1405 /* GL_UNSIGNED_INT */:
       case 0x1406 /* GL_FLOAT */:
+#if USE_WEBGL2
+      case 0x1404 /* GL_INT */:
+#endif
         sizePerPixel = numChannels*4;
         break;
-      case 0x84FA /* UNSIGNED_INT_24_8_WEBGL/UNSIGNED_INT_24_8 */:
+      case 0x84FA /* GL_UNSIGNED_INT_24_8_WEBGL/GL_UNSIGNED_INT_24_8 */:
+#if USE_WEBGL2
+      case 0x8C3E /* GL_UNSIGNED_INT_5_9_9_9_REV */:
+      case 0x8368 /* GL_UNSIGNED_INT_2_10_10_10_REV */:
+      case 0x8C3B /* GL_UNSIGNED_INT_10F_11F_11F_REV */:
+      case 0x84FA /* GL_UNSIGNED_INT_24_8 */:
+#endif
         sizePerPixel = 4;
         break;
       case 0x8363 /* GL_UNSIGNED_SHORT_5_6_5 */:
@@ -1116,74 +1126,94 @@ var LibraryGL = {
 #if GL_ASSERTIONS
         Module.printErr('GL_INVALID_ENUM in glTex[Sub]Image/glReadPixels, type: ' + type + ', format: ' + format);
 #endif
-        return {
-          pixels: null,
-          internalFormat: 0x0
-        };
+        return null;
     }
     var bytes = emscriptenWebGLComputeImageSize(width, height, sizePerPixel, GL.unpackAlignment);
-    if (type == 0x1401 /* GL_UNSIGNED_BYTE */) {
-      pixels = {{{ makeHEAPView('U8', 'pixels', 'pixels+bytes') }}};
-    } else if (type == 0x1406 /* GL_FLOAT */) {
+    switch(type) {
+#if USE_WEBGL2
+      case 0x1400 /* GL_BYTE */:
+        return {{{ makeHEAPView('8', 'pixels', 'pixels+bytes') }}};
+#endif
+      case 0x1401 /* GL_UNSIGNED_BYTE */:
+        return {{{ makeHEAPView('U8', 'pixels', 'pixels+bytes') }}};
+#if USE_WEBGL2
+      case 0x1402 /* GL_SHORT */:
 #if GL_ASSERTIONS
-      assert((pixels & 3) == 0, 'Pointer to float data passed to texture get function must be aligned to four bytes!');
+        assert((pixels & 1) == 0, 'Pointer to int16 data passed to texture get function must be aligned to two bytes!');
 #endif
-      pixels = {{{ makeHEAPView('F32', 'pixels', 'pixels+bytes') }}};
-    } else if (type == 0x1405 /* GL_UNSIGNED_INT */ || type == 0x84FA /* UNSIGNED_INT_24_8_WEBGL */) {
+        return {{{ makeHEAPView('16', 'pixels', 'pixels+bytes') }}};
+      case 0x1404 /* GL_INT */:
 #if GL_ASSERTIONS
-      assert((pixels & 3) == 0, 'Pointer to integer data passed to texture get function must be aligned to four bytes!');
+        assert((pixels & 3) == 0, 'Pointer to integer data passed to texture get function must be aligned to four bytes!');
 #endif
-      pixels = {{{ makeHEAPView('U32', 'pixels', 'pixels+bytes') }}};
-    } else {
+        return {{{ makeHEAPView('32', 'pixels', 'pixels+bytes') }}};
+#endif
+      case 0x1406 /* GL_FLOAT */:
 #if GL_ASSERTIONS
-      assert((pixels & 1) == 0, 'Pointer to int16 data passed to texture get function must be aligned to two bytes!');
+        assert((pixels & 3) == 0, 'Pointer to float data passed to texture get function must be aligned to four bytes!');
 #endif
-      pixels = {{{ makeHEAPView('U16', 'pixels', 'pixels+bytes') }}};
+        return {{{ makeHEAPView('F32', 'pixels', 'pixels+bytes') }}};
+      case 0x1405 /* GL_UNSIGNED_INT */:
+      case 0x84FA /* GL_UNSIGNED_INT_24_8_WEBGL/GL_UNSIGNED_INT_24_8 */:
+#if USE_WEBGL2
+      case 0x8C3E /* GL_UNSIGNED_INT_5_9_9_9_REV */:
+      case 0x8368 /* GL_UNSIGNED_INT_2_10_10_10_REV */:
+      case 0x8C3B /* GL_UNSIGNED_INT_10F_11F_11F_REV */:
+      case 0x84FA /* GL_UNSIGNED_INT_24_8 */:
+#endif
+#if GL_ASSERTIONS
+        assert((pixels & 3) == 0, 'Pointer to integer data passed to texture get function must be aligned to four bytes!');
+#endif
+        return {{{ makeHEAPView('U32', 'pixels', 'pixels+bytes') }}};
+      case 0x1403 /* GL_UNSIGNED_SHORT */:
+      case 0x8363 /* GL_UNSIGNED_SHORT_5_6_5 */:
+      case 0x8033 /* GL_UNSIGNED_SHORT_4_4_4_4 */:
+      case 0x8034 /* GL_UNSIGNED_SHORT_5_5_5_1 */:
+      case 0x8D61 /* GL_HALF_FLOAT_OES */:
+#if USE_WEBGL2
+      case 0x140B /* GL_HALF_FLOAT */:
+#endif
+#if GL_ASSERTIONS
+        assert((pixels & 1) == 0, 'Pointer to int16 data passed to texture get function must be aligned to two bytes!');
+#endif
+        return {{{ makeHEAPView('U16', 'pixels', 'pixels+bytes') }}};
+      default:
+        GL.recordError(0x0500); // GL_INVALID_ENUM
+#if GL_ASSERTIONS
+        Module.printErr('GL_INVALID_ENUM in glTex[Sub]Image/glReadPixels, type: ' + type);
+#endif
+        return null;
     }
-    return {
-      pixels: pixels,
-      internalFormat: internalFormat
-    };
   },
 
   glTexImage2D__sig: 'viiiiiiiii',
   glTexImage2D__deps: ['$emscriptenWebGLGetTexPixelData'],
   glTexImage2D: function(target, level, internalFormat, width, height, border, format, type, pixels) {
-    var pixelData;
-    if (pixels) {
-      var data = emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, internalFormat);
-      pixelData = data.pixels;
-      internalFormat = data.internalFormat;
-    } else {
-      pixelData = null;
-    }
+    var pixelData = null;
+    if (pixels) pixelData = emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, internalFormat);
     GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixelData);
   },
 
   glTexSubImage2D__sig: 'viiiiiiiii',
   glTexSubImage2D__deps: ['$emscriptenWebGLGetTexPixelData'],
   glTexSubImage2D: function(target, level, xoffset, yoffset, width, height, format, type, pixels) {
-    var pixelData;
-    if (pixels) {
-      pixelData = emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, -1).pixels;
-    } else {
-      pixelData = null;
-    }
+    var pixelData = null;
+    if (pixels) pixelData = emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, 0);
     GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixelData);
   },
 
   glReadPixels__sig: 'viiiiiii',
   glReadPixels__deps: ['$emscriptenWebGLGetTexPixelData'],
   glReadPixels: function(x, y, width, height, format, type, pixels) {
-    var data = emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, format);
-    if (!data.pixels) {
+    var pixelData = emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, format);
+    if (!pixelData) {
       GL.recordError(0x0500/*GL_INVALID_ENUM*/);
 #if GL_ASSERTIONS
       Module.printErr('GL_INVALID_ENUM in glReadPixels: Unrecognized combination of type=' + type + ' and format=' + format + '!');
 #endif
       return;
     }
-    GLctx.readPixels(x, y, width, height, format, type, data.pixels);
+    GLctx.readPixels(x, y, width, height, format, type, pixelData);
   },
 
   glBindTexture__sig: 'vii',
diff --git a/src/library_glfw.js b/src/library_glfw.js
index 6ed1ac8e9b0fb..1888550823752 100644
--- a/src/library_glfw.js
+++ b/src/library_glfw.js
@@ -39,6 +39,7 @@ var LibraryGLFW = {
       this.id = id;
       this.x = 0;
       this.y = 0;
+      this.fullscreen = false; // Used to determine if app in fullscreen mode
       this.storedX = 0; // Used to store X before fullscreen
       this.storedY = 0; // Used to store Y before fullscreen
       this.width = width;
@@ -407,6 +408,26 @@ var LibraryGLFW = {
 #endif
     },
 
+    onMouseenter: function(event) {
+      if (!GLFW.active) return;
+
+      if (event.target != Module["canvas"] || !GLFW.active.cursorEnterFunc) return;
+
+#if USE_GLFW == 3
+      Runtime.dynCall('vii', GLFW.active.cursorEnterFunc, [GLFW.active.id, 1]);
+#endif
+    },
+
+    onMouseleave: function(event) {
+      if (!GLFW.active) return;
+
+      if (event.target != Module["canvas"] || !GLFW.active.cursorEnterFunc) return;
+
+#if USE_GLFW == 3
+      Runtime.dynCall('vii', GLFW.active.cursorEnterFunc, [GLFW.active.id, 0]);
+#endif
+    },
+
     onMouseButtonChanged: function(event, status) {
       if (!GLFW.active || !GLFW.active.mouseButtonFunc) return;
 
@@ -480,9 +501,12 @@ var LibraryGLFW = {
       event.preventDefault();
     },
 
-    onFullScreenEventChange: function() {
+    onCanvasResize: function(width, height) {
       if (!GLFW.active) return;
 
+      var resizeNeeded = true;
+
+      // If the client is requestiong fullscreen mode
       if (document["fullScreen"] || document["mozFullScreen"] || document["webkitIsFullScreen"]) {
         GLFW.active.storedX = GLFW.active.x;
         GLFW.active.storedY = GLFW.active.y;
@@ -491,14 +515,37 @@ var LibraryGLFW = {
         GLFW.active.x = GLFW.active.y = 0;
         GLFW.active.width = screen.width;
         GLFW.active.height = screen.height;
-      } else {
+        GLFW.active.fullscreen = true;
+
+      // If the client is reverting from fullscreen mode
+      } else if (GLFW.active.fullscreen == true) {
         GLFW.active.x = GLFW.active.storedX;
         GLFW.active.y = GLFW.active.storedY;
         GLFW.active.width = GLFW.active.storedWidth;
         GLFW.active.height = GLFW.active.storedHeight;
+        GLFW.active.fullscreen = false;
+
+      // If the width/height values do not match current active window sizes
+      } else if (GLFW.active.width != width || GLFW.active.height != height) {
+          GLFW.active.width = width;
+          GLFW.active.height = height;
+      } else {
+        resizeNeeded = false;
       }
 
-      Browser.setCanvasSize(GLFW.active.width, GLFW.active.height, true); // resets the canvas size to counter the aspect preservation of Browser.updateCanvasDimensions
+      // If any of the above conditions were true, we need to resize the canvas
+      if (resizeNeeded) {
+        // resets the canvas size to counter the aspect preservation of Browser.updateCanvasDimensions
+        Browser.setCanvasSize(GLFW.active.width, GLFW.active.height);
+        // TODO: Client dimensions (clientWidth/clientHeight) vs pixel dimensions (width/height) of
+        // the canvas should drive window and framebuffer size respectfully.
+        GLFW.onWindowSizeChanged();
+        GLFW.onFramebufferSizeChanged();
+      }
+    },
+
+    onWindowSizeChanged: function() {
+      if (!GLFW.active) return;
 
       if (!GLFW.active.windowSizeFunc) return;
 
@@ -511,6 +558,16 @@ var LibraryGLFW = {
 #endif
     },
 
+    onFramebufferSizeChanged: function() {
+      if (!GLFW.active) return;
+
+      if (!GLFW.active.framebufferSizeFunc) return;
+
+#if USE_GLFW == 3
+      Runtime.dynCall('viii', GLFW.active.framebufferSizeFunc, [GLFW.active.id, GLFW.active.width, GLFW.active.height]);
+#endif
+    },
+
     requestFullScreen: function() {
       var RFS = Module["canvas"]['requestFullscreen'] ||
                 Module["canvas"]['requestFullScreen'] ||
@@ -866,9 +923,11 @@ var LibraryGLFW = {
     Module["canvas"].addEventListener("mouseup", GLFW.onMouseButtonUp, true);
     Module["canvas"].addEventListener('wheel', GLFW.onMouseWheel, true);
     Module["canvas"].addEventListener('mousewheel', GLFW.onMouseWheel, true);
+    Module["canvas"].addEventListener('mouseenter', GLFW.onMouseenter, true);
+    Module["canvas"].addEventListener('mouseleave', GLFW.onMouseleave, true);
 
     Browser.resizeListeners.push(function(width, height) {
-       GLFW.onFullScreenEventChange();
+       GLFW.onCanvasResize(width, height);
     });
     return 1; // GL_TRUE
   },
@@ -882,6 +941,8 @@ var LibraryGLFW = {
     Module["canvas"].removeEventListener("mouseup", GLFW.onMouseButtonUp, true);
     Module["canvas"].removeEventListener('wheel', GLFW.onMouseWheel, true);
     Module["canvas"].removeEventListener('mousewheel', GLFW.onMouseWheel, true);
+    Module["canvas"].removeEventListener('mouseenter', GLFW.onMouseenter, true);
+    Module["canvas"].removeEventListener('mouseleave', GLFW.onMouseleave, true);
     Module["canvas"].width = Module["canvas"].height = 1;
     GLFW.windows = null;
     GLFW.active = null;
@@ -1137,7 +1198,7 @@ var LibraryGLFW = {
   glfwSetFramebufferSizeCallback: function(winid, cbfun) {
     var win = GLFW.WindowFromId(winid);
     if (!win) return;
-    win.windowFramebufferSizeFunc = cbfun;
+    win.framebufferSizeFunc = cbfun;
   },
 
   glfwGetInputMode: function(winid, mode) {
diff --git a/src/library_html5.js b/src/library_html5.js
index 8e2e5c59d8696..9b18f38fbbbf8 100644
--- a/src/library_html5.js
+++ b/src/library_html5.js
@@ -13,6 +13,13 @@ var LibraryJSEvents = {
     visibilityChangeEvent: 0,
     touchEvent: 0,
 
+    // In order to ensure most coherent Gamepad API state as possible (https://github.com/w3c/gamepad/issues/22) and
+    // to minimize the amount of garbage created, we sample the gamepad state at most once per frame, and not e.g. once per
+    // each controller or similar. To implement that, the following variables retain a cache of the most recent polled gamepad
+    // state.
+    lastGamepadState: null,
+    lastGamepadStateFrame: null, // The integer value of Browser.mainLoop.currentFrameNumber of when the last gamepad state was produced.
+
     // When we transition from fullscreen to windowed mode, we remember here the element that was just in fullscreen mode
     // so that we can report information about that element in the event message.
     previousFullscreenElement: null,
@@ -1650,37 +1657,36 @@ var LibraryJSEvents = {
     return {{{ cDefine('EMSCRIPTEN_RESULT_SUCCESS') }}};
  },
   
-  emscripten_get_num_gamepads: function() {
-    if (!navigator.getGamepads && !navigator.webkitGetGamepads) return {{{ cDefine('EMSCRIPTEN_RESULT_NOT_SUPPORTED') }}};
-    if (navigator.getGamepads) {
-      return navigator.getGamepads().length;
-    } else if (navigator.webkitGetGamepads) {
-      return navigator.webkitGetGamepads().length;
+  _emscripten_sample_gamepad_data: function() {
+    // Produce a new Gamepad API sample if we are ticking a new game frame, or if not using emscripten_set_main_loop() at all to drive animation.
+    if (Browser.mainLoop.currentFrameNumber !== JSEvents.lastGamepadStateFrame || !Browser.mainLoop.currentFrameNumber) {
+      JSEvents.lastGamepadState = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : null);
+      JSEvents.lastGamepadStateFrame = Browser.mainLoop.currentFrameNumber;
     }
   },
+
+  emscripten_get_num_gamepads__deps: ['_emscripten_sample_gamepad_data'],
+  emscripten_get_num_gamepads: function() {
+    __emscripten_sample_gamepad_data();
+    if (!JSEvents.lastGamepadState) return {{{ cDefine('EMSCRIPTEN_RESULT_NOT_SUPPORTED') }}};
+    return JSEvents.lastGamepadState.length;
+  },
   
+  emscripten_get_gamepad_status__deps: ['_emscripten_sample_gamepad_data'],
   emscripten_get_gamepad_status: function(index, gamepadState) {
-    if (!navigator.getGamepads && !navigator.webkitGetGamepads) return {{{ cDefine('EMSCRIPTEN_RESULT_NOT_SUPPORTED') }}};
-    var gamepads;
-    if (navigator.getGamepads) {
-      gamepads = navigator.getGamepads();
-    } else if (navigator.webkitGetGamepads) {
-      gamepads = navigator.webkitGetGamepads();
-    }
-    if (index < 0 || index >= gamepads.length) {
-      return {{{ cDefine('EMSCRIPTEN_RESULT_INVALID_PARAM') }}};
-    }
-    // For previously disconnected gamepads there should be a null at the index.
+    __emscripten_sample_gamepad_data();
+    if (!JSEvents.lastGamepadState) return {{{ cDefine('EMSCRIPTEN_RESULT_NOT_SUPPORTED') }}};
+
+    // INVALID_PARAM is returned on a Gamepad index that never was there.
+    if (index < 0 || index >= JSEvents.lastGamepadState.length) return {{{ cDefine('EMSCRIPTEN_RESULT_INVALID_PARAM') }}};
+
+    // NO_DATA is returned on a Gamepad index that was removed.
+    // For previously disconnected gamepads there should be an empty slot (null/undefined/false) at the index.
     // This is because gamepads must keep their original position in the array.
-    // For example, removing the first of two gamepads produces [null, gamepad].
-    // Older implementations of the Gamepad API used undefined instead of null.
-    // The following check works because null and undefined evaluate to false.
-    if (!gamepads[index]) {
-      // There is a "false" but no gamepad at index because it was disconnected.
-      return {{{ cDefine('EMSCRIPTEN_RESULT_NO_DATA') }}};
-    }
-    // There should be a gamepad at index which can be queried.
-    JSEvents.fillGamepadEventData(gamepadState, gamepads[index]);
+    // For example, removing the first of two gamepads produces [null/undefined/false, gamepad].
+    if (!JSEvents.lastGamepadState[index]) return {{{ cDefine('EMSCRIPTEN_RESULT_NO_DATA') }}};
+
+    JSEvents.fillGamepadEventData(gamepadState, JSEvents.lastGamepadState[index]);
     return {{{ cDefine('EMSCRIPTEN_RESULT_SUCCESS') }}};
   },
   
diff --git a/system/include/emscripten/html5.h b/system/include/emscripten/html5.h
index 975a52e72c1a0..7d979e252606b 100644
--- a/system/include/emscripten/html5.h
+++ b/system/include/emscripten/html5.h
@@ -68,6 +68,8 @@ extern "C" {
 #define EMSCRIPTEN_RESULT_NO_DATA             -7
 
 #define EM_BOOL int
+#define EM_TRUE 1
+#define EM_FALSE 0
 #define EM_UTF8 char
 
 #define DOM_KEY_LOCATION int
diff --git a/system/include/emscripten/trace.h b/system/include/emscripten/trace.h
index 3e1545c62c22b..45000f6dd8389 100644
--- a/system/include/emscripten/trace.h
+++ b/system/include/emscripten/trace.h
@@ -76,6 +76,7 @@ void emscripten_trace_close(void);
 #define emscripten_trace_record_reallocation(old_address, new_address, size)
 #define emscripten_trace_record_free(address)
 #define emscripten_trace_annotate_address_type(address, type)
+#define emscripten_trace_associate_storage_size(address, size)
 #define emscripten_trace_report_memory_layout()
 #define emscripten_trace_report_off_heap_data()
 #define emscripten_trace_enter_context(name)
diff --git a/system/include/libcxx/CMakeLists.txt b/system/include/libcxx/CMakeLists.txt
new file mode 100644
index 0000000000000..6484289bd01f9
--- /dev/null
+++ b/system/include/libcxx/CMakeLists.txt
@@ -0,0 +1,62 @@
+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}
+  )
+
+file(COPY .
+  DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1"
+  FILES_MATCHING
+  ${LIBCXX_HEADER_PATTERN}
+  )
+
+if (LIBCXX_INSTALL_HEADERS)
+  install(DIRECTORY .
+    DESTINATION include/c++/v1
+    COMPONENT libcxx-headers
+    FILES_MATCHING
+    ${LIBCXX_HEADER_PATTERN}
+    PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+  )
+
+  if (LIBCXX_NEEDS_SITE_CONFIG)
+    set(UNIX_CAT cat)
+    if (WIN32)
+      set(UNIX_CAT type)
+    endif()
+    # 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 ${CMAKE_COMMAND} -E copy ${LIBCXX_BINARY_DIR}/__config_site ${LIBCXX_BINARY_DIR}/__generated_config
+      COMMAND ${UNIX_CAT} ${LIBCXX_SOURCE_DIR}/include/__config >> ${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(generate_config_header ALL
+      DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config)
+    # Install the generated header as __config.
+    install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
+      DESTINATION include/c++/v1
+      PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+      RENAME __config
+      COMPONENT libcxx-headers)
+  endif()
+
+  if (NOT CMAKE_CONFIGURATION_TYPES)
+    # this target is just needed as a placeholder for the distribution target
+    add_custom_target(libcxx-headers)
+    add_custom_target(install-libcxx-headers
+                      DEPENDS ${name} libcxx-headers
+                      COMMAND "${CMAKE_COMMAND}"
+                              -DCMAKE_INSTALL_COMPONENT=libcxx-headers
+                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  endif()
+
+endif()
diff --git a/system/include/libcxx/CREDITS.TXT b/system/include/libcxx/CREDITS.TXT
index 7a28adae09659..1cf713a688427 100644
--- a/system/include/libcxx/CREDITS.TXT
+++ b/system/include/libcxx/CREDITS.TXT
@@ -12,6 +12,10 @@ N: Saleem Abdulrasool
 E: compnerd@compnerd.org
 D: Minor patches and Linux fixes.
 
+N: Dan Albert
+E: danalbert@google.com
+D: Android support and test runner improvements.
+
 N: Dimitry Andric
 E: dimitry@andric.com
 D: Visibility fixes, minor FreeBSD portability patches.
@@ -84,6 +88,10 @@ N: Nico Rieck
 E: nico.rieck@gmail.com
 D: Windows fixes
 
+N: Jon Roelofs
+E: jonathan@codesourcery.com
+D: Remote testing, Newlib port, baremetal/single-threaded support.
+
 N: Jonathan Sauer
 D: Minor patches, mostly related to constexpr
 
@@ -105,6 +113,9 @@ D: Minor <atomic> fix
 N: Michael van der Westhuizen
 E: r1mikey at gmail dot com
 
+N: Larisse Voufo
+D: Minor patches.
+
 N: Klaas de Vries
 E: klaas at klaasgaaf dot nl
 D: Minor bug fix.
diff --git a/system/include/libcxx/LICENSE.TXT b/system/include/libcxx/LICENSE.TXT
index 41ca5d19cc658..339e232c68fd4 100644
--- a/system/include/libcxx/LICENSE.TXT
+++ b/system/include/libcxx/LICENSE.TXT
@@ -14,7 +14,7 @@ Full text of the relevant licenses is included below.
 University of Illinois/NCSA
 Open Source License
 
-Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
+Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT
 
 All rights reserved.
 
diff --git a/system/include/libcxx/__bit_reference b/system/include/libcxx/__bit_reference
index d9ebfbe5e610b..5659ed068246a 100644
--- a/system/include/libcxx/__bit_reference
+++ b/system/include/libcxx/__bit_reference
@@ -705,7 +705,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 __bit_iterator<_Cp, false>
 move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
 {
-    return _VSTD::copy(__first, __last, __result);
+    return _VSTD::copy_backward(__first, __last, __result);
 }
 
 // swap_ranges
@@ -906,7 +906,6 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
 {
     typedef __bit_iterator<_Cp, false> _I1;
     typedef  typename _I1::difference_type difference_type;
-    typedef typename _I1::__storage_type __storage_type;
     difference_type __d1 = __middle - __first;
     difference_type __d2 = __last - __middle;
     _I1 __r = __first + __d2;
diff --git a/system/include/libcxx/__bsd_locale_defaults.h b/system/include/libcxx/__bsd_locale_defaults.h
new file mode 100644
index 0000000000000..f315ca2949e31
--- /dev/null
+++ b/system/include/libcxx/__bsd_locale_defaults.h
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//===---------------------- __bsd_locale_defaults.h -----------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+// The BSDs have lots of *_l functions.  We don't want to define those symbols
+// on other platforms though, for fear of conflicts with user code.  So here,
+// we will define the mapping from an internal macro to the real BSD symbol.
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H
+#define _LIBCPP_BSD_LOCALE_DEFAULTS_H
+
+#define __libcpp_mb_cur_max_l(loc)                          MB_CUR_MAX_L(loc)
+#define __libcpp_btowc_l(ch, loc)                           btowc_l(ch, loc)
+#define __libcpp_wctob_l(wch, loc)                          wctob_l(wch, loc)
+#define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc)  wcsnrtombs_l(dst, src, nwc, len, ps, loc)
+#define __libcpp_wcrtomb_l(src, wc, ps, loc)                wcrtomb_l(src, wc, ps, loc)
+#define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc)  mbsnrtowcs_l(dst, src, nms, len, ps, loc)
+#define __libcpp_mbrtowc_l(pwc, s, n, ps, l)                mbrtowc_l(pwc, s, n, ps, l)
+#define __libcpp_mbtowc_l(pwc, pmb, max, l)                 mbtowc_l(pwc, pmb, max, l)
+#define __libcpp_mbrlen_l(s, n, ps, l)                      mbrlen_l(s, n, ps, l)
+#define __libcpp_localeconv_l(l)                            localeconv_l(l)
+#define __libcpp_mbsrtowcs_l(dest, src, len, ps, l)         mbsrtowcs_l(dest, src, len, ps, l)
+#define __libcpp_snprintf_l(...)                            snprintf_l(__VA_ARGS__)
+#define __libcpp_asprintf_l(...)                            asprintf_l(__VA_ARGS__)
+#define __libcpp_sscanf_l(...)                              sscanf_l(__VA_ARGS__)
+
+#endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H
diff --git a/system/include/libcxx/__bsd_locale_fallbacks.h b/system/include/libcxx/__bsd_locale_fallbacks.h
new file mode 100644
index 0000000000000..cbc8ad226fd20
--- /dev/null
+++ b/system/include/libcxx/__bsd_locale_fallbacks.h
@@ -0,0 +1,138 @@
+// -*- C++ -*-
+//===---------------------- __bsd_locale_fallbacks.h ----------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+// The BSDs have lots of *_l functions.  This file provides reimplementations
+// of those functions for non-BSD platforms.
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
+#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
+
+#include <stdlib.h>
+#include <memory>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+typedef _VSTD::remove_pointer<locale_t>::type __use_locale_struct;
+typedef _VSTD::unique_ptr<__use_locale_struct, decltype(&uselocale)> __locale_raii;
+
+inline _LIBCPP_ALWAYS_INLINE
+decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return MB_CUR_MAX;
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+wint_t __libcpp_btowc_l(int __c, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return btowc(__c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_wctob_l(wint_t __c, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return wctob(__c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
+                         size_t __len, mbstate_t *__ps, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return wcrtomb(__s, __wc, __ps);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
+                      size_t __len, mbstate_t *__ps, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
+                   mbstate_t *__ps, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return mbrtowc(__pwc, __s, __n, __ps);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return mbtowc(__pwc, __pmb, __max);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return mbrlen(__s, __n, __ps);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+lconv *__libcpp_localeconv_l(locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return localeconv();
+}
+
+inline _LIBCPP_ALWAYS_INLINE
+size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
+                     mbstate_t *__ps, locale_t __l)
+{
+    __locale_raii __current( uselocale(__l), uselocale );
+    return mbsrtowcs(__dest, __src, __len, __ps);
+}
+
+inline
+int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
+    va_list __va;
+    va_start(__va, __format);
+    __locale_raii __current( uselocale(__l), uselocale );
+    int __res = vsnprintf(__s, __n, __format, __va);
+    va_end(__va);
+    return __res;
+}
+
+inline
+int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
+    va_list __va;
+    va_start(__va, __format);
+    __locale_raii __current( uselocale(__l), uselocale );
+    int __res = vasprintf(__s, __format, __va);
+    va_end(__va);
+    return __res;
+}
+
+inline
+int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
+    va_list __va;
+    va_start(__va, __format);
+    __locale_raii __current( uselocale(__l), uselocale );
+    int __res = vsscanf(__s, __format, __va);
+    va_end(__va);
+    return __res;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
diff --git a/system/include/libcxx/__config b/system/include/libcxx/__config
index fcf82c80d2c26..a4c6cec719160 100644
--- a/system/include/libcxx/__config
+++ b/system/include/libcxx/__config
@@ -11,28 +11,65 @@
 #ifndef _LIBCPP_CONFIG
 #define _LIBCPP_CONFIG
 
-#if !defined(_MSC_VER) || defined(__clang__)
+#if defined(_MSC_VER) && !defined(__clang__)
+#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+#endif
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #pragma GCC system_header
 #endif
 
+#ifdef __cplusplus
+
 #ifdef __GNUC__
 #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
+#else
+#define _GNUC_VER 0
 #endif
 
-#if !_WIN32
-#include <unistd.h>
-#include <errno.h>  // for ELAST on FreeBSD
-#endif
-
-#define _LIBCPP_VERSION 1101
+#define _LIBCPP_VERSION 3900
 
+#ifndef _LIBCPP_ABI_VERSION
 #define _LIBCPP_ABI_VERSION 1
+#endif
+
+#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
+// Change short string represention so that string data starts at offset 0,
+// improving its alignment in some cases.
+#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+// Fix deque iterator type in order to support incomplete types.
+#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+// Fix undefined behavior in how std::list stores it's linked nodes.
+#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
+#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
+#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
+#endif
 
 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
 #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
 
 #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
 
+
+#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
+// '__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
+
+
 #ifdef __LITTLE_ENDIAN__
 #if __LITTLE_ENDIAN__
 #define _LIBCPP_LITTLE_ENDIAN 1
@@ -47,6 +84,16 @@
 #endif  // __BIG_ENDIAN__
 #endif  // __BIG_ENDIAN__
 
+#ifdef __BYTE_ORDER__
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define _LIBCPP_LITTLE_ENDIAN 1
+#define _LIBCPP_BIG_ENDIAN 0
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define _LIBCPP_LITTLE_ENDIAN 0
+#define _LIBCPP_BIG_ENDIAN 1
+#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#endif // __BYTE_ORDER__
+
 #ifdef __FreeBSD__
 # include <sys/endian.h>
 #  if _BYTE_ORDER == _LITTLE_ENDIAN
@@ -76,10 +123,8 @@
 #ifdef _WIN32
 #  define _LIBCPP_LITTLE_ENDIAN 1
 #  define _LIBCPP_BIG_ENDIAN    0
-// Compiler intrinsics (GCC or MSVC)
-#  if defined(__clang__) \
-   || (defined(_MSC_VER) && _MSC_VER >= 1400) \
-   || (defined(__GNUC__) && _GNUC_VER > 403)
+// Compiler intrinsics (MSVC)
+#if defined(_MSC_VER) && _MSC_VER >= 1400
 #    define _LIBCPP_HAS_IS_BASE_OF
 #  endif
 #  if defined(_MSC_VER) && !defined(__clang__)
@@ -94,12 +139,6 @@
 #  endif
 #endif  // _WIN32
 
-#ifdef __linux__
-#  if defined(__GNUC__) && _GNUC_VER >= 403
-#    define _LIBCPP_HAS_IS_BASE_OF
-#  endif
-#endif
-
 #ifdef __sun__
 # include <sys/isa_defs.h>
 # ifdef _LITTLE_ENDIAN
@@ -111,6 +150,23 @@
 # endif
 #endif // __sun__
 
+#if defined(__CloudABI__)
+  // 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(__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
+#elif defined(_WIN32)
+# define _LIBCPP_USING_WIN32_RANDOM
+#else
+# define _LIBCPP_USING_DEV_RANDOM
+#endif
+
 #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
 # include <endian.h>
 # if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -124,6 +180,12 @@
 # endif
 #endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
 
+#if __has_attribute(__no_sanitize__)
+#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCPP_NO_CFI
+#endif
+
 #ifdef _WIN32
 
 // only really useful for a DLL
@@ -166,10 +228,6 @@
 
 #endif // _WIN32
 
-#ifndef __has_attribute
-#define __has_attribute(__x) 0
-#endif
-
 #ifndef _LIBCPP_HIDDEN
 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
 #endif
@@ -186,6 +244,12 @@
 #  endif
 #endif
 
+#ifndef _LIBCPP_PREFERRED_OVERLOAD
+#  if __has_attribute(__enable_if__)
+#    define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
+#  endif
+#endif
+
 #ifndef _LIBCPP_TYPE_VIS_ONLY
 # define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS
 #endif
@@ -208,9 +272,12 @@
 
 #if defined(__clang__)
 
-#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&        \
-    !defined(__arm__)
-#define _LIBCPP_ALTERNATE_STRING_LAYOUT
+// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
+// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
+#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&       \
+     !defined(__arm__)) ||                                                     \
+    defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
+#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 #endif
 
 #if __has_feature(cxx_alignas)
@@ -226,15 +293,11 @@
 #endif
 
 #if __cplusplus < 201103L
-#ifdef __linux__
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#else
 typedef __char16_t char16_t;
 typedef __char32_t char32_t;
 #endif
-#endif
 
-#if !(__has_feature(cxx_exceptions))
+#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
 #define _LIBCPP_NO_EXCEPTIONS
 #endif
 
@@ -256,6 +319,10 @@ typedef __char32_t char32_t;
 #  define _LIBCPP_NORETURN __attribute__ ((noreturn))
 #endif
 
+#if !(__has_feature(cxx_default_function_template_args))
+#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
+#endif
+
 #if !(__has_feature(cxx_defaulted_functions))
 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 #endif  // !(__has_feature(cxx_defaulted_functions))
@@ -304,6 +371,10 @@ typedef __char32_t char32_t;
 #  define _LIBCPP_HAS_IS_BASE_OF
 #endif
 
+#if __has_feature(is_final)
+#  define _LIBCPP_HAS_IS_FINAL
+#endif
+
 // Objective-C++ features (opt-in)
 #if __has_feature(objc_arc)
 #define _LIBCPP_HAS_OBJC_ARC
@@ -322,6 +393,10 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #endif
 
+#if !(__has_feature(cxx_variable_templates))
+#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+#endif
+
 #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
 #if defined(__FreeBSD__)
 #define _LIBCPP_HAS_QUICK_EXIT
@@ -329,24 +404,23 @@ typedef __char32_t char32_t;
 #elif defined(__ANDROID__)
 #define _LIBCPP_HAS_QUICK_EXIT
 #elif defined(__linux__)
-#include <features.h>
+#if !defined(_LIBCPP_HAS_MUSL_LIBC)
+# include <features.h>
 #if __GLIBC_PREREQ(2, 15)
 #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 _NOEXCEPT noexcept
-#  define _NOEXCEPT_(x) noexcept(x)
-#  define _NOEXCEPT_OR_FALSE(x) noexcept(x)
-#else
-#  define _NOEXCEPT throw()
-#  define _NOEXCEPT_(x)
-#  define _NOEXCEPT_OR_FALSE(x) false
+#if !(__has_feature(cxx_noexcept))
+#define _LIBCPP_HAS_NO_NOEXCEPT
 #endif
 
 #if __has_feature(underlying_type)
@@ -371,6 +445,11 @@ namespace std {
 #define _LIBCPP_HAS_NO_ASAN
 #endif
 
+// 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 
+
 #elif defined(__GNUC__)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -381,14 +460,17 @@ namespace std {
 #if _GNUC_VER >= 407
 #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
 #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
+#define _LIBCPP_HAS_IS_FINAL
+#endif
+
+#if defined(__GNUC__) && _GNUC_VER >= 403
+#  define _LIBCPP_HAS_IS_BASE_OF
 #endif
 
 #if !__EXCEPTIONS
 #define _LIBCPP_NO_EXCEPTIONS
 #endif
 
-#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-
 // constexpr was added to GCC in 4.6.
 #if _GNUC_VER < 406
 #define _LIBCPP_HAS_NO_CONSTEXPR
@@ -397,17 +479,21 @@ namespace std {
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #endif
 
-// No version of GCC supports relaxed constexpr rules
+// Determine if GCC supports relaxed constexpr
+#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
+#endif
 
-#define _NOEXCEPT throw()
-#define _NOEXCEPT_(x)
-#define _NOEXCEPT_OR_FALSE(x) false
+// GCC 5 will support variable templates
+#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
+#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+#endif
 
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
 
 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
 #define _LIBCPP_HAS_NO_DECLTYPE
+#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 #define _LIBCPP_HAS_NO_NULLPTR
@@ -415,32 +501,32 @@ namespace std {
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_NO_VARIADICS
 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
 #define _LIBCPP_HAS_NO_STRONG_ENUMS
+#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+#define _LIBCPP_HAS_NO_NOEXCEPT
 
 #else  // __GXX_EXPERIMENTAL_CXX0X__
 
-#define _LIBCPP_HAS_NO_TRAILING_RETURN
-#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
-
 #if _GNUC_VER < 403
+#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#endif
-
-#if _GNUC_VER < 403
 #define _LIBCPP_HAS_NO_STATIC_ASSERT
 #endif
 
+
 #if _GNUC_VER < 404
 #define _LIBCPP_HAS_NO_DECLTYPE
 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define _LIBCPP_HAS_NO_TRAILING_RETURN
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_NO_VARIADICS
 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 #endif  // _GNUC_VER < 404
 
 #if _GNUC_VER < 406
+#define _LIBCPP_HAS_NO_NOEXCEPT
 #define _LIBCPP_HAS_NO_NULLPTR
+#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
 #endif
 
 #if _GNUC_VER < 407
@@ -467,20 +553,19 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
 #elif defined(_LIBCPP_MSVC)
 
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
+#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
 #define _ALIGNAS(x) __declspec(align(x))
 #define _LIBCPP_HAS_NO_VARIADICS
 
-#define _NOEXCEPT throw ()
-#define _NOEXCEPT_(x)
-#define _NOEXCEPT_OR_FALSE(x) false
+
 
 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
 #define _LIBCPP_END_NAMESPACE_STD  }
@@ -499,17 +584,16 @@ namespace std {
 #define _ATTRIBUTE(x) __attribute__((x))
 #define _LIBCPP_NORETURN __attribute__((noreturn))
 
-#define _NOEXCEPT throw()
-#define _NOEXCEPT_(x)
-#define _NOEXCEPT_OR_FALSE(x) false
-
+#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
-#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#define _LIBCPP_HAS_NO_NOEXCEPT
 #define _LIBCPP_HAS_NO_NULLPTR
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_IS_BASE_OF
+#define _LIBCPP_HAS_IS_FINAL
+#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 
 #if defined(_AIX)
 #define __MULTILOCALE_API
@@ -528,6 +612,14 @@ namespace std {
 
 #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
 
+#ifndef _LIBCPP_HAS_NO_NOEXCEPT
+#  define _NOEXCEPT noexcept
+#  define _NOEXCEPT_(x) noexcept(x)
+#else
+#  define _NOEXCEPT throw()
+#  define _NOEXCEPT_(x)
+#endif
+
 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
 typedef unsigned short char16_t;
 typedef unsigned int   char32_t;
@@ -539,9 +631,11 @@ typedef unsigned int   char32_t;
 
 #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
 
+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__)
@@ -549,7 +643,12 @@ template <unsigned> struct __static_assert_check {};
 #endif  // _LIBCPP_HAS_NO_STATIC_ASSERT
 
 #ifdef _LIBCPP_HAS_NO_DECLTYPE
-#define decltype(x) __typeof__(x)
+// GCC 4.6 provides __decltype in all standard modes.
+#if !__is_identifier(__decltype) || _GNUC_VER >= 406
+#  define decltype(__x) __decltype(__x)
+#else
+#  define decltype(__x) __typeof__(__x)
+#endif
 #endif
 
 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
@@ -564,20 +663,18 @@ template <unsigned> struct __static_assert_check {};
 #define _LIBCPP_DEFAULT = default;
 #endif
 
+#ifdef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define _LIBCPP_EQUAL_DELETE
+#else
+#define _LIBCPP_EQUAL_DELETE = delete
+#endif
+
 #ifdef __GNUC__
 #define _NOALIAS __attribute__((__malloc__))
 #else
 #define _NOALIAS
 #endif
 
-#ifndef __has_feature
-#define __has_feature(__x) 0
-#endif
-
-#ifndef __has_builtin
-#define __has_builtin(__x) 0
-#endif
-
 #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
 #   define _LIBCPP_EXPLICIT explicit
 #else
@@ -624,10 +721,18 @@ template <unsigned> struct __static_assert_check {};
 #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
 #endif
 
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
+    defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
 
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+// Most unix variants have catopen.  These are the specific ones that don't.
+#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
+#define _LIBCPP_HAS_CATOPEN 1
+#endif
+#endif
+
 #ifdef __FreeBSD__
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
@@ -640,21 +745,6 @@ template <unsigned> struct __static_assert_check {};
 #define _LIBCPP_WCTYPE_IS_MASK
 #endif
 
-#if defined(ELAST)
-#define _LIBCPP_ELAST ELAST
-#elif defined(__linux__)
-#define _LIBCPP_ELAST 4095
-#elif defined(_NEWLIB_VERSION)
-#define _LIBCPP_ELAST __ELASTERROR
-#elif defined(__APPLE__)
-// Not _LIBCPP_ELAST needed on Apple
-#elif defined(__EMSCRIPTEN__)
-#define _LIBCPP_ELAST 256
-#else
-// Warn here so that the person doing the libcxx port has an easier time:
-#warning This platform's ELAST hasn't been ported yet
-#endif
-
 #ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
 #  define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1
 #endif
@@ -689,6 +779,18 @@ template <unsigned> struct __static_assert_check {};
 #define _LIBCPP_CONSTEXPR_AFTER_CXX11
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
+#else
+#define _LIBCPP_CONSTEXPR_AFTER_CXX14
+#endif
+
+#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#  define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
+#else
+#  define _LIBCPP_EXPLICIT_MOVE(x) (x)
+#endif
+
 #ifndef _LIBCPP_HAS_NO_ASAN
 extern "C" void __sanitizer_annotate_contiguous_container(
   const void *, const void *, const void *, const void *);
@@ -698,7 +800,7 @@ 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(__GNUG__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
+#  if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
    (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
 #    define _LIBCPP_NO_RTTI
 #  elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
@@ -710,4 +812,64 @@ extern "C" void __sanitizer_annotate_contiguous_container(
 #  define _LIBCPP_WEAK __attribute__((__weak__))
 #endif
 
-#endif  // _LIBCPP_CONFIG
+#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.
+#endif
+
+// Systems that use capability-based security (FreeBSD with Capsicum,
+// Nuxi CloudABI) may only provide local filesystem access (using *at()).
+// Functions like open(), rename(), unlink() and stat() should not be
+// used, as they attempt to access the global filesystem namespace.
+#ifdef __CloudABI__
+#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+#endif
+
+// CloudABI is intended for running networked services. Processes do not
+// have standard input and output channels.
+#ifdef __CloudABI__
+#define _LIBCPP_HAS_NO_STDIN
+#define _LIBCPP_HAS_NO_STDOUT
+#endif
+
+#if defined(__ANDROID__) || defined(__CloudABI__) || defined(_LIBCPP_HAS_MUSL_LIBC)
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+#endif
+
+// Thread-unsafe functions such as strtok(), mbtowc() and localtime()
+// are not available.
+#ifdef __CloudABI__
+#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+#endif
+
+#if __has_feature(cxx_atomic) || __has_extension(c_atomic)
+#define _LIBCPP_HAS_C_ATOMIC_IMP
+#elif _GNUC_VER > 407
+#define _LIBCPP_HAS_GCC_ATOMIC_IMP
+#endif
+
+#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
+     || defined(_LIBCPP_HAS_NO_THREADS)
+#define _LIBCPP_HAS_NO_ATOMIC_HEADER
+#endif
+
+#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+#endif
+
+#if __cplusplus < 201103L
+#define _LIBCPP_CXX03_LANG
+#else
+#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
+#endif
+#endif
+
+#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
+      && __has_attribute(acquire_capability))
+#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#endif
+
+#endif // __cplusplus
+
+#endif // _LIBCPP_CONFIG
diff --git a/system/include/libcxx/__config_site.in b/system/include/libcxx/__config_site.in
new file mode 100644
index 0000000000000..ec64485289fa5
--- /dev/null
+++ b/system/include/libcxx/__config_site.in
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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_CONFIG_SITE
+#define _LIBCPP_CONFIG_SITE
+
+#cmakedefine _LIBCPP_ABI_VERSION @_LIBCPP_ABI_VERSION@
+#cmakedefine _LIBCPP_ABI_UNSTABLE
+#cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+#cmakedefine _LIBCPP_HAS_NO_STDIN
+#cmakedefine _LIBCPP_HAS_NO_STDOUT
+#cmakedefine _LIBCPP_HAS_NO_THREADS
+#cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
+#cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+#cmakedefine _LIBCPP_HAS_MUSL_LIBC
+
+#endif // _LIBCPP_CONFIG_SITE
diff --git a/system/include/libcxx/__debug b/system/include/libcxx/__debug
index c1512246bfcf2..a21f9a89884be 100644
--- a/system/include/libcxx/__debug
+++ b/system/include/libcxx/__debug
@@ -22,7 +22,7 @@
 #   include <cstdio>
 #   include <cstddef>
 #   ifndef _LIBCPP_ASSERT
-#      define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort()))
+#      define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::fprintf(stderr, "%s\n", m), _VSTD::abort()))
 #   endif
 #endif
 
diff --git a/system/include/libcxx/__functional_03 b/system/include/libcxx/__functional_03
index d8a9f05fa124b..4edbb0996ca0d 100644
--- a/system/include/libcxx/__functional_03
+++ b/system/include/libcxx/__functional_03
@@ -17,218 +17,7 @@
 #pragma GCC system_header
 #endif
 
-template <class _Tp>
-class __mem_fn
-    : public __weak_result_type<_Tp>
-{
-public:
-    // types
-    typedef _Tp type;
-private:
-    type __f_;
-
-public:
-    _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}
-
-    // invoke
-
-    typename __invoke_return<type>::type
-       operator() () const
-       {
-           return __invoke(__f_);
-       }
-
-    template <class _A0>
-       typename __invoke_return0<type, _A0>::type
-          operator() (_A0& __a0) const
-          {
-              return __invoke(__f_, __a0);
-          }
-
-    template <class _A0, class _A1>
-       typename __invoke_return1<type, _A0, _A1>::type
-          operator() (_A0& __a0, _A1& __a1) const
-          {
-              return __invoke(__f_, __a0, __a1);
-          }
-
-    template <class _A0, class _A1, class _A2>
-       typename __invoke_return2<type, _A0, _A1, _A2>::type
-          operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
-          {
-              return __invoke(__f_, __a0, __a1, __a2);
-          }
-};
-
-template<class _Rp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp _Tp::*>
-mem_fn(_Rp _Tp::* __pm)
-{
-    return __mem_fn<_Rp _Tp::*>(__pm);
-}
-
-template<class _Rp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)()>
-mem_fn(_Rp (_Tp::* __pm)())
-{
-    return __mem_fn<_Rp (_Tp::*)()>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0)>
-mem_fn(_Rp (_Tp::* __pm)(_A0))
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0)>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0, _A1)>
-mem_fn(_Rp (_Tp::* __pm)(_A0, _A1))
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0, _A1)>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>
-mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2))
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>(__pm);
-}
-
-template<class _Rp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)() const>
-mem_fn(_Rp (_Tp::* __pm)() const)
-{
-    return __mem_fn<_Rp (_Tp::*)() const>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0) const>
-mem_fn(_Rp (_Tp::* __pm)(_A0) const)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0) const>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0, _A1) const>
-mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const>
-mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const>(__pm);
-}
-
-template<class _Rp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)() volatile>
-mem_fn(_Rp (_Tp::* __pm)() volatile)
-{
-    return __mem_fn<_Rp (_Tp::*)() volatile>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0) volatile>
-mem_fn(_Rp (_Tp::* __pm)(_A0) volatile)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0) volatile>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile>
-mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) volatile)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) volatile>
-mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) volatile)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) volatile>(__pm);
-}
-
-template<class _Rp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)() const volatile>
-mem_fn(_Rp (_Tp::* __pm)() const volatile)
-{
-    return __mem_fn<_Rp (_Tp::*)() const volatile>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0) const volatile>
-mem_fn(_Rp (_Tp::* __pm)(_A0) const volatile)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0) const volatile>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile>
-mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const volatile)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile>(__pm);
-}
-
-template<class _Rp, class _Tp, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile>
-mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const volatile)
-{
-    return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile>(__pm);
-}
-
-// bad_function_call
-
-class _LIBCPP_EXCEPTION_ABI bad_function_call
-    : public exception
-{
-};
-
-template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
-
-namespace __function
-{
-
-template<class _Fp>
-struct __maybe_derive_from_unary_function
-{
-};
-
-template<class _Rp, class _A1>
-struct __maybe_derive_from_unary_function<_Rp(_A1)>
-    : public unary_function<_A1, _Rp>
-{
-};
-
-template<class _Fp>
-struct __maybe_derive_from_binary_function
-{
-};
-
-template<class _Rp, class _A1, class _A2>
-struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
-    : public binary_function<_A1, _A2, _Rp>
-{
-};
+namespace __function {
 
 template<class _Fp> class __base;
 
@@ -333,7 +122,8 @@ template<class _Fp, class _Alloc, class _Rp>
 __base<_Rp()>*
 __func<_Fp, _Alloc, _Rp()>::__clone() const
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     typedef __allocator_destructor<_Ap> _Dp;
     unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -359,7 +149,8 @@ template<class _Fp, class _Alloc, class _Rp>
 void
 __func<_Fp, _Alloc, _Rp()>::destroy_deallocate()
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     __f_.~__compressed_pair<_Fp, _Alloc>();
     __a.deallocate(this, 1);
@@ -369,7 +160,8 @@ template<class _Fp, class _Alloc, class _Rp>
 _Rp
 __func<_Fp, _Alloc, _Rp()>::operator()()
 {
-    return __invoke(__f_.first());
+    typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+    return _Invoker::__call(__f_.first());
 }
 
 #ifndef _LIBCPP_NO_RTTI
@@ -416,7 +208,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0>
 __base<_Rp(_A0)>*
 __func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     typedef __allocator_destructor<_Ap> _Dp;
     unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -442,7 +235,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0>
 void
 __func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate()
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     __f_.~__compressed_pair<_Fp, _Alloc>();
     __a.deallocate(this, 1);
@@ -452,7 +246,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0>
 _Rp
 __func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0)
 {
-    return __invoke(__f_.first(), __a0);
+    typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+    return _Invoker::__call(__f_.first(), __a0);
 }
 
 #ifndef _LIBCPP_NO_RTTI
@@ -499,7 +294,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
 __base<_Rp(_A0, _A1)>*
 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     typedef __allocator_destructor<_Ap> _Dp;
     unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -525,7 +321,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
 void
 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate()
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     __f_.~__compressed_pair<_Fp, _Alloc>();
     __a.deallocate(this, 1);
@@ -535,7 +332,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
 _Rp
 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1)
 {
-    return __invoke(__f_.first(), __a0, __a1);
+    typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+    return _Invoker::__call(__f_.first(), __a0, __a1);
 }
 
 #ifndef _LIBCPP_NO_RTTI
@@ -582,7 +380,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
 __base<_Rp(_A0, _A1, _A2)>*
 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     typedef __allocator_destructor<_Ap> _Dp;
     unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -608,7 +407,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
 void
 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate()
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     __f_.~__compressed_pair<_Fp, _Alloc>();
     __a.deallocate(this, 1);
@@ -618,7 +418,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
 _Rp
 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2)
 {
-    return __invoke(__f_.first(), __a0, __a1, __a2);
+    typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+    return _Invoker::__call(__f_.first(), __a0, __a1, __a2);
 }
 
 #ifndef _LIBCPP_NO_RTTI
@@ -650,15 +451,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp()>
     aligned_storage<3*sizeof(void*)>::type __buf_;
     __base* __f_;
 
-    template <class _Fp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const _Fp&) {return true;}
-    template <class _R2>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (*__p)()) {return __p;}
-    template <class _R2>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const function<_R2()>& __p) {return __p;}
 public:
     typedef _Rp result_type;
 
@@ -757,7 +549,7 @@ function<_Rp()>::function(_Fp __f,
                                      typename enable_if<!is_integral<_Fp>::value>::type*)
     : __f_(0)
 {
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF;
         if (sizeof(_FF) <= sizeof(__buf_))
@@ -784,23 +576,17 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
     : __f_(0)
 {
     typedef allocator_traits<_Alloc> __alloc_traits;
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, _Alloc, _Rp()> _FF;
         if (sizeof(_FF) <= sizeof(__buf_))
         {
             __f_ = (__base*)&__buf_;
-            ::new (__f_) _FF(__f);
+            ::new (__f_) _FF(__f, __a0);
         }
         else
         {
-            typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<_FF>
-#else
-                rebind_alloc<_FF>::other
-#endif
-                                                         _Ap;
+            typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
             _Ap __a(__a0);
             typedef __allocator_destructor<_Ap> _Dp;
             unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -827,6 +613,7 @@ function<_Rp()>::operator=(nullptr_t)
     else if (__f_)
         __f_->destroy_deallocate();
     __f_ = 0;
+    return *this;
 }
 
 template<class _Rp>
@@ -940,27 +727,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)>
     aligned_storage<3*sizeof(void*)>::type __buf_;
     __base* __f_;
 
-    template <class _Fp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const _Fp&) {return true;}
-    template <class _R2, class _B0>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (*__p)(_B0)) {return __p;}
-    template <class _R2, class _Cp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)()) {return __p;}
-    template <class _R2, class _Cp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)() const) {return __p;}
-    template <class _R2, class _Cp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)() volatile) {return __p;}
-    template <class _R2, class _Cp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)() const volatile) {return __p;}
-    template <class _R2, class _B0>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const function<_R2(_B0)>& __p) {return __p;}
 public:
     typedef _Rp result_type;
 
@@ -1059,7 +825,7 @@ function<_Rp(_A0)>::function(_Fp __f,
                                      typename enable_if<!is_integral<_Fp>::value>::type*)
     : __f_(0)
 {
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF;
         if (sizeof(_FF) <= sizeof(__buf_))
@@ -1086,23 +852,17 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
     : __f_(0)
 {
     typedef allocator_traits<_Alloc> __alloc_traits;
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF;
         if (sizeof(_FF) <= sizeof(__buf_))
         {
             __f_ = (__base*)&__buf_;
-            ::new (__f_) _FF(__f);
+            ::new (__f_) _FF(__f, __a0);
         }
         else
         {
-            typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<_FF>
-#else
-                rebind_alloc<_FF>::other
-#endif
-                                                         _Ap;
+            typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
             _Ap __a(__a0);
             typedef __allocator_destructor<_Ap> _Dp;
             unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1129,6 +889,7 @@ function<_Rp(_A0)>::operator=(nullptr_t)
     else if (__f_)
         __f_->destroy_deallocate();
     __f_ = 0;
+    return *this;
 }
 
 template<class _Rp, class _A0>
@@ -1242,27 +1003,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)>
     aligned_storage<3*sizeof(void*)>::type __buf_;
     __base* __f_;
 
-    template <class _Fp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const _Fp&) {return true;}
-    template <class _R2, class _B0, class _B1>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (*__p)(_B0, _B1)) {return __p;}
-    template <class _R2, class _Cp, class _B1>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_B1)) {return __p;}
-    template <class _R2, class _Cp, class _B1>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_B1) const) {return __p;}
-    template <class _R2, class _Cp, class _B1>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_B1) volatile) {return __p;}
-    template <class _R2, class _Cp, class _B1>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_B1) const volatile) {return __p;}
-    template <class _R2, class _B0, class _B1>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const function<_R2(_B0, _B1)>& __p) {return __p;}
 public:
     typedef _Rp result_type;
 
@@ -1361,7 +1101,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f,
                                  typename enable_if<!is_integral<_Fp>::value>::type*)
     : __f_(0)
 {
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF;
         if (sizeof(_FF) <= sizeof(__buf_))
@@ -1388,23 +1128,17 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
     : __f_(0)
 {
     typedef allocator_traits<_Alloc> __alloc_traits;
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF;
         if (sizeof(_FF) <= sizeof(__buf_))
         {
             __f_ = (__base*)&__buf_;
-            ::new (__f_) _FF(__f);
+            ::new (__f_) _FF(__f, __a0);
         }
         else
         {
-            typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<_FF>
-#else
-                rebind_alloc<_FF>::other
-#endif
-                                                         _Ap;
+            typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
             _Ap __a(__a0);
             typedef __allocator_destructor<_Ap> _Dp;
             unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1431,6 +1165,7 @@ function<_Rp(_A0, _A1)>::operator=(nullptr_t)
     else if (__f_)
         __f_->destroy_deallocate();
     __f_ = 0;
+    return *this;
 }
 
 template<class _Rp, class _A0, class _A1>
@@ -1543,27 +1278,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)>
     aligned_storage<3*sizeof(void*)>::type __buf_;
     __base* __f_;
 
-    template <class _Fp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const _Fp&) {return true;}
-    template <class _R2, class _B0, class _B1, class _B2>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (*__p)(_B0, _B1, _B2)) {return __p;}
-    template <class _R2, class _Cp, class _B1, class _B2>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2)) {return __p;}
-    template <class _R2, class _Cp, class _B1, class _B2>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const) {return __p;}
-    template <class _R2, class _Cp, class _B1, class _B2>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) volatile) {return __p;}
-    template <class _R2, class _Cp, class _B1, class _B2>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const volatile) {return __p;}
-    template <class _R2, class _B0, class _B1, class _B2>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const function<_R2(_B0, _B1, _B2)>& __p) {return __p;}
 public:
     typedef _Rp result_type;
 
@@ -1663,7 +1377,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
                                      typename enable_if<!is_integral<_Fp>::value>::type*)
     : __f_(0)
 {
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF;
         if (sizeof(_FF) <= sizeof(__buf_))
@@ -1690,23 +1404,17 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp
     : __f_(0)
 {
     typedef allocator_traits<_Alloc> __alloc_traits;
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF;
         if (sizeof(_FF) <= sizeof(__buf_))
         {
             __f_ = (__base*)&__buf_;
-            ::new (__f_) _FF(__f);
+            ::new (__f_) _FF(__f, __a0);
         }
         else
         {
-            typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<_FF>
-#else
-                rebind_alloc<_FF>::other
-#endif
-                                                         _Ap;
+            typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
             _Ap __a(__a0);
             typedef __allocator_destructor<_Ap> _Dp;
             unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1733,6 +1441,7 @@ function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
     else if (__f_)
         __f_->destroy_deallocate();
     __f_ = 0;
+    return *this;
 }
 
 template<class _Rp, class _A0, class _A1, class _A2>
@@ -1864,272 +1573,4 @@ void
 swap(function<_Fp>& __x, function<_Fp>& __y)
 {return __x.swap(__y);}
 
-template<class _Tp> struct __is_bind_expression : public false_type {};
-template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
-    : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
-
-template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
-template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
-    : public __is_placeholder<typename remove_cv<_Tp>::type> {};
-
-namespace placeholders
-{
-
-template <int _Np> struct __ph {};
-
-extern __ph<1>   _1;
-extern __ph<2>   _2;
-extern __ph<3>   _3;
-extern __ph<4>   _4;
-extern __ph<5>   _5;
-extern __ph<6>   _6;
-extern __ph<7>   _7;
-extern __ph<8>   _8;
-extern __ph<9>   _9;
-extern __ph<10> _10;
-
-}  // placeholders
-
-template<int _Np>
-struct __is_placeholder<placeholders::__ph<_Np> >
-    : public integral_constant<int, _Np> {};
-
-template <class _Tp, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-_Tp&
-__mu(reference_wrapper<_Tp> __t, _Uj&)
-{
-    return __t.get();
-}
-/*
-template <bool _IsBindExpr, class _Ti, class ..._Uj>
-struct __mu_return1 {};
-
-template <class _Ti, class ..._Uj>
-struct __mu_return1<true, _Ti, _Uj...>
-{
-    typedef typename result_of<_Ti(_Uj...)>::type type;
-};
-
-template <class _Ti, class ..._Uj, size_t ..._Indx>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __mu_return1<true, _Ti, _Uj...>::type
-__mu_expand(_Ti& __ti, tuple<_Uj...>&& __uj, __tuple_indices<_Indx...>)
-{
-    __ti(_VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj))...);
-}
-
-template <class _Ti, class ..._Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_bind_expression<_Ti>::value,
-    typename __mu_return1<is_bind_expression<_Ti>::value, _Ti, _Uj...>::type
->::type
-__mu(_Ti& __ti, tuple<_Uj...>& __uj)
-{
-    typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
-    return  __mu_expand(__ti, __uj, __indices());
-}
-
-template <bool IsPh, class _Ti, class _Uj>
-struct __mu_return2 {};
-
-template <class _Ti, class _Uj>
-struct __mu_return2<true, _Ti, _Uj>
-{
-    typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
-};
-
-template <class _Ti, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    0 < is_placeholder<_Ti>::value,
-    typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
->::type
-__mu(_Ti&, _Uj& __uj)
-{
-    const size_t _Indx = is_placeholder<_Ti>::value - 1;
-    // compiler bug workaround
-    typename tuple_element<_Indx, _Uj>::type __t = _VSTD::get<_Indx>(__uj);
-    return __t;
-//    return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
-}
-
-template <class _Ti, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_bind_expression<_Ti>::value &&
-    is_placeholder<_Ti>::value == 0 &&
-    !__is_reference_wrapper<_Ti>::value,
-    _Ti&
->::type
-__mu(_Ti& __ti, _Uj& __uj)
-{
-    return __ti;
-}
-
-template <class _Ti, bool IsBindEx, bool IsPh, class _TupleUj>
-struct ____mu_return;
-
-template <class _Ti, class ..._Uj>
-struct ____mu_return<_Ti, true, false, tuple<_Uj...> >
-{
-    typedef typename result_of<_Ti(_Uj...)>::type type;
-};
-
-template <class _Ti, class _TupleUj>
-struct ____mu_return<_Ti, false, true, _TupleUj>
-{
-    typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
-                                   _TupleUj>::type&& type;
-};
-
-template <class _Ti, class _TupleUj>
-struct ____mu_return<_Ti, false, false, _TupleUj>
-{
-    typedef _Ti& type;
-};
-
-template <class _Ti, class _TupleUj>
-struct __mu_return
-    : public ____mu_return<_Ti,
-                           is_bind_expression<_Ti>::value,
-                           0 < is_placeholder<_Ti>::value,
-                           _TupleUj>
-{
-};
-
-template <class _Ti, class _TupleUj>
-struct __mu_return<reference_wrapper<_Ti>, _TupleUj>
-{
-    typedef _Ti& type;
-};
-
-template <class _Fp, class _BoundArgs, class _TupleUj>
-struct __bind_return;
-
-template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
-{
-    typedef typename __ref_return
-    <
-        _Fp&,
-        typename __mu_return
-        <
-            _BoundArgs,
-            _TupleUj
-        >::type...
-    >::type type;
-};
-
-template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
-{
-    typedef typename __ref_return
-    <
-        _Fp&,
-        typename __mu_return
-        <
-            const _BoundArgs,
-            _TupleUj
-        >::type...
-    >::type type;
-};
-
-template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __bind_return<_Fp, _BoundArgs, _Args>::type
-__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
-                _Args&& __args)
-{
-    return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
-}
-
-template<class _Fp, class ..._BoundArgs>
-class __bind
-{
-    _Fp __f_;
-    tuple<_BoundArgs...> __bound_args_;
-
-    typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
-public:
-    template <class _Gp, class ..._BA>
-      explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
-        : __f_(_VSTD::forward<_Gp>(__f)),
-          __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
-
-    template <class ..._Args>
-        typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type
-        operator()(_Args&& ...__args)
-        {
-            // compiler bug workaround
-            return __apply_functor(__f_, __bound_args_, __indices(),
-                                  tuple<_Args&&...>(__args...));
-        }
-
-    template <class ..._Args>
-        typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type
-        operator()(_Args&& ...__args) const
-        {
-            return __apply_functor(__f_, __bound_args_, __indices(),
-                                   tuple<_Args&&...>(__args...));
-        }
-};
-
-template<class _Fp, class ..._BoundArgs>
-struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-class __bind_r
-    : public __bind<_Fp, _BoundArgs...>
-{
-    typedef __bind<_Fp, _BoundArgs...> base;
-public:
-    typedef _Rp result_type;
-
-    template <class _Gp, class ..._BA>
-      explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
-        : base(_VSTD::forward<_Gp>(__f),
-               _VSTD::forward<_BA>(__bound_args)...) {}
-
-    template <class ..._Args>
-        result_type
-        operator()(_Args&& ...__args)
-        {
-            return base::operator()(_VSTD::forward<_Args>(__args)...);
-        }
-
-    template <class ..._Args>
-        result_type
-        operator()(_Args&& ...__args) const
-        {
-            return base::operator()(_VSTD::forward<_Args>(__args)...);
-        }
-};
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
-
-template<class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY
-__bind<typename decay<_Fp>::type, typename decay<_BoundArgs>::type...>
-bind(_Fp&& __f, _BoundArgs&&... __bound_args)
-{
-    typedef __bind<typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> type;
-    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
-}
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY
-__bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...>
-bind(_Fp&& __f, _BoundArgs&&... __bound_args)
-{
-    typedef __bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> type;
-    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
-}
-*/
-
 #endif  // _LIBCPP_FUNCTIONAL_03
diff --git a/system/include/libcxx/__functional_base b/system/include/libcxx/__functional_base
index 6766793d7c8ae..1a08ea29deea3 100644
--- a/system/include/libcxx/__functional_base
+++ b/system/include/libcxx/__functional_base
@@ -38,8 +38,6 @@ struct _LIBCPP_TYPE_VIS_ONLY binary_function
     typedef _Result result_type;
 };
 
-template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
-
 template <class _Tp>
 struct __has_result_type
 {
@@ -70,67 +68,13 @@ struct _LIBCPP_TYPE_VIS_ONLY less<void>
     template <class _T1, class _T2> 
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
 
-// addressof
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_Tp*
-addressof(_Tp& __x) _NOEXCEPT
-{
-    return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
-}
-
-#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
-// Objective-C++ Automatic Reference Counting uses qualified pointers
-// that require special addressof() signatures. When
-// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
-// itself is providing these definitions. Otherwise, we provide them.
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__strong _Tp*
-addressof(__strong _Tp& __x) _NOEXCEPT
-{
-  return &__x;
-}
-
-#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__weak _Tp*
-addressof(__weak _Tp& __x) _NOEXCEPT
-{
-  return &__x;
-}
-#endif
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__autoreleasing _Tp*
-addressof(__autoreleasing _Tp& __x) _NOEXCEPT
-{
-  return &__x;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-__unsafe_unretained _Tp*
-addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
-{
-  return &__x;
-}
-#endif
-
-#ifdef _LIBCPP_HAS_NO_VARIADICS
-
-#include <__functional_base_03>
-
-#else  // _LIBCPP_HAS_NO_VARIADICS
-
 // __weak_result_type
 
 template <class _Tp>
@@ -312,6 +256,8 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
 {
 };
 
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
 // 3 or more arguments
 
 template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
@@ -356,67 +302,83 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
     typedef _Rp result_type;
 };
 
-// __invoke
+#endif // _LIBCPP_HAS_NO_VARIADICS
 
-// bullets 1 and 2
+#ifndef _LIBCPP_CXX03_LANG
 
-template <class _Fp, class _A0, class ..._Args,
-            class>
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
-{
-    return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
-}
-
-template <class _Fp, class _A0, class ..._Args,
-            class>
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
+template <class _Tp, class ..._Args>
+struct __invoke_return
 {
-    return ((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...);
-}
+    typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
+};
 
-// bullets 3 and 4
+#else // defined(_LIBCPP_CXX03_LANG)
 
-template <class _Fp, class _A0,
-            class>
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0)
-    -> decltype(_VSTD::forward<_A0>(__a0).*__f)
-{
-    return _VSTD::forward<_A0>(__a0).*__f;
-}
+#include <__functional_base_03>
 
-template <class _Fp, class _A0,
-            class>
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0)
-    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f)
-{
-    return (*_VSTD::forward<_A0>(__a0)).*__f;
-}
+#endif  // !defined(_LIBCPP_CXX03_LANG)
 
-// bullet 5
 
-template <class _Fp, class ..._Args>
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _Args&& ...__args)
-    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
+template <class _Ret>
+struct __invoke_void_return_wrapper
 {
-    return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
-}
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class ..._Args>
+    static _Ret __call(_Args&&... __args) {
+        return __invoke(_VSTD::forward<_Args>(__args)...);
+    }
+#else
+    template <class _Fn>
+    static _Ret __call(_Fn __f) {
+        return __invoke(__f);
+    }
+
+    template <class _Fn, class _A0>
+    static _Ret __call(_Fn __f, _A0& __a0) {
+        return __invoke(__f, __a0);
+    }
+
+    template <class _Fn, class _A0, class _A1>
+    static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
+        return __invoke(__f, __a0, __a1);
+    }
+
+    template <class _Fn, class _A0, class _A1, class _A2>
+    static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
+        return __invoke(__f, __a0, __a1, __a2);
+    }
+#endif
+};
 
-template <class _Tp, class ..._Args>
-struct __invoke_return
+template <>
+struct __invoke_void_return_wrapper<void>
 {
-    typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class ..._Args>
+    static void __call(_Args&&... __args) {
+        __invoke(_VSTD::forward<_Args>(__args)...);
+    }
+#else
+    template <class _Fn>
+    static void __call(_Fn __f) {
+        __invoke(__f);
+    }
+
+    template <class _Fn, class _A0>
+    static void __call(_Fn __f, _A0& __a0) {
+        __invoke(__f, __a0);
+    }
+
+    template <class _Fn, class _A0, class _A1>
+    static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
+        __invoke(__f, __a0, __a1);
+    }
+
+    template <class _Fn, class _A0, class _A1, class _A2>
+    static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
+        __invoke(__f, __a0, __a1, __a2);
+    }
+#endif
 };
 
 template <class _Tp>
@@ -441,20 +403,122 @@ public:
     _LIBCPP_INLINE_VISIBILITY operator type&    () const _NOEXCEPT {return *__f_;}
     _LIBCPP_INLINE_VISIBILITY          type& get() const _NOEXCEPT {return *__f_;}
 
+#ifndef _LIBCPP_HAS_NO_VARIADICS
     // invoke
     template <class... _ArgTypes>
-       _LIBCPP_INLINE_VISIBILITY
-       typename __invoke_of<type&, _ArgTypes...>::type
-          operator() (_ArgTypes&&... __args) const
-          {
-              return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
-          }
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_of<type&, _ArgTypes...>::type
+    operator() (_ArgTypes&&... __args) const {
+        return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
+    }
+#else
+
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return<type>::type
+    operator() () const {
+        return __invoke(get());
+    }
+
+    template <class _A0>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return0<type, _A0>::type
+    operator() (_A0& __a0) const {
+        return __invoke(get(), __a0);
+    }
+
+    template <class _A0>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return0<type, _A0 const>::type
+    operator() (_A0 const& __a0) const {
+        return __invoke(get(), __a0);
+    }
+
+    template <class _A0, class _A1>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return1<type, _A0, _A1>::type
+    operator() (_A0& __a0, _A1& __a1) const {
+        return __invoke(get(), __a0, __a1);
+    }
+
+    template <class _A0, class _A1>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return1<type, _A0 const, _A1>::type
+    operator() (_A0 const& __a0, _A1& __a1) const {
+        return __invoke(get(), __a0, __a1);
+    }
+
+    template <class _A0, class _A1>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return1<type, _A0, _A1 const>::type
+    operator() (_A0& __a0, _A1 const& __a1) const {
+        return __invoke(get(), __a0, __a1);
+    }
+
+    template <class _A0, class _A1>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return1<type, _A0 const, _A1 const>::type
+    operator() (_A0 const& __a0, _A1 const& __a1) const {
+        return __invoke(get(), __a0, __a1);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0, _A1, _A2>::type
+    operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
+        return __invoke(get(), __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0 const, _A1, _A2>::type
+    operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
+        return __invoke(get(), __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0, _A1 const, _A2>::type
+    operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
+        return __invoke(get(), __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0, _A1, _A2 const>::type
+    operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
+        return __invoke(get(), __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
+    operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
+        return __invoke(get(), __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
+    operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
+        return __invoke(get(), __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
+    operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
+        return __invoke(get(), __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
+    operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
+        return __invoke(get(), __a0, __a1, __a2);
+    }
+#endif // _LIBCPP_HAS_NO_VARIADICS
 };
 
-template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
-template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
-template <class _Tp> struct __is_reference_wrapper
-    : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
 
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -488,6 +552,7 @@ cref(reference_wrapper<_Tp> __t) _NOEXCEPT
     return cref(__t.get());
 }
 
+#ifndef _LIBCPP_HAS_NO_VARIADICS
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 
diff --git a/system/include/libcxx/__functional_base_03 b/system/include/libcxx/__functional_base_03
index 22c06add90f4f..8407dcfa39ca3 100644
--- a/system/include/libcxx/__functional_base_03
+++ b/system/include/libcxx/__functional_base_03
@@ -13,943 +13,166 @@
 
 // manual variadic expansion for <functional>
 
-// __weak_result_type
-
-template <class _Tp>
-struct __derives_from_unary_function
-{
-private:
-    struct __two {char __lx; char __lxx;};
-    static __two __test(...);
-    template <class _Ap, class _Rp>
-        static unary_function<_Ap, _Rp>
-        __test(const volatile unary_function<_Ap, _Rp>*);
-public:
-    static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
-    typedef decltype(__test((_Tp*)0)) type;
-};
-
-template <class _Tp>
-struct __derives_from_binary_function
-{
-private:
-    struct __two {char __lx; char __lxx;};
-    static __two __test(...);
-    template <class _A1, class _A2, class _Rp>
-        static binary_function<_A1, _A2, _Rp>
-        __test(const volatile binary_function<_A1, _A2, _Rp>*);
-public:
-    static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
-    typedef decltype(__test((_Tp*)0)) type;
-};
-
-template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
-struct __maybe_derive_from_unary_function  // bool is true
-    : public __derives_from_unary_function<_Tp>::type
-{
-};
-
-template <class _Tp>
-struct __maybe_derive_from_unary_function<_Tp, false>
-{
-};
-
-template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
-struct __maybe_derive_from_binary_function  // bool is true
-    : public __derives_from_binary_function<_Tp>::type
-{
-};
-
-template <class _Tp>
-struct __maybe_derive_from_binary_function<_Tp, false>
-{
-};
-
-template <class _Tp, bool = __has_result_type<_Tp>::value>
-struct __weak_result_type_imp // bool is true
-    : public __maybe_derive_from_unary_function<_Tp>,
-      public __maybe_derive_from_binary_function<_Tp>
-{
-    typedef typename _Tp::result_type result_type;
-};
-
-template <class _Tp>
-struct __weak_result_type_imp<_Tp, false>
-    : public __maybe_derive_from_unary_function<_Tp>,
-      public __maybe_derive_from_binary_function<_Tp>
-{
-};
-
-template <class _Tp>
-struct __weak_result_type
-    : public __weak_result_type_imp<typename remove_reference<_Tp>::type>
-{
-};
-
-// 0 argument case
-
-template <class _Rp>
-struct __weak_result_type<_Rp ()>
-{
-    typedef _Rp result_type;
-};
-
-template <class _Rp>
-struct __weak_result_type<_Rp (&)()>
-{
-    typedef _Rp result_type;
-};
-
-template <class _Rp>
-struct __weak_result_type<_Rp (*)()>
-{
-    typedef _Rp result_type;
-};
-
-// 1 argument case
-
-template <class _Rp, class _A1>
-struct __weak_result_type<_Rp (_A1)>
-    : public unary_function<_A1, _Rp>
-{
-};
-
-template <class _Rp, class _A1>
-struct __weak_result_type<_Rp (&)(_A1)>
-    : public unary_function<_A1, _Rp>
-{
-};
-
-template <class _Rp, class _A1>
-struct __weak_result_type<_Rp (*)(_A1)>
-    : public unary_function<_A1, _Rp>
-{
-};
-
-template <class _Rp, class _Cp>
-struct __weak_result_type<_Rp (_Cp::*)()>
-    : public unary_function<_Cp*, _Rp>
-{
-};
-
-template <class _Rp, class _Cp>
-struct __weak_result_type<_Rp (_Cp::*)() const>
-    : public unary_function<const _Cp*, _Rp>
-{
-};
-
-template <class _Rp, class _Cp>
-struct __weak_result_type<_Rp (_Cp::*)() volatile>
-    : public unary_function<volatile _Cp*, _Rp>
-{
-};
-
-template <class _Rp, class _Cp>
-struct __weak_result_type<_Rp (_Cp::*)() const volatile>
-    : public unary_function<const volatile _Cp*, _Rp>
-{
-};
-
-// 2 argument case
-
-template <class _Rp, class _A1, class _A2>
-struct __weak_result_type<_Rp (_A1, _A2)>
-    : public binary_function<_A1, _A2, _Rp>
-{
-};
-
-template <class _Rp, class _A1, class _A2>
-struct __weak_result_type<_Rp (*)(_A1, _A2)>
-    : public binary_function<_A1, _A2, _Rp>
-{
-};
-
-template <class _Rp, class _A1, class _A2>
-struct __weak_result_type<_Rp (&)(_A1, _A2)>
-    : public binary_function<_A1, _A2, _Rp>
-{
-};
-
-template <class _Rp, class _Cp, class _A1>
-struct __weak_result_type<_Rp (_Cp::*)(_A1)>
-    : public binary_function<_Cp*, _A1, _Rp>
-{
-};
-
-template <class _Rp, class _Cp, class _A1>
-struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
-    : public binary_function<const _Cp*, _A1, _Rp>
-{
-};
-
-template <class _Rp, class _Cp, class _A1>
-struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
-    : public binary_function<volatile _Cp*, _A1, _Rp>
-{
-};
-
-template <class _Rp, class _Cp, class _A1>
-struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
-    : public binary_function<const volatile _Cp*, _A1, _Rp>
-{
-};
+// __invoke
 
-// 3 or more arguments
+template <class _Ret, class _T1, bool _IsFunc, bool _IsBase>
+struct __enable_invoke_imp;
 
-template <class _Rp, class _A1, class _A2, class _A3>
-struct __weak_result_type<_Rp (_A1, _A2, _A3)>
-{
-    typedef _Rp result_type;
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1, true, true> {
+    typedef _Ret _Bullet1;
+    typedef _Bullet1 type;
 };
 
-template <class _Rp, class _A1, class _A2, class _A3>
-struct __weak_result_type<_Rp (&)(_A1, _A2, _A3)>
-{
-    typedef _Rp result_type;
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1, true, false>  {
+    typedef _Ret _Bullet2;
+    typedef _Bullet2 type;
 };
 
-template <class _Rp, class _A1, class _A2, class _A3>
-struct __weak_result_type<_Rp (*)(_A1, _A2, _A3)>
-{
-    typedef _Rp result_type;
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1, false, true>  {
+    typedef typename add_lvalue_reference<
+                typename __apply_cv<_T1, _Ret>::type
+            >::type _Bullet3;
+    typedef _Bullet3 type;
 };
 
-template <class _Rp, class _Cp, class _A1, class _A2>
-struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2)>
-{
-    typedef _Rp result_type;
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1, false, false>  {
+    typedef typename add_lvalue_reference<
+                typename __apply_cv<decltype(*_VSTD::declval<_T1>()), _Ret>::type
+            >::type _Bullet4;
+    typedef _Bullet4 type;
 };
 
-template <class _Rp, class _Cp, class _A1, class _A2>
-struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) const>
-{
-    typedef _Rp result_type;
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1*, false, false>  {
+    typedef typename add_lvalue_reference<
+                typename __apply_cv<_T1, _Ret>::type
+            >::type _Bullet4;
+    typedef _Bullet4  type;
 };
 
-template <class _Rp, class _Cp, class _A1, class _A2>
-struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) volatile>
+template <class _Fn, class _T1,
+          class _Traits = __member_pointer_traits<_Fn>,
+          class _Ret = typename _Traits::_ReturnType,
+          class _Class = typename _Traits::_ClassType>
+struct __enable_invoke : __enable_invoke_imp<
+    _Ret, _T1,
+    is_member_function_pointer<_Fn>::value,
+    is_base_of<_Class, typename remove_reference<_T1>::type>::value>
 {
-    typedef _Rp result_type;
 };
 
-// __invoke
-
-// __ref_return0
-//
-// template <class _Tp, bool _HasResultType>
-// struct ________ref_return0  // _HasResultType is true
-// {
-//     typedef typename _Tp::result_type type;
-// };
-//
-// template <class _Tp>
-// struct ________ref_return0<_Tp, false>
-// {
-//     typedef void type;
-// };
-//
-// template <class _Tp, bool _IsClass>
-// struct ____ref_return0  // _IsClass is true
-//     : public ________ref_return0<_Tp, __has_result_type<typename remove_cv<_Tp>::type>::value>
-// {
-// };
-//
-// template <class _Tp, bool _HasResultType>
-// struct ______ref_return0  // _HasResultType is true
-// {
-//     typedef typename __callable_type<_Tp>::result_type type;
-// };
-//
-// template <class _Tp>
-// struct ______ref_return0<_Tp, false>  // pointer to member data
-// {
-//     typedef void type;
-// };
-//
-// template <class _Tp>
-// struct ____ref_return0<_Tp, false>
-//     : public ______ref_return0<typename remove_cv<_Tp>::type,
-//                  __has_result_type<__callable_type<typename remove_cv<_Tp>::type> >::value>
-// {
-// };
-//
-// template <class _Tp>
-// struct __ref_return0
-//     : public ____ref_return0<typename remove_reference<_Tp>::type,
-//                    is_class<typename remove_reference<_Tp>::type>::value>
-// {
-// };
-//
-// __ref_return1
-//
-// template <class _Tp, bool _IsClass, class _A0>
-// struct ____ref_return1  // _IsClass is true
-// {
-//     typedef typename result_of<_Tp(_A0)>::type type;
-// };
-//
-// template <class _Tp, bool _HasResultType, class _A0>
-// struct ______ref_return1  // _HasResultType is true
-// {
-//     typedef typename __callable_type<_Tp>::result_type type;
-// };
-//
-// template <class _Tp, class _A0, bool>
-// struct __ref_return1_member_data1;
-//
-// template <class _Rp, class _Cp, class _A0>
-// struct __ref_return1_member_data1<_Rp _Cp::*, _A0, true>
-// {
-//     typedef typename __apply_cv<_A0, _Rp>::type& type;
-// };
-//
-// template <class _Rp, class _Cp, class _A0>
-// struct __ref_return1_member_data1<_Rp _Cp::*, _A0, false>
-// {
-//     static _A0 __a;
-//     typedef typename __apply_cv<decltype(*__a), _Rp>::type& type;
-// };
-//
-// template <class _Tp, class _A0>
-// struct __ref_return1_member_data;
-//
-// template <class _Rp, class _Cp, class _A0>
-// struct __ref_return1_member_data<_Rp _Cp::*, _A0>
-//     : public __ref_return1_member_data1<_Rp _Cp::*, _A0,
-//                 is_same<typename remove_cv<_Cp>::type,
-//                         typename remove_cv<typename remove_reference<_A0>::type>::type>::value>
-// {
-// };
-//
-// template <class _Tp, class _A0>
-// struct ______ref_return1<_Tp, false, _A0>  // pointer to member data
-//     : public __ref_return1_member_data<typename remove_cv<_Tp>::type, _A0>
-// {
-// };
-//
-// template <class _Tp, class _A0>
-// struct ____ref_return1<_Tp, false, _A0>
-//     : public ______ref_return1<typename remove_cv<_Tp>::type,
-//                  __has_result_type<__callable_type<typename remove_cv<_Tp>::type> >::value, _A0>
-// {
-// };
-//
-// template <class _Tp, class _A0>
-// struct __ref_return1
-//     : public ____ref_return1<typename remove_reference<_Tp>::type,
-//                    is_class<typename remove_reference<_Tp>::type>::value, _A0>
-// {
-// };
-//
-// __ref_return2
-//
-// template <class _Tp, bool _IsClass, class _A0, class _A1>
-// struct ____ref_return2  // _IsClass is true
-// {
-//     typedef typename result_of<_Tp(_A0, _A1)>::type type;
-// };
-//
-// template <class _Tp, bool _HasResultType, class _A0, class _A1>
-// struct ______ref_return2  // _HasResultType is true
-// {
-//     typedef typename __callable_type<_Tp>::result_type type;
-// };
-//
-// template <class _Tp>
-// struct ______ref_return2<_Tp, false, class _A0, class _A1>  // pointer to member data
-// {
-//     static_assert(sizeof(_Tp) == 0, "An attempt has been made to `call` a pointer"
-//                          " to member data with too many arguments.");
-// };
-//
-// template <class _Tp, class _A0, class _A1>
-// struct ____ref_return2<_Tp, false, _A0, _A1>
-//     : public ______ref_return2<typename remove_cv<_Tp>::type,
-//                  __has_result_type<__callable_type<typename remove_cv<_Tp>::type> >::value, _A0, _A1>
-// {
-// };
-//
-// template <class _Tp, class _A0, class _A1>
-// struct __ref_return2
-//     : public ____ref_return2<typename remove_reference<_Tp>::type,
-//                    is_class<typename remove_reference<_Tp>::type>::value, _A0, _A1>
-// {
-// };
-//
-// __ref_return3
-//
-// template <class _Tp, bool _IsClass, class _A0, class _A1, class _A2>
-// struct ____ref_return3  // _IsClass is true
-// {
-//     typedef typename result_of<_Tp(_A0, _A1, _A2)>::type type;
-// };
-//
-// template <class _Tp, bool _HasResultType, class _A0, class _A1, class _A2>
-// struct ______ref_return3  // _HasResultType is true
-// {
-//     typedef typename __callable_type<_Tp>::result_type type;
-// };
-//
-// template <class _Tp>
-// struct ______ref_return3<_Tp, false, class _A0, class _A1, class _A2>  // pointer to member data
-// {
-//     static_assert(sizeof(_Tp) == 0, "An attempt has been made to `call` a pointer"
-//                          " to member data with too many arguments.");
-// };
-//
-// template <class _Tp, class _A0, class _A1, class _A2>
-// struct ____ref_return3<_Tp, false, _A0, _A1, _A2>
-//     : public ______ref_return3<typename remove_cv<_Tp>::type,
-//                  __has_result_type<__callable_type<typename remove_cv<_Tp>::type> >::value, _A0, _A1, _A2>
-// {
-// };
-//
-// template <class _Tp, class _A0, class _A1, class _A2>
-// struct __ref_return3
-//     : public ____ref_return3<typename remove_reference<_Tp>::type,
-//                    is_class<typename remove_reference<_Tp>::type>::value, _A0, _A1, _A2>
-// {
-// };
+__nat __invoke(__any, ...);
 
 // first bullet
 
-template <class _Rp, class _Tp, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(), _T1& __t1)
-{
-    return (__t1.*__f)();
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0), _T1& __t1, _A0& __a0)
-{
-    return (__t1.*__f)(__a0);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1), _T1& __t1, _A0& __a0, _A1& __a1)
-{
-    return (__t1.*__f)(__a0, __a1);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2), _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2)
-{
-    return (__t1.*__f)(__a0, __a1, __a2);
-}
-
-template <class _Rp, class _Tp, class _T1>
+template <class _Fn, class _T1>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)() const, _T1& __t1)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet1
+__invoke(_Fn __f, _T1& __t1) {
     return (__t1.*__f)();
 }
 
-template <class _Rp, class _Tp, class _T1, class _A0>
+template <class _Fn, class _T1, class _A0>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0) const, _T1& __t1, _A0& __a0)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet1
+__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
     return (__t1.*__f)(__a0);
 }
 
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1>
+template <class _Fn, class _T1, class _A0, class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1) const, _T1& __t1, _A0& __a0, _A1& __a1)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet1
+__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
     return (__t1.*__f)(__a0, __a1);
 }
 
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1, class _A2>
+template <class _Fn, class _T1, class _A0, class _A1, class _A2>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet1
+__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
     return (__t1.*__f)(__a0, __a1, __a2);
 }
 
-template <class _Rp, class _Tp, class _T1>
+template <class _Fn, class _T1>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)() volatile, _T1& __t1)
-{
-    return (__t1.*__f)();
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0) volatile, _T1& __t1, _A0& __a0)
-{
-    return (__t1.*__f)(__a0);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1) volatile, _T1& __t1, _A0& __a0, _A1& __a1)
-{
-    return (__t1.*__f)(__a0, __a1);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) volatile, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2)
-{
-    return (__t1.*__f)(__a0, __a1, __a2);
-}
-
-template <class _Rp, class _Tp, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)() const volatile, _T1& __t1)
-{
-    return (__t1.*__f)();
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0) const volatile, _T1& __t1, _A0& __a0)
-{
-    return (__t1.*__f)(__a0);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1) const volatile, _T1& __t1, _A0& __a0, _A1& __a1)
-{
-    return (__t1.*__f)(__a0, __a1);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const volatile, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2)
-{
-    return (__t1.*__f)(__a0, __a1, __a2);
-}
-
-// second bullet
-
-template <class _Rp, class _Tp, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(), _T1 __t1)
-{
-    return ((*__t1).*__f)();
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0), _T1 __t1, _A0& __a0)
-{
-    return ((*__t1).*__f)(__a0);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1), _T1 __t1, _A0& __a0, _A1& __a1)
-{
-    return ((*__t1).*__f)(__a0, __a1);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2), _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2)
-{
-    return ((*__t1).*__f)(__a0, __a1, __a2);
-}
-
-template <class _Rp, class _Tp, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)() const, _T1 __t1)
-{
-    return ((*__t1).*__f)();
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0) const, _T1 __t1, _A0& __a0)
-{
-    return ((*__t1).*__f)(__a0);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1) const, _T1 __t1, _A0& __a0, _A1& __a1)
-{
-    return ((*__t1).*__f)(__a0, __a1);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2)
-{
-    return ((*__t1).*__f)(__a0, __a1, __a2);
-}
-
-template <class _Rp, class _Tp, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)() volatile, _T1 __t1)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet2
+__invoke(_Fn __f, _T1& __t1) {
     return ((*__t1).*__f)();
 }
 
-template <class _Rp, class _Tp, class _T1, class _A0>
+template <class _Fn, class _T1, class _A0>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0) volatile, _T1 __t1, _A0& __a0)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet2
+__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
     return ((*__t1).*__f)(__a0);
 }
 
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1>
+template <class _Fn, class _T1, class _A0, class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1) volatile, _T1 __t1, _A0& __a0, _A1& __a1)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet2
+__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
     return ((*__t1).*__f)(__a0, __a1);
 }
 
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1, class _A2>
+template <class _Fn, class _T1, class _A0, class _A1, class _A2>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) volatile, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet2
+__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
     return ((*__t1).*__f)(__a0, __a1, __a2);
 }
 
-template <class _Rp, class _Tp, class _T1>
+template <class _Fn, class _T1>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)() const volatile, _T1 __t1)
-{
-    return ((*__t1).*__f)();
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0) const volatile, _T1 __t1, _A0& __a0)
-{
-    return ((*__t1).*__f)(__a0);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1) const volatile, _T1 __t1, _A0& __a0, _A1& __a1)
-{
-    return ((*__t1).*__f)(__a0, __a1);
-}
-
-template <class _Rp, class _Tp, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    _Rp
->::type
-__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const volatile, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2)
-{
-    return ((*__t1).*__f)(__a0, __a1, __a2);
-}
-
-// third bullet
-
-template <class _Rp, class _Tp, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-    typename __apply_cv<_T1, _Rp>::type&
->::type
-__invoke(_Rp _Tp::* __f, _T1& __t1)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet3
+__invoke(_Fn __f, _T1& __t1) {
     return __t1.*__f;
 }
 
-template <class _Rp, class _Tp>
+template <class _Fn, class _T1>
 inline _LIBCPP_INLINE_VISIBILITY
-void
-__invoke(_Rp _Tp::*)
-{
-}
-
-// template <class _Dp, class _Rp, class _Tp, class _T1>
-// inline _LIBCPP_INLINE_VISIBILITY
-// typename enable_if
-// <
-//     is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-//     typename __ref_return1<_Rp _Tp::*, _T1>::type
-// >::type
-// __invoke(_Rp _Tp::* __f, _T1& __t1)
-// {
-//     return __t1.*__f;
-// }
-
-// forth bullet
-
-template <class _T1, class _Rp, bool>
-struct __4th_helper
-{
-};
-
-template <class _T1, class _Rp>
-struct __4th_helper<_T1, _Rp, true>
-{
-    typedef typename __apply_cv<decltype(*_VSTD::declval<_T1>()), _Rp>::type type;
-};
-
-template <class _Rp, class _Tp, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __4th_helper<_T1, _Rp,
-                      !is_base_of<_Tp,
-                                  typename remove_reference<_T1>::type
-                                 >::value
-                     >::type&
-__invoke(_Rp _Tp::* __f, _T1& __t1)
-{
+typename __enable_invoke<_Fn, _T1>::_Bullet4
+__invoke(_Fn __f, _T1& __t1) {
     return (*__t1).*__f;
 }
 
-// template <class _Dp, class _Rp, class _Tp, class _T1>
-// inline _LIBCPP_INLINE_VISIBILITY
-// typename enable_if
-// <
-//     !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
-//     typename __ref_return1<_Rp _Tp::*, _T1>::type
-// >::type
-// __invoke(_Rp _Tp::* __f, _T1 __t1)
-// {
-//     return (*__t1).*__f;
-// }
-
 // fifth bullet
 
 template <class _Fp>
 inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp>()())
-__invoke(_Fp __f)
+decltype(_VSTD::declval<_Fp&>()())
+__invoke(_Fp& __f)
 {
     return __f();
 }
 
 template <class _Fp, class _A0>
 inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp>()(declval<_A0&>()))
-__invoke(_Fp __f, _A0& __a0)
+decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>()))
+__invoke(_Fp& __f, _A0& __a0)
 {
     return __f(__a0);
 }
 
 template <class _Fp, class _A0, class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp>()(declval<_A0&>(), declval<_A1&>()))
-__invoke(_Fp __f, _A0& __a0, _A1& __a1)
+decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>()))
+__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
 {
     return __f(__a0, __a1);
 }
 
 template <class _Fp, class _A0, class _A1, class _A2>
 inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
-__invoke(_Fp __f, _A0& __a0, _A1& __a1, _A2& __a2)
+decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>()))
+__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
 {
     return __f(__a0, __a1, __a2);
 }
 
-// template <class _Rp, class _Fp>
-// inline _LIBCPP_INLINE_VISIBILITY
-// _Rp
-// __invoke(_Fp& __f)
-// {
-//     return __f();
-// }
-//
-// template <class _Rp, class _Fp, class _A0>
-// inline _LIBCPP_INLINE_VISIBILITY
-// typename enable_if
-// <
-//     !is_member_pointer<_Fp>::value,
-//     _Rp
-// >::type
-// __invoke(_Fp& __f, _A0& __a0)
-// {
-//     return __f(__a0);
-// }
-//
-// template <class _Rp, class _Fp, class _A0, class _A1>
-// inline _LIBCPP_INLINE_VISIBILITY
-// _Rp
-// __invoke(_Fp& __f, _A0& __a0, _A1& __a1)
-// {
-//     return __f(__a0, __a1);
-// }
-//
-// template <class _Rp, class _Fp, class _A0, class _A1, class _A2>
-// inline _LIBCPP_INLINE_VISIBILITY
-// _Rp
-// __invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
-// {
-//     return __f(__a0, __a1, __a2);
-// }
-
-template <class _Tp>
-struct __has_type
-{
-private:
-    struct __two {char __lx; char __lxx;};
-    template <class _Up> static __two __test(...);
-    template <class _Up> static char __test(typename _Up::type* = 0);
-public:
-    static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
-
 template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value>
 struct __invoke_return
 {
@@ -959,129 +182,43 @@ struct __invoke_return
 template <class _Fp>
 struct __invoke_return<_Fp, false>
 {
-    typedef decltype(__invoke(_VSTD::declval<_Fp>())) type;
+    typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type;
 };
 
 template <class _Tp, class _A0>
 struct __invoke_return0
 {
-    typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>())) type;
+    typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type;
 };
 
 template <class _Rp, class _Tp, class _A0>
 struct __invoke_return0<_Rp _Tp::*, _A0>
 {
-    typedef typename __apply_cv<_A0, _Rp>::type& type;
-};
-
-template <class _Rp, class _Tp, class _A0>
-struct __invoke_return0<_Rp _Tp::*, _A0*>
-{
-    typedef typename __apply_cv<_A0, _Rp>::type& type;
+    typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type;
 };
 
 template <class _Tp, class _A0, class _A1>
 struct __invoke_return1
 {
-    typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(),
-                                                    _VSTD::declval<_A1>())) type;
+    typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
+                                                      _VSTD::declval<_A1&>())) type;
+};
+
+template <class _Rp, class _Class, class _A0, class _A1>
+struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
+    typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type;
 };
 
 template <class _Tp, class _A0, class _A1, class _A2>
 struct __invoke_return2
 {
-    typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(),
-                                                    _VSTD::declval<_A1>(),
-                                                    _VSTD::declval<_A2>())) type;
+    typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
+                                                      _VSTD::declval<_A1&>(),
+                                                      _VSTD::declval<_A2&>())) type;
 };
 
-template <class _Tp>
-class _LIBCPP_TYPE_VIS_ONLY reference_wrapper
-    : public __weak_result_type<_Tp>
-{
-public:
-    // types
-    typedef _Tp type;
-private:
-    type* __f_;
-
-public:
-    // construct/copy/destroy
-    _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) : __f_(&__f) {}
-
-    // access
-    _LIBCPP_INLINE_VISIBILITY operator type&    () const {return *__f_;}
-    _LIBCPP_INLINE_VISIBILITY          type& get() const {return *__f_;}
-
-    // invoke
-
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return<type&>::type
-       operator() () const
-       {
-           return __invoke(get());
-       }
-
-    template <class _A0>
-       _LIBCPP_INLINE_VISIBILITY
-       typename __invoke_return0<type&, _A0>::type
-          operator() (_A0& __a0) const
-          {
-              return __invoke<type&, _A0>(get(), __a0);
-          }
-
-    template <class _A0, class _A1>
-       _LIBCPP_INLINE_VISIBILITY
-       typename __invoke_return1<type&, _A0, _A1>::type
-          operator() (_A0& __a0, _A1& __a1) const
-          {
-              return __invoke<type&, _A0, _A1>(get(), __a0, __a1);
-          }
-
-    template <class _A0, class _A1, class _A2>
-       _LIBCPP_INLINE_VISIBILITY
-       typename __invoke_return2<type&, _A0, _A1, _A2>::type
-          operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
-          {
-              return __invoke<type&, _A0, _A1, _A2>(get(), __a0, __a1, __a2);
-          }
+template <class _Ret, class _Class, class _A0, class _A1, class _A2>
+struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> {
+    typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type;
 };
-
-template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
-template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
-template <class _Tp> struct __is_reference_wrapper
-    : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-reference_wrapper<_Tp>
-ref(_Tp& __t)
-{
-    return reference_wrapper<_Tp>(__t);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-reference_wrapper<_Tp>
-ref(reference_wrapper<_Tp> __t)
-{
-    return ref(__t.get());
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-reference_wrapper<const _Tp>
-cref(const _Tp& __t)
-{
-    return reference_wrapper<const _Tp>(__t);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-reference_wrapper<const _Tp>
-cref(reference_wrapper<_Tp> __t)
-{
-    return cref(__t.get());
-}
-
 #endif  // _LIBCPP_FUNCTIONAL_BASE_03
diff --git a/system/include/libcxx/__hash_table b/system/include/libcxx/__hash_table
index 7c954b68011dd..13ab928e16fe9 100644
--- a/system/include/libcxx/__hash_table
+++ b/system/include/libcxx/__hash_table
@@ -17,8 +17,10 @@
 #include <iterator>
 #include <algorithm>
 #include <cmath>
+#include <utility>
 
 #include <__undef_min_max>
+#include <__undef___deallocate>
 
 #include <__debug>
 
@@ -28,6 +30,29 @@
 
 _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
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+struct __is_hash_value_type_imp : false_type {};
+
+template <class _Key, class _Value>
+struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {};
+
+template <class ..._Args>
+struct __is_hash_value_type : false_type {};
+
+template <class _One>
+struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};
+#endif
+
 _LIBCPP_FUNC_VIS
 size_t __next_prime(size_t __n);
 
@@ -45,23 +70,18 @@ template <class _Tp, class _VoidPtr>
 struct __hash_node
     : public __hash_node_base
              <
-                 typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                     rebind<__hash_node<_Tp, _VoidPtr> >
-#else
-                     rebind<__hash_node<_Tp, _VoidPtr> >::other
-#endif
+                 typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type
              >
 {
-    typedef _Tp value_type;
+    typedef _Tp __node_value_type;
 
     size_t     __hash_;
-    value_type __value_;
+    __node_value_type __value_;
 };
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__is_power2(size_t __bc)
+__is_hash_power2(size_t __bc)
 {
     return __bc > 2 && !(__bc & (__bc - 1));
 }
@@ -75,37 +95,178 @@ __constrain_hash(size_t __h, size_t __bc)
 
 inline _LIBCPP_INLINE_VISIBILITY
 size_t
-__next_pow2(size_t __n)
+__next_hash_pow2(size_t __n)
 {
     return size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1));
 }
 
+
 template <class _Tp, class _Hash, class _Equal, class _Alloc> class __hash_table;
+
+template <class _NodePtr>      class _LIBCPP_TYPE_VIS_ONLY __hash_iterator;
 template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
+template <class _NodePtr>      class _LIBCPP_TYPE_VIS_ONLY __hash_local_iterator;
+template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
 template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator;
 template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-    class _LIBCPP_TYPE_VIS_ONLY unordered_map;
+
+template <class _Tp>
+struct __hash_key_value_types {
+  static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, "");
+  typedef _Tp key_type;
+  typedef _Tp __node_value_type;
+  typedef _Tp __container_value_type;
+  static const bool __is_map = false;
+
+  _LIBCPP_INLINE_VISIBILITY
+  static key_type const& __get_key(_Tp const& __v) {
+    return __v;
+  }
+  _LIBCPP_INLINE_VISIBILITY
+  static __container_value_type const& __get_value(__node_value_type const& __v) {
+    return __v;
+  }
+  _LIBCPP_INLINE_VISIBILITY
+  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) {
+    return _VSTD::move(__v);
+  }
+#endif
+};
+
+template <class _Key, class _Tp>
+struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
+  typedef _Key                                         key_type;
+  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;
+
+  _LIBCPP_INLINE_VISIBILITY
+  static key_type const& __get_key(__container_value_type const& __v) {
+    return __v.first;
+  }
+
+  template <class _Up>
+  _LIBCPP_INLINE_VISIBILITY
+  static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
+      __container_value_type const&>::type
+  __get_value(_Up& __t) {
+    return __t.__cc;
+  }
+
+  template <class _Up>
+  _LIBCPP_INLINE_VISIBILITY
+  static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
+      __container_value_type const&>::type
+  __get_value(_Up& __t) {
+    return __t;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  static __container_value_type* __get_ptr(__node_value_type& __n) {
+    return _VSTD::addressof(__n.__cc);
+  }
+#ifndef _LIBCPP_CXX03_LANG
+  _LIBCPP_INLINE_VISIBILITY
+  static __nc_value_type&& __move(__node_value_type& __v) {
+    return _VSTD::move(__v.__nc);
+  }
+#endif
+
+};
+
+template <class _Tp, class _AllocPtr, class _KVTypes = __hash_key_value_types<_Tp>,
+          bool = _KVTypes::__is_map>
+struct __hash_map_pointer_types {};
+
+template <class _Tp, class _AllocPtr, class _KVTypes>
+struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
+  typedef typename _KVTypes::__map_value_type   _Mv;
+  typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
+                                                       __map_value_type_pointer;
+  typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
+                                                 __const_map_value_type_pointer;
+};
+
+template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>
+struct __hash_node_types;
+
+template <class _NodePtr, class _Tp, class _VoidPtr>
+struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> >
+    : public __hash_key_value_types<_Tp>, __hash_map_pointer_types<_Tp, _VoidPtr>
+
+{
+  typedef __hash_key_value_types<_Tp>           __base;
+
+public:
+  typedef ptrdiff_t difference_type;
+  typedef size_t size_type;
+
+  typedef typename __rebind_pointer<_NodePtr, void>::type       __void_pointer;
+
+  typedef typename pointer_traits<_NodePtr>::element_type       __node_type;
+  typedef _NodePtr                                              __node_pointer;
+
+  typedef __hash_node_base<__node_pointer>                      __node_base_type;
+  typedef typename __rebind_pointer<_NodePtr, __node_base_type>::type
+                                                             __node_base_pointer;
+
+  typedef _Tp                                                 __node_value_type;
+  typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
+                                                      __node_value_type_pointer;
+  typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
+                                                __const_node_value_type_pointer;
+private:
+    static_assert(!is_const<__node_type>::value,
+                "_NodePtr should never be a pointer to const");
+    static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
+                  "_VoidPtr does not point to unqualified void type");
+    static_assert((is_same<typename __rebind_pointer<_VoidPtr, __node_type>::type,
+                          _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
+};
+
+
+
+template <class _HashIterator>
+struct __hash_node_types_from_iterator;
+template <class _NodePtr>
+struct __hash_node_types_from_iterator<__hash_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
+template <class _NodePtr>
+struct __hash_node_types_from_iterator<__hash_const_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
+template <class _NodePtr>
+struct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
+template <class _NodePtr>
+struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
+
+
+template <class _NodeValueTp, class _VoidPtr>
+struct __make_hash_node_types {
+  typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp;
+  typedef typename __rebind_pointer<_VoidPtr, _NodeTp>::type _NodePtr;
+  typedef __hash_node_types<_NodePtr> type;
+};
 
 template <class _NodePtr>
 class _LIBCPP_TYPE_VIS_ONLY __hash_iterator
 {
-    typedef _NodePtr __node_pointer;
+    typedef __hash_node_types<_NodePtr> _NodeTypes;
+    typedef _NodePtr                    __node_pointer;
 
     __node_pointer            __node_;
 
 public:
-    typedef forward_iterator_tag                         iterator_category;
-    typedef typename pointer_traits<__node_pointer>::element_type::value_type value_type;
-    typedef typename pointer_traits<__node_pointer>::difference_type difference_type;
-    typedef value_type&                                  reference;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                     rebind<value_type>
-#else
-                     rebind<value_type>::other
-#endif
-                                                         pointer;
+    typedef forward_iterator_tag                           iterator_category;
+    typedef typename _NodeTypes::__node_value_type         value_type;
+    typedef typename _NodeTypes::difference_type           difference_type;
+    typedef value_type&                                    reference;
+    typedef typename _NodeTypes::__node_value_type_pointer pointer;
 
     _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT
 #if _LIBCPP_STD_VER > 11
@@ -214,37 +375,24 @@ private:
     template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
 };
 
-template <class _ConstNodePtr>
+template <class _NodePtr>
 class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator
 {
-    typedef _ConstNodePtr __node_pointer;
-
-    __node_pointer         __node_;
+    static_assert(!is_const<typename pointer_traits<_NodePtr>::element_type>::value, "");
+    typedef __hash_node_types<_NodePtr> _NodeTypes;
+    typedef _NodePtr __node_pointer;
 
-    typedef typename remove_const<
-        typename pointer_traits<__node_pointer>::element_type
-                                 >::type __node;
+    __node_pointer __node_;
 
 public:
-    typedef forward_iterator_tag                       iterator_category;
-    typedef typename __node::value_type                value_type;
-    typedef typename pointer_traits<__node_pointer>::difference_type difference_type;
-    typedef const value_type&                          reference;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const value_type>
-#else
-            rebind<const value_type>::other
-#endif
-                                                       pointer;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__node>
-#else
-            rebind<__node>::other
-#endif
-                                                      __non_const_node_pointer;
-    typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator;
+    typedef __hash_iterator<_NodePtr> __non_const_iterator;
+
+    typedef forward_iterator_tag                                 iterator_category;
+    typedef typename _NodeTypes::__node_value_type               value_type;
+    typedef typename _NodeTypes::difference_type                 difference_type;
+    typedef const value_type&                                    reference;
+    typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
+
 
     _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT
 #if _LIBCPP_STD_VER > 11
@@ -360,30 +508,22 @@ private:
     template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
 };
 
-template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
-
 template <class _NodePtr>
 class _LIBCPP_TYPE_VIS_ONLY __hash_local_iterator
 {
-    typedef _NodePtr __node_pointer;
+    typedef __hash_node_types<_NodePtr> _NodeTypes;
+    typedef _NodePtr                    __node_pointer;
 
     __node_pointer         __node_;
     size_t                 __bucket_;
     size_t                 __bucket_count_;
 
-    typedef pointer_traits<__node_pointer>          __pointer_traits;
 public:
     typedef forward_iterator_tag                                iterator_category;
-    typedef typename __pointer_traits::element_type::value_type value_type;
-    typedef typename __pointer_traits::difference_type          difference_type;
+    typedef typename _NodeTypes::__node_value_type              value_type;
+    typedef typename _NodeTypes::difference_type                difference_type;
     typedef value_type&                                         reference;
-    typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<value_type>
-#else
-            rebind<value_type>::other
-#endif
-                                                                pointer;
+    typedef typename _NodeTypes::__node_value_type_pointer      pointer;
 
     _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT
     {
@@ -506,7 +646,8 @@ private:
 template <class _ConstNodePtr>
 class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator
 {
-    typedef _ConstNodePtr __node_pointer;
+    typedef __hash_node_types<_ConstNodePtr> _NodeTypes;
+    typedef _ConstNodePtr                    __node_pointer;
 
     __node_pointer         __node_;
     size_t                 __bucket_;
@@ -515,29 +656,18 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator
     typedef pointer_traits<__node_pointer>          __pointer_traits;
     typedef typename __pointer_traits::element_type __node;
     typedef typename remove_const<__node>::type     __non_const_node;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__non_const_node>
-#else
-            rebind<__non_const_node>::other
-#endif
-                                                    __non_const_node_pointer;
+    typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type
+        __non_const_node_pointer;
+public:
     typedef __hash_local_iterator<__non_const_node_pointer>
                                                     __non_const_iterator;
-public:
-    typedef forward_iterator_tag                       iterator_category;
-    typedef typename remove_const<
-                        typename __pointer_traits::element_type::value_type
-                     >::type                           value_type;
-    typedef typename __pointer_traits::difference_type difference_type;
-    typedef const value_type&                          reference;
-    typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const value_type>
-#else
-            rebind<const value_type>::other
-#endif
-                                                       pointer;
+
+    typedef forward_iterator_tag                                 iterator_category;
+    typedef typename _NodeTypes::__node_value_type               value_type;
+    typedef typename _NodeTypes::difference_type                 difference_type;
+    typedef const value_type&                                    reference;
+    typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
+
 
     _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT
     {
@@ -724,10 +854,11 @@ class __hash_node_destructor
 {
     typedef _Alloc                                          allocator_type;
     typedef allocator_traits<allocator_type>                __alloc_traits;
-    typedef typename __alloc_traits::value_type::value_type value_type;
+
 public:
     typedef typename __alloc_traits::pointer                pointer;
 private:
+    typedef __hash_node_types<pointer> _NodeTypes;
 
     allocator_type& __na_;
 
@@ -747,7 +878,7 @@ public:
     void operator()(pointer __p) _NOEXCEPT
     {
         if (__value_constructed)
-            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_));
+            __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_));
         if (__p)
             __alloc_traits::deallocate(__na_, __p, 1);
     }
@@ -766,54 +897,61 @@ public:
 
 private:
     typedef allocator_traits<allocator_type> __alloc_traits;
+    typedef typename
+      __make_hash_node_types<value_type, typename __alloc_traits::void_pointer>::type
+                                                                     _NodeTypes;
 public:
+
+    typedef typename _NodeTypes::__node_value_type           __node_value_type;
+    typedef typename _NodeTypes::__container_value_type      __container_value_type;
+    typedef typename _NodeTypes::key_type                    key_type;
     typedef value_type&                              reference;
     typedef const value_type&                        const_reference;
     typedef typename __alloc_traits::pointer         pointer;
     typedef typename __alloc_traits::const_pointer   const_pointer;
+#ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
     typedef typename __alloc_traits::size_type       size_type;
-    typedef typename __alloc_traits::difference_type difference_type;
-public:
-    // Create __node
-    typedef __hash_node<value_type, typename __alloc_traits::void_pointer> __node;
-    typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__node>
 #else
-            rebind_alloc<__node>::other
+    typedef typename _NodeTypes::size_type           size_type;
 #endif
-                                                     __node_allocator;
+    typedef typename _NodeTypes::difference_type     difference_type;
+public:
+    // Create __node
+
+    typedef typename _NodeTypes::__node_type __node;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
     typedef allocator_traits<__node_allocator>       __node_traits;
-    typedef typename __node_traits::pointer          __node_pointer;
-    typedef typename __node_traits::pointer          __node_const_pointer;
-    typedef __hash_node_base<__node_pointer>         __first_node;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__first_node>
-#else
-            rebind<__first_node>::other
-#endif
-                                                     __node_base_pointer;
+    typedef typename _NodeTypes::__void_pointer      __void_pointer;
+    typedef typename _NodeTypes::__node_pointer      __node_pointer;
+    typedef typename _NodeTypes::__node_pointer      __node_const_pointer;
+    typedef typename _NodeTypes::__node_base_type    __first_node;
+    typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
 
 private:
+    // check for sane allocator pointer rebinding semantics. Rebinding the
+    // allocator for a new pointer type should be exactly the same as rebinding
+    // the pointer using 'pointer_traits'.
+    static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
+                  "Allocator does not rebind pointers in a sane manner.");
+    typedef typename __rebind_alloc_helper<__node_traits, __first_node>::type
+        __node_base_allocator;
+    typedef allocator_traits<__node_base_allocator> __node_base_traits;
+    static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
+                 "Allocator does not rebind pointers in a sane manner.");
 
-    typedef typename __node_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__node_pointer>
-#else
-            rebind_alloc<__node_pointer>::other
-#endif
-                                                            __pointer_allocator;
+private:
+
+    typedef typename __rebind_alloc_helper<__node_traits, __node_pointer>::type __pointer_allocator;
     typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;
     typedef unique_ptr<__node_pointer[], __bucket_list_deleter> __bucket_list;
     typedef allocator_traits<__pointer_allocator>          __pointer_alloc_traits;
     typedef typename __bucket_list_deleter::pointer __node_pointer_pointer;
 
     // --- Member data begin ---
-    __bucket_list                                     __bucket_list_;
-    __compressed_pair<__first_node, __node_allocator> __p1_;
-    __compressed_pair<size_type, hasher>              __p2_;
-    __compressed_pair<float, key_equal>               __p3_;
+    __bucket_list                                         __bucket_list_;
+    __compressed_pair<__first_node, __node_allocator>     __p1_;
+    __compressed_pair<size_type, hasher>                  __p2_;
+    __compressed_pair<float, key_equal>                   __p3_;
     // --- Member data end ---
 
     _LIBCPP_INLINE_VISIBILITY
@@ -849,6 +987,7 @@ public:
     typedef __hash_local_iterator<__node_pointer>             local_iterator;
     typedef __hash_const_local_iterator<__node_pointer>       const_local_iterator;
 
+    _LIBCPP_INLINE_VISIBILITY
     __hash_table()
         _NOEXCEPT_(
             is_nothrow_default_constructible<__bucket_list>::value &&
@@ -856,13 +995,14 @@ public:
             is_nothrow_default_constructible<__node_allocator>::value &&
             is_nothrow_default_constructible<hasher>::value &&
             is_nothrow_default_constructible<key_equal>::value);
+    _LIBCPP_INLINE_VISIBILITY
     __hash_table(const hasher& __hf, const key_equal& __eql);
     __hash_table(const hasher& __hf, const key_equal& __eql,
                  const allocator_type& __a);
     explicit __hash_table(const allocator_type& __a);
     __hash_table(const __hash_table& __u);
     __hash_table(const __hash_table& __u, const allocator_type& __a);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
     __hash_table(__hash_table&& __u)
         _NOEXCEPT_(
             is_nothrow_move_constructible<__bucket_list>::value &&
@@ -871,11 +1011,12 @@ public:
             is_nothrow_move_constructible<hasher>::value &&
             is_nothrow_move_constructible<key_equal>::value);
     __hash_table(__hash_table&& __u, const allocator_type& __a);
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
     ~__hash_table();
 
     __hash_table& operator=(const __hash_table& __u);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
+    _LIBCPP_INLINE_VISIBILITY
     __hash_table& operator=(__hash_table&& __u)
         _NOEXCEPT_(
             __node_traits::propagate_on_container_move_assignment::value &&
@@ -900,31 +1041,103 @@ public:
     iterator             __node_insert_multi(const_iterator __p,
                                              __node_pointer __nd);
 
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+#ifndef _LIBCPP_CXX03_LANG
+    template <class _Key, class ..._Args>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __emplace_unique_key_args(_Key const& __k, _Args&&... __args);
+
     template <class... _Args>
-        pair<iterator, bool> __emplace_unique(_Args&&... __args);
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __emplace_unique_impl(_Args&&... __args);
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __emplace_unique(_Pp&& __x) {
+      return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x),
+                                          __can_extract_key<_Pp, key_type>());
+    }
+
+    template <class _First, class _Second>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<
+        __can_extract_map_key<_First, key_type, __container_value_type>::value,
+        pair<iterator, bool>
+    >::type __emplace_unique(_First&& __f, _Second&& __s) {
+        return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
+                                              _VSTD::forward<_Second>(__s));
+    }
+
+    template <class... _Args>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __emplace_unique(_Args&&... __args) {
+      return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...);
+    }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+    __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) {
+      return __emplace_unique_impl(_VSTD::forward<_Pp>(__x));
+    }
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+    __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) {
+      return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x));
+    }
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+    __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) {
+      return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x));
+    }
+
     template <class... _Args>
-        iterator __emplace_multi(_Args&&... __args);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __emplace_multi(_Args&&... __args);
     template <class... _Args>
-        iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
-#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
 
-    pair<iterator, bool> __insert_unique(const value_type& __x);
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    template <class _Pp>
-        pair<iterator, bool> __insert_unique(_Pp&& __x);
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+    __insert_unique(__container_value_type&& __x) {
+      return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x));
+    }
+
+    template <class _Pp, class = typename enable_if<
+            !__is_same_uncvref<_Pp, __container_value_type>::value
+        >::type>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __insert_unique(_Pp&& __x) {
+      return __emplace_unique(_VSTD::forward<_Pp>(__x));
+    }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template <class _Pp>
-        iterator __insert_multi(_Pp&& __x);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_multi(_Pp&& __x) {
+      return __emplace_multi(_VSTD::forward<_Pp>(__x));
+    }
+
     template <class _Pp>
-        iterator __insert_multi(const_iterator __p, _Pp&& __x);
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    iterator __insert_multi(const value_type& __x);
-    iterator __insert_multi(const_iterator __p, const value_type& __x);
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_multi(const_iterator __p, _Pp&& __x) {
+        return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x));
+    }
+
+#else  // !defined(_LIBCPP_CXX03_LANG)
+    template <class _Key, class _Args>
+    pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args& __args);
+
+    iterator __insert_multi(const __container_value_type& __x);
+    iterator __insert_multi(const_iterator __p, const __container_value_type& __x);
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __insert_unique(const __container_value_type& __x) {
+        return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
+    }
 
     void clear() _NOEXCEPT;
     void rehash(size_type __n);
@@ -937,9 +1150,13 @@ public:
         return __bucket_list_.get_deleter().size();
     }
 
+    _LIBCPP_INLINE_VISIBILITY
     iterator       begin() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     iterator       end() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     const_iterator begin() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     const_iterator end() const _NOEXCEPT;
 
     template <class _Key>
@@ -968,6 +1185,7 @@ public:
     __node_holder remove(const_iterator __p) _NOEXCEPT;
 
     template <class _Key>
+        _LIBCPP_INLINE_VISIBILITY
         size_type __count_unique(const _Key& __k) const;
     template <class _Key>
         size_type __count_multi(const _Key& __k) const;
@@ -987,13 +1205,17 @@ public:
         __equal_range_multi(const _Key& __k) const;
 
     void swap(__hash_table& __u)
+#if _LIBCPP_STD_VER <= 11
         _NOEXCEPT_(
-            (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
-             __is_nothrow_swappable<__pointer_allocator>::value) &&
-            (!__node_traits::propagate_on_container_swap::value ||
-             __is_nothrow_swappable<__node_allocator>::value) &&
-            __is_nothrow_swappable<hasher>::value &&
-            __is_nothrow_swappable<key_equal>::value);
+            __is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
+            && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
+                  || __is_nothrow_swappable<__pointer_allocator>::value)
+            && (!__node_traits::propagate_on_container_swap::value
+                  || __is_nothrow_swappable<__node_allocator>::value)
+            );
+#else
+     _NOEXCEPT_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value);
+#endif
 
     _LIBCPP_INLINE_VISIBILITY
     size_type max_bucket_count() const _NOEXCEPT
@@ -1075,16 +1297,17 @@ public:
 private:
     void __rehash(size_type __n);
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
     template <class ..._Args>
-        __node_holder __construct_node(_Args&& ...__args);
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-    __node_holder __construct_node(value_type&& __v, size_t __hash);
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    __node_holder __construct_node(const value_type& __v);
+    __node_holder __construct_node(_Args&& ...__args);
+
+    template <class _First, class ..._Rest>
+    __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest);
+#else // _LIBCPP_CXX03_LANG
+    __node_holder __construct_node(const __container_value_type& __v);
+    __node_holder __construct_node_hash(size_t __hash, const __container_value_type& __v);
 #endif
-    __node_holder __construct_node(const value_type& __v, size_t __hash);
+
 
     _LIBCPP_INLINE_VISIBILITY
     void __copy_assign_alloc(const __hash_table& __u)
@@ -1094,6 +1317,7 @@ private:
     _LIBCPP_INLINE_VISIBILITY
         void __copy_assign_alloc(const __hash_table&, false_type) {}
 
+#ifndef _LIBCPP_CXX03_LANG
     void __move_assign(__hash_table& __u, false_type);
     void __move_assign(__hash_table& __u, true_type)
         _NOEXCEPT_(
@@ -1120,38 +1344,7 @@ private:
     }
     _LIBCPP_INLINE_VISIBILITY
         void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
-
-    template <class _Ap>
-    _LIBCPP_INLINE_VISIBILITY
-    static
-    void
-    __swap_alloc(_Ap& __x, _Ap& __y)
-        _NOEXCEPT_(
-            !allocator_traits<_Ap>::propagate_on_container_swap::value ||
-            __is_nothrow_swappable<_Ap>::value)
-    {
-        __swap_alloc(__x, __y,
-                     integral_constant<bool,
-                        allocator_traits<_Ap>::propagate_on_container_swap::value
-                                      >());
-    }
-
-    template <class _Ap>
-    _LIBCPP_INLINE_VISIBILITY
-    static
-    void
-    __swap_alloc(_Ap& __x, _Ap& __y, true_type)
-        _NOEXCEPT_(__is_nothrow_swappable<_Ap>::value)
-    {
-        using _VSTD::swap;
-        swap(__x, __y);
-    }
-
-    template <class _Ap>
-    _LIBCPP_INLINE_VISIBILITY
-    static
-    void
-    __swap_alloc(_Ap&, _Ap&, false_type) _NOEXCEPT {}
+#endif // _LIBCPP_CXX03_LANG
 
     void __deallocate(__node_pointer __np) _NOEXCEPT;
     __node_pointer __detach() _NOEXCEPT;
@@ -1161,11 +1354,12 @@ private:
 };
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table()
     _NOEXCEPT_(
         is_nothrow_default_constructible<__bucket_list>::value &&
         is_nothrow_default_constructible<__first_node>::value &&
+        is_nothrow_default_constructible<__node_allocator>::value &&
         is_nothrow_default_constructible<hasher>::value &&
         is_nothrow_default_constructible<key_equal>::value)
     : __p2_(0),
@@ -1174,7 +1368,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table()
 }
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
                                                        const key_equal& __eql)
     : __bucket_list_(nullptr, __bucket_list_deleter()),
@@ -1227,13 +1421,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
 {
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
         _NOEXCEPT_(
             is_nothrow_move_constructible<__bucket_list>::value &&
             is_nothrow_move_constructible<__first_node>::value &&
+            is_nothrow_move_constructible<__node_allocator>::value &&
             is_nothrow_move_constructible<hasher>::value &&
             is_nothrow_move_constructible<key_equal>::value)
     : __bucket_list_(_VSTD::move(__u.__bucket_list_)),
@@ -1275,7 +1470,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
     }
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
@@ -1340,7 +1535,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__node_pointer __np)
         }
         __get_db()->unlock();
 #endif
-        __node_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+        __node_traits::destroy(__na, _NodeTypes::__get_ptr(__np->__value_));
         __node_traits::deallocate(__na, __np, 1);
         __np = __next;
     }
@@ -1359,7 +1554,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT
     return __cache;
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 void
@@ -1432,8 +1627,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
         const_iterator __i = __u.begin();
         while (__u.size() != 0)
         {
-            __node_holder __h =
-                    __construct_node(_VSTD::move(__u.remove(__i++)->__value_));
+            __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__value_));
             __node_insert_multi(__h.get());
             __h.release();
         }
@@ -1441,7 +1635,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
 }
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __hash_table<_Tp, _Hash, _Equal, _Alloc>&
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
     _NOEXCEPT_(
@@ -1455,7 +1649,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
     return *this;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 template <class _InputIterator>
@@ -1463,6 +1657,11 @@ void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first,
                                                           _InputIterator __last)
 {
+    typedef iterator_traits<_InputIterator> _ITraits;
+    typedef typename _ITraits::value_type _ItValueType;
+    static_assert((is_same<_ItValueType, __container_value_type>::value),
+                  "__assign_unique may only be called with the containers value type");
+
     if (bucket_count() != 0)
     {
         __node_pointer __cache = __detach();
@@ -1497,6 +1696,12 @@ void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
                                                          _InputIterator __last)
 {
+    typedef iterator_traits<_InputIterator> _ITraits;
+    typedef typename _ITraits::value_type _ItValueType;
+    static_assert((is_same<_ItValueType, __container_value_type>::value ||
+                  is_same<_ItValueType, __node_value_type>::value),
+                  "__assign_multi may only be called with the containers value type"
+                  " or the nodes value type");
     if (bucket_count() != 0)
     {
         __node_pointer __cache = __detach();
@@ -1522,11 +1727,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
         __deallocate(__cache);
     }
     for (; __first != __last; ++__first)
-        __insert_multi(*__first);
+        __insert_multi(_NodeTypes::__get_value(*__first));
 }
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
 {
@@ -1538,7 +1743,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
 }
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
 {
@@ -1550,7 +1755,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
 }
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
 {
@@ -1562,7 +1767,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
 }
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
 {
@@ -1615,7 +1820,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __
     {
         if (size()+1 > __bc * max_load_factor() || __bc == 0)
         {
-            rehash(_VSTD::max<size_type>(2 * __bc + !__is_power2(__bc),
+            rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
                            size_type(ceil(float(size() + 1) / max_load_factor()))));
             __bc = bucket_count();
             __chash = __constrain_hash(__nd->__hash_, __bc);
@@ -1658,7 +1863,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c
     size_type __bc = bucket_count();
     if (size()+1 > __bc * max_load_factor() || __bc == 0)
     {
-        rehash(_VSTD::max<size_type>(2 * __bc + !__is_power2(__bc),
+        rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
                        size_type(ceil(float(size() + 1) / max_load_factor()))));
         __bc = bucket_count();
     }
@@ -1728,7 +1933,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
         size_type __bc = bucket_count();
         if (size()+1 > __bc * max_load_factor() || __bc == 0)
         {
-            rehash(_VSTD::max<size_type>(2 * __bc + !__is_power2(__bc),
+            rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
                            size_type(ceil(float(size() + 1) / max_load_factor()))));
             __bc = bucket_count();
         }
@@ -1748,11 +1953,24 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
     return __node_insert_multi(__cp);
 }
 
+
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key, class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
+#else
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key, class _Args>
+_LIBCPP_INLINE_VISIBILITY
 pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args& __args)
+#endif
 {
-    size_t __hash = hash_function()(__x);
+
+    size_t __hash = hash_function()(__k);
     size_type __bc = bucket_count();
     bool __inserted = false;
     __node_pointer __nd;
@@ -1767,16 +1985,20 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x)
                                        __constrain_hash(__nd->__hash_, __bc) == __chash;
                                                            __nd = __nd->__next_)
             {
-                if (key_eq()(__nd->__value_, __x))
+                if (key_eq()(__nd->__value_, __k))
                     goto __done;
             }
         }
     }
     {
-        __node_holder __h = __construct_node(__x, __hash);
+#ifndef _LIBCPP_CXX03_LANG
+        __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
+#else
+        __node_holder __h = __construct_node_hash(__hash, __args);
+#endif
         if (size()+1 > __bc * max_load_factor() || __bc == 0)
         {
-            rehash(_VSTD::max<size_type>(2 * __bc + !__is_power2(__bc),
+            rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
                            size_type(ceil(float(size() + 1) / max_load_factor()))));
             __bc = bucket_count();
             __chash = __constrain_hash(__hash, __bc);
@@ -1785,7 +2007,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x)
         __node_pointer __pn = __bucket_list_[__chash];
         if (__pn == nullptr)
         {
-            __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
+            __pn = static_cast<__node_pointer>(static_cast<__void_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())));
             __h->__next_ = __pn->__next_;
             __pn->__next_ = __h.get();
             // fix up __bucket_list_
@@ -1811,13 +2033,12 @@ __done:
 #endif
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 template <class... _Args>
 pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique(_Args&&... __args)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_impl(_Args&&... __args)
 {
     __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
     pair<iterator, bool> __r = __node_insert_unique(__h.get());
@@ -1854,57 +2075,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
     return __r;
 }
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-
-template <class _Tp, class _Hash, class _Equal, class _Alloc>
-template <class _Pp>
-pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(_Pp&& __x)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x));
-    pair<iterator, bool> __r = __node_insert_unique(__h.get());
-    if (__r.second)
-        __h.release();
-    return __r;
-}
-
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-template <class _Tp, class _Hash, class _Equal, class _Alloc>
-template <class _Pp>
-typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(_Pp&& __x)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x));
-    iterator __r = __node_insert_multi(__h.get());
-    __h.release();
-    return __r;
-}
-
-template <class _Tp, class _Hash, class _Equal, class _Alloc>
-template <class _Pp>
-typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
-                                                         _Pp&& __x)
-{
-#if _LIBCPP_DEBUG_LEVEL >= 2
-    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
-        "unordered container::insert(const_iterator, rvalue) called with an iterator not"
-        " referring to this unordered container");
-#endif
-    __node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x));
-    iterator __r = __node_insert_multi(__p, __h.get());
-    __h.release();
-    return __r;
-}
-
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else // _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const value_type& __x)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const __container_value_type& __x)
 {
     __node_holder __h = __construct_node(__x);
     iterator __r = __node_insert_multi(__h.get());
@@ -1915,7 +2090,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const value_type& __x)
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
-                                                         const value_type& __x)
+                                                         const __container_value_type& __x)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
     _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
@@ -1928,7 +2103,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
     return __r;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 void
@@ -1946,8 +2121,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
         __n = _VSTD::max<size_type>
               (
                   __n,
-                  __is_power2(__bc) ? __next_pow2(size_t(ceil(float(size()) / max_load_factor()))) :
-                                      __next_prime(size_t(ceil(float(size()) / max_load_factor())))
+                  __is_hash_power2(__bc) ? __next_hash_pow2(size_t(ceil(float(size()) / max_load_factor()))) :
+                                           __next_prime(size_t(ceil(float(size()) / max_load_factor())))
               );
         if (__n < __bc)
             __rehash(__n);
@@ -2067,70 +2242,74 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
     return end();
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 template <class ..._Args>
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args)
 {
+    static_assert(!__is_hash_value_type<_Args...>::value,
+                  "Construct cannot be called with a hash value type");
     __node_allocator& __na = __node_alloc();
     __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_Args>(__args)...);
+    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...);
     __h.get_deleter().__value_constructed = true;
     __h->__hash_ = hash_function()(__h->__value_);
     __h->__next_ = nullptr;
     return __h;
 }
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _First, class ..._Rest>
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v,
-                                                           size_t __hash)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(
+    size_t __hash, _First&& __f, _Rest&& ...__rest)
 {
+    static_assert(!__is_hash_value_type<_First, _Rest...>::value,
+                  "Construct cannot be called with a hash value type");
     __node_allocator& __na = __node_alloc();
     __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::move(__v));
+    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_),
+                             _VSTD::forward<_First>(__f),
+                             _VSTD::forward<_Rest>(__rest)...);
     __h.get_deleter().__value_constructed = true;
     __h->__hash_ = __hash;
     __h->__next_ = nullptr;
     return __h;
 }
 
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else  // _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const __container_value_type& __v)
 {
     __node_allocator& __na = __node_alloc();
     __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v);
+    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
     __h.get_deleter().__value_constructed = true;
     __h->__hash_ = hash_function()(__h->__value_);
     __h->__next_ = nullptr;
-    return _VSTD::move(__h);  // explicitly moved for C++03
+    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v,
-                                                           size_t __hash)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash,
+                                                                const __container_value_type& __v)
 {
     __node_allocator& __na = __node_alloc();
     __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v);
+    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
     __h.get_deleter().__value_constructed = true;
     __h->__hash_ = __hash;
     __h->__next_ = nullptr;
-    return _VSTD::move(__h);  // explicitly moved for C++03
+    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
 
+#endif  // _LIBCPP_CXX03_LANG
+
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
@@ -2260,7 +2439,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
 
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 template <class _Key>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const
 {
@@ -2357,13 +2536,17 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
+#if _LIBCPP_STD_VER <= 11
     _NOEXCEPT_(
-        (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
-         __is_nothrow_swappable<__pointer_allocator>::value) &&
-        (!__node_traits::propagate_on_container_swap::value ||
-         __is_nothrow_swappable<__node_allocator>::value) &&
-        __is_nothrow_swappable<hasher>::value &&
-        __is_nothrow_swappable<key_equal>::value)
+        __is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
+        && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
+              || __is_nothrow_swappable<__pointer_allocator>::value)
+        && (!__node_traits::propagate_on_container_swap::value
+              || __is_nothrow_swappable<__node_allocator>::value)
+            )
+#else
+  _NOEXCEPT_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value)
+#endif
 {
     {
     __node_pointer_pointer __npp = __bucket_list_.release();
@@ -2371,9 +2554,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
     __u.__bucket_list_.reset(__npp);
     }
     _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());
-    __swap_alloc(__bucket_list_.get_deleter().__alloc(),
+    __swap_allocator(__bucket_list_.get_deleter().__alloc(),
              __u.__bucket_list_.get_deleter().__alloc());
-    __swap_alloc(__node_alloc(), __u.__node_alloc());
+    __swap_allocator(__node_alloc(), __u.__node_alloc());
     _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);
     __p2_.swap(__u.__p2_);
     __p3_.swap(__u.__p3_);
diff --git a/system/include/libcxx/__locale b/system/include/libcxx/__locale
index 5ccd795b8774a..7bc701dda6e3c 100644
--- a/system/include/libcxx/__locale
+++ b/system/include/libcxx/__locale
@@ -29,9 +29,16 @@
 # if __ANDROID_API__ <= 20
 #  include <support/android/locale_bionic.h>
 # endif
+#elif defined(__sun__)
+# include <xlocale.h>
+# include <support/solaris/xlocale.h>
+#elif defined(_NEWLIB_VERSION)
+# include <support/newlib/xlocale.h>
 #elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-    || defined(__sun__)   || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
+    || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
 # include <xlocale.h>
+#elif defined(_LIBCPP_HAS_MUSL_LIBC)
+# include <support/musl/xlocale.h>
 #endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -324,7 +331,7 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
 class _LIBCPP_TYPE_VIS ctype_base
 {
 public:
-#ifdef __GLIBC__
+#if defined(__GLIBC__)
     typedef unsigned short mask;
     static const mask space  = _ISspace;
     static const mask print  = _ISprint;
@@ -348,16 +355,15 @@ public:
     static const mask punct  = _PUNCT;
     static const mask xdigit = _HEX;
     static const mask blank  = _BLANK;
-#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__ANDROID__)
-#ifdef __APPLE__
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
+#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+# ifdef __APPLE__
     typedef __uint32_t mask;
-#elif defined(__FreeBSD__)
+# elif defined(__FreeBSD__)
     typedef unsigned long mask;
-#elif defined(__EMSCRIPTEN__) ||  defined(__NetBSD__)
+# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
     typedef unsigned short mask;
-#elif defined(__ANDROID__)
-    typedef unsigned char mask;
-#endif
+# endif
     static const mask space  = _CTYPE_S;
     static const mask print  = _CTYPE_R;
     static const mask cntrl  = _CTYPE_C;
@@ -366,11 +372,7 @@ public:
     static const mask alpha  = _CTYPE_A;
     static const mask digit  = _CTYPE_D;
     static const mask punct  = _CTYPE_P;
-# if defined(__ANDROID__)
-    static const mask xdigit = _CTYPE_X | _CTYPE_D;
-# else
     static const mask xdigit = _CTYPE_X;
-# endif
 
 # if defined(__NetBSD__)
     static const mask blank  = _CTYPE_BL;
@@ -389,7 +391,23 @@ public:
     static const mask punct  = _ISPUNCT;
     static const mask xdigit = _ISXDIGIT;
     static const mask blank  = _ISBLANK;
-#else  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || __EMSCRIPTEN__ || __sun__
+#elif defined(_NEWLIB_VERSION)
+    // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
+    typedef char mask;
+    static const mask space  = _S;
+    static const mask print  = _P | _U | _L | _N | _B;
+    static const mask cntrl  = _C;
+    static const mask upper  = _U;
+    static const mask lower  = _L;
+    static const mask alpha  = _U | _L;
+    static const mask digit  = _N;
+    static const mask punct  = _P;
+    static const mask xdigit = _X | _N;
+    static const mask blank  = _B;
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
+#else
     typedef unsigned long mask;
     static const mask space  = 1<<0;
     static const mask print  = 1<<1;
@@ -401,7 +419,7 @@ public:
     static const mask punct  = 1<<7;
     static const mask xdigit = 1<<8;
     static const mask blank  = 1<<9;
-#endif  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__
+#endif
     static const mask alnum  = alpha | digit;
     static const mask graph  = alnum | punct;
 
@@ -1416,7 +1434,7 @@ protected:
 
 // template <class charT> class numpunct_byname
 
-template <class charT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname;
+template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname;
 
 template <>
 class _LIBCPP_TYPE_VIS numpunct_byname<char>
diff --git a/system/include/libcxx/__mutex_base b/system/include/libcxx/__mutex_base
index d5ece7c1454c8..364c69e45d689 100644
--- a/system/include/libcxx/__mutex_base
+++ b/system/include/libcxx/__mutex_base
@@ -14,7 +14,9 @@
 #include <__config>
 #include <chrono>
 #include <system_error>
+#ifndef _LIBCPP_HAS_NO_THREADS
 #include <pthread.h>
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -24,7 +26,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-class _LIBCPP_TYPE_VIS mutex
+#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
+#  ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+#  else
+#    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+#  endif
+#endif  // _LIBCPP_THREAD_SAFETY_ANNOTATION
+
+class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
 {
     pthread_mutex_t __m_;
 
@@ -42,9 +52,9 @@ private:
     mutex& operator=(const mutex&);// = delete;
 
 public:
-    void lock();
-    bool try_lock() _NOEXCEPT;
-    void unlock() _NOEXCEPT;
+    void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());
+    bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
+    void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
 
     typedef pthread_mutex_t* native_handle_type;
     _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
@@ -69,7 +79,7 @@ constexpr adopt_lock_t  adopt_lock  = adopt_lock_t();
 #endif
 
 template <class _Mutex>
-class _LIBCPP_TYPE_VIS_ONLY lock_guard
+class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) lock_guard
 {
 public:
     typedef _Mutex mutex_type;
@@ -79,13 +89,13 @@ private:
 public:
 
     _LIBCPP_INLINE_VISIBILITY
-    explicit lock_guard(mutex_type& __m)
+    explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
         : __m_(__m) {__m_.lock();}
     _LIBCPP_INLINE_VISIBILITY
-    lock_guard(mutex_type& __m, adopt_lock_t)
+    lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
         : __m_(__m) {}
     _LIBCPP_INLINE_VISIBILITY
-    ~lock_guard() {__m_.unlock();}
+    ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}
 
 private:
     lock_guard(lock_guard const&);// = delete;
@@ -107,24 +117,24 @@ public:
     unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
     _LIBCPP_INLINE_VISIBILITY
     explicit unique_lock(mutex_type& __m)
-        : __m_(&__m), __owns_(true) {__m_->lock();}
+        : __m_(_VSTD::addressof(__m)), __owns_(true) {__m_->lock();}
     _LIBCPP_INLINE_VISIBILITY
     unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
-        : __m_(&__m), __owns_(false) {}
+        : __m_(_VSTD::addressof(__m)), __owns_(false) {}
     _LIBCPP_INLINE_VISIBILITY
     unique_lock(mutex_type& __m, try_to_lock_t)
-        : __m_(&__m), __owns_(__m.try_lock()) {}
+        : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock()) {}
     _LIBCPP_INLINE_VISIBILITY
     unique_lock(mutex_type& __m, adopt_lock_t)
-        : __m_(&__m), __owns_(true) {}
+        : __m_(_VSTD::addressof(__m)), __owns_(true) {}
     template <class _Clock, class _Duration>
     _LIBCPP_INLINE_VISIBILITY
         unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
-            : __m_(&__m), __owns_(__m.try_lock_until(__t)) {}
+            : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
     template <class _Rep, class _Period>
     _LIBCPP_INLINE_VISIBILITY
         unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
-            : __m_(&__m), __owns_(__m.try_lock_for(__d)) {}
+            : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
     _LIBCPP_INLINE_VISIBILITY
     ~unique_lock()
     {
@@ -306,6 +316,7 @@ public:
 
     template <class _Rep, class _Period, class _Predicate>
         bool
+        _LIBCPP_INLINE_VISIBILITY
         wait_for(unique_lock<mutex>& __lk,
                  const chrono::duration<_Rep, _Period>& __d,
                  _Predicate __pred);
@@ -390,7 +401,7 @@ condition_variable::wait_for(unique_lock<mutex>& __lk,
 }
 
 template <class _Rep, class _Period, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 condition_variable::wait_for(unique_lock<mutex>& __lk,
                              const chrono::duration<_Rep, _Period>& __d,
diff --git a/system/include/libcxx/__nullptr b/system/include/libcxx/__nullptr
new file mode 100644
index 0000000000000..95415a6325a31
--- /dev/null
+++ b/system/include/libcxx/__nullptr
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+//===--------------------------- __nullptr --------------------------------===//
+//
+//                     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_NULLPTR
+#define _LIBCPP_NULLPTR
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_HAS_NO_NULLPTR
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
+{
+    void* __lx;
+
+    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_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
+
+    template <class _Tp>
+        _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
+        operator _Tp* () const {return 0;}
+
+    template <class _Tp, class _Up>
+        _LIBCPP_ALWAYS_INLINE
+        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_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;}
+    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_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;}
+};
+
+inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
+
+#define nullptr _VSTD::__get_nullptr_t()
+
+_LIBCPP_END_NAMESPACE_STD
+
+#else  // _LIBCPP_HAS_NO_NULLPTR
+
+namespace std
+{
+    typedef decltype(nullptr) nullptr_t;
+}
+
+#endif  // _LIBCPP_HAS_NO_NULLPTR
+
+#endif  // _LIBCPP_NULLPTR
diff --git a/system/include/libcxx/__refstring b/system/include/libcxx/__refstring
index 6866bf1b9736e..61ccc75122a5a 100644
--- a/system/include/libcxx/__refstring
+++ b/system/include/libcxx/__refstring
@@ -13,7 +13,7 @@
 #include <__config>
 #include <cstddef>
 #include <cstring>
-#if __APPLE__
+#ifdef __APPLE__
 #include <dlfcn.h>
 #include <mach-o/dyld.h>
 #endif
@@ -49,7 +49,7 @@ private:
         return data + sizeof(*rep);
     }
 
-#if __APPLE__
+#ifdef __APPLE__
     static
     const char*
     compute_gcc_empty_string_storage() _NOEXCEPT
diff --git a/system/include/libcxx/__split_buffer b/system/include/libcxx/__split_buffer
index 1d529cbe27d20..79d1aa1d7c4a9 100644
--- a/system/include/libcxx/__split_buffer
+++ b/system/include/libcxx/__split_buffer
@@ -56,9 +56,12 @@ public:
     _LIBCPP_INLINE_VISIBILITY pointer&              __end_cap() _NOEXCEPT       {return __end_cap_.first();}
     _LIBCPP_INLINE_VISIBILITY const pointer&        __end_cap() const _NOEXCEPT {return __end_cap_.first();}
 
+    _LIBCPP_INLINE_VISIBILITY
     __split_buffer()
         _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+    _LIBCPP_INLINE_VISIBILITY
     explicit __split_buffer(__alloc_rr& __a);
+    _LIBCPP_INLINE_VISIBILITY
     explicit __split_buffer(const __alloc_rr& __a);
     __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
     ~__split_buffer();
@@ -128,7 +131,9 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
         {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
+        _LIBCPP_INLINE_VISIBILITY
         void __destruct_at_begin(pointer __new_begin, false_type);
+        _LIBCPP_INLINE_VISIBILITY
         void __destruct_at_begin(pointer __new_begin, true_type);
 
     _LIBCPP_INLINE_VISIBILITY
@@ -156,25 +161,6 @@ private:
     _LIBCPP_INLINE_VISIBILITY
     void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
         {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
-                   __is_nothrow_swappable<__alloc_rr>::value)
-        {__swap_alloc(__x, __y, integral_constant<bool,
-                      __alloc_traits::propagate_on_container_swap::value>());}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, true_type)
-        _NOEXCEPT_(__is_nothrow_swappable<__alloc_rr>::value)
-        {
-            using _VSTD::swap;
-            swap(__x, __y);
-        }
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__alloc_rr&, __alloc_rr&, false_type) _NOEXCEPT
-        {}
 };
 
 template <class _Tp, class _Allocator>
@@ -285,7 +271,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
 {
@@ -294,7 +280,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
 {
@@ -328,7 +314,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __split_buffer<_Tp, _Allocator>::__split_buffer()
     _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
     : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr)
@@ -336,14 +322,14 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
     : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
 {
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
     : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
 {
@@ -431,7 +417,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
     _VSTD::swap(__begin_, __x.__begin_);
     _VSTD::swap(__end_, __x.__end_);
     _VSTD::swap(__end_cap(), __x.__end_cap());
-    __swap_alloc(__alloc(), __x.__alloc());
+    __swap_allocator(__alloc(), __x.__alloc());
 }
 
 template <class _Tp, class _Allocator>
diff --git a/system/include/libcxx/__sso_allocator b/system/include/libcxx/__sso_allocator
index 645f2ba174598..ca3b937c01384 100644
--- a/system/include/libcxx/__sso_allocator
+++ b/system/include/libcxx/__sso_allocator
@@ -15,6 +15,8 @@
 #include <type_traits>
 #include <new>
 
+#include <__undef___deallocate>
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
diff --git a/system/include/libcxx/__std_stream b/system/include/libcxx/__std_stream
index 5403adabc343e..f867cd23bdd5c 100644
--- a/system/include/libcxx/__std_stream
+++ b/system/include/libcxx/__std_stream
@@ -276,7 +276,6 @@ __stdoutbuf<_CharT>::overflow(int_type __c)
             codecvt_base::result __r;
             char_type* pbase = &__1buf;
             char_type* pptr = pbase + 1;
-            char_type* epptr = pptr;
             do
             {
                 const char_type* __e;
diff --git a/system/include/libcxx/__tree b/system/include/libcxx/__tree
index 8e5447a2ffb58..89707e38fdd60 100644
--- a/system/include/libcxx/__tree
+++ b/system/include/libcxx/__tree
@@ -28,14 +28,22 @@ template <class _Tp, class _NodePtr, class _DiffType>
     class _LIBCPP_TYPE_VIS_ONLY __tree_iterator;
 template <class _Tp, class _ConstNodePtr, class _DiffType>
     class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator;
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-    class _LIBCPP_TYPE_VIS_ONLY map;
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-    class _LIBCPP_TYPE_VIS_ONLY multimap;
-template <class _Key, class _Compare, class _Allocator>
-    class _LIBCPP_TYPE_VIS_ONLY set;
-template <class _Key, class _Compare, class _Allocator>
-    class _LIBCPP_TYPE_VIS_ONLY multiset;
+
+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 _Allocator> class __map_node_destructor;
+template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_iterator;
+template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator;
 
 /*
 
@@ -502,41 +510,165 @@ __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
     }
 }
 
-template <class _Allocator> class __map_node_destructor;
+// node traits
 
-template <class _Allocator>
-class __tree_node_destructor
-{
-    typedef _Allocator                                      allocator_type;
-    typedef allocator_traits<allocator_type>                __alloc_traits;
-    typedef typename __alloc_traits::value_type::value_type value_type;
-public:
-    typedef typename __alloc_traits::pointer                pointer;
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+struct __is_tree_value_type_imp : false_type {};
+
+template <class _Key, class _Value>
+struct __is_tree_value_type_imp<__value_type<_Key, _Value>> : true_type {};
+
+template <class ..._Args>
+struct __is_tree_value_type : false_type {};
+
+template <class _One>
+struct __is_tree_value_type<_One> : __is_tree_value_type_imp<typename __uncvref<_One>::type> {};
+#endif
+
+template <class _Tp>
+struct __tree_key_value_types {
+  typedef _Tp key_type;
+  typedef _Tp __node_value_type;
+  typedef _Tp __container_value_type;
+  static const bool __is_map = false;
+
+  _LIBCPP_INLINE_VISIBILITY
+  static key_type const& __get_key(_Tp const& __v) {
+    return __v;
+  }
+  _LIBCPP_INLINE_VISIBILITY
+  static __container_value_type const& __get_value(__node_value_type const& __v) {
+    return __v;
+  }
+  _LIBCPP_INLINE_VISIBILITY
+  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) {
+    return _VSTD::move(__v);
+  }
+#endif
+};
+
+template <class _Key, class _Tp>
+struct __tree_key_value_types<__value_type<_Key, _Tp> > {
+  typedef _Key                                         key_type;
+  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;
+  }
+
+  template <class _Up>
+  _LIBCPP_INLINE_VISIBILITY
+  static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
+      key_type const&>::type
+  __get_key(_Up& __t) {
+    return __t.first;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  static __container_value_type const&
+  __get_value(__node_value_type const& __t) {
+    return __t.__cc;
+  }
+
+  template <class _Up>
+  _LIBCPP_INLINE_VISIBILITY
+  static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
+      __container_value_type const&>::type
+  __get_value(_Up& __t) {
+    return __t;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  static __container_value_type* __get_ptr(__node_value_type& __n) {
+    return _VSTD::addressof(__n.__cc);
+  }
+
+#ifndef _LIBCPP_CXX03_LANG
+  _LIBCPP_INLINE_VISIBILITY
+  static  __nc_value_type&& __move(__node_value_type& __v) {
+    return _VSTD::move(__v.__nc);
+  }
+#endif
+};
+
+template <class _VoidPtr>
+struct __tree_node_base_types {
+  typedef _VoidPtr                                               __void_pointer;
+
+  typedef __tree_node_base<__void_pointer>                      __node_base_type;
+  typedef typename __rebind_pointer<_VoidPtr, __node_base_type>::type
+                                                             __node_base_pointer;
+
+  typedef __tree_end_node<__node_base_pointer>                  __end_node_type;
+  typedef typename __rebind_pointer<_VoidPtr, __end_node_type>::type
+                                                             __end_node_pointer;
 private:
+  static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
+                  "_VoidPtr does not point to unqualified void type");
+};
 
-    allocator_type& __na_;
+template <class _Tp, class _AllocPtr, class _KVTypes = __tree_key_value_types<_Tp>,
+         bool = _KVTypes::__is_map>
+struct __tree_map_pointer_types {};
+
+template <class _Tp, class _AllocPtr, class _KVTypes>
+struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
+  typedef typename _KVTypes::__map_value_type   _Mv;
+  typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
+                                                       __map_value_type_pointer;
+  typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
+                                                 __const_map_value_type_pointer;
+};
 
-    __tree_node_destructor& operator=(const __tree_node_destructor&);
+template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>
+struct __tree_node_types;
 
+template <class _NodePtr, class _Tp, class _VoidPtr>
+struct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> >
+    : public __tree_node_base_types<_VoidPtr>,
+             __tree_key_value_types<_Tp>,
+             __tree_map_pointer_types<_Tp, _VoidPtr>
+{
+  typedef __tree_node_base_types<_VoidPtr> __base;
+  typedef __tree_key_value_types<_Tp>      __key_base;
+  typedef __tree_map_pointer_types<_Tp, _VoidPtr> __map_pointer_base;
 public:
-    bool __value_constructed;
 
-    _LIBCPP_INLINE_VISIBILITY
-    explicit __tree_node_destructor(allocator_type& __na) _NOEXCEPT
-        : __na_(__na),
-          __value_constructed(false)
-        {}
+  typedef typename pointer_traits<_NodePtr>::element_type       __node_type;
+  typedef _NodePtr                                              __node_pointer;
 
-    _LIBCPP_INLINE_VISIBILITY
-    void operator()(pointer __p) _NOEXCEPT
-    {
-        if (__value_constructed)
-            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_));
-        if (__p)
-            __alloc_traits::deallocate(__na_, __p, 1);
-    }
+  typedef _Tp                                                 __node_value_type;
+  typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
+                                                      __node_value_type_pointer;
+  typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
+                                                __const_node_value_type_pointer;
+private:
+    static_assert(!is_const<__node_type>::value,
+                "_NodePtr should never be a pointer to const");
+    static_assert((is_same<typename __rebind_pointer<_VoidPtr, __node_type>::type,
+                          _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
+};
 
-    template <class> friend class __map_node_destructor;
+template <class _ValueTp, class _VoidPtr>
+struct __make_tree_node_types {
+  typedef typename __rebind_pointer<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >::type
+                                                                        _NodePtr;
+  typedef __tree_node_types<_NodePtr> type;
 };
 
 // node
@@ -554,42 +686,21 @@ public:
 
 template <class _VoidPtr>
 class __tree_node_base
-    : public __tree_end_node
-             <
-                typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                     rebind<__tree_node_base<_VoidPtr> >
-#else
-                     rebind<__tree_node_base<_VoidPtr> >::other
-#endif
-             >
+    : public __tree_node_base_types<_VoidPtr>::__end_node_type
 {
-    __tree_node_base(const __tree_node_base&);
-    __tree_node_base& operator=(const __tree_node_base&);
+    typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes;
+
 public:
-    typedef typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__tree_node_base>
-#else
-            rebind<__tree_node_base>::other
-#endif
-                                                pointer;
-    typedef typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const __tree_node_base>
-#else
-            rebind<const __tree_node_base>::other
-#endif
-                                                const_pointer;
-    typedef __tree_end_node<pointer> base;
+    typedef typename _NodeBaseTypes::__node_base_pointer pointer;
 
     pointer __right_;
     pointer __parent_;
     bool __is_black_;
 
-    _LIBCPP_INLINE_VISIBILITY
-    __tree_node_base() _NOEXCEPT
-        : __right_(), __parent_(), __is_black_(false) {}
+private:
+  ~__tree_node_base() _LIBCPP_EQUAL_DELETE;
+  __tree_node_base(__tree_node_base const&) _LIBCPP_EQUAL_DELETE;
+  __tree_node_base& operator=(__tree_node_base const&) _LIBCPP_EQUAL_DELETE;
 };
 
 template <class _Tp, class _VoidPtr>
@@ -597,49 +708,69 @@ class __tree_node
     : public __tree_node_base<_VoidPtr>
 {
 public:
-    typedef __tree_node_base<_VoidPtr> base;
-    typedef _Tp value_type;
+    typedef _Tp __node_value_type;
 
-    value_type __value_;
+    __node_value_type __value_;
+
+private:
+  ~__tree_node() _LIBCPP_EQUAL_DELETE;
+  __tree_node(__tree_node const&) _LIBCPP_EQUAL_DELETE;
+  __tree_node& operator=(__tree_node const&) _LIBCPP_EQUAL_DELETE;
+};
+
+
+template <class _Allocator>
+class __tree_node_destructor
+{
+    typedef _Allocator                                      allocator_type;
+    typedef allocator_traits<allocator_type>                __alloc_traits;
+
+public:
+    typedef typename __alloc_traits::pointer                pointer;
+private:
+    typedef __tree_node_types<pointer> _NodeTypes;
+    allocator_type& __na_;
+
+    __tree_node_destructor& operator=(const __tree_node_destructor&);
+
+public:
+    bool __value_constructed;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT
+        : __na_(__na),
+          __value_constructed(__val)
+        {}
 
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
-    template <class ..._Args>
-        _LIBCPP_INLINE_VISIBILITY
-        explicit __tree_node(_Args&& ...__args)
-            : __value_(_VSTD::forward<_Args>(__args)...) {}
-#else  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
     _LIBCPP_INLINE_VISIBILITY
-    explicit __tree_node(const value_type& __v)
-            : __value_(__v) {}
-#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    void operator()(pointer __p) _NOEXCEPT
+    {
+        if (__value_constructed)
+            __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_));
+        if (__p)
+            __alloc_traits::deallocate(__na_, __p, 1);
+    }
+
+    template <class> friend class __map_node_destructor;
 };
 
-template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_iterator;
-template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator;
 
 template <class _Tp, class _NodePtr, class _DiffType>
 class _LIBCPP_TYPE_VIS_ONLY __tree_iterator
 {
-    typedef _NodePtr                                              __node_pointer;
-    typedef typename pointer_traits<__node_pointer>::element_type __node;
-    typedef typename __node::base                                 __node_base;
-    typedef typename __node_base::pointer                         __node_base_pointer;
+    typedef __tree_node_types<_NodePtr>                     _NodeTypes;
+    typedef _NodePtr                                        __node_pointer;
+    typedef typename _NodeTypes::__node_base_pointer        __node_base_pointer;
+    typedef pointer_traits<__node_pointer> __pointer_traits;
 
     __node_pointer __ptr_;
 
-    typedef pointer_traits<__node_pointer> __pointer_traits;
 public:
-    typedef bidirectional_iterator_tag iterator_category;
-    typedef _Tp                        value_type;
-    typedef _DiffType                  difference_type;
-    typedef value_type&                reference;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<value_type>
-#else
-            rebind<value_type>::other
-#endif
-                                       pointer;
+    typedef bidirectional_iterator_tag                     iterator_category;
+    typedef _Tp                                            value_type;
+    typedef _DiffType                                      difference_type;
+    typedef value_type&                                    reference;
+    typedef typename _NodeTypes::__node_value_type_pointer pointer;
 
     _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT
 #if _LIBCPP_STD_VER > 11
@@ -652,17 +783,21 @@ public:
         {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
-    __tree_iterator& operator++()
-        {__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_)));
-         return *this;}
+    __tree_iterator& operator++() {
+      __ptr_ = static_cast<__node_pointer>(
+          __tree_next(static_cast<__node_base_pointer>(__ptr_)));
+      return *this;
+    }
     _LIBCPP_INLINE_VISIBILITY
     __tree_iterator operator++(int)
         {__tree_iterator __t(*this); ++(*this); return __t;}
 
     _LIBCPP_INLINE_VISIBILITY
-    __tree_iterator& operator--()
-        {__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_)));
-         return *this;}
+    __tree_iterator& operator--() {
+      __ptr_ = static_cast<__node_pointer>(
+          __tree_prev(static_cast<__node_base_pointer>(__ptr_)));
+      return *this;
+    }
     _LIBCPP_INLINE_VISIBILITY
     __tree_iterator operator--(int)
         {__tree_iterator __t(*this); --(*this); return __t;}
@@ -686,35 +821,22 @@ private:
     template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multiset;
 };
 
-template <class _Tp, class _ConstNodePtr, class _DiffType>
+template <class _Tp, class _NodePtr, class _DiffType>
 class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator
 {
-    typedef _ConstNodePtr                                         __node_pointer;
-    typedef typename pointer_traits<__node_pointer>::element_type __node;
-    typedef typename __node::base                                 __node_base;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__node_base>
-#else
-            rebind<__node_base>::other
-#endif
-                                                                  __node_base_pointer;
+    typedef __tree_node_types<_NodePtr>                     _NodeTypes;
+    typedef typename _NodeTypes::__node_pointer             __node_pointer;
+    typedef typename _NodeTypes::__node_base_pointer        __node_base_pointer;
+    typedef pointer_traits<__node_pointer> __pointer_traits;
 
     __node_pointer __ptr_;
 
-    typedef pointer_traits<__node_pointer> __pointer_traits;
 public:
-    typedef bidirectional_iterator_tag       iterator_category;
-    typedef _Tp                              value_type;
-    typedef _DiffType                        difference_type;
-    typedef const value_type&                reference;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const value_type>
-#else
-            rebind<const value_type>::other
-#endif
-                                       pointer;
+    typedef bidirectional_iterator_tag                           iterator_category;
+    typedef _Tp                                                  value_type;
+    typedef _DiffType                                            difference_type;
+    typedef const value_type&                                    reference;
+    typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
 
     _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT
 #if _LIBCPP_STD_VER > 11
@@ -723,16 +845,8 @@ public:
     {}
 
 private:
-    typedef typename remove_const<__node>::type  __non_const_node;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__non_const_node>
-#else
-            rebind<__non_const_node>::other
-#endif
-                                                 __non_const_node_pointer;
-    typedef __tree_iterator<value_type, __non_const_node_pointer, difference_type>
-                                                 __non_const_iterator;
+    typedef __tree_iterator<value_type, __node_pointer, difference_type>
+                                                           __non_const_iterator;
 public:
     _LIBCPP_INLINE_VISIBILITY
     __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT
@@ -743,17 +857,23 @@ public:
         {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
-    __tree_const_iterator& operator++()
-        {__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_)));
-         return *this;}
+    __tree_const_iterator& operator++() {
+      __ptr_ = static_cast<__node_pointer>(
+          __tree_next(static_cast<__node_base_pointer>(__ptr_)));
+      return *this;
+    }
+
     _LIBCPP_INLINE_VISIBILITY
     __tree_const_iterator operator++(int)
         {__tree_const_iterator __t(*this); ++(*this); return __t;}
 
     _LIBCPP_INLINE_VISIBILITY
-    __tree_const_iterator& operator--()
-        {__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_)));
-         return *this;}
+    __tree_const_iterator& operator--() {
+      __ptr_ = static_cast<__node_pointer>(
+          __tree_prev(static_cast<__node_base_pointer>(__ptr_)));
+      return *this;
+    }
+
     _LIBCPP_INLINE_VISIBILITY
     __tree_const_iterator operator--(int)
         {__tree_const_iterator __t(*this); --(*this); return __t;}
@@ -784,46 +904,51 @@ public:
     typedef _Tp                                      value_type;
     typedef _Compare                                 value_compare;
     typedef _Allocator                               allocator_type;
+
+private:
     typedef allocator_traits<allocator_type>         __alloc_traits;
+    typedef typename __make_tree_node_types<value_type,
+        typename __alloc_traits::void_pointer>::type
+                                                    _NodeTypes;
+    typedef typename _NodeTypes::key_type           key_type;
+public:
+    typedef typename _NodeTypes::__node_value_type      __node_value_type;
+    typedef typename _NodeTypes::__container_value_type __container_value_type;
+
     typedef typename __alloc_traits::pointer         pointer;
     typedef typename __alloc_traits::const_pointer   const_pointer;
     typedef typename __alloc_traits::size_type       size_type;
     typedef typename __alloc_traits::difference_type difference_type;
 
-    typedef typename __alloc_traits::void_pointer  __void_pointer;
+public:
+    typedef typename _NodeTypes::__void_pointer        __void_pointer;
+
+    typedef typename _NodeTypes::__node_type           __node;
+    typedef typename _NodeTypes::__node_pointer        __node_pointer;
+
+    typedef typename _NodeTypes::__node_base_type      __node_base;
+    typedef typename _NodeTypes::__node_base_pointer   __node_base_pointer;
+
+    typedef typename _NodeTypes::__end_node_type       __end_node_t;
+    typedef typename _NodeTypes::__end_node_pointer    __end_node_ptr;
+
+    typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
+    typedef allocator_traits<__node_allocator>         __node_traits;
 
-    typedef __tree_node<value_type, __void_pointer> __node;
-    typedef __tree_node_base<__void_pointer>        __node_base;
-    typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__node>
-#else
-            rebind_alloc<__node>::other
-#endif
-                                                     __node_allocator;
-    typedef allocator_traits<__node_allocator>       __node_traits;
-    typedef typename __node_traits::pointer          __node_pointer;
-    typedef typename __node_traits::pointer          __node_const_pointer;
-    typedef typename __node_base::pointer            __node_base_pointer;
-    typedef typename __node_base::pointer            __node_base_const_pointer;
 private:
-    typedef typename __node_base::base __end_node_t;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__end_node_t>
-#else
-            rebind<__end_node_t>::other
-#endif
-                                                     __end_node_ptr;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__end_node_t>
-#else
-            rebind<__end_node_t>::other
-#endif
-                                                     __end_node_const_ptr;
+    // check for sane allocator pointer rebinding semantics. Rebinding the
+    // allocator for a new pointer type should be exactly the same as rebinding
+    // the pointer using 'pointer_traits'.
+    static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
+                  "Allocator does not rebind pointers in a sane manner.");
+    typedef typename __rebind_alloc_helper<__node_traits, __node_base>::type
+        __node_base_allocator;
+    typedef allocator_traits<__node_base_allocator> __node_base_traits;
+    static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
+                 "Allocator does not rebind pointers in a sane manner.");
 
-    __node_pointer                                          __begin_node_;
+private:
+    __node_pointer                                     __begin_node_;
     __compressed_pair<__end_node_t, __node_allocator>  __pair1_;
     __compressed_pair<size_type, value_compare>        __pair3_;
 
@@ -831,18 +956,18 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     __node_pointer __end_node() _NOEXCEPT
     {
-        return static_cast<__node_pointer>
-               (
-                   pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())
-               );
+        return static_cast<__node_pointer>(
+                pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())
+        );
     }
     _LIBCPP_INLINE_VISIBILITY
-    __node_const_pointer __end_node() const _NOEXCEPT
+    __node_pointer __end_node() const _NOEXCEPT
     {
-        return static_cast<__node_const_pointer>
-               (
-                   pointer_traits<__end_node_const_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first()))
-               );
+        return static_cast<__node_pointer>(
+            pointer_traits<__end_node_ptr>::pointer_to(
+                const_cast<__end_node_t&>(__pair1_.first())
+            )
+        );
     }
     _LIBCPP_INLINE_VISIBILITY
           __node_allocator& __node_alloc() _NOEXCEPT {return __pair1_.second();}
@@ -870,12 +995,10 @@ public:
     const value_compare& value_comp() const _NOEXCEPT
         {return __pair3_.second();}
 public:
+
     _LIBCPP_INLINE_VISIBILITY
-    __node_pointer __root() _NOEXCEPT
-        {return static_cast<__node_pointer>      (__end_node()->__left_);}
-    _LIBCPP_INLINE_VISIBILITY
-    __node_const_pointer __root() const _NOEXCEPT
-        {return static_cast<__node_const_pointer>(__end_node()->__left_);}
+    __node_pointer __root() const _NOEXCEPT
+        {return static_cast<__node_pointer>(__end_node()->__left_);}
 
     typedef __tree_iterator<value_type, __node_pointer, difference_type>             iterator;
     typedef __tree_const_iterator<value_type, __node_pointer, difference_type> const_iterator;
@@ -924,41 +1047,201 @@ public:
 
     void swap(__tree& __t)
         _NOEXCEPT_(
-            __is_nothrow_swappable<value_compare>::value &&
-            (!__node_traits::propagate_on_container_swap::value ||
-             __is_nothrow_swappable<__node_allocator>::value));
+            __is_nothrow_swappable<value_compare>::value
+#if _LIBCPP_STD_VER <= 11
+            && (!__node_traits::propagate_on_container_swap::value ||
+                 __is_nothrow_swappable<__node_allocator>::value)
+#endif
+            );
+
+
+#ifndef _LIBCPP_CXX03_LANG
+    template <class _Key, class ..._Args>
+    pair<iterator, bool>
+    __emplace_unique_key_args(_Key const&, _Args&&... __args);
+    template <class _Key, class ..._Args>
+    iterator
+    __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...);
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
     template <class... _Args>
-        pair<iterator, bool>
-        __emplace_unique(_Args&&... __args);
+    pair<iterator, bool> __emplace_unique_impl(_Args&&... __args);
+
     template <class... _Args>
-        iterator
-        __emplace_multi(_Args&&... __args);
+    iterator __emplace_hint_unique_impl(const_iterator __p, _Args&&... __args);
 
     template <class... _Args>
-        iterator
-        __emplace_hint_unique(const_iterator __p, _Args&&... __args);
+    iterator __emplace_multi(_Args&&... __args);
+
     template <class... _Args>
+    iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __emplace_unique(_Pp&& __x) {
+        return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x),
+                                            __can_extract_key<_Pp, key_type>());
+    }
+
+    template <class _First, class _Second>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<
+        __can_extract_map_key<_First, key_type, __container_value_type>::value,
+        pair<iterator, bool>
+    >::type __emplace_unique(_First&& __f, _Second&& __s) {
+        return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
+                                              _VSTD::forward<_Second>(__s));
+    }
+
+    template <class... _Args>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __emplace_unique(_Args&&... __args) {
+        return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...);
+    }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+    __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) {
+      return __emplace_unique_impl(_VSTD::forward<_Pp>(__x));
+    }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+    __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) {
+      return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x));
+    }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+    __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) {
+      return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x));
+    }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __emplace_hint_unique(const_iterator __p, _Pp&& __x) {
+        return __emplace_hint_unique_extract_key(__p, _VSTD::forward<_Pp>(__x),
+                                            __can_extract_key<_Pp, key_type>());
+    }
+
+    template <class _First, class _Second>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<
+        __can_extract_map_key<_First, key_type, __container_value_type>::value,
         iterator
-        __emplace_hint_multi(const_iterator __p, _Args&&... __args);
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+    >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
+        return __emplace_hint_unique_key_args(__p, __f,
+                                              _VSTD::forward<_First>(__f),
+                                              _VSTD::forward<_Second>(__s));
+    }
+
+    template <class... _Args>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args) {
+        return __emplace_hint_unique_impl(__p, _VSTD::forward<_Args>(__args)...);
+    }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator
+    __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_fail_tag) {
+      return __emplace_hint_unique_impl(__p, _VSTD::forward<_Pp>(__x));
+    }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator
+    __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) {
+      return __emplace_hint_unique_key_args(__p, __x, _VSTD::forward<_Pp>(__x));
+    }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator
+    __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) {
+      return __emplace_hint_unique_key_args(__p, __x.first, _VSTD::forward<_Pp>(__x));
+    }
+
+#else
+    template <class _Key, class _Args>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args& __args);
+    template <class _Key, class _Args>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&);
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __insert_unique(const __container_value_type& __v) {
+        return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_unique(const_iterator __p, const __container_value_type& __v) {
+        return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v);
+    }
+
+#ifdef _LIBCPP_CXX03_LANG
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_multi(const __container_value_type& __v);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_multi(const_iterator __p, const __container_value_type& __v);
+#else
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __insert_unique(__container_value_type&& __v) {
+        return __emplace_unique_key_args(_NodeTypes::__get_key(__v), _VSTD::move(__v));
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_unique(const_iterator __p, __container_value_type&& __v) {
+        return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v));
+    }
+
+    template <class _Vp, class = typename enable_if<
+            !is_same<typename __unconstref<_Vp>::type,
+                     __container_value_type
+            >::value
+        >::type>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> __insert_unique(_Vp&& __v) {
+        return __emplace_unique(_VSTD::forward<_Vp>(__v));
+    }
+
+    template <class _Vp, class = typename enable_if<
+            !is_same<typename __unconstref<_Vp>::type,
+                     __container_value_type
+            >::value
+        >::type>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_unique(const_iterator __p, _Vp&& __v) {
+        return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v));
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_multi(__container_value_type&& __v) {
+        return __emplace_multi(_VSTD::move(__v));
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_multi(const_iterator __p, __container_value_type&& __v) {
+        return __emplace_hint_multi(__p, _VSTD::move(__v));
+    }
 
     template <class _Vp>
-        pair<iterator, bool> __insert_unique(_Vp&& __v);
-    template <class _Vp>
-        iterator __insert_unique(const_iterator __p, _Vp&& __v);
-    template <class _Vp>
-        iterator __insert_multi(_Vp&& __v);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_multi(_Vp&& __v) {
+        return __emplace_multi(_VSTD::forward<_Vp>(__v));
+    }
+
     template <class _Vp>
-        iterator __insert_multi(const_iterator __p, _Vp&& __v);
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __insert_multi(const_iterator __p, _Vp&& __v) {
+        return __emplace_hint_multi(__p, _VSTD::forward<_Vp>(__v));
+    }
 
-    pair<iterator, bool> __insert_unique(const value_type& __v);
-    iterator __insert_unique(const_iterator __p, const value_type& __v);
-    iterator __insert_multi(const value_type& __v);
-    iterator __insert_multi(const_iterator __p, const value_type& __v);
+#endif // !_LIBCPP_CXX03_LANG
 
     pair<iterator, bool> __node_insert_unique(__node_pointer __nd);
     iterator             __node_insert_unique(const_iterator __p,
@@ -1002,8 +1285,8 @@ public:
             {return __lower_bound(__v, __root(), __end_node());}
     template <class _Key>
         const_iterator __lower_bound(const _Key& __v,
-                                     __node_const_pointer __root,
-                                     __node_const_pointer __result) const;
+                                     __node_pointer __root,
+                                     __node_pointer __result) const;
     template <class _Key>
         _LIBCPP_INLINE_VISIBILITY
         iterator upper_bound(const _Key& __v)
@@ -1018,8 +1301,8 @@ public:
             {return __upper_bound(__v, __root(), __end_node());}
     template <class _Key>
         const_iterator __upper_bound(const _Key& __v,
-                                     __node_const_pointer __root,
-                                     __node_const_pointer __result) const;
+                                     __node_pointer __root,
+                                     __node_pointer __result) const;
     template <class _Key>
         pair<iterator, iterator>
         __equal_range_unique(const _Key& __k);
@@ -1040,12 +1323,12 @@ public:
     __node_holder remove(const_iterator __p) _NOEXCEPT;
 private:
     typename __node_base::pointer&
-        __find_leaf_low(typename __node_base::pointer& __parent, const value_type& __v);
+        __find_leaf_low(typename __node_base::pointer& __parent, const key_type& __v);
     typename __node_base::pointer&
-        __find_leaf_high(typename __node_base::pointer& __parent, const value_type& __v);
+        __find_leaf_high(typename __node_base::pointer& __parent, const key_type& __v);
     typename __node_base::pointer&
         __find_leaf(const_iterator __hint,
-                    typename __node_base::pointer& __parent, const value_type& __v);
+                    typename __node_base::pointer& __parent, const key_type& __v);
     template <class _Key>
         typename __node_base::pointer&
         __find_equal(typename __node_base::pointer& __parent, const _Key& __v);
@@ -1054,11 +1337,11 @@ private:
         __find_equal(const_iterator __hint, typename __node_base::pointer& __parent,
                      const _Key& __v);
 
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+#ifndef _LIBCPP_CXX03_LANG
     template <class ..._Args>
-        __node_holder __construct_node(_Args&& ...__args);
-#else  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
-        __node_holder __construct_node(const value_type& __v);
+    __node_holder __construct_node(_Args&& ...__args);
+#else
+    __node_holder __construct_node(const __container_value_type& __v);
 #endif
 
     void destroy(__node_pointer __nd) _NOEXCEPT;
@@ -1094,25 +1377,6 @@ private:
     _LIBCPP_INLINE_VISIBILITY
     void __move_assign_alloc(__tree& __t, false_type) _NOEXCEPT {}
 
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y)
-        _NOEXCEPT_(
-            !__node_traits::propagate_on_container_swap::value ||
-            __is_nothrow_swappable<__node_allocator>::value)
-        {__swap_alloc(__x, __y, integral_constant<bool,
-                      __node_traits::propagate_on_container_swap::value>());}
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type)
-        _NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value)
-        {
-            using _VSTD::swap;
-            swap(__x, __y);
-        }
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type)
-        _NOEXCEPT
-        {}
-
     __node_pointer __detach();
     static __node_pointer __detach(__node_pointer);
 
@@ -1132,8 +1396,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp)
 
 template <class _Tp, class _Compare, class _Allocator>
 __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
-    : __pair1_(__node_allocator(__a)),
-      __begin_node_(__node_pointer()),
+    : __begin_node_(__node_pointer()),
+      __pair1_(__node_allocator(__a)),
       __pair3_(0)
 {
     __begin_node() = __end_node();
@@ -1142,8 +1406,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
 template <class _Tp, class _Compare, class _Allocator>
 __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp,
                                            const allocator_type& __a)
-    : __pair1_(__node_allocator(__a)),
-      __begin_node_(__node_pointer()),
+    : __begin_node_(__node_pointer()),
+      __pair1_(__node_allocator(__a)),
       __pair3_(0, __comp)
 {
     __begin_node() = __end_node();
@@ -1211,6 +1475,11 @@ template <class _InputIterator>
 void
 __tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _InputIterator __last)
 {
+    typedef iterator_traits<_InputIterator> _ITraits;
+    typedef typename _ITraits::value_type _ItValueType;
+    static_assert((is_same<_ItValueType, __container_value_type>::value),
+                  "__assign_unique may only be called with the containers value type");
+
     if (size() != 0)
     {
         __node_pointer __cache = __detach();
@@ -1251,6 +1520,12 @@ template <class _InputIterator>
 void
 __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last)
 {
+    typedef iterator_traits<_InputIterator> _ITraits;
+    typedef typename _ITraits::value_type _ItValueType;
+    static_assert((is_same<_ItValueType, __container_value_type>::value ||
+                  is_same<_ItValueType, __node_value_type>::value),
+                  "__assign_multi may only be called with the containers value type"
+                  " or the nodes value type");
     if (size() != 0)
     {
         __node_pointer __cache = __detach();
@@ -1283,7 +1558,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _Input
         }
     }
     for (; __first != __last; ++__first)
-        __insert_multi(*__first);
+        __insert_multi(_NodeTypes::__get_value(*__first));
 }
 
 template <class _Tp, class _Compare, class _Allocator>
@@ -1407,7 +1682,7 @@ __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type)
             }
         }
         while (__t.size() != 0)
-            __insert_multi(__e, _VSTD::move(__t.remove(__t.begin())->__value_));
+            __insert_multi(__e, _NodeTypes::__move(__t.remove(__t.begin())->__value_));
     }
 }
 
@@ -1442,7 +1717,7 @@ __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT
         destroy(static_cast<__node_pointer>(__nd->__left_));
         destroy(static_cast<__node_pointer>(__nd->__right_));
         __node_allocator& __na = __node_alloc();
-        __node_traits::destroy(__na, _VSTD::addressof(__nd->__value_));
+        __node_traits::destroy(__na, _NodeTypes::__get_ptr(__nd->__value_));
         __node_traits::deallocate(__na, __nd, 1);
     }
 }
@@ -1450,15 +1725,18 @@ __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT
 template <class _Tp, class _Compare, class _Allocator>
 void
 __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
-    _NOEXCEPT_(
-        __is_nothrow_swappable<value_compare>::value &&
-        (!__node_traits::propagate_on_container_swap::value ||
-         __is_nothrow_swappable<__node_allocator>::value))
+        _NOEXCEPT_(
+            __is_nothrow_swappable<value_compare>::value
+#if _LIBCPP_STD_VER <= 11
+            && (!__node_traits::propagate_on_container_swap::value ||
+                 __is_nothrow_swappable<__node_allocator>::value)
+#endif
+            )
 {
     using _VSTD::swap;
     swap(__begin_node_, __t.__begin_node_);
     swap(__pair1_.first(), __t.__pair1_.first());
-    __swap_alloc(__node_alloc(), __t.__node_alloc());
+    __swap_allocator(__node_alloc(), __t.__node_alloc());
     __pair3_.swap(__t.__pair3_);
     if (size() == 0)
         __begin_node() = __end_node();
@@ -1486,7 +1764,7 @@ __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT
 template <class _Tp, class _Compare, class _Allocator>
 typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer&
 __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(typename __node_base::pointer& __parent,
-                                                   const value_type& __v)
+                                                   const key_type& __v)
 {
     __node_pointer __nd = __root();
     if (__nd != nullptr)
@@ -1525,7 +1803,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(typename __node_base::pointer
 template <class _Tp, class _Compare, class _Allocator>
 typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer&
 __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(typename __node_base::pointer& __parent,
-                                                    const value_type& __v)
+                                                    const key_type& __v)
 {
     __node_pointer __nd = __root();
     if (__nd != nullptr)
@@ -1568,7 +1846,7 @@ template <class _Tp, class _Compare, class _Allocator>
 typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer&
 __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint,
                                                typename __node_base::pointer& __parent,
-                                               const value_type& __v)
+                                               const key_type& __v)
 {
     if (__hint == end() || !value_comp()(*__hint, __v))  // check before
     {
@@ -1711,6 +1989,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_node_at(__node_base_pointer __parent
     __new_node->__left_   = nullptr;
     __new_node->__right_  = nullptr;
     __new_node->__parent_ = __parent;
+    // __new_node->__is_black_ is initialized in __tree_balance_after_insert
     __child = __new_node;
     if (__begin_node()->__left_ != nullptr)
         __begin_node() = static_cast<__node_pointer>(__begin_node()->__left_);
@@ -1718,25 +1997,89 @@ __tree<_Tp, _Compare, _Allocator>::__insert_node_at(__node_base_pointer __parent
     ++size();
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key, class... _Args>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
+__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
+#else
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key, class _Args>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
+__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args& __args)
+#endif
+{
+    __node_base_pointer __parent;
+    __node_base_pointer& __child = __find_equal(__parent, __k);
+    __node_pointer __r = static_cast<__node_pointer>(__child);
+    bool __inserted = false;
+    if (__child == nullptr)
+    {
+#ifndef _LIBCPP_CXX03_LANG
+        __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+#else
+        __node_holder __h = __construct_node(__args);
+#endif
+        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+        __r = __h.release();
+        __inserted = true;
+    }
+    return pair<iterator, bool>(iterator(__r), __inserted);
+}
+
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key, class... _Args>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
+    const_iterator __p, _Key const& __k, _Args&&... __args)
+#else
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key, class _Args>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
+    const_iterator __p, _Key const& __k, _Args& __args)
+#endif
+{
+    __node_base_pointer __parent;
+    __node_base_pointer& __child = __find_equal(__p, __parent, __k);
+    __node_pointer __r = static_cast<__node_pointer>(__child);
+    if (__child == nullptr)
+    {
+#ifndef _LIBCPP_CXX03_LANG
+        __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+#else
+        __node_holder __h = __construct_node(__args);
+#endif
+        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+        __r = __h.release();
+    }
+    return iterator(__r);
+}
+
+
+#ifndef _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Compare, class _Allocator>
 template <class ..._Args>
 typename __tree<_Tp, _Compare, _Allocator>::__node_holder
 __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&& ...__args)
 {
+    static_assert(!__is_tree_value_type<_Args...>::value,
+                  "Cannot construct from __value_type");
     __node_allocator& __na = __node_alloc();
     __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_Args>(__args)...);
+    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...);
     __h.get_deleter().__value_constructed = true;
     return __h;
 }
 
+
 template <class _Tp, class _Compare, class _Allocator>
 template <class... _Args>
 pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
-__tree<_Tp, _Compare, _Allocator>::__emplace_unique(_Args&&... __args)
+__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args)
 {
     __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
     __node_base_pointer __parent;
@@ -1755,7 +2098,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique(_Args&&... __args)
 template <class _Tp, class _Compare, class _Allocator>
 template <class... _Args>
 typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique(const_iterator __p, _Args&&... __args)
+__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args)
 {
     __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
     __node_base_pointer __parent;
@@ -1776,7 +2119,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args)
 {
     __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
     __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_);
+    __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__h->__value_));
     __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
     return iterator(static_cast<__node_pointer>(__h.release()));
 }
@@ -1789,116 +2132,34 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p,
 {
     __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
     __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_);
+    __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__h->__value_));
     __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
     return iterator(static_cast<__node_pointer>(__h.release()));
 }
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-
-template <class _Tp, class _Compare, class _Allocator>
-template <class _Vp>
-pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
-__tree<_Tp, _Compare, _Allocator>::__insert_unique(_Vp&& __v)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v));
-    pair<iterator, bool> __r = __node_insert_unique(__h.get());
-    if (__r.second)
-        __h.release();
-    return __r;
-}
-
-template <class _Tp, class _Compare, class _Allocator>
-template <class _Vp>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, _Vp&& __v)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v));
-    iterator __r = __node_insert_unique(__p, __h.get());
-    if (__r.__ptr_ == __h.get())
-        __h.release();
-    return __r;
-}
-
-template <class _Tp, class _Compare, class _Allocator>
-template <class _Vp>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__insert_multi(_Vp&& __v)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v));
-    __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_);
-    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
-    return iterator(__h.release());
-}
-
-template <class _Tp, class _Compare, class _Allocator>
-template <class _Vp>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, _Vp&& __v)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v));
-    __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_);
-    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
-    return iterator(__h.release());
-}
 
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else  // _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Compare, class _Allocator>
 typename __tree<_Tp, _Compare, _Allocator>::__node_holder
-__tree<_Tp, _Compare, _Allocator>::__construct_node(const value_type& __v)
+__tree<_Tp, _Compare, _Allocator>::__construct_node(const __container_value_type& __v)
 {
     __node_allocator& __na = __node_alloc();
     __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v);
+    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
     __h.get_deleter().__value_constructed = true;
-    return _VSTD::move(__h);  // explicitly moved for C++03
-}
-
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-template <class _Tp, class _Compare, class _Allocator>
-pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
-__tree<_Tp, _Compare, _Allocator>::__insert_unique(const value_type& __v)
-{
-    __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_equal(__parent, __v);
-    __node_pointer __r = static_cast<__node_pointer>(__child);
-    bool __inserted = false;
-    if (__child == nullptr)
-    {
-        __node_holder __h = __construct_node(__v);
-        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
-        __r = __h.release();
-        __inserted = true;
-    }
-    return pair<iterator, bool>(iterator(__r), __inserted);
+    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
 
-template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, const value_type& __v)
-{
-    __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_equal(__p, __parent, __v);
-    __node_pointer __r = static_cast<__node_pointer>(__child);
-    if (__child == nullptr)
-    {
-        __node_holder __h = __construct_node(__v);
-        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
-        __r = __h.release();
-    }
-    return iterator(__r);
-}
+#endif  // _LIBCPP_CXX03_LANG
 
+#ifdef _LIBCPP_CXX03_LANG
 template <class _Tp, class _Compare, class _Allocator>
 typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__insert_multi(const value_type& __v)
+__tree<_Tp, _Compare, _Allocator>::__insert_multi(const __container_value_type& __v)
 {
     __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_leaf_high(__parent, __v);
+    __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__v));
     __node_holder __h = __construct_node(__v);
     __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
     return iterator(__h.release());
@@ -1906,14 +2167,15 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(const value_type& __v)
 
 template <class _Tp, class _Compare, class _Allocator>
 typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const value_type& __v)
+__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const __container_value_type& __v)
 {
     __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_leaf(__p, __parent, __v);
+    __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__v));
     __node_holder __h = __construct_node(__v);
     __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
     return iterator(__h.release());
 }
+#endif
 
 template <class _Tp, class _Compare, class _Allocator>
 pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
@@ -1953,7 +2215,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator
 __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd)
 {
     __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_leaf_high(__parent, __nd->__value_);
+    __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__nd->__value_));
     __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
     return iterator(__nd);
 }
@@ -1964,7 +2226,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p,
                                                        __node_pointer __nd)
 {
     __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_leaf(__p, __parent, __nd->__value_);
+    __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__nd->__value_));
     __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
     return iterator(__nd);
 }
@@ -1982,7 +2244,8 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p)
     __node_allocator& __na = __node_alloc();
     __tree_remove(__end_node()->__left_,
                   static_cast<__node_base_pointer>(__np));
-    __node_traits::destroy(__na, const_cast<value_type*>(_VSTD::addressof(*__p)));
+    __node_traits::destroy(__na, _NodeTypes::__get_ptr(
+        const_cast<__node_value_type&>(*__p)));
     __node_traits::deallocate(__na, __np, 1);
     return __r;
 }
@@ -2047,17 +2310,17 @@ template <class _Key>
 typename __tree<_Tp, _Compare, _Allocator>::size_type
 __tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const
 {
-    __node_const_pointer __result = __end_node();
-    __node_const_pointer __rt = __root();
+    __node_pointer __result = __end_node();
+    __node_pointer __rt = __root();
     while (__rt != nullptr)
     {
         if (value_comp()(__k, __rt->__value_))
         {
             __result = __rt;
-            __rt = static_cast<__node_const_pointer>(__rt->__left_);
+            __rt = static_cast<__node_pointer>(__rt->__left_);
         }
         else if (value_comp()(__rt->__value_, __k))
-            __rt = static_cast<__node_const_pointer>(__rt->__right_);
+            __rt = static_cast<__node_pointer>(__rt->__right_);
         else
             return 1;
     }
@@ -2069,22 +2332,21 @@ template <class _Key>
 typename __tree<_Tp, _Compare, _Allocator>::size_type
 __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const
 {
-    typedef pair<const_iterator, const_iterator> _Pp;
-    __node_const_pointer __result = __end_node();
-    __node_const_pointer __rt = __root();
+    __node_pointer __result = __end_node();
+    __node_pointer __rt = __root();
     while (__rt != nullptr)
     {
         if (value_comp()(__k, __rt->__value_))
         {
             __result = __rt;
-            __rt = static_cast<__node_const_pointer>(__rt->__left_);
+            __rt = static_cast<__node_pointer>(__rt->__left_);
         }
         else if (value_comp()(__rt->__value_, __k))
-            __rt = static_cast<__node_const_pointer>(__rt->__right_);
+            __rt = static_cast<__node_pointer>(__rt->__right_);
         else
             return _VSTD::distance(
-                __lower_bound(__k, static_cast<__node_const_pointer>(__rt->__left_), __rt),
-                __upper_bound(__k, static_cast<__node_const_pointer>(__rt->__right_), __result)
+                __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), __rt),
+                __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)
             );
     }
     return 0;
@@ -2114,18 +2376,18 @@ template <class _Tp, class _Compare, class _Allocator>
 template <class _Key>
 typename __tree<_Tp, _Compare, _Allocator>::const_iterator
 __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v,
-                                                 __node_const_pointer __root,
-                                                 __node_const_pointer __result) const
+                                                 __node_pointer __root,
+                                                 __node_pointer __result) const
 {
     while (__root != nullptr)
     {
         if (!value_comp()(__root->__value_, __v))
         {
             __result = __root;
-            __root = static_cast<__node_const_pointer>(__root->__left_);
+            __root = static_cast<__node_pointer>(__root->__left_);
         }
         else
-            __root = static_cast<__node_const_pointer>(__root->__right_);
+            __root = static_cast<__node_pointer>(__root->__right_);
     }
     return const_iterator(__result);
 }
@@ -2154,18 +2416,18 @@ template <class _Tp, class _Compare, class _Allocator>
 template <class _Key>
 typename __tree<_Tp, _Compare, _Allocator>::const_iterator
 __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v,
-                                                 __node_const_pointer __root,
-                                                 __node_const_pointer __result) const
+                                                 __node_pointer __root,
+                                                 __node_pointer __result) const
 {
     while (__root != nullptr)
     {
         if (value_comp()(__v, __root->__value_))
         {
             __result = __root;
-            __root = static_cast<__node_const_pointer>(__root->__left_);
+            __root = static_cast<__node_pointer>(__root->__left_);
         }
         else
-            __root = static_cast<__node_const_pointer>(__root->__right_);
+            __root = static_cast<__node_pointer>(__root->__right_);
     }
     return const_iterator(__result);
 }
@@ -2205,22 +2467,22 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
 __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const
 {
     typedef pair<const_iterator, const_iterator> _Pp;
-    __node_const_pointer __result = __end_node();
-    __node_const_pointer __rt = __root();
+    __node_pointer __result = __end_node();
+    __node_pointer __rt = __root();
     while (__rt != nullptr)
     {
         if (value_comp()(__k, __rt->__value_))
         {
             __result = __rt;
-            __rt = static_cast<__node_const_pointer>(__rt->__left_);
+            __rt = static_cast<__node_pointer>(__rt->__left_);
         }
         else if (value_comp()(__rt->__value_, __k))
-            __rt = static_cast<__node_const_pointer>(__rt->__right_);
+            __rt = static_cast<__node_pointer>(__rt->__right_);
         else
             return _Pp(const_iterator(__rt),
                       const_iterator(
                           __rt->__right_ != nullptr ?
-                              static_cast<__node_const_pointer>(__tree_min(__rt->__right_))
+                              static_cast<__node_pointer>(__tree_min(__rt->__right_))
                             : __result));
     }
     return _Pp(const_iterator(__result), const_iterator(__result));
@@ -2258,20 +2520,20 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
 __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const
 {
     typedef pair<const_iterator, const_iterator> _Pp;
-    __node_const_pointer __result = __end_node();
-    __node_const_pointer __rt = __root();
+    __node_pointer __result = __end_node();
+    __node_pointer __rt = __root();
     while (__rt != nullptr)
     {
         if (value_comp()(__k, __rt->__value_))
         {
             __result = __rt;
-            __rt = static_cast<__node_const_pointer>(__rt->__left_);
+            __rt = static_cast<__node_pointer>(__rt->__left_);
         }
         else if (value_comp()(__rt->__value_, __k))
-            __rt = static_cast<__node_const_pointer>(__rt->__right_);
+            __rt = static_cast<__node_pointer>(__rt->__right_);
         else
-            return _Pp(__lower_bound(__k, static_cast<__node_const_pointer>(__rt->__left_), __rt),
-                      __upper_bound(__k, static_cast<__node_const_pointer>(__rt->__right_), __result));
+            return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), __rt),
+                      __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));
     }
     return _Pp(const_iterator(__result), const_iterator(__result));
 }
@@ -2291,7 +2553,7 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT
     --size();
     __tree_remove(__end_node()->__left_,
                   static_cast<__node_base_pointer>(__np));
-    return __node_holder(__np, _Dp(__node_alloc()));
+    return __node_holder(__np, _Dp(__node_alloc(), true));
 }
 
 template <class _Tp, class _Compare, class _Allocator>
diff --git a/system/include/libcxx/__tuple b/system/include/libcxx/__tuple
index ee5b916fa52a9..09c68393aed1f 100644
--- a/system/include/libcxx/__tuple
+++ b/system/include/libcxx/__tuple
@@ -19,40 +19,9 @@
 #pragma GCC system_header
 #endif
 
-#ifdef _LIBCPP_HAS_NO_VARIADICS
-
-#include <__tuple_03>
-
-#else  // _LIBCPP_HAS_NO_VARIADICS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-// __lazy_and
-
-template <bool _Last, class ..._Preds>
-struct __lazy_and_impl;
-
-template <class ..._Preds>
-struct __lazy_and_impl<false, _Preds...> : false_type {};
-
-template <>
-struct __lazy_and_impl<true> : true_type {};
-
-template <class _Pred>
-struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
-
-template <class _Hp, class ..._Tp>
-struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
-
-template <class _P1, class ..._Pr>
-struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
-
-// __lazy_not
-
-template <class _Pred>
-struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
-
-
 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
 
 template <class _Tp>
@@ -90,19 +59,18 @@ public:
     typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
 };
 
-template <class ..._Tp> class _LIBCPP_TYPE_VIS_ONLY tuple;
-template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
-template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;
-
 template <class _Tp> struct __tuple_like : false_type {};
 
 template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
 template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
 template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
 
+// tuple specializations
+
+#if !defined(_LIBCPP_HAS_NO_VARIADICS)
+template <class ..._Tp> class _LIBCPP_TYPE_VIS_ONLY tuple;
+
 template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
-template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
-template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
 
 template <size_t _Ip, class ..._Tp>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -119,6 +87,16 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
 get(tuple<_Tp...>&&) _NOEXCEPT;
 
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(const tuple<_Tp...>&&) _NOEXCEPT;
+#endif
+
+// pair specializations
+
+template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
+
 template <size_t _Ip, class _T1, class _T2>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 typename tuple_element<_Ip, pair<_T1, _T2> >::type&
@@ -129,11 +107,24 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
 get(const pair<_T1, _T2>&) _NOEXCEPT;
 
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
 template <size_t _Ip, class _T1, class _T2>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
 get(pair<_T1, _T2>&&) _NOEXCEPT;
 
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(const pair<_T1, _T2>&&) _NOEXCEPT;
+#endif
+
+// array specializations
+
+template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;
+
+template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
+
 template <size_t _Ip, class _Tp, size_t _Size>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp&
@@ -144,11 +135,20 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 const _Tp&
 get(const array<_Tp, _Size>&) _NOEXCEPT;
 
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
 template <size_t _Ip, class _Tp, size_t _Size>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp&&
 get(array<_Tp, _Size>&&) _NOEXCEPT;
 
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&&
+get(const array<_Tp, _Size>&&) _NOEXCEPT;
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_VARIADICS)
+
 // __make_tuple_indices
 
 template <size_t...> struct __tuple_indices {};
@@ -245,19 +245,30 @@ struct __make_tuple_types
 
 // __tuple_convertible
 
-template <bool, class _Tp, class _Up>
+template <class, class>
 struct __tuple_convertible_imp : public false_type {};
 
 template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
-struct __tuple_convertible_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
+struct __tuple_convertible_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
     : public integral_constant<bool,
                                is_convertible<_Tp0, _Up0>::value &&
-                               __tuple_convertible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
+                               __tuple_convertible_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
 
 template <>
-struct __tuple_convertible_imp<true, __tuple_types<>, __tuple_types<> >
+struct __tuple_convertible_imp<__tuple_types<>, __tuple_types<> >
     : public true_type {};
 
+template <bool, class, class>
+struct __tuple_convertible_apply : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_convertible_apply<true, _Tp, _Up>
+  : public __tuple_convertible_imp<
+      typename __make_tuple_types<_Tp>::type
+    , typename __make_tuple_types<_Up>::type
+    >
+{};
+
 template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
                                 bool = __tuple_like<_Up>::value>
 struct __tuple_convertible
@@ -265,26 +276,36 @@ struct __tuple_convertible
 
 template <class _Tp, class _Up>
 struct __tuple_convertible<_Tp, _Up, true, true>
-    : public __tuple_convertible_imp<tuple_size<typename remove_reference<_Tp>::type>::value ==
-                                     tuple_size<_Up>::value,
-             typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type>
+    : public __tuple_convertible_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
+                                     tuple_size<_Up>::value, _Tp, _Up>
 {};
 
 // __tuple_constructible
 
-template <bool, class _Tp, class _Up>
+template <class, class>
 struct __tuple_constructible_imp : public false_type {};
 
 template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
-struct __tuple_constructible_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
+struct __tuple_constructible_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
     : public integral_constant<bool,
                                is_constructible<_Up0, _Tp0>::value &&
-                               __tuple_constructible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
+                               __tuple_constructible_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
 
 template <>
-struct __tuple_constructible_imp<true, __tuple_types<>, __tuple_types<> >
+struct __tuple_constructible_imp<__tuple_types<>, __tuple_types<> >
     : public true_type {};
 
+template <bool _SameSize, class, class>
+struct __tuple_constructible_apply : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_constructible_apply<true, _Tp, _Up>
+  : public __tuple_constructible_imp<
+      typename __make_tuple_types<_Tp>::type
+    , typename __make_tuple_types<_Up>::type
+    >
+{};
+
 template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
                                 bool = __tuple_like<_Up>::value>
 struct __tuple_constructible
@@ -292,26 +313,36 @@ struct __tuple_constructible
 
 template <class _Tp, class _Up>
 struct __tuple_constructible<_Tp, _Up, true, true>
-    : public __tuple_constructible_imp<tuple_size<typename remove_reference<_Tp>::type>::value ==
-                                     tuple_size<_Up>::value,
-             typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type>
+    : public __tuple_constructible_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
+                                     tuple_size<_Up>::value, _Tp, _Up>
 {};
 
 // __tuple_assignable
 
-template <bool, class _Tp, class _Up>
+template <class, class>
 struct __tuple_assignable_imp : public false_type {};
 
 template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
-struct __tuple_assignable_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
+struct __tuple_assignable_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
     : public integral_constant<bool,
                                is_assignable<_Up0&, _Tp0>::value &&
-                               __tuple_assignable_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
+                               __tuple_assignable_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
 
 template <>
-struct __tuple_assignable_imp<true, __tuple_types<>, __tuple_types<> >
+struct __tuple_assignable_imp<__tuple_types<>, __tuple_types<> >
     : public true_type {};
 
+template <bool, class, class>
+struct __tuple_assignable_apply : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_assignable_apply<true, _Tp, _Up>
+  : __tuple_assignable_imp<
+      typename __make_tuple_types<_Tp>::type
+    , typename __make_tuple_types<_Up>::type
+    >
+{};
+
 template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
                                 bool = __tuple_like<_Up>::value>
 struct __tuple_assignable
@@ -319,13 +350,12 @@ struct __tuple_assignable
 
 template <class _Tp, class _Up>
 struct __tuple_assignable<_Tp, _Up, true, true>
-    : public __tuple_assignable_imp<tuple_size<typename remove_reference<_Tp>::type>::value ==
-                                    tuple_size<_Up>::value,
-             typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type>
+    : public __tuple_assignable_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
+                                    tuple_size<_Up>::value, _Tp, _Up>
 {};
 
-_LIBCPP_END_NAMESPACE_STD
-
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
+_LIBCPP_END_NAMESPACE_STD
+
 #endif  // _LIBCPP___TUPLE
diff --git a/system/include/libcxx/__undef___deallocate b/system/include/libcxx/__undef___deallocate
new file mode 100644
index 0000000000000..2b4ad99dad381
--- /dev/null
+++ b/system/include/libcxx/__undef___deallocate
@@ -0,0 +1,18 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifdef __deallocate
+#if defined(_MSC_VER) && !defined(__clang__)
+_LIBCPP_WARNING("macro __deallocate is incompatible with C++.  #undefining __deallocate")
+#else
+#warning: macro __deallocate is incompatible with C++.  #undefining __deallocate
+#endif
+#undef __deallocate
+#endif
diff --git a/system/include/libcxx/algorithm b/system/include/libcxx/algorithm
index dbe888f78ddf3..7a6db7abd26db 100644
--- a/system/include/libcxx/algorithm
+++ b/system/include/libcxx/algorithm
@@ -521,11 +521,11 @@ template <class RandomAccessIterator, class Compare>
 
 template <class ForwardIterator>
     ForwardIterator
-    min_element(ForwardIterator first, ForwardIterator last);
+    min_element(ForwardIterator first, ForwardIterator last);  // constexpr in C++14
 
 template <class ForwardIterator, class Compare>
     ForwardIterator
-    min_element(ForwardIterator first, ForwardIterator last, Compare comp);
+    min_element(ForwardIterator first, ForwardIterator last, Compare comp);  // constexpr in C++14
 
 template <class T>
     const T&
@@ -543,13 +543,19 @@ template<class T, class Compare>
     T
     min(initializer_list<T> t, Compare comp);  // constexpr in C++14
 
+template<class T>
+    constexpr const T& clamp( const T& v, const T& lo, const T& hi );               // C++17
+
+template<class T, class Compare>
+    constexpr const T& clamp( const T& v, const T& lo, const T& hi, Compare comp ); // C++17
+
 template <class ForwardIterator>
     ForwardIterator
-    max_element(ForwardIterator first, ForwardIterator last);
+    max_element(ForwardIterator first, ForwardIterator last);  // constexpr in C++14
 
 template <class ForwardIterator, class Compare>
     ForwardIterator
-    max_element(ForwardIterator first, ForwardIterator last, Compare comp);
+    max_element(ForwardIterator first, ForwardIterator last, Compare comp);  // constexpr in C++14
 
 template <class T>
     const T&
@@ -569,11 +575,11 @@ template<class T, class Compare>
 
 template<class ForwardIterator>
     pair<ForwardIterator, ForwardIterator>
-    minmax_element(ForwardIterator first, ForwardIterator last);
+    minmax_element(ForwardIterator first, ForwardIterator last);   // constexpr in C++14
 
 template<class ForwardIterator, class Compare>
     pair<ForwardIterator, ForwardIterator>
-    minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
+    minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);   // constexpr in C++14
 
 template<class T>
     pair<const T&, const T&>
@@ -624,7 +630,7 @@ template <class BidirectionalIterator, class Compare>
 #include <initializer_list>
 #include <type_traits>
 #include <cstring>
-#include <utility>
+#include <utility> // needed to provide swap_ranges.
 #include <memory>
 #include <iterator>
 #include <cstddef>
@@ -851,7 +857,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f)
 {
     for (; __first != __last; ++__first)
         __f(*__first);
-    return _VSTD::move(__f);  // explicitly moved for (emulated) C++03
+    return _LIBCPP_EXPLICIT_MOVE(__f);  // explicitly moved for (emulated) C++03
 }
 
 // find
@@ -1189,7 +1195,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 bool
 equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred)
 {
-    for (; __first1 != __last1; ++__first1, ++__first2)
+    for (; __first1 != __last1; ++__first1, (void) ++__first2)
         if (!__pred(*__first1, *__first2))
             return false;
     return true;
@@ -1213,7 +1219,7 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1,
         _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred,
         input_iterator_tag, input_iterator_tag )
 {
-    for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
+    for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
         if (!__pred(*__first1, *__first2))
             return false;
     return __first1 == __last1 && __first2 == __last2;
@@ -1267,7 +1273,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
                _ForwardIterator2 __first2, _BinaryPredicate __pred)
 {
     // shorten sequences as much as possible by lopping of any equal parts
-    for (; __first1 != __last1; ++__first1, ++__first2)
+    for (; __first1 != __last1; ++__first1, (void) ++__first2)
         if (!__pred(*__first1, *__first2))
             goto __not_done;
     return true;
@@ -1327,7 +1333,7 @@ __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
                  forward_iterator_tag, forward_iterator_tag )
 {
     // shorten sequences as much as possible by lopping of any equal parts
-    for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
+    for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
         if (!__pred(*__first1, *__first2))
             goto __not_done;
     return __first1 == __last1 && __first2 == __last2;
@@ -1415,20 +1421,20 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 // search
 
 template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-_ForwardIterator1
+pair<_ForwardIterator1, _ForwardIterator1>
 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
          _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
          forward_iterator_tag, forward_iterator_tag)
 {
     if (__first2 == __last2)
-        return __first1;  // Everything matches an empty sequence
+        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 __last1;
+                return make_pair(__last1, __last1);
             if (__pred(*__first1, *__first2))
                 break;
             ++__first1;
@@ -1439,9 +1445,9 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
         while (true)
         {
             if (++__m2 == __last2)  // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
-                return __first1;
+                return make_pair(__first1, __m1);
             if (++__m1 == __last1)  // Otherwise if source exhaused, pattern not found
-                return __last1;
+                return make_pair(__last1, __last1);
             if (!__pred(*__m1, *__m2))  // if there is a mismatch, restart with a new __first1
             {
                 ++__first1;
@@ -1452,20 +1458,21 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 }
 
 template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1
+_LIBCPP_CONSTEXPR_AFTER_CXX11 
+pair<_RandomAccessIterator1, _RandomAccessIterator1>
 __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
-           _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
+         _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
            random_access_iterator_tag, random_access_iterator_tag)
 {
-    typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type _D1;
-    typedef typename std::iterator_traits<_RandomAccessIterator2>::difference_type _D2;
+    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
-    _D2 __len2 = __last2 - __first2;
+    const _D2 __len2 = __last2 - __first2;
     if (__len2 == 0)
-        return __first1;
-    _D1 __len1 = __last1 - __first1;
+        return make_pair(__first1, __first1);
+    const _D1 __len1 = __last1 - __first1;
     if (__len1 < __len2)
-        return __last1;
+        return make_pair(__last1, __last1);
     const _RandomAccessIterator1 __s = __last1 - (__len2 - 1);  // Start of pattern match can't go beyond here
     while (true)
     {
@@ -1473,7 +1480,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
         while (true)
         {
             if (__first1 == __s)
-                return __last1;
+                return make_pair(__last1, __last1);
             if (__pred(*__first1, *__first2))
                 break;
             ++__first1;
@@ -1505,7 +1512,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
             if (__pred(*__first1, *__first2))
                 break;
         case 0:
-            return __last1;
+            return make_pair(__last1, __last1);
         }
     __phase2:
 #endif  // !_LIBCPP_UNROLL_LOOPS
@@ -1515,7 +1522,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
          while (true)
          {
              if (++__m2 == __last2)
-                 return __first1;
+                 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))
              {
@@ -1555,7 +1562,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
             if (!__pred(*__m1, *__m2))
                 break;
         case 0:
-            return __first1;
+            return make_pair(__first1, __first1 + __len2);
         }
     __continue:
         ++__first1;
@@ -1571,8 +1578,9 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
 {
     return _VSTD::__search<typename add_lvalue_reference<_BinaryPredicate>::type>
                          (__first1, __last1, __first2, __last2, __pred,
-                          typename std::iterator_traits<_ForwardIterator1>::iterator_category(),
-                          typename std::iterator_traits<_ForwardIterator2>::iterator_category());
+                          typename iterator_traits<_ForwardIterator1>::iterator_category(),
+                          typename iterator_traits<_ForwardIterator2>::iterator_category())
+            .first;
 }
 
 template <class _ForwardIterator1, class _ForwardIterator2>
@@ -1581,8 +1589,8 @@ _ForwardIterator1
 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
        _ForwardIterator2 __first2, _ForwardIterator2 __last2)
 {
-    typedef typename std::iterator_traits<_ForwardIterator1>::value_type __v1;
-    typedef typename std::iterator_traits<_ForwardIterator2>::value_type __v2;
+    typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+    typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
     return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
 }
 
@@ -1672,7 +1680,8 @@ search_n(_ForwardIterator __first, _ForwardIterator __last,
          _Size __count, const _Tp& __value_, _BinaryPredicate __pred)
 {
     return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>
-           (__first, __last, __count, __value_, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+           (__first, __last, __convert_to_integral(__count), __value_, __pred,
+           typename iterator_traits<_ForwardIterator>::iterator_category());
 }
 
 template <class _ForwardIterator, class _Size, class _Tp>
@@ -1681,29 +1690,11 @@ _ForwardIterator
 search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)
 {
     typedef typename iterator_traits<_ForwardIterator>::value_type __v;
-    return _VSTD::search_n(__first, __last, __count, __value_, __equal_to<__v, _Tp>());
+    return _VSTD::search_n(__first, __last, __convert_to_integral(__count),
+                           __value_, __equal_to<__v, _Tp>());
 }
 
 // copy
-
-template <class _Iter>
-struct __libcpp_is_trivial_iterator
-{
-    static const bool value = is_pointer<_Iter>::value;
-};
-
-template <class _Iter>
-struct __libcpp_is_trivial_iterator<move_iterator<_Iter> >
-{
-    static const bool value = is_pointer<_Iter>::value;
-};
-
-template <class _Iter>
-struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> >
-{
-    static const bool value = is_pointer<_Iter>::value;
-};
-
 template <class _Iter>
 inline _LIBCPP_INLINE_VISIBILITY
 _Iter
@@ -1745,7 +1736,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 _OutputIterator
 __copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
 {
-    for (; __first != __last; ++__first, ++__result)
+    for (; __first != __last; ++__first, (void) ++__result)
         *__result = *__first;
     return __result;
 }
@@ -1761,7 +1752,8 @@ typename enable_if
 __copy(_Tp* __first, _Tp* __last, _Up* __result)
 {
     const size_t __n = static_cast<size_t>(__last - __first);
-    _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+    if (__n > 0)
+        _VSTD::memmove(__result, __first, __n * sizeof(_Up));
     return __result + __n;
 }
 
@@ -1796,8 +1788,11 @@ typename enable_if
 __copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
 {
     const size_t __n = static_cast<size_t>(__last - __first);
-    __result -= __n;
-    _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+    if (__n > 0)
+    {
+        __result -= __n;
+        _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+    }
     return __result;
 }
 
@@ -1839,8 +1834,10 @@ typename enable_if
    !__is_random_access_iterator<_InputIterator>::value,
     _OutputIterator
 >::type
-copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
+copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
 {
+    typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+    _IntegralSize __n = __orig_n;
     if (__n > 0)
     {
         *__result = *__first;
@@ -1862,8 +1859,10 @@ typename enable_if
     __is_random_access_iterator<_InputIterator>::value,
     _OutputIterator
 >::type
-copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
+copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
 {
+    typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+    _IntegralSize __n = __orig_n;
     return _VSTD::copy(__first, __first + __n, __result);
 }
 
@@ -1874,7 +1873,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 _OutputIterator
 __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
 {
-    for (; __first != __last; ++__first, ++__result)
+    for (; __first != __last; ++__first, (void) ++__result)
         *__result = _VSTD::move(*__first);
     return __result;
 }
@@ -1890,7 +1889,8 @@ typename enable_if
 __move(_Tp* __first, _Tp* __last, _Up* __result)
 {
     const size_t __n = static_cast<size_t>(__last - __first);
-    _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+    if (__n > 0)
+        _VSTD::memmove(__result, __first, __n * sizeof(_Up));
     return __result + __n;
 }
 
@@ -1925,8 +1925,11 @@ typename enable_if
 __move_backward(_Tp* __first, _Tp* __last, _Up* __result)
 {
     const size_t __n = static_cast<size_t>(__last - __first);
-    __result -= __n;
-    _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+    if (__n > 0)
+    {
+        __result -= __n;
+        _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+    }
     return __result;
 }
 
@@ -1950,7 +1953,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 _OutputIterator
 transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
 {
-    for (; __first != __last; ++__first, ++__result)
+    for (; __first != __last; ++__first, (void) ++__result)
         *__result = __op(*__first);
     return __result;
 }
@@ -1961,7 +1964,7 @@ _OutputIterator
 transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
           _OutputIterator __result, _BinaryOperation __binary_op)
 {
-    for (; __first1 != __last1; ++__first1, ++__first2, ++__result)
+    for (; __first1 != __last1; ++__first1, (void) ++__first2, ++__result)
         *__result = __binary_op(*__first1, *__first2);
     return __result;
 }
@@ -1998,7 +2001,7 @@ _OutputIterator
 replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
              const _Tp& __old_value, const _Tp& __new_value)
 {
-    for (; __first != __last; ++__first, ++__result)
+    for (; __first != __last; ++__first, (void) ++__result)
         if (*__first == __old_value)
             *__result = __new_value;
         else
@@ -2014,7 +2017,7 @@ _OutputIterator
 replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
                 _Predicate __pred, const _Tp& __new_value)
 {
-    for (; __first != __last; ++__first, ++__result)
+    for (; __first != __last; ++__first, (void) ++__result)
         if (__pred(*__first))
             *__result = __new_value;
         else
@@ -2029,7 +2032,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 _OutputIterator
 __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
 {
-    for (; __n > 0; ++__first, --__n)
+    for (; __n > 0; ++__first, (void) --__n)
         *__first = __value_;
     return __first;
 }
@@ -2055,7 +2058,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 _OutputIterator
 fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
 {
-   return _VSTD::__fill_n(__first, __n, __value_);
+   return _VSTD::__fill_n(__first, __convert_to_integral(__n), __value_);
 }
 
 // fill
@@ -2101,9 +2104,11 @@ generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
 template <class _OutputIterator, class _Size, class _Generator>
 inline _LIBCPP_INLINE_VISIBILITY
 _OutputIterator
-generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
+generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
 {
-    for (; __n > 0; ++__first, --__n)
+    typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+    _IntegralSize __n = __orig_n;
+    for (; __n > 0; ++__first, (void) --__n)
         *__first = __gen();
     return __first;
 }
@@ -2314,7 +2319,7 @@ __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirec
     {
         if (__first == --__last)
             break;
-        swap(*__first, *__last);
+        _VSTD::iter_swap(__first, __last);
         ++__first;
     }
 }
@@ -2326,7 +2331,7 @@ __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_ac
 {
     if (__first != __last)
         for (; __first < --__last; ++__first)
-            swap(*__first, *__last);
+            _VSTD::iter_swap(__first, __last);
 }
 
 template <class _BidirectionalIterator>
@@ -2536,7 +2541,7 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato
 template <class _ForwardIterator, class _Compare>
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _ForwardIterator
-__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
 {
     if (__first != __last)
     {
@@ -2548,20 +2553,12 @@ __min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
     return __first;
 }
 
-template <class _ForwardIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIterator
-min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
-    return __min_element(__first, __last, __comp);
-}
-
 template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _ForwardIterator
 min_element(_ForwardIterator __first, _ForwardIterator __last)
 {
-    return __min_element(__first, __last,
+    return _VSTD::min_element(__first, __last,
               __less<typename iterator_traits<_ForwardIterator>::value_type>());
 }
 
@@ -2590,7 +2587,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp
 min(initializer_list<_Tp> __t, _Compare __comp)
 {
-    return *__min_element(__t.begin(), __t.end(), __comp);
+    return *_VSTD::min_element(__t.begin(), __t.end(), __comp);
 }
 
 template<class _Tp>
@@ -2598,7 +2595,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp
 min(initializer_list<_Tp> __t)
 {
-    return *__min_element(__t.begin(), __t.end(), __less<_Tp>());
+    return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>());
 }
 
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -2608,7 +2605,7 @@ min(initializer_list<_Tp> __t)
 template <class _ForwardIterator, class _Compare>
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _ForwardIterator
-__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
 {
     if (__first != __last)
     {
@@ -2621,20 +2618,12 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
 }
 
 
-template <class _ForwardIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIterator
-max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
-    return __max_element(__first, __last, __comp);
-}
-
 template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _ForwardIterator
 max_element(_ForwardIterator __first, _ForwardIterator __last)
 {
-    return __max_element(__first, __last,
+    return _VSTD::max_element(__first, __last,
               __less<typename iterator_traits<_ForwardIterator>::value_type>());
 }
 
@@ -2663,7 +2652,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp
 max(initializer_list<_Tp> __t, _Compare __comp)
 {
-    return *__max_element(__t.begin(), __t.end(), __comp);
+    return *_VSTD::max_element(__t.begin(), __t.end(), __comp);
 }
 
 template<class _Tp>
@@ -2671,14 +2660,36 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp
 max(initializer_list<_Tp> __t)
 {
-    return *__max_element(__t.begin(), __t.end(), __less<_Tp>());
+    return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>());
 }
 
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
+#if _LIBCPP_STD_VER > 14
+// clamp
+template<class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+const _Tp&
+clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
+{
+    _LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
+    return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
+
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+const _Tp&
+clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
+{
+    return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>());
+}
+#endif
+
 // minmax_element
 
 template <class _ForwardIterator, class _Compare>
+_LIBCPP_CONSTEXPR_AFTER_CXX11
 std::pair<_ForwardIterator, _ForwardIterator>
 minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
 {
@@ -2726,7 +2737,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
 }
 
 template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 std::pair<_ForwardIterator, _ForwardIterator>
 minmax_element(_ForwardIterator __first, _ForwardIterator __last)
 {
@@ -2763,7 +2774,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
     typedef typename initializer_list<_Tp>::const_iterator _Iter;
     _Iter __first = __t.begin();
     _Iter __last  = __t.end();
-    std::pair<_Tp, _Tp> __result ( *__first, *__first );
+    std::pair<_Tp, _Tp> __result(*__first, *__first);
 
     ++__first;
     if (__t.size() % 2 == 0)
@@ -2778,13 +2789,13 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
     while (__first != __last)
     {
         _Tp __prev = *__first++;
-        if (__comp(__prev, *__first)) {
-            if (__comp(__prev, __result.first))    __result.first  = __prev;
-            if (__comp(__result.second, *__first)) __result.second = *__first;
+        if (__comp(*__first, __prev)) {
+            if ( __comp(*__first, __result.first)) __result.first  = *__first;
+            if (!__comp(__prev, __result.second))  __result.second = __prev;
             }
         else {
-            if (__comp(*__first, __result.first)) __result.first  = *__first;
-            if (__comp(__result.second, __prev))  __result.second = __prev;
+            if ( __comp(__prev, __result.first))    __result.first  = __prev;
+            if (!__comp(*__first, __result.second)) __result.second = *__first;
             }
                 
         __first++;
@@ -3036,7 +3047,7 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p
     if (_Rp == 0)
         return static_cast<result_type>(_Eng(__g, _Dt)());
     size_t __w = _Dt - __clz(_Rp) - 1;
-    if ((_Rp & (_UIntType(~0) >> (_Dt - __w))) != 0)
+    if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
         ++__w;
     _Eng __e(__g, __w);
     _UIntType __u;
@@ -3148,6 +3159,9 @@ is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
     for (; __first != __last; ++__first)
         if (!__pred(*__first))
             break;
+    if ( __first == __last )
+        return true;
+    ++__first;
     for (; __first != __last; ++__first)
         if (__pred(*__first))
             return false;
@@ -4357,6 +4371,34 @@ merge(_InputIterator1 __first1, _InputIterator1 __last1,
 
 // inplace_merge
 
+template <class _Compare, class _InputIterator1, class _InputIterator2,
+          class _OutputIterator>
+void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
+                          _InputIterator2 __first2, _InputIterator2 __last2,
+                          _OutputIterator __result, _Compare __comp)
+{
+    for (; __first1 != __last1; ++__result)
+    {
+        if (__first2 == __last2)
+        {
+            _VSTD::move(__first1, __last1, __result);
+            return;
+        }
+
+        if (__comp(*__first2, *__first1))
+        {
+            *__result = _VSTD::move(*__first2);
+            ++__first2;
+        }
+        else
+        {
+            *__result = _VSTD::move(*__first1);
+            ++__first1;
+        }
+    }
+    // __first2 through __last2 are already in the right spot.
+}
+
 template <class _Compare, class _BidirectionalIterator>
 void
 __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
@@ -4365,31 +4407,25 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
                 typename iterator_traits<_BidirectionalIterator>::value_type* __buff)
 {
     typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
-    typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
-    typedef typename iterator_traits<_BidirectionalIterator>::pointer pointer;
     __destruct_n __d(0);
     unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
     if (__len1 <= __len2)
     {
         value_type* __p = __buff;
-        for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), ++__i, ++__p)
+        for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, ++__p)
             ::new(__p) value_type(_VSTD::move(*__i));
-        __merge<_Compare>(move_iterator<value_type*>(__buff),
-                          move_iterator<value_type*>(__p),
-                          move_iterator<_BidirectionalIterator>(__middle),
-                          move_iterator<_BidirectionalIterator>(__last),
-                          __first, __comp);
+        __half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);
     }
     else
     {
         value_type* __p = __buff;
-        for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), ++__i, ++__p)
+        for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), (void) ++__i, ++__p)
             ::new(__p) value_type(_VSTD::move(*__i));
         typedef reverse_iterator<_BidirectionalIterator> _RBi;
         typedef reverse_iterator<value_type*> _Rv;
-        __merge(move_iterator<_RBi>(_RBi(__middle)), move_iterator<_RBi>(_RBi(__first)),
-                move_iterator<_Rv>(_Rv(__p)), move_iterator<_Rv>(_Rv(__buff)),
-                _RBi(__last), __negate<_Compare>(__comp));
+        __half_inplace_merge(_Rv(__p), _Rv(__buff), 
+                             _RBi(__middle), _RBi(__first),
+                             _RBi(__last), __negate<_Compare>(__comp));
     }
 }
 
@@ -4400,26 +4436,23 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
                                  typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
                 typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size)
 {
-    typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
     typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
     while (true)
     {
         // if __middle == __last, we're done
         if (__len2 == 0)
             return;
+        if (__len1 <= __buff_size || __len2 <= __buff_size)
+            return __buffered_inplace_merge<_Compare>
+                   (__first, __middle, __last, __comp, __len1, __len2, __buff);
         // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
-        for (; true; ++__first, --__len1)
+        for (; true; ++__first, (void) --__len1)
         {
             if (__len1 == 0)
                 return;
             if (__comp(*__middle, *__first))
                 break;
         }
-        if (__len1 <= __buff_size || __len2 <= __buff_size)
-        {
-            __buffered_inplace_merge<_Compare>(__first, __middle, __last, __comp, __len1, __len2, __buff);
-            return;
-        }
         // __first < __middle < __last
         // *__first > *__middle
         // partition [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) such that
@@ -4484,12 +4517,6 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
     }
 }
 
-template <class _Tp>
-struct __inplace_merge_switch
-{
-    static const unsigned value = is_trivially_copy_assignable<_Tp>::value;
-};
-
 template <class _BidirectionalIterator, class _Compare>
 inline _LIBCPP_INLINE_VISIBILITY
 void
@@ -4501,13 +4528,9 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _
     difference_type __len1 = _VSTD::distance(__first, __middle);
     difference_type __len2 = _VSTD::distance(__middle, __last);
     difference_type __buf_size = _VSTD::min(__len1, __len2);
-    pair<value_type*, ptrdiff_t> __buf(0, 0);
-    unique_ptr<value_type, __return_temporary_buffer> __h;
-    if (__inplace_merge_switch<value_type>::value && __buf_size > 8)
-    {
-        __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
-        __h.reset(__buf.first);
-    }
+    pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
+    unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
+
 #ifdef _LIBCPP_DEBUG
     typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
     __debug_less<_Compare> __c(__comp);
@@ -4799,7 +4822,6 @@ void
 __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
           typename iterator_traits<_RandomAccessIterator>::difference_type __len)
 {
-    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
     typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
     if (__len > 1)
     {
@@ -5067,7 +5089,7 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last,
     _RandomAccessIterator __r = __result_first;
     if (__r != __result_last)
     {
-        for (; __first != __last && __r != __result_last; ++__first, ++__r)
+        for (; __first != __last && __r != __result_last; (void) ++__first, ++__r)
             *__r = *__first;
         __make_heap<_Compare>(__result_first, __r, __comp);
         typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
@@ -5589,7 +5611,7 @@ bool
 __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
                           _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
 {
-    for (; __first2 != __last2; ++__first1, ++__first2)
+    for (; __first2 != __last2; ++__first1, (void) ++__first2)
     {
         if (__first1 == __last1 || __comp(*__first1, *__first2))
             return true;
@@ -5732,34 +5754,6 @@ prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
                                   __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
 }
 
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_integral<_Tp>::value,
-    _Tp
->::type
-__rotate_left(_Tp __t, _Tp __n = 1)
-{
-    const unsigned __bits = static_cast<unsigned>(sizeof(_Tp) * __CHAR_BIT__ - 1);
-    __n &= __bits;
-    return static_cast<_Tp>((__t << __n) | (static_cast<typename make_unsigned<_Tp>::type>(__t) >> (__bits - __n)));
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_integral<_Tp>::value,
-    _Tp
->::type
-__rotate_right(_Tp __t, _Tp __n = 1)
-{
-    const unsigned __bits = static_cast<unsigned>(sizeof(_Tp) * __CHAR_BIT__ - 1);
-    __n &= __bits;
-    return static_cast<_Tp>((__t << (__bits - __n)) | (static_cast<typename make_unsigned<_Tp>::type>(__t) >> __n));
-}
-
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_ALGORITHM
diff --git a/system/include/libcxx/array b/system/include/libcxx/array
index d37075da1a2a9..719286d52ea3d 100644
--- a/system/include/libcxx/array
+++ b/system/include/libcxx/array
@@ -34,7 +34,7 @@ struct array
 
     // No explicit construct/copy/destroy for aggregate type
     void fill(const T& u);
-    void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
+    void swap(array& a) noexcept(is_nothrow_swappable_v<T>);
 
     // iterators:
     iterator begin() noexcept;
@@ -89,12 +89,13 @@ template <class T, size_t N >
   void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y)));
 
 template <class T> class tuple_size;
-template <int I, class T> class tuple_element;
+template <size_t I, class T> class tuple_element;
 template <class T, size_t N> struct tuple_size<array<T, N>>;
-template <int I, class T, size_t N> struct tuple_element<I, array<T, N>>;
-template <int I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
-template <int I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
-template <int I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
+template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
+template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
+template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
+template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
+template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
 
 }  // std
 
@@ -140,8 +141,15 @@ struct _LIBCPP_TYPE_VIS_ONLY array
     _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
         {_VSTD::fill_n(__elems_, _Size, __u);}
     _LIBCPP_INLINE_VISIBILITY
-    void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
-        {_VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+    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 __swap_dispatch(std::false_type, array& __a)
+        { _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
 
     // iterators:
     _LIBCPP_INLINE_VISIBILITY
@@ -275,11 +283,12 @@ template <class _Tp, size_t _Size>
 inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if
 <
+    _Size == 0 ||
     __is_swappable<_Tp>::value,
     void
 >::type
-swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
-                                  _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
+swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
+                                  _NOEXCEPT_(noexcept(__x.swap(__y)))
 {
     __x.swap(__y);
 }
@@ -288,10 +297,6 @@ template <class _Tp, size_t _Size>
 class _LIBCPP_TYPE_VIS_ONLY tuple_size<array<_Tp, _Size> >
     : public integral_constant<size_t, _Size> {};
 
-template <class _Tp, size_t _Size>
-class _LIBCPP_TYPE_VIS_ONLY tuple_size<const array<_Tp, _Size> >
-    : public integral_constant<size_t, _Size> {};
-
 template <size_t _Ip, class _Tp, size_t _Size>
 class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, array<_Tp, _Size> >
 {
@@ -299,13 +304,6 @@ public:
     typedef _Tp type;
 };
 
-template <size_t _Ip, class _Tp, size_t _Size>
-class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const array<_Tp, _Size> >
-{
-public:
-    typedef const _Tp type;
-};
-
 template <size_t _Ip, class _Tp, size_t _Size>
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp&
@@ -335,6 +333,15 @@ get(array<_Tp, _Size>&& __a) _NOEXCEPT
     return _VSTD::move(__a.__elems_[_Ip]);
 }
 
+template <size_t _Ip, class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&&
+get(const array<_Tp, _Size>&& __a) _NOEXCEPT
+{
+    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
+    return _VSTD::move(__a.__elems_[_Ip]);
+}
+
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/system/include/libcxx/atomic b/system/include/libcxx/atomic
index b01a59f5f96f0..dc117e93a29be 100644
--- a/system/include/libcxx/atomic
+++ b/system/include/libcxx/atomic
@@ -17,6 +17,10 @@
 namespace std
 {
 
+// feature test macro
+
+#define __cpp_lib_atomic_is_always_lock_free // as specified by SG10
+
 // order and consistency
 
 typedef enum memory_order
@@ -89,6 +93,7 @@ void
 template <class T>
 struct atomic
 {
+    static constexpr bool is_always_lock_free;
     bool is_lock_free() const volatile noexcept;
     bool is_lock_free() const noexcept;
     void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
@@ -127,6 +132,7 @@ struct atomic
 template <>
 struct atomic<integral>
 {
+    static constexpr bool is_always_lock_free;
     bool is_lock_free() const volatile noexcept;
     bool is_lock_free() const noexcept;
     void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
@@ -202,6 +208,7 @@ struct atomic<integral>
 template <class T>
 struct atomic<T*>
 {
+    static constexpr bool is_always_lock_free;
     bool is_lock_free() const volatile noexcept;
     bool is_lock_free() const noexcept;
     void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
@@ -535,13 +542,17 @@ void atomic_signal_fence(memory_order m) noexcept;
 
 #ifdef _LIBCPP_HAS_NO_THREADS
 #error <atomic> is not supported on this single threaded system
-#else // !_LIBCPP_HAS_NO_THREADS
+#endif
+#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
+#error <atomic> is not implemented
+#endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+// FIXME: use the right feature test macro value as chose by SG10.
+# define __cpp_lib_atomic_is_always_lock_free 201603L
+#endif
 
-#if !__has_feature(cxx_atomic) && _GNUC_VER < 407
-#error <atomic> is not implemented
-#else
+_LIBCPP_BEGIN_NAMESPACE_STD
 
 typedef enum memory_order
 {
@@ -549,31 +560,43 @@ typedef enum memory_order
     memory_order_release, memory_order_acq_rel, memory_order_seq_cst
 } memory_order;
 
-#if _GNUC_VER >= 407
+#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
 namespace __gcc_atomic {
-template <typename T>
+template <typename _Tp>
 struct __gcc_atomic_t {
-  __gcc_atomic_t() _NOEXCEPT {}
-  explicit __gcc_atomic_t(T value) _NOEXCEPT : __a_value(value) {}
-  T __a_value;
+
+#if _GNUC_VER >= 501
+    static_assert(is_trivially_copyable<_Tp>::value,
+      "std::atomic<Tp> requires that 'Tp' be a trivially copyable type");
+#endif
+
+  _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+    __gcc_atomic_t() _NOEXCEPT = default;
+#else
+    __gcc_atomic_t() _NOEXCEPT : __a_value() {}
+#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+  _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT
+    : __a_value(value) {}
+  _Tp __a_value;
 };
 #define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x>
 
-template <typename T> T __create();
+template <typename _Tp> _Tp __create();
 
-template <typename __Tp, typename __Td>
-typename enable_if<sizeof(__Tp()->__a_value = __create<__Td>()), char>::type
+template <typename _Tp, typename _Td>
+typename enable_if<sizeof(_Tp()->__a_value = __create<_Td>()), char>::type
     __test_atomic_assignable(int);
-template <typename T, typename U>
+template <typename _Tp, typename _Up>
 __two __test_atomic_assignable(...);
 
-template <typename __Tp, typename __Td>
+template <typename _Tp, typename _Td>
 struct __can_assign {
   static const bool value =
-      sizeof(__test_atomic_assignable<__Tp, __Td>(1)) == sizeof(char);
+      sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char);
 };
 
-static inline constexpr int __to_gcc_order(memory_order __order) {
+static inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) {
   // Avoid switch statement to make this a constexpr.
   return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
          (__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
@@ -583,6 +606,16 @@ static inline constexpr int __to_gcc_order(memory_order __order) {
               __ATOMIC_CONSUME))));
 }
 
+static inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) {
+  // Avoid switch statement to make this a constexpr.
+  return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
+         (__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
+          (__order == memory_order_release ? __ATOMIC_RELAXED:
+           (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST:
+            (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE:
+              __ATOMIC_CONSUME))));
+}
+
 } // namespace __gcc_atomic
 
 template <typename _Tp>
@@ -623,10 +656,6 @@ static inline void __c11_atomic_signal_fence(memory_order __order) {
   __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order));
 }
 
-static inline bool __c11_atomic_is_lock_free(size_t __size) {
-  return __atomic_is_lock_free(__size, 0);
-}
-
 template <typename _Tp>
 static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a,  _Tp __val,
                                       memory_order __order) {
@@ -637,8 +666,8 @@ static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a,  _Tp __val,
 template <typename _Tp>
 static inline void __c11_atomic_store(_Atomic(_Tp)* __a,  _Tp __val,
                                       memory_order __order) {
-  return __atomic_store(&__a->__a_value, &__val,
-                        __gcc_atomic::__to_gcc_order(__order));
+  __atomic_store(&__a->__a_value, &__val,
+                 __gcc_atomic::__to_gcc_order(__order));
 }
 
 template <typename _Tp>
@@ -683,7 +712,7 @@ static inline bool __c11_atomic_compare_exchange_strong(
   return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
                                    false,
                                    __gcc_atomic::__to_gcc_order(__success),
-                                   __gcc_atomic::__to_gcc_order(__failure));
+                                   __gcc_atomic::__to_gcc_failure_order(__failure));
 }
 
 template <typename _Tp>
@@ -693,7 +722,7 @@ static inline bool __c11_atomic_compare_exchange_strong(
   return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
                                    false,
                                    __gcc_atomic::__to_gcc_order(__success),
-                                   __gcc_atomic::__to_gcc_order(__failure));
+                                   __gcc_atomic::__to_gcc_failure_order(__failure));
 }
 
 template <typename _Tp>
@@ -703,7 +732,7 @@ static inline bool __c11_atomic_compare_exchange_weak(
   return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
                                    true,
                                    __gcc_atomic::__to_gcc_order(__success),
-                                   __gcc_atomic::__to_gcc_order(__failure));
+                                   __gcc_atomic::__to_gcc_failure_order(__failure));
 }
 
 template <typename _Tp>
@@ -713,7 +742,7 @@ static inline bool __c11_atomic_compare_exchange_weak(
   return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
                                    true,
                                    __gcc_atomic::__to_gcc_order(__success),
-                                   __gcc_atomic::__to_gcc_order(__failure));
+                                   __gcc_atomic::__to_gcc_failure_order(__failure));
 }
 
 template <typename _Tp>
@@ -798,7 +827,7 @@ static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern,
   return __atomic_fetch_xor(&__a->__a_value, __pattern,
                             __gcc_atomic::__to_gcc_order(__order));
 }
-#endif // _GNUC_VER >= 407
+#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP
 
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -808,6 +837,17 @@ kill_dependency(_Tp __y) _NOEXCEPT
     return __y;
 }
 
+#define ATOMIC_BOOL_LOCK_FREE      __GCC_ATOMIC_BOOL_LOCK_FREE
+#define ATOMIC_CHAR_LOCK_FREE      __GCC_ATOMIC_CHAR_LOCK_FREE
+#define ATOMIC_CHAR16_T_LOCK_FREE  __GCC_ATOMIC_CHAR16_T_LOCK_FREE
+#define ATOMIC_CHAR32_T_LOCK_FREE  __GCC_ATOMIC_CHAR32_T_LOCK_FREE
+#define ATOMIC_WCHAR_T_LOCK_FREE   __GCC_ATOMIC_WCHAR_T_LOCK_FREE
+#define ATOMIC_SHORT_LOCK_FREE     __GCC_ATOMIC_SHORT_LOCK_FREE
+#define ATOMIC_INT_LOCK_FREE       __GCC_ATOMIC_INT_LOCK_FREE
+#define ATOMIC_LONG_LOCK_FREE      __GCC_ATOMIC_LONG_LOCK_FREE
+#define ATOMIC_LLONG_LOCK_FREE     __GCC_ATOMIC_LLONG_LOCK_FREE
+#define ATOMIC_POINTER_LOCK_FREE   __GCC_ATOMIC_POINTER_LOCK_FREE
+
 // general atomic<T>
 
 template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
@@ -815,12 +855,22 @@ struct __atomic_base  // false
 {
     mutable _Atomic(_Tp) __a_;
 
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+  static _LIBCPP_CONSTEXPR bool is_always_lock_free = __atomic_always_lock_free(sizeof(__a_), 0);
+#endif
+
     _LIBCPP_INLINE_VISIBILITY
     bool is_lock_free() const volatile _NOEXCEPT
-        {return __c11_atomic_is_lock_free(sizeof(_Tp));}
+    {
+#if defined(_LIBCPP_HAS_C_ATOMIC_IMP)
+    return __c11_atomic_is_lock_free(sizeof(_Tp));
+#else
+    return __atomic_is_lock_free(sizeof(_Tp), 0);
+#endif
+    }
     _LIBCPP_INLINE_VISIBILITY
     bool is_lock_free() const _NOEXCEPT
-        {return __c11_atomic_is_lock_free(sizeof(_Tp));}
+        {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();}
     _LIBCPP_INLINE_VISIBILITY
     void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
         {__c11_atomic_store(&__a_, __d, __m);}
@@ -897,6 +947,11 @@ private:
 #endif  // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 };
 
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+template <class _Tp, bool __b>
+_LIBCPP_CONSTEXPR bool __atomic_base<_Tp, __b>::is_always_lock_free;
+#endif
+
 // atomic<Integral>
 
 template <class _Tp>
@@ -1766,23 +1821,6 @@ typedef atomic<uintmax_t> atomic_uintmax_t;
 #define ATOMIC_FLAG_INIT {false}
 #define ATOMIC_VAR_INIT(__v) {__v}
 
-// lock-free property
-
-#define ATOMIC_BOOL_LOCK_FREE      __GCC_ATOMIC_BOOL_LOCK_FREE
-#define ATOMIC_CHAR_LOCK_FREE      __GCC_ATOMIC_CHAR_LOCK_FREE
-#define ATOMIC_CHAR16_T_LOCK_FREE  __GCC_ATOMIC_CHAR16_T_LOCK_FREE
-#define ATOMIC_CHAR32_T_LOCK_FREE  __GCC_ATOMIC_CHAR32_T_LOCK_FREE
-#define ATOMIC_WCHAR_T_LOCK_FREE   __GCC_ATOMIC_WCHAR_T_LOCK_FREE
-#define ATOMIC_SHORT_LOCK_FREE     __GCC_ATOMIC_SHORT_LOCK_FREE
-#define ATOMIC_INT_LOCK_FREE       __GCC_ATOMIC_INT_LOCK_FREE
-#define ATOMIC_LONG_LOCK_FREE      __GCC_ATOMIC_LONG_LOCK_FREE
-#define ATOMIC_LLONG_LOCK_FREE     __GCC_ATOMIC_LLONG_LOCK_FREE
-#define ATOMIC_POINTER_LOCK_FREE   __GCC_ATOMIC_POINTER_LOCK_FREE
-
-#endif  //  !__has_feature(cxx_atomic)
-
 _LIBCPP_END_NAMESPACE_STD
 
-#endif  // !_LIBCPP_HAS_NO_THREADS
-
 #endif  // _LIBCPP_ATOMIC
diff --git a/system/include/libcxx/bitset b/system/include/libcxx/bitset
index 8c278cc724f1f..3f9b964e45acb 100644
--- a/system/include/libcxx/bitset
+++ b/system/include/libcxx/bitset
@@ -168,7 +168,9 @@ protected:
     typedef __bit_iterator<__bitset, false>            iterator;
     typedef __bit_iterator<__bitset, true>             const_iterator;
 
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
 
     _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
@@ -180,8 +182,11 @@ protected:
     _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT
         {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
 
+    _LIBCPP_INLINE_VISIBILITY
     void operator&=(const __bitset& __v) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     void operator|=(const __bitset& __v) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     void operator^=(const __bitset& __v) _NOEXCEPT;
 
     void flip() _NOEXCEPT;
@@ -192,22 +197,27 @@ protected:
 
     bool all() const _NOEXCEPT;
     bool any() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     size_t __hash_code() const _NOEXCEPT;
 private:
 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
     void __init(unsigned long long __v, false_type) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     void __init(unsigned long long __v, true_type) _NOEXCEPT;
 #endif  // _LIBCPP_HAS_NO_CONSTEXPR
     unsigned long to_ulong(false_type) const;
+    _LIBCPP_INLINE_VISIBILITY
     unsigned long to_ulong(true_type) const;
     unsigned long long to_ullong(false_type) const;
+    _LIBCPP_INLINE_VISIBILITY
     unsigned long long to_ullong(true_type) const;
+    _LIBCPP_INLINE_VISIBILITY
     unsigned long long to_ullong(true_type, false_type) const;
     unsigned long long to_ullong(true_type, true_type) const;
 };
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 __bitset<_N_words, _Size>::__bitset() _NOEXCEPT
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
@@ -245,7 +255,7 @@ __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT
 #endif  // _LIBCPP_HAS_NO_CONSTEXPR
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
@@ -264,7 +274,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
 }
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
 {
@@ -273,7 +283,7 @@ __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
 }
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
 {
@@ -282,7 +292,7 @@ __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
 }
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
 {
@@ -325,7 +335,7 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const
 }
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unsigned long
 __bitset<_N_words, _Size>::to_ulong(true_type) const
 {
@@ -348,7 +358,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const
 }
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unsigned long long
 __bitset<_N_words, _Size>::to_ullong(true_type) const
 {
@@ -356,7 +366,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type) const
 }
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unsigned long long
 __bitset<_N_words, _Size>::to_ullong(true_type, false_type) const
 {
@@ -414,7 +424,7 @@ __bitset<_N_words, _Size>::any() const _NOEXCEPT
 }
 
 template <size_t _N_words, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 size_t
 __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT
 {
@@ -450,7 +460,9 @@ protected:
     typedef __bit_iterator<__bitset, false>            iterator;
     typedef __bit_iterator<__bitset, true>             const_iterator;
 
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
 
     _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
@@ -462,23 +474,32 @@ protected:
     _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT
         {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
 
+    _LIBCPP_INLINE_VISIBILITY
     void operator&=(const __bitset& __v) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     void operator|=(const __bitset& __v) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     void operator^=(const __bitset& __v) _NOEXCEPT;
 
+    _LIBCPP_INLINE_VISIBILITY
     void flip() _NOEXCEPT;
 
+    _LIBCPP_INLINE_VISIBILITY
     unsigned long to_ulong() const;
+    _LIBCPP_INLINE_VISIBILITY
     unsigned long long to_ullong() const;
 
+    _LIBCPP_INLINE_VISIBILITY
     bool all() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     bool any() const _NOEXCEPT;
 
+    _LIBCPP_INLINE_VISIBILITY
     size_t __hash_code() const _NOEXCEPT;
 };
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 __bitset<1, _Size>::__bitset() _NOEXCEPT
     : __first_(0)
@@ -486,7 +507,7 @@ __bitset<1, _Size>::__bitset() _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
     : __first_(static_cast<__storage_type>(__v))
@@ -494,7 +515,7 @@ __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
 {
@@ -502,7 +523,7 @@ __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
 {
@@ -510,7 +531,7 @@ __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
 {
@@ -518,7 +539,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __bitset<1, _Size>::flip() _NOEXCEPT
 {
@@ -528,7 +549,7 @@ __bitset<1, _Size>::flip() _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unsigned long
 __bitset<1, _Size>::to_ulong() const
 {
@@ -536,7 +557,7 @@ __bitset<1, _Size>::to_ulong() const
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unsigned long long
 __bitset<1, _Size>::to_ullong() const
 {
@@ -544,7 +565,7 @@ __bitset<1, _Size>::to_ullong() const
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 __bitset<1, _Size>::all() const _NOEXCEPT
 {
@@ -553,7 +574,7 @@ __bitset<1, _Size>::all() const _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 __bitset<1, _Size>::any() const _NOEXCEPT
 {
@@ -562,7 +583,7 @@ __bitset<1, _Size>::any() const _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 size_t
 __bitset<1, _Size>::__hash_code() const _NOEXCEPT
 {
@@ -593,7 +614,9 @@ protected:
     typedef __bit_iterator<__bitset, false>            iterator;
     typedef __bit_iterator<__bitset, true>             const_iterator;
 
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
 
     _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
@@ -620,20 +643,20 @@ protected:
     _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;}
 };
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 __bitset<0, 0>::__bitset() _NOEXCEPT
 {
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT
 {
 }
 
 template <size_t _Size> class _LIBCPP_TYPE_VIS_ONLY bitset;
-template <size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY hash<bitset<_Size> >;
+template <size_t _Size> struct hash<bitset<_Size> >;
 
 template <size_t _Size>
 class _LIBCPP_TYPE_VIS_ONLY bitset
@@ -663,16 +686,23 @@ public:
                         _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
 
     // 23.3.5.2 bitset operations:
+    _LIBCPP_INLINE_VISIBILITY
     bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
     bitset& operator<<=(size_t __pos) _NOEXCEPT;
     bitset& operator>>=(size_t __pos) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     bitset& set() _NOEXCEPT;
     bitset& set(size_t __pos, bool __val = true);
+    _LIBCPP_INLINE_VISIBILITY
     bitset& reset() _NOEXCEPT;
     bitset& reset(size_t __pos);
+    _LIBCPP_INLINE_VISIBILITY
     bitset  operator~() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     bitset& flip() _NOEXCEPT;
     bitset& flip(size_t __pos);
 
@@ -680,28 +710,40 @@ public:
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
                               const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
     _LIBCPP_INLINE_VISIBILITY       reference operator[](size_t __p)       {return base::__make_ref(__p);}
+    _LIBCPP_INLINE_VISIBILITY
     unsigned long to_ulong() const;
+    _LIBCPP_INLINE_VISIBILITY
     unsigned long long to_ullong() const;
     template <class _CharT, class _Traits, class _Allocator>
         basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'),
                                                             _CharT __one = _CharT('1')) const;
     template <class _CharT, class _Traits>
+        _LIBCPP_INLINE_VISIBILITY
         basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
                                                                     _CharT __one = _CharT('1')) const;
     template <class _CharT>
+        _LIBCPP_INLINE_VISIBILITY
         basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
                                                                                 _CharT __one = _CharT('1')) const;
+    _LIBCPP_INLINE_VISIBILITY
     basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0',
                                                                       char __one = '1') const;
+    _LIBCPP_INLINE_VISIBILITY
     size_t count() const _NOEXCEPT;
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;}
+    _LIBCPP_INLINE_VISIBILITY
     bool operator==(const bitset& __rhs) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     bool operator!=(const bitset& __rhs) const _NOEXCEPT;
     bool test(size_t __pos) const;
+    _LIBCPP_INLINE_VISIBILITY
     bool all() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     bool any() const _NOEXCEPT;
     _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();}
+    _LIBCPP_INLINE_VISIBILITY
     bitset operator<<(size_t __pos) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     bitset operator>>(size_t __pos) const _NOEXCEPT;
 
 private:
@@ -774,7 +816,7 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>&
 bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
 {
@@ -783,7 +825,7 @@ bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>&
 bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
 {
@@ -792,7 +834,7 @@ bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>&
 bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
 {
@@ -821,7 +863,7 @@ bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>&
 bitset<_Size>::set() _NOEXCEPT
 {
@@ -844,7 +886,7 @@ bitset<_Size>::set(size_t __pos, bool __val)
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>&
 bitset<_Size>::reset() _NOEXCEPT
 {
@@ -867,7 +909,7 @@ bitset<_Size>::reset(size_t __pos)
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>
 bitset<_Size>::operator~() const _NOEXCEPT
 {
@@ -877,7 +919,7 @@ bitset<_Size>::operator~() const _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>&
 bitset<_Size>::flip() _NOEXCEPT
 {
@@ -901,7 +943,7 @@ bitset<_Size>::flip(size_t __pos)
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unsigned long
 bitset<_Size>::to_ulong() const
 {
@@ -909,7 +951,7 @@ bitset<_Size>::to_ulong() const
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unsigned long long
 bitset<_Size>::to_ullong() const
 {
@@ -932,7 +974,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
 
 template <size_t _Size>
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_string<_CharT, _Traits, allocator<_CharT> >
 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
 {
@@ -941,7 +983,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
 
 template <size_t _Size>
 template <class _CharT>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
 {
@@ -949,7 +991,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_string<char, char_traits<char>, allocator<char> >
 bitset<_Size>::to_string(char __zero, char __one) const
 {
@@ -957,7 +999,7 @@ bitset<_Size>::to_string(char __zero, char __one) const
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 size_t
 bitset<_Size>::count() const _NOEXCEPT
 {
@@ -965,7 +1007,7 @@ bitset<_Size>::count() const _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
 {
@@ -973,7 +1015,7 @@ bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
 {
@@ -994,7 +1036,7 @@ bitset<_Size>::test(size_t __pos) const
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 bitset<_Size>::all() const _NOEXCEPT
 {
@@ -1002,7 +1044,7 @@ bitset<_Size>::all() const _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 bitset<_Size>::any() const _NOEXCEPT
 {
@@ -1010,7 +1052,7 @@ bitset<_Size>::any() const _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>
 bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
 {
@@ -1020,7 +1062,7 @@ bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
 }
 
 template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bitset<_Size>
 bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
 {
diff --git a/system/include/libcxx/cctype b/system/include/libcxx/cctype
index b647903c45cda..7fc81344696de 100644
--- a/system/include/libcxx/cctype
+++ b/system/include/libcxx/cctype
@@ -37,9 +37,6 @@ int toupper(int c);
 
 #include <__config>
 #include <ctype.h>
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/support.h"
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -48,116 +45,76 @@ int toupper(int c);
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #ifdef isalnum
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalnum(int __c) {return isalnum(__c);}
 #undef isalnum
-inline _LIBCPP_INLINE_VISIBILITY int isalnum(int __c) {return __libcpp_isalnum(__c);}
-#else  // isalnum
-using ::isalnum;
-#endif  // isalnum
+#endif
 
 #ifdef isalpha
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalpha(int __c) {return isalpha(__c);}
 #undef isalpha
-inline _LIBCPP_INLINE_VISIBILITY int isalpha(int __c) {return __libcpp_isalpha(__c);}
-#else  // isalpha
-using ::isalpha;
-#endif  // isalpha
+#endif
 
 #ifdef isblank
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isblank(int __c) {return isblank(__c);}
 #undef isblank
-inline _LIBCPP_INLINE_VISIBILITY int isblank(int __c) {return __libcpp_isblank(__c);}
-#else  // isblank
-using ::isblank;
-#endif  // isblank
+#endif
 
 #ifdef iscntrl
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iscntrl(int __c) {return iscntrl(__c);}
 #undef iscntrl
-inline _LIBCPP_INLINE_VISIBILITY int iscntrl(int __c) {return __libcpp_iscntrl(__c);}
-#else  // iscntrl
-using ::iscntrl;
-#endif  // iscntrl
+#endif
 
 #ifdef isdigit
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isdigit(int __c) {return isdigit(__c);}
 #undef isdigit
-inline _LIBCPP_INLINE_VISIBILITY int isdigit(int __c) {return __libcpp_isdigit(__c);}
-#else  // isdigit
-using ::isdigit;
-#endif  // isdigit
+#endif
 
 #ifdef isgraph
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isgraph(int __c) {return isgraph(__c);}
 #undef isgraph
-inline _LIBCPP_INLINE_VISIBILITY int isgraph(int __c) {return __libcpp_isgraph(__c);}
-#else  // isgraph
-using ::isgraph;
-#endif  // isgraph
+#endif
 
 #ifdef islower
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_islower(int __c) {return islower(__c);}
 #undef islower
-inline _LIBCPP_INLINE_VISIBILITY int islower(int __c) {return __libcpp_islower(__c);}
-#else  // islower
-using ::islower;
-#endif  // islower
+#endif
 
 #ifdef isprint
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isprint(int __c) {return isprint(__c);}
 #undef isprint
-inline _LIBCPP_INLINE_VISIBILITY int isprint(int __c) {return __libcpp_isprint(__c);}
-#else  // isprint
-using ::isprint;
-#endif  // isprint
+#endif
 
 #ifdef ispunct
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ispunct(int __c) {return ispunct(__c);}
 #undef ispunct
-inline _LIBCPP_INLINE_VISIBILITY int ispunct(int __c) {return __libcpp_ispunct(__c);}
-#else  // ispunct
-using ::ispunct;
-#endif  // ispunct
+#endif
 
 #ifdef isspace
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isspace(int __c) {return isspace(__c);}
 #undef isspace
-inline _LIBCPP_INLINE_VISIBILITY int isspace(int __c) {return __libcpp_isspace(__c);}
-#else  // isspace
-using ::isspace;
-#endif  // isspace
+#endif
 
 #ifdef isupper
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isupper(int __c) {return isupper(__c);}
 #undef isupper
-inline _LIBCPP_INLINE_VISIBILITY int isupper(int __c) {return __libcpp_isupper(__c);}
-#else  // isupper
-using ::isupper;
-#endif  // isupper
+#endif
 
 #ifdef isxdigit
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isxdigit(int __c) {return isxdigit(__c);}
 #undef isxdigit
-inline _LIBCPP_INLINE_VISIBILITY int isxdigit(int __c) {return __libcpp_isxdigit(__c);}
-#else  // isxdigit
-using ::isxdigit;
-#endif  // isxdigit
+#endif
 
 #ifdef tolower
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_tolower(int __c) {return tolower(__c);}
 #undef tolower
-inline _LIBCPP_INLINE_VISIBILITY int tolower(int __c) {return __libcpp_tolower(__c);}
-#else  // tolower
-using ::tolower;
-#endif  // tolower
+#endif
 
 #ifdef toupper
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_toupper(int __c) {return toupper(__c);}
 #undef toupper
-inline _LIBCPP_INLINE_VISIBILITY int toupper(int __c) {return __libcpp_toupper(__c);}
-#else  // toupper
+#endif
+
+
+using ::isalnum;
+using ::isalpha;
+using ::isblank;
+using ::iscntrl;
+using ::isdigit;
+using ::isgraph;
+using ::islower;
+using ::isprint;
+using ::ispunct;
+using ::isspace;
+using ::isupper;
+using ::isxdigit;
+using ::tolower;
 using ::toupper;
-#endif  // toupper
 
 _LIBCPP_END_NAMESPACE_STD
 
diff --git a/system/include/libcxx/cerrno b/system/include/libcxx/cerrno
index 9804e4e3dcfec..bab13b8aa861f 100644
--- a/system/include/libcxx/cerrno
+++ b/system/include/libcxx/cerrno
@@ -30,364 +30,4 @@ Macros:
 #pragma GCC system_header
 #endif
 
-#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
-
-#ifdef ELAST
-
-const int __elast1 = ELAST+1;
-const int __elast2 = ELAST+2;
-
-#else
-
-const int __elast1 = 104;
-const int __elast2 = 105;
-
-#endif
-
-#ifdef ENOTRECOVERABLE
-
-#define EOWNERDEAD __elast1
-
-#ifdef ELAST
-#undef ELAST
-#define ELAST EOWNERDEAD
-#endif
-
-#elif defined(EOWNERDEAD)
-
-#define ENOTRECOVERABLE __elast1
-#ifdef ELAST
-#undef ELAST
-#define ELAST ENOTRECOVERABLE
-#endif
-
-#else  // defined(EOWNERDEAD)
-
-#define EOWNERDEAD __elast1
-#define ENOTRECOVERABLE __elast2
-#ifdef ELAST
-#undef ELAST
-#define ELAST ENOTRECOVERABLE
-#endif
-
-#endif  // defined(EOWNERDEAD)
-
-#endif  // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
-
-//  supply errno values likely to be missing, particularly on Windows
-
-#ifndef EAFNOSUPPORT
-#define EAFNOSUPPORT 9901
-#endif
-
-#ifndef EADDRINUSE
-#define EADDRINUSE 9902
-#endif
-
-#ifndef EADDRNOTAVAIL
-#define EADDRNOTAVAIL 9903
-#endif
-
-#ifndef EISCONN
-#define EISCONN 9904
-#endif
-
-#ifndef EBADMSG
-#define EBADMSG 9905
-#endif
-
-#ifndef ECONNABORTED
-#define ECONNABORTED 9906
-#endif
-
-#ifndef EALREADY
-#define EALREADY 9907
-#endif
-
-#ifndef ECONNREFUSED
-#define ECONNREFUSED 9908
-#endif
-
-#ifndef ECONNRESET
-#define ECONNRESET 9909
-#endif
-
-#ifndef EDESTADDRREQ
-#define EDESTADDRREQ 9910
-#endif
-
-#ifndef EHOSTUNREACH
-#define EHOSTUNREACH 9911
-#endif
-
-#ifndef EIDRM
-#define EIDRM 9912
-#endif
-
-#ifndef EMSGSIZE
-#define EMSGSIZE 9913
-#endif
-
-#ifndef ENETDOWN
-#define ENETDOWN 9914
-#endif
-
-#ifndef ENETRESET
-#define ENETRESET 9915
-#endif
-
-#ifndef ENETUNREACH
-#define ENETUNREACH 9916
-#endif
-
-#ifndef ENOBUFS
-#define ENOBUFS 9917
-#endif
-
-#ifndef ENOLINK
-#define ENOLINK 9918
-#endif
-
-#ifndef ENODATA
-#define ENODATA 9919
-#endif
-
-#ifndef ENOMSG
-#define ENOMSG 9920
-#endif
-
-#ifndef ENOPROTOOPT
-#define ENOPROTOOPT 9921
-#endif
-
-#ifndef ENOSR
-#define ENOSR 9922
-#endif
-
-#ifndef ENOTSOCK
-#define ENOTSOCK 9923
-#endif
-
-#ifndef ENOSTR
-#define ENOSTR 9924
-#endif
-
-#ifndef ENOTCONN
-#define ENOTCONN 9925
-#endif
-
-#ifndef ENOTSUP
-#define ENOTSUP 9926
-#endif
-
-#ifndef ECANCELED
-#define ECANCELED 9927
-#endif
-
-#ifndef EINPROGRESS
-#define EINPROGRESS 9928
-#endif
-
-#ifndef EOPNOTSUPP
-#define EOPNOTSUPP 9929
-#endif
-
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK 9930
-#endif
-
-#ifndef EOWNERDEAD
-#define EOWNERDEAD  9931
-#endif
-
-#ifndef EPROTO
-#define EPROTO 9932
-#endif
-
-#ifndef EPROTONOSUPPORT
-#define EPROTONOSUPPORT 9933
-#endif
-
-#ifndef ENOTRECOVERABLE
-#define ENOTRECOVERABLE 9934
-#endif
-
-#ifndef ETIME
-#define ETIME 9935
-#endif
-
-#ifndef ETXTBSY
-#define ETXTBSY 9936
-#endif
-
-#ifndef ETIMEDOUT
-#define ETIMEDOUT 9938
-#endif
-
-#ifndef ELOOP
-#define ELOOP 9939
-#endif
-
-#ifndef EOVERFLOW
-#define EOVERFLOW 9940
-#endif
-
-#ifndef EPROTOTYPE
-#define EPROTOTYPE 9941
-#endif
-
-#ifndef ENOSYS
-#define ENOSYS 9942
-#endif
-
-#ifndef EINVAL
-#define EINVAL 9943
-#endif
-
-#ifndef ERANGE
-#define ERANGE 9944
-#endif
-
-#ifndef EILSEQ
-#define EILSEQ 9945
-#endif
-
-//  Windows Mobile doesn't appear to define these:
-
-#ifndef E2BIG
-#define E2BIG 9946
-#endif
-
-#ifndef EDOM
-#define EDOM 9947
-#endif
-
-#ifndef EFAULT
-#define EFAULT 9948
-#endif
-
-#ifndef EBADF
-#define EBADF 9949
-#endif
-
-#ifndef EPIPE
-#define EPIPE 9950
-#endif
-
-#ifndef EXDEV
-#define EXDEV 9951
-#endif
-
-#ifndef EBUSY
-#define EBUSY 9952
-#endif
-
-#ifndef ENOTEMPTY
-#define ENOTEMPTY 9953
-#endif
-
-#ifndef ENOEXEC
-#define ENOEXEC 9954
-#endif
-
-#ifndef EEXIST
-#define EEXIST 9955
-#endif
-
-#ifndef EFBIG
-#define EFBIG 9956
-#endif
-
-#ifndef ENAMETOOLONG
-#define ENAMETOOLONG 9957
-#endif
-
-#ifndef ENOTTY
-#define ENOTTY 9958
-#endif
-
-#ifndef EINTR
-#define EINTR 9959
-#endif
-
-#ifndef ESPIPE
-#define ESPIPE 9960
-#endif
-
-#ifndef EIO
-#define EIO 9961
-#endif
-
-#ifndef EISDIR
-#define EISDIR 9962
-#endif
-
-#ifndef ECHILD
-#define ECHILD 9963
-#endif
-
-#ifndef ENOLCK
-#define ENOLCK 9964
-#endif
-
-#ifndef ENOSPC
-#define ENOSPC 9965
-#endif
-
-#ifndef ENXIO
-#define ENXIO 9966
-#endif
-
-#ifndef ENODEV
-#define ENODEV 9967
-#endif
-
-#ifndef ENOENT
-#define ENOENT 9968
-#endif
-
-#ifndef ESRCH
-#define ESRCH 9969
-#endif
-
-#ifndef ENOTDIR
-#define ENOTDIR 9970
-#endif
-
-#ifndef ENOMEM
-#define ENOMEM 9971
-#endif
-
-#ifndef EPERM
-#define EPERM 9972
-#endif
-
-#ifndef EACCES
-#define EACCES 9973
-#endif
-
-#ifndef EROFS
-#define EROFS 9974
-#endif
-
-#ifndef EDEADLK
-#define EDEADLK 9975
-#endif
-
-#ifndef EAGAIN
-#define EAGAIN 9976
-#endif
-
-#ifndef ENFILE
-#define ENFILE 9977
-#endif
-
-#ifndef EMFILE
-#define EMFILE 9978
-#endif
-
-#ifndef EMLINK
-#define EMLINK 9979
-#endif
-
 #endif  // _LIBCPP_CERRNO
diff --git a/system/include/libcxx/cfenv b/system/include/libcxx/cfenv
index dd7db37f8e484..4fc630419bde5 100644
--- a/system/include/libcxx/cfenv
+++ b/system/include/libcxx/cfenv
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===---------------------------- cctype ----------------------------------===//
+//===---------------------------- cfenv -----------------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
diff --git a/system/include/libcxx/cfloat b/system/include/libcxx/cfloat
index 5fa56550fa6a1..176fa9de3cec1 100644
--- a/system/include/libcxx/cfloat
+++ b/system/include/libcxx/cfloat
@@ -67,12 +67,4 @@ Macros:
 #pragma GCC system_header
 #endif
 
-#ifndef FLT_EVAL_METHOD
-#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
-#endif
-
-#ifndef DECIMAL_DIG
-#define DECIMAL_DIG __DECIMAL_DIG__
-#endif
-
 #endif  // _LIBCPP_CFLOAT
diff --git a/system/include/libcxx/chrono b/system/include/libcxx/chrono
index 9229234ce55a8..68484e9824326 100644
--- a/system/include/libcxx/chrono
+++ b/system/include/libcxx/chrono
@@ -26,6 +26,9 @@ duration_cast(const duration<Rep, Period>& fd);
 
 template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
 
+template <class Rep> constexpr bool treat_as_floating_point_v
+    = treat_as_floating_point<Rep>::value;                       // C++17
+
 template <class Rep>
 struct duration_values
 {
@@ -194,6 +197,13 @@ template <class Rep1, class Period1, class Rep2, class Period2>
 template <class ToDuration, class Rep, class Period>
   ToDuration duration_cast(const duration<Rep, Period>& d);
 
+template <class ToDuration, class Rep, class Period>
+    constexpr ToDuration floor(const duration<Rep, Period>& d);    // C++17
+template <class ToDuration, class Rep, class Period>
+    constexpr ToDuration ceil(const duration<Rep, Period>& d);     // C++17
+template <class ToDuration, class Rep, class Period>
+    constexpr ToDuration round(const duration<Rep, Period>& d);    // C++17
+
 // 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>
@@ -227,6 +237,20 @@ template <class Clock, class Duration1, class Duration2>
 template <class ToDuration, class Clock, class Duration>
   time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
 
+template <class ToDuration, class Clock, class Duration>
+    constexpr time_point<Clock, ToDuration>
+    floor(const time_point<Clock, Duration>& tp);                  // C++17
+
+template <class ToDuration, class Clock, class Duration>
+    constexpr time_point<Clock, ToDuration>
+    ceil(const time_point<Clock, Duration>& tp);                   // C++17
+
+template <class ToDuration, class Clock, class Duration>
+    constexpr time_point<Clock, ToDuration>
+    round(const time_point<Clock, Duration>& tp);                  // C++17
+
+template <class Rep, class Period>
+    constexpr duration<Rep, Period> abs(duration<Rep, Period> d);  // C++17
 // Clocks
 
 class system_clock
@@ -392,6 +416,11 @@ duration_cast(const duration<_Rep, _Period>& __fd)
 template <class _Rep>
 struct _LIBCPP_TYPE_VIS_ONLY treat_as_floating_point : is_floating_point<_Rep> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
+    = treat_as_floating_point<_Rep>::value;
+#endif
+
 template <class _Rep>
 struct _LIBCPP_TYPE_VIS_ONLY duration_values
 {
@@ -401,6 +430,58 @@ public:
     _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min()  {return numeric_limits<_Rep>::lowest();}
 };
 
+#if _LIBCPP_STD_VER > 14
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+    __is_duration<_ToDuration>::value,
+    _ToDuration
+>::type
+floor(const duration<_Rep, _Period>& __d)
+{
+    _ToDuration __t = duration_cast<_ToDuration>(__d);
+    if (__t > __d)
+        __t = __t - _ToDuration{1};
+    return __t;
+}
+
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+    __is_duration<_ToDuration>::value,
+    _ToDuration
+>::type
+ceil(const duration<_Rep, _Period>& __d)
+{
+    _ToDuration __t = duration_cast<_ToDuration>(__d);
+    if (__t < __d)
+        __t = __t + _ToDuration{1};
+    return __t;
+}
+
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+    __is_duration<_ToDuration>::value,
+    _ToDuration
+>::type
+round(const duration<_Rep, _Period>& __d)
+{
+    _ToDuration __lower = floor<_ToDuration>(__d);
+    _ToDuration __upper = __lower + _ToDuration{1};
+    auto __lowerDiff = __d - __lower;
+    auto __upperDiff = __upper - __d;
+    if (__lowerDiff < __upperDiff)
+        return __lower;
+    if (__lowerDiff > __upperDiff)
+        return __upper;
+    return __lower.count() & 1 ? __upper : __lower;
+}
+#endif
+
 // duration
 
 template <class _Rep, class _Period>
@@ -807,6 +888,56 @@ time_point_cast(const time_point<_Clock, _Duration>& __t)
     return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
 }
 
+#if _LIBCPP_STD_VER > 14
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+    __is_duration<_ToDuration>::value,
+    time_point<_Clock, _ToDuration>
+>::type
+floor(const time_point<_Clock, _Duration>& __t)
+{
+    return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+    __is_duration<_ToDuration>::value,
+    time_point<_Clock, _ToDuration>
+>::type
+ceil(const time_point<_Clock, _Duration>& __t)
+{
+    return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+    __is_duration<_ToDuration>::value,
+    time_point<_Clock, _ToDuration>
+>::type
+round(const time_point<_Clock, _Duration>& __t)
+{
+    return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+    numeric_limits<_Rep>::is_signed,
+    duration<_Rep, _Period>
+>::type
+abs(duration<_Rep, _Period> __d)
+{
+    return __d >= __d.zero() ? __d : -__d;
+}
+#endif
+
 // time_point ==
 
 template <class _Clock, class _Duration1, class _Duration2>
diff --git a/system/include/libcxx/cinttypes b/system/include/libcxx/cinttypes
index 786692b8fec3c..3f61b0634b171 100644
--- a/system/include/libcxx/cinttypes
+++ b/system/include/libcxx/cinttypes
@@ -246,7 +246,6 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using::imaxdiv_t;
-
 using::imaxabs;
 using::imaxdiv;
 using::strtoimax;
diff --git a/system/include/libcxx/clocale b/system/include/libcxx/clocale
index f8b8f0dd34b6f..05fa9c6edda8e 100644
--- a/system/include/libcxx/clocale
+++ b/system/include/libcxx/clocale
@@ -45,7 +45,9 @@ lconv* localeconv();
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::lconv;
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 using ::setlocale;
+#endif
 using ::localeconv;
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/system/include/libcxx/cmath b/system/include/libcxx/cmath
index 4719abad3ca4d..ebbde18168ff7 100644
--- a/system/include/libcxx/cmath
+++ b/system/include/libcxx/cmath
@@ -299,340 +299,11 @@ long double    truncl(long double x);
 
 #include <__config>
 #include <math.h>
-#include <type_traits>
-
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/math_win32.h"
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-// signbit
-
-#ifdef signbit
-
-template <class _A1>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
-{
-    return signbit(__lcpp_x);
-}
-
-#undef signbit
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
-signbit(_A1 __lcpp_x) _NOEXCEPT
-{
-    return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
-}
-
-#endif  // signbit
-
-// fpclassify
-
-#ifdef fpclassify
-
-template <class _A1>
-_LIBCPP_ALWAYS_INLINE
-int
-__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
-{
-    return fpclassify(__lcpp_x);
-}
-
-#undef fpclassify
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if<std::is_arithmetic<_A1>::value, int>::type
-fpclassify(_A1 __lcpp_x) _NOEXCEPT
-{
-    return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
-}
-
-#endif  // fpclassify
-
-// isfinite
-
-#ifdef isfinite
-
-template <class _A1>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
-{
-    return isfinite(__lcpp_x);
-}
-
-#undef isfinite
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
-isfinite(_A1 __lcpp_x) _NOEXCEPT
-{
-    return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
-}
-
-#endif  // isfinite
-
-// isinf
-
-#ifdef isinf
-
-template <class _A1>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
-{
-    return isinf(__lcpp_x);
-}
-
-#undef isinf
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
-isinf(_A1 __lcpp_x) _NOEXCEPT
-{
-    return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
-}
-
-#endif  // isinf
-
-// isnan
-
-#ifdef isnan
-
-template <class _A1>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
-{
-    return isnan(__lcpp_x);
-}
-
-#undef isnan
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
-isnan(_A1 __lcpp_x) _NOEXCEPT
-{
-    return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
-}
-
-#endif  // isnan
-
-// isnormal
-
-#ifdef isnormal
-
-template <class _A1>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
-{
-    return isnormal(__lcpp_x);
-}
-
-#undef isnormal
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
-isnormal(_A1 __lcpp_x) _NOEXCEPT
-{
-    return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
-}
-
-#endif  // isnormal
-
-// isgreater
-
-#ifdef isgreater
-
-template <class _A1, class _A2>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    return isgreater(__lcpp_x, __lcpp_y);
-}
-
-#undef isgreater
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if
-<
-    std::is_arithmetic<_A1>::value &&
-    std::is_arithmetic<_A2>::value,
-    bool
->::type
-isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename std::__promote<_A1, _A2>::type type;
-    return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
-}
-
-#endif  // isgreater
-
-// isgreaterequal
-
-#ifdef isgreaterequal
-
-template <class _A1, class _A2>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    return isgreaterequal(__lcpp_x, __lcpp_y);
-}
-
-#undef isgreaterequal
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if
-<
-    std::is_arithmetic<_A1>::value &&
-    std::is_arithmetic<_A2>::value,
-    bool
->::type
-isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename std::__promote<_A1, _A2>::type type;
-    return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
-}
-
-#endif  // isgreaterequal
-
-// isless
-
-#ifdef isless
-
-template <class _A1, class _A2>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    return isless(__lcpp_x, __lcpp_y);
-}
-
-#undef isless
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if
-<
-    std::is_arithmetic<_A1>::value &&
-    std::is_arithmetic<_A2>::value,
-    bool
->::type
-isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename std::__promote<_A1, _A2>::type type;
-    return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
-}
-
-#endif  // isless
-
-// islessequal
-
-#ifdef islessequal
-
-template <class _A1, class _A2>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    return islessequal(__lcpp_x, __lcpp_y);
-}
-
-#undef islessequal
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if
-<
-    std::is_arithmetic<_A1>::value &&
-    std::is_arithmetic<_A2>::value,
-    bool
->::type
-islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename std::__promote<_A1, _A2>::type type;
-    return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
-}
-
-#endif  // islessequal
-
-// islessgreater
-
-#ifdef islessgreater
-
-template <class _A1, class _A2>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    return islessgreater(__lcpp_x, __lcpp_y);
-}
-
-#undef islessgreater
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if
-<
-    std::is_arithmetic<_A1>::value &&
-    std::is_arithmetic<_A2>::value,
-    bool
->::type
-islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename std::__promote<_A1, _A2>::type type;
-    return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
-}
-
-#endif  // islessgreater
-
-// isunordered
-
-#ifdef isunordered
-
-template <class _A1, class _A2>
-_LIBCPP_ALWAYS_INLINE
-bool
-__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    return isunordered(__lcpp_x, __lcpp_y);
-}
-
-#undef isunordered
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if
-<
-    std::is_arithmetic<_A1>::value &&
-    std::is_arithmetic<_A2>::value,
-    bool
->::type
-isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename std::__promote<_A1, _A2>::type type;
-    return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
-}
-
-#endif  // isunordered
-
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::signbit;
@@ -652,782 +323,130 @@ using ::isunordered;
 using ::float_t;
 using ::double_t;
 
-// abs
-
-#if !defined(_AIX)
-inline _LIBCPP_INLINE_VISIBILITY
-float
-abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
-
-inline _LIBCPP_INLINE_VISIBILITY
-double
-abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);}
-
-inline _LIBCPP_INLINE_VISIBILITY
-long double
-abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
-#endif // !defined(_AIX)
+#ifndef _AIX
+using ::abs;
+#endif
 
 #ifndef __sun__
-
-// acos
-
 using ::acos;
 using ::acosf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       acos(float __lcpp_x) _NOEXCEPT       {return acosf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);}
-
-// asin
-
 using ::asin;
 using ::asinf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       asin(float __lcpp_x) _NOEXCEPT       {return asinf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);}
-
-// atan
-
 using ::atan;
 using ::atanf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       atan(float __lcpp_x) _NOEXCEPT       {return atanf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);}
-
-// atan2
-
 using ::atan2;
 using ::atan2f;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT             {return atan2f(__lcpp_y, __lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);}
-#endif
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
-}
-
-// ceil
-
 using ::ceil;
 using ::ceilf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       ceil(float __lcpp_x) _NOEXCEPT       {return ceilf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);}
-
-// cos
-
 using ::cos;
 using ::cosf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       cos(float __lcpp_x) _NOEXCEPT       {return cosf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);}
-
-// cosh
-
 using ::cosh;
 using ::coshf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       cosh(float __lcpp_x) _NOEXCEPT       {return coshf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);}
-
 #endif // __sun__
-// exp
 
 using ::exp;
 using ::expf;
 
 #ifndef __sun__
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       exp(float __lcpp_x) _NOEXCEPT       {return expf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);}
-#endif
-
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);}
-
-// fabs
-
 using ::fabs;
 using ::fabsf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       fabs(float __lcpp_x) _NOEXCEPT       {return fabsf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);}
-
-// floor
-
 using ::floor;
 using ::floorf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       floor(float __lcpp_x) _NOEXCEPT       {return floorf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);}
-
-// fmod
-
 #endif //__sun__
+
 using ::fmod;
 using ::fmodf;
-#ifndef __sun__
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return fmodf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);}
-#endif
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
-
-// frexp
 
+#ifndef __sun__
 using ::frexp;
 using ::frexpf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT       {return frexpf(__lcpp_x, __lcpp_e);}
-inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __lcpp_e);}
-
-// ldexp
-
 using ::ldexp;
 using ::ldexpf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT       {return ldexpf(__lcpp_x, __lcpp_e);}
-inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lcpp_e);}
-
-// log
-
 #endif // __sun__
+
 using ::log;
 using ::logf;
-#ifndef __sun__
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       log(float __lcpp_x) _NOEXCEPT       {return logf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);}
-
-
-// log10
 
+#ifndef __sun__
 using ::log10;
 using ::log10f;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       log10(float __lcpp_x) _NOEXCEPT       {return log10f(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);}
-
-// modf
-
 using ::modf;
 using ::modff;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT             {return modff(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);}
-#endif
-
-// pow
-
 #endif // __sun__ 
+
 using ::pow;
 using ::powf;
 
 #ifndef __sun__
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return powf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);}
-#endif
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
-// sin
-
 using ::sin;
 using ::sinf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       sin(float __lcpp_x) _NOEXCEPT       {return sinf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);}
-
-// sinh
-
 using ::sinh;
 using ::sinhf;
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       sinh(float __lcpp_x) _NOEXCEPT       {return sinhf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);}
-
-// sqrt
-
 #endif // __sun__
+
 using ::sqrt;
 using ::sqrtf;
-
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       sqrt(float __lcpp_x) _NOEXCEPT       {return sqrtf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);}
-
-// tan
-
 using ::tan;
 using ::tanf;
-#ifndef __sun__
-
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       tan(float __lcpp_x) _NOEXCEPT       {return tanf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);}
-
-// tanh
 
+#ifndef __sun__
 using ::tanh;
 using ::tanhf;
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
-inline _LIBCPP_INLINE_VISIBILITY float       tanh(float __lcpp_x) _NOEXCEPT       {return tanhf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);}
-#endif
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-tanh(_A1 __lcpp_x) _NOEXCEPT {return tanh((double)__lcpp_x);}
-
-// acosh
-
 #ifndef _LIBCPP_MSVCRT
 using ::acosh;
 using ::acoshf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       acosh(float __lcpp_x) _NOEXCEPT       {return acoshf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return acoshl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-acosh(_A1 __lcpp_x) _NOEXCEPT {return acosh((double)__lcpp_x);}
-#endif
-
-// asinh
-
-#ifndef _LIBCPP_MSVCRT
 using ::asinh;
 using ::asinhf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       asinh(float __lcpp_x) _NOEXCEPT       {return asinhf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return asinhl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-asinh(_A1 __lcpp_x) _NOEXCEPT {return asinh((double)__lcpp_x);}
-#endif
-
-// atanh
-
-#ifndef _LIBCPP_MSVCRT
 using ::atanh;
 using ::atanhf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       atanh(float __lcpp_x) _NOEXCEPT       {return atanhf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return atanhl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-atanh(_A1 __lcpp_x) _NOEXCEPT {return atanh((double)__lcpp_x);}
-#endif
-
-// cbrt
-
-#ifndef _LIBCPP_MSVCRT
 using ::cbrt;
 using ::cbrtf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       cbrt(float __lcpp_x) _NOEXCEPT       {return cbrtf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return cbrtl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);}
 #endif
 
-// copysign
-
 using ::copysign;
 using ::copysignf;
 
-inline _LIBCPP_INLINE_VISIBILITY float       copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return copysignf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return copysignl(__lcpp_x, __lcpp_y);}
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
 #ifndef _LIBCPP_MSVCRT
-
-// erf
-
 using ::erf;
 using ::erff;
-
-inline _LIBCPP_INLINE_VISIBILITY float       erf(float __lcpp_x) _NOEXCEPT       {return erff(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return erfl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-erf(_A1 __lcpp_x) _NOEXCEPT {return erf((double)__lcpp_x);}
-
-// erfc
-
 using ::erfc;
 using ::erfcf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       erfc(float __lcpp_x) _NOEXCEPT       {return erfcf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return erfcl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-erfc(_A1 __lcpp_x) _NOEXCEPT {return erfc((double)__lcpp_x);}
-
-// exp2
-
 using ::exp2;
 using ::exp2f;
-
-inline _LIBCPP_INLINE_VISIBILITY float       exp2(float __lcpp_x) _NOEXCEPT       {return exp2f(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return exp2l(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-exp2(_A1 __lcpp_x) _NOEXCEPT {return exp2((double)__lcpp_x);}
-
-// expm1
-
 using ::expm1;
 using ::expm1f;
-
-inline _LIBCPP_INLINE_VISIBILITY float       expm1(float __lcpp_x) _NOEXCEPT       {return expm1f(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return expm1l(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-expm1(_A1 __lcpp_x) _NOEXCEPT {return expm1((double)__lcpp_x);}
-
-// fdim
-
 using ::fdim;
 using ::fdimf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return fdimf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fdiml(__lcpp_x, __lcpp_y);}
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
-// fma
-
 using ::fmaf;
 using ::fma;
-
-inline _LIBCPP_INLINE_VISIBILITY float       fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT                   {return fmaf(__lcpp_x, __lcpp_y, __lcpp_z);}
-inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return fmal(__lcpp_x, __lcpp_y, __lcpp_z);}
-
-template <class _A1, class _A2, class _A3>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value &&
-    is_arithmetic<_A3>::value,
-    typename __promote<_A1, _A2, _A3>::type
->::type
-fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2, _A3>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value &&
-                      is_same<_A3, __result_type>::value)), "");
-    return fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
-}
-
-// fmax
-
 using ::fmax;
 using ::fmaxf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return fmaxf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmaxl(__lcpp_x, __lcpp_y);}
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
-// fmin
-
 using ::fmin;
 using ::fminf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return fminf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fminl(__lcpp_x, __lcpp_y);}
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
-// hypot
-
 using ::hypot;
 using ::hypotf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return hypotf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return hypotl(__lcpp_x, __lcpp_y);}
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
-// ilogb
-
 using ::ilogb;
 using ::ilogbf;
-
-inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT       {return ilogbf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ilogbl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, int>::type
-ilogb(_A1 __lcpp_x) _NOEXCEPT {return ilogb((double)__lcpp_x);}
-
-// lgamma
-
 using ::lgamma;
 using ::lgammaf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       lgamma(float __lcpp_x) _NOEXCEPT       {return lgammaf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return lgammal(__lcpp_x);}
-
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-lgamma(_A1 __lcpp_x) _NOEXCEPT {return lgamma((double)__lcpp_x);}
-
-
-// llrint
-
 using ::llrint;
 using ::llrintf;
-
-inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT       {return llrintf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return llrintl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, long long>::type
-llrint(_A1 __lcpp_x) _NOEXCEPT {return llrint((double)__lcpp_x);}
-
-// llround
-
 using ::llround;
 using ::llroundf;
-
-inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT       {return llroundf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return llroundl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, long long>::type
-llround(_A1 __lcpp_x) _NOEXCEPT {return llround((double)__lcpp_x);}
-
-// log1p
-
 using ::log1p;
 using ::log1pf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       log1p(float __lcpp_x) _NOEXCEPT       {return log1pf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return log1pl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-log1p(_A1 __lcpp_x) _NOEXCEPT {return log1p((double)__lcpp_x);}
-
-// log2
-
 using ::log2;
 using ::log2f;
-
-inline _LIBCPP_INLINE_VISIBILITY float       log2(float __lcpp_x) _NOEXCEPT       {return log2f(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-log2(_A1 __lcpp_x) _NOEXCEPT {return log2((double)__lcpp_x);}
-
-// logb
-
 using ::logb;
 using ::logbf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       logb(float __lcpp_x) _NOEXCEPT       {return logbf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-logb(_A1 __lcpp_x) _NOEXCEPT {return logb((double)__lcpp_x);}
-
-// lrint
-
 using ::lrint;
 using ::lrintf;
-
-inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT       {return lrintf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return lrintl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, long>::type
-lrint(_A1 __lcpp_x) _NOEXCEPT {return lrint((double)__lcpp_x);}
-
-// lround
-
 using ::lround;
 using ::lroundf;
-
-inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT       {return lroundf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return lroundl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, long>::type
-lround(_A1 __lcpp_x) _NOEXCEPT {return lround((double)__lcpp_x);}
-
 #endif // _LIBCPP_MSVCRT
 #endif // __sun__
 
-// nan
-
 #ifndef _LIBCPP_MSVCRT
 using ::nan;
 using ::nanf;
@@ -1435,183 +454,28 @@ using ::nanf;
 
 #ifndef __sun__
 #ifndef _LIBCPP_MSVCRT
-
-// nearbyint
-
 using ::nearbyint;
 using ::nearbyintf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       nearbyint(float __lcpp_x) _NOEXCEPT       {return nearbyintf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return nearbyintl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-nearbyint(_A1 __lcpp_x) _NOEXCEPT {return nearbyint((double)__lcpp_x);}
-
-// nextafter
-
 using ::nextafter;
 using ::nextafterf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return nextafterf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nextafterl(__lcpp_x, __lcpp_y);}
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
-// nexttoward
-
 using ::nexttoward;
 using ::nexttowardf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT       {return nexttowardf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardl(__lcpp_x, __lcpp_y);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);}
-
-// remainder
-
 using ::remainder;
 using ::remainderf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return remainderf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return remainderl(__lcpp_x, __lcpp_y);}
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
-}
-
-// remquo
-
 using ::remquo;
 using ::remquof;
-
-inline _LIBCPP_INLINE_VISIBILITY float       remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT             {return remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
-inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquol(__lcpp_x, __lcpp_y, __lcpp_z);}
-
-template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    is_arithmetic<_A1>::value &&
-    is_arithmetic<_A2>::value,
-    typename __promote<_A1, _A2>::type
->::type
-remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
-{
-    typedef typename __promote<_A1, _A2>::type __result_type;
-    static_assert((!(is_same<_A1, __result_type>::value &&
-                      is_same<_A2, __result_type>::value)), "");
-    return remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
-}
-
-// rint
-
 using ::rint;
 using ::rintf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       rint(float __lcpp_x) _NOEXCEPT       {return rintf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return rintl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-rint(_A1 __lcpp_x) _NOEXCEPT {return rint((double)__lcpp_x);}
-
-// round
-
 using ::round;
 using ::roundf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       round(float __lcpp_x) _NOEXCEPT       {return roundf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return roundl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-round(_A1 __lcpp_x) _NOEXCEPT {return round((double)__lcpp_x);}
-
-// scalbln
-
 using ::scalbln;
 using ::scalblnf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT       {return scalblnf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnl(__lcpp_x, __lcpp_y);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalbln((double)__lcpp_x, __lcpp_y);}
-
-// scalbn
-
 using ::scalbn;
 using ::scalbnf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT       {return scalbnf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnl(__lcpp_x, __lcpp_y);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbn((double)__lcpp_x, __lcpp_y);}
-
-// tgamma
-
 using ::tgamma;
 using ::tgammaf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       tgamma(float __lcpp_x) _NOEXCEPT       {return tgammaf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return tgammal(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-tgamma(_A1 __lcpp_x) _NOEXCEPT {return tgamma((double)__lcpp_x);}
-
-// trunc
-
 using ::trunc;
 using ::truncf;
-
-inline _LIBCPP_INLINE_VISIBILITY float       trunc(float __lcpp_x) _NOEXCEPT       {return truncf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return truncl(__lcpp_x);}
-
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<is_integral<_A1>::value, double>::type
-trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);}
-
 #endif // !_LIBCPP_MSVCRT
 
 using ::acosl;
@@ -1635,6 +499,7 @@ using ::sinl;
 using ::sinhl;
 using ::sqrtl;
 using ::tanl;
+
 #ifndef _LIBCPP_MSVCRT
 using ::tanhl;
 using ::acoshl;
@@ -1642,7 +507,9 @@ using ::asinhl;
 using ::atanhl;
 using ::cbrtl;
 #endif  // !_LIBCPP_MSVCRT
+
 using ::copysignl;
+
 #ifndef _LIBCPP_MSVCRT
 using ::erfl;
 using ::erfcl;
@@ -1680,6 +547,7 @@ using ::truncl;
 using ::lgamma;
 using ::lgammaf;
 #endif // __sun__
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_CMATH
diff --git a/system/include/libcxx/complex b/system/include/libcxx/complex
index 2943da1d775ca..f56138fa2d16e 100644
--- a/system/include/libcxx/complex
+++ b/system/include/libcxx/complex
@@ -332,7 +332,9 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f)
         : __re_(__re), __im_(__im) {}
+    _LIBCPP_INLINE_VISIBILITY
     explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
+    _LIBCPP_INLINE_VISIBILITY
     explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}
@@ -388,7 +390,9 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0)
         : __re_(__re), __im_(__im) {}
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
+    _LIBCPP_INLINE_VISIBILITY
     explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}
@@ -444,7 +448,9 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L)
         : __re_(__re), __im_(__im) {}
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}
@@ -490,32 +496,32 @@ public:
         }
 };
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 complex<float>::complex(const complex<double>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 complex<float>::complex(const complex<long double>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 complex<double>::complex(const complex<float>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 complex<double>::complex(const complex<long double>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 complex<long double>::complex(const complex<float>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 complex<long double>::complex(const complex<double>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
@@ -1399,7 +1405,7 @@ acos(const complex<_Tp>& __x)
     }
     if (isinf(__x.imag()))
         return complex<_Tp>(__pi/_Tp(2), -__x.imag());
-    if (__x.real() == 0)
+    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)));
     if (signbit(__x.imag()))
diff --git a/system/include/libcxx/complex.h b/system/include/libcxx/complex.h
index 7003d31a89cdc..c2359665add5b 100644
--- a/system/include/libcxx/complex.h
+++ b/system/include/libcxx/complex.h
@@ -18,6 +18,12 @@
 
 */
 
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 #ifdef __cplusplus
 
 #include <ccomplex>
@@ -28,8 +34,4 @@
 
 #endif  // __cplusplus
 
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
 #endif  // _LIBCPP_COMPLEX_H
diff --git a/system/include/libcxx/condition_variable b/system/include/libcxx/condition_variable
index 1af2484abd7bc..10e007701672d 100644
--- a/system/include/libcxx/condition_variable
+++ b/system/include/libcxx/condition_variable
@@ -124,14 +124,18 @@ class _LIBCPP_TYPE_VIS condition_variable_any
     condition_variable __cv_;
     shared_ptr<mutex>  __mut_;
 public:
+    _LIBCPP_INLINE_VISIBILITY
     condition_variable_any();
 
+    _LIBCPP_INLINE_VISIBILITY
     void notify_one() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     void notify_all() _NOEXCEPT;
 
     template <class _Lock>
         void wait(_Lock& __lock);
     template <class _Lock, class _Predicate>
+        _LIBCPP_INLINE_VISIBILITY
         void wait(_Lock& __lock, _Predicate __pred);
 
     template <class _Lock, class _Clock, class _Duration>
@@ -141,27 +145,30 @@ public:
 
     template <class _Lock, class _Clock, class _Duration, class _Predicate>
         bool
+        _LIBCPP_INLINE_VISIBILITY
         wait_until(_Lock& __lock,
                    const chrono::time_point<_Clock, _Duration>& __t,
                    _Predicate __pred);
 
     template <class _Lock, class _Rep, class _Period>
         cv_status
+        _LIBCPP_INLINE_VISIBILITY
         wait_for(_Lock& __lock,
                  const chrono::duration<_Rep, _Period>& __d);
 
     template <class _Lock, class _Rep, class _Period, class _Predicate>
         bool
+        _LIBCPP_INLINE_VISIBILITY
         wait_for(_Lock& __lock,
                  const chrono::duration<_Rep, _Period>& __d,
                  _Predicate __pred);
 };
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 condition_variable_any::condition_variable_any()
     : __mut_(make_shared<mutex>()) {}
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 condition_variable_any::notify_one() _NOEXCEPT
 {
@@ -169,7 +176,7 @@ condition_variable_any::notify_one() _NOEXCEPT
     __cv_.notify_one();
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 condition_variable_any::notify_all() _NOEXCEPT
 {
@@ -196,7 +203,7 @@ condition_variable_any::wait(_Lock& __lock)
 }  // __mut_.unlock(), __lock.lock()
 
 template <class _Lock, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 condition_variable_any::wait(_Lock& __lock, _Predicate __pred)
 {
@@ -218,7 +225,7 @@ condition_variable_any::wait_until(_Lock& __lock,
 }  // __mut_.unlock(), __lock.lock()
 
 template <class _Lock, class _Clock, class _Duration, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 condition_variable_any::wait_until(_Lock& __lock,
                                    const chrono::time_point<_Clock, _Duration>& __t,
@@ -231,7 +238,7 @@ condition_variable_any::wait_until(_Lock& __lock,
 }
 
 template <class _Lock, class _Rep, class _Period>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 cv_status
 condition_variable_any::wait_for(_Lock& __lock,
                                  const chrono::duration<_Rep, _Period>& __d)
@@ -240,7 +247,7 @@ condition_variable_any::wait_for(_Lock& __lock,
 }
 
 template <class _Lock, class _Rep, class _Period, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 condition_variable_any::wait_for(_Lock& __lock,
                                  const chrono::duration<_Rep, _Period>& __d,
diff --git a/system/include/libcxx/csetjmp b/system/include/libcxx/csetjmp
index d0b2c078967df..58a9c73ab56f6 100644
--- a/system/include/libcxx/csetjmp
+++ b/system/include/libcxx/csetjmp
@@ -38,10 +38,6 @@ void longjmp(jmp_buf env, int val);
 #pragma GCC system_header
 #endif
 
-#ifndef setjmp
-#define setjmp(env) setjmp(env)
-#endif
-
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::jmp_buf;
diff --git a/system/include/libcxx/cstddef b/system/include/libcxx/cstddef
index c3ca64a9c0149..edd106c001bcb 100644
--- a/system/include/libcxx/cstddef
+++ b/system/include/libcxx/cstddef
@@ -35,12 +35,14 @@ Types:
 
 #include <__config>
 
-#include <stddef.h>
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
+#include_next <stddef.h>
+#include <__nullptr>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::ptrdiff_t;
@@ -53,50 +55,6 @@ using ::max_align_t;
 typedef long double max_align_t;
 #endif
 
-#ifdef _LIBCPP_HAS_NO_NULLPTR
-
-struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
-{
-    void* __lx;
-
-    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_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
-
-    template <class _Tp>
-        _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
-        operator _Tp* () const {return 0;}
-
-    template <class _Tp, class _Up>
-        _LIBCPP_ALWAYS_INLINE
-        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_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;}
-    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_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;}
-};
-
-inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
-
-#define nullptr _VSTD::__get_nullptr_t()
-
-#endif  // _LIBCPP_HAS_NO_NULLPTR
-
 _LIBCPP_END_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_NULLPTR
-
-namespace std
-{
-    typedef decltype(nullptr) nullptr_t;
-}
-
-#endif  // _LIBCPP_HAS_NO_NULLPTR
-
 #endif  // _LIBCPP_CSTDDEF
diff --git a/system/include/libcxx/cstdio b/system/include/libcxx/cstdio
index ce3af4d91dc4b..50fdd34574267 100644
--- a/system/include/libcxx/cstdio
+++ b/system/include/libcxx/cstdio
@@ -103,53 +103,26 @@ void perror(const char* s);
 #pragma GCC system_header
 #endif
 
-// snprintf
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/support.h"
-#endif
-
-#ifdef getc
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);}
-#undef getc
-inline _LIBCPP_INLINE_VISIBILITY int getc(FILE* __stream) {return __libcpp_getc(__stream);}
-#endif  // getc
-
-#ifdef putc
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);}
-#undef putc
-inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
-#endif  // putc
-
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::FILE;
 using ::fpos_t;
 using ::size_t;
 
-using ::remove;
-using ::rename;
-using ::tmpfile;
-using ::tmpnam;
 using ::fclose;
 using ::fflush;
-using ::fopen;
-using ::freopen;
 using ::setbuf;
 using ::setvbuf;
 using ::fprintf;
 using ::fscanf;
-using ::printf;
-using ::scanf;
 using ::snprintf;
 using ::sprintf;
 using ::sscanf;
 #ifndef _LIBCPP_MSVCRT
 using ::vfprintf;
 using ::vfscanf;
-using ::vscanf;
 using ::vsscanf;
 #endif // _LIBCPP_MSVCRT
-using ::vprintf;
 using ::vsnprintf;
 using ::vsprintf;
 using ::fgetc;
@@ -157,13 +130,7 @@ using ::fgets;
 using ::fputc;
 using ::fputs;
 using ::getc;
-using ::getchar;
-#if _LIBCPP_STD_VER <= 11
-using ::gets;
-#endif
 using ::putc;
-using ::putchar;
-using ::puts;
 using ::ungetc;
 using ::fread;
 using ::fwrite;
@@ -177,6 +144,31 @@ using ::feof;
 using ::ferror;
 using ::perror;
 
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+using ::fopen;
+using ::freopen;
+using ::remove;
+using ::rename;
+using ::tmpfile;
+using ::tmpnam;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDIN
+using ::getchar;
+#if _LIBCPP_STD_VER <= 11
+using ::gets;
+#endif
+using ::scanf;
+using ::vscanf;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDOUT
+using ::printf;
+using ::putchar;
+using ::puts;
+using ::vprintf;
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_CSTDIO
diff --git a/system/include/libcxx/cstdlib b/system/include/libcxx/cstdlib
index 152b891de78e4..10ed231078d8d 100644
--- a/system/include/libcxx/cstdlib
+++ b/system/include/libcxx/cstdlib
@@ -84,9 +84,6 @@ void *aligned_alloc(size_t alignment, size_t size);                       // C11
 
 #include <__config>
 #include <stdlib.h>
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -141,9 +138,11 @@ using ::ldiv;
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
 using ::lldiv;
 #endif // _LIBCPP_HAS_NO_LONG_LONG
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 using ::mblen;
 using ::mbtowc;
 using ::wctomb;
+#endif
 using ::mbstowcs;
 using ::wcstombs;
 #ifdef _LIBCPP_HAS_QUICK_EXIT
@@ -154,19 +153,6 @@ using ::quick_exit;
 using ::aligned_alloc;
 #endif
 
-// MSVCRT already has the correct prototype in <stdlib.h> #ifdef __cplusplus
-#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
-inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-
-inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-#endif // _LIBCPP_MSVCRT
-
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_CSTDLIB
diff --git a/system/include/libcxx/cstring b/system/include/libcxx/cstring
index 21c9155cd4d9d..d550695caa42f 100644
--- a/system/include/libcxx/cstring
+++ b/system/include/libcxx/cstring
@@ -78,31 +78,16 @@ using ::strcmp;
 using ::strncmp;
 using ::strcoll;
 using ::strxfrm;
-
 using ::memchr;
-
 using ::strchr;
-
 using ::strcspn;
-
 using ::strpbrk;
-
 using ::strrchr;
-
 using ::strspn;
-
 using ::strstr;
-
-// MSVCRT, GNU libc and its derivates already have the correct prototype in <string.h> #ifdef __cplusplus
-#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
-inline _LIBCPP_INLINE_VISIBILITY       char* strchr(      char* __s, int __c) {return ::strchr(__s, __c);}
-inline _LIBCPP_INLINE_VISIBILITY       char* strpbrk(      char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}
-inline _LIBCPP_INLINE_VISIBILITY       char* strrchr(      char* __s, int __c) {return ::strrchr(__s, __c);}
-inline _LIBCPP_INLINE_VISIBILITY       void* memchr(      void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}
-inline _LIBCPP_INLINE_VISIBILITY       char* strstr(      char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}
-#endif
-
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 using ::strtok;
+#endif
 using ::memset;
 using ::strerror;
 using ::strlen;
diff --git a/system/include/libcxx/ctime b/system/include/libcxx/ctime
index fc4eb26f54305..da9e3290bbb20 100644
--- a/system/include/libcxx/ctime
+++ b/system/include/libcxx/ctime
@@ -61,10 +61,12 @@ using ::clock;
 using ::difftime;
 using ::mktime;
 using ::time;
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 using ::asctime;
 using ::ctime;
 using ::gmtime;
 using ::localtime;
+#endif
 using ::strftime;
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/system/include/libcxx/ctype.h b/system/include/libcxx/ctype.h
new file mode 100644
index 0000000000000..22d6c49be9e17
--- /dev/null
+++ b/system/include/libcxx/ctype.h
@@ -0,0 +1,69 @@
+// -*- C++ -*-
+//===---------------------------- ctype.h ---------------------------------===//
+//
+//                     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_CTYPE_H
+#define _LIBCPP_CTYPE_H
+
+/*
+    ctype.h synopsis
+
+int isalnum(int c);
+int isalpha(int c);
+int isblank(int c);  // C99
+int iscntrl(int c);
+int isdigit(int c);
+int isgraph(int c);
+int islower(int c);
+int isprint(int c);
+int ispunct(int c);
+int isspace(int c);
+int isupper(int c);
+int isxdigit(int c);
+int tolower(int c);
+int toupper(int c);
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <ctype.h>
+
+#ifdef __cplusplus
+
+#if defined(_LIBCPP_MSVCRT)
+// We support including .h headers inside 'extern "C"' contexts, so switch
+// back to C++ linkage before including these C++ headers.
+extern "C++" {
+  #include "support/win32/support.h"
+  #include "support/win32/locale_win32.h"
+}
+#endif // _LIBCPP_MSVCRT
+
+#undef isalnum
+#undef isalpha
+#undef isblank
+#undef iscntrl
+#undef isdigit
+#undef isgraph
+#undef islower
+#undef isprint
+#undef ispunct
+#undef isspace
+#undef isupper
+#undef isxdigit
+#undef tolower
+#undef toupper
+
+#endif
+
+#endif  // _LIBCPP_CTYPE_H
diff --git a/system/include/libcxx/cwchar b/system/include/libcxx/cwchar
index 9f51587caa5fd..52dde9e18021b 100644
--- a/system/include/libcxx/cwchar
+++ b/system/include/libcxx/cwchar
@@ -106,9 +106,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
 #include <__config>
 #include <cwctype>
 #include <wchar.h>
-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
-#include <support/win32/support.h> // pull in *swprintf defines
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -126,24 +123,18 @@ using ::fwscanf;
 using ::swprintf;
 using ::vfwprintf;
 using ::vswprintf;
-using ::vwprintf;
 #ifndef _LIBCPP_MSVCRT
 using ::swscanf;
 using ::vfwscanf;
 using ::vswscanf;
-using ::vwscanf;
 #endif // _LIBCPP_MSVCRT
-using ::wprintf;
-using ::wscanf;
 using ::fgetwc;
 using ::fgetws;
 using ::fputwc;
 using ::fputws;
 using ::fwide;
 using ::getwc;
-using ::getwchar;
 using ::putwc;
-using ::putwchar;
 using ::ungetwc;
 using ::wcstod;
 #ifndef _LIBCPP_MSVCRT
@@ -166,34 +157,11 @@ using ::wcscmp;
 using ::wcscoll;
 using ::wcsncmp;
 using ::wcsxfrm;
-
-#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
-
 using ::wcschr;
 using ::wcspbrk;
 using ::wcsrchr;
 using ::wcsstr;
 using ::wmemchr;
-
-#else
-
-inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);}
-inline _LIBCPP_INLINE_VISIBILITY       wchar_t* wcschr(      wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);}
-
-inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);}
-inline _LIBCPP_INLINE_VISIBILITY       wchar_t* wcspbrk(      wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);}
-
-inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);}
-inline _LIBCPP_INLINE_VISIBILITY       wchar_t* wcsrchr(      wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);}
-
-inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);}
-inline _LIBCPP_INLINE_VISIBILITY       wchar_t* wcsstr(      wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);}
-
-inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
-inline _LIBCPP_INLINE_VISIBILITY       wchar_t* wmemchr(      wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
-
-#endif
-
 using ::wcscspn;
 using ::wcslen;
 using ::wcsspn;
@@ -212,6 +180,20 @@ using ::wcrtomb;
 using ::mbsrtowcs;
 using ::wcsrtombs;
 
+#ifndef _LIBCPP_HAS_NO_STDIN
+using ::getwchar;
+#ifndef _LIBCPP_MSVCRT
+using ::vwscanf;
+#endif // _LIBCPP_MSVCRT
+using ::wscanf;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDOUT
+using ::putwchar;
+using ::vwprintf;
+using ::wprintf;
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_CWCHAR
diff --git a/system/include/libcxx/cwctype b/system/include/libcxx/cwctype
index 4f89b52db27ce..25b2489edf2c9 100644
--- a/system/include/libcxx/cwctype
+++ b/system/include/libcxx/cwctype
@@ -63,150 +63,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 using ::wint_t;
 using ::wctrans_t;
 using ::wctype_t;
-
-#ifdef iswalnum
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalnum(wint_t __wc) {return iswalnum(__wc);}
-#undef iswalnum
-inline _LIBCPP_INLINE_VISIBILITY int iswalnum(wint_t __wc) {return __libcpp_iswalnum(__wc);}
-#else  // iswalnum
 using ::iswalnum;
-#endif
-
-#ifdef iswalpha
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalpha(wint_t __wc) {return iswalpha(__wc);}
-#undef iswalpha
-inline _LIBCPP_INLINE_VISIBILITY int iswalpha(wint_t __wc) {return __libcpp_iswalpha(__wc);}
-#else  // iswalpha
 using ::iswalpha;
-#endif
-
-#ifdef iswblank
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswblank(wint_t __wc) {return iswblank(__wc);}
-#undef iswblank
-inline _LIBCPP_INLINE_VISIBILITY int iswblank(wint_t __wc) {return __libcpp_iswblank(__wc);}
-#else  // iswblank
 using ::iswblank;
-#endif
-
-#ifdef iswcntrl
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswcntrl(wint_t __wc) {return iswcntrl(__wc);}
-#undef iswcntrl
-inline _LIBCPP_INLINE_VISIBILITY int iswcntrl(wint_t __wc) {return __libcpp_iswcntrl(__wc);}
-#else  // iswcntrl
 using ::iswcntrl;
-#endif
-
-#ifdef iswdigit
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswdigit(wint_t __wc) {return iswdigit(__wc);}
-#undef iswdigit
-inline _LIBCPP_INLINE_VISIBILITY int iswdigit(wint_t __wc) {return __libcpp_iswdigit(__wc);}
-#else  // iswdigit
 using ::iswdigit;
-#endif
-
-#ifdef iswgraph
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswgraph(wint_t __wc) {return iswgraph(__wc);}
-#undef iswgraph
-inline _LIBCPP_INLINE_VISIBILITY int iswgraph(wint_t __wc) {return __libcpp_iswgraph(__wc);}
-#else  // iswgraph
 using ::iswgraph;
-#endif
-
-#ifdef iswlower
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswlower(wint_t __wc) {return iswlower(__wc);}
-#undef iswlower
-inline _LIBCPP_INLINE_VISIBILITY int iswlower(wint_t __wc) {return __libcpp_iswlower(__wc);}
-#else  // iswlower
 using ::iswlower;
-#endif
-
-#ifdef iswprint
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswprint(wint_t __wc) {return iswprint(__wc);}
-#undef iswprint
-inline _LIBCPP_INLINE_VISIBILITY int iswprint(wint_t __wc) {return __libcpp_iswprint(__wc);}
-#else  // iswprint
 using ::iswprint;
-#endif
-
-#ifdef iswpunct
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswpunct(wint_t __wc) {return iswpunct(__wc);}
-#undef iswpunct
-inline _LIBCPP_INLINE_VISIBILITY int iswpunct(wint_t __wc) {return __libcpp_iswpunct(__wc);}
-#else  // iswpunct
 using ::iswpunct;
-#endif
-
-#ifdef iswspace
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswspace(wint_t __wc) {return iswspace(__wc);}
-#undef iswspace
-inline _LIBCPP_INLINE_VISIBILITY int iswspace(wint_t __wc) {return __libcpp_iswspace(__wc);}
-#else  // iswspace
 using ::iswspace;
-#endif
-
-#ifdef iswupper
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswupper(wint_t __wc) {return iswupper(__wc);}
-#undef iswupper
-inline _LIBCPP_INLINE_VISIBILITY int iswupper(wint_t __wc) {return __libcpp_iswupper(__wc);}
-#else  // iswupper
 using ::iswupper;
-#endif
-
-#ifdef iswxdigit
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswxdigit(wint_t __wc) {return iswxdigit(__wc);}
-#undef iswxdigit
-inline _LIBCPP_INLINE_VISIBILITY int iswxdigit(wint_t __wc) {return __libcpp_iswxdigit(__wc);}
-#else  // iswxdigit
 using ::iswxdigit;
-#endif
-
-#ifdef iswctype
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswctype(wint_t __w, wctype_t __d) {return iswctype(__w, __d);}
-#undef iswctype
-inline _LIBCPP_INLINE_VISIBILITY int iswctype(wint_t __w, wctype_t __d) {return __libcpp_iswctype(__w, __d);}
-#else  // iswctype
 using ::iswctype;
-#endif
-
-#ifdef wctype
-inline _LIBCPP_INLINE_VISIBILITY wctype_t __libcpp_wctype(const char* __p) {return wctype(__p);}
-#undef wctype
-inline _LIBCPP_INLINE_VISIBILITY wctype_t wctype(const char* __p) {return __libcpp_wctype(__p);}
-#else  // wctype
 using ::wctype;
-#endif
-
-#ifdef towlower
-inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towlower(wint_t __wc) {return towlower(__wc);}
-#undef towlower
-inline _LIBCPP_INLINE_VISIBILITY wint_t towlower(wint_t __wc) {return __libcpp_towlower(__wc);}
-#else  // towlower
 using ::towlower;
-#endif
-
-#ifdef towupper
-inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towupper(wint_t __wc) {return towupper(__wc);}
-#undef towupper
-inline _LIBCPP_INLINE_VISIBILITY wint_t towupper(wint_t __wc) {return __libcpp_towupper(__wc);}
-#else  // towupper
 using ::towupper;
-#endif
-
-#ifdef towctrans
-inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towctrans(wint_t __wc, wctype_t __d) {return towctrans(__wc, __d);}
-#undef towctrans
-inline _LIBCPP_INLINE_VISIBILITY wint_t towctrans(wint_t __wc, wctype_t __d) {return __libcpp_towctrans(__wc, __d);}
-#else  // towctrans
 using ::towctrans;
-#endif
-
-#ifdef wctrans
-inline _LIBCPP_INLINE_VISIBILITY wctrans_t __libcpp_wctrans(const char* __p) {return wctrans(__p);}
-#undef wctrans
-inline _LIBCPP_INLINE_VISIBILITY wctrans_t wctrans(const char* __p) {return __libcpp_wctrans(__p);}
-#else  // wctrans
 using ::wctrans;
-#endif
 
 _LIBCPP_END_NAMESPACE_STD
 
diff --git a/system/include/libcxx/deque b/system/include/libcxx/deque
index 9b256b74d4f2c..c6fbd512a1c6e 100644
--- a/system/include/libcxx/deque
+++ b/system/include/libcxx/deque
@@ -117,15 +117,14 @@ public:
     iterator insert(const_iterator p, value_type&& v);
     iterator insert(const_iterator p, size_type n, const value_type& v);
     template <class InputIterator>
-        iterator insert (const_iterator p, InputIterator f, InputIterator l);
+        iterator insert(const_iterator p, InputIterator f, InputIterator l);
     iterator insert(const_iterator p, initializer_list<value_type> il);
     void pop_front();
     void pop_back();
     iterator erase(const_iterator p);
     iterator erase(const_iterator f, const_iterator l);
     void swap(deque& c)
-        noexcept(!allocator_type::propagate_on_container_swap::value ||
-                 __is_nothrow_swappable<allocator_type>::value);
+        noexcept(allocator_traits<allocator_type>::is_always_equal::value);  // C++17
     void clear() noexcept;
 };
 
@@ -168,6 +167,7 @@ template <class T, class Allocator>
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp, class _Allocator> class __deque_base;
+template <class _Tp, class _Allocator = allocator<_Tp> > class _LIBCPP_TYPE_VIS_ONLY deque;
 
 template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
           class _DiffType, _DiffType _BlockSize>
@@ -261,8 +261,21 @@ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
               __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
               __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
 
+template <class _ValueType, class _DiffType>
+struct __deque_block_size {
+  static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
+};
+
 template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
-          class _DiffType, _DiffType _BlockSize>
+          class _DiffType, _DiffType _BS =
+#ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+// Keep template parameter to avoid changing all template declarations thoughout
+// this file.
+                               0
+#else
+                               __deque_block_size<_ValueType, _DiffType>::value
+#endif
+          >
 class _LIBCPP_TYPE_VIS_ONLY __deque_iterator
 {
     typedef _MapPointer __map_iterator;
@@ -273,7 +286,7 @@ private:
     __map_iterator __m_iter_;
     pointer        __ptr_;
 
-    static const difference_type __block_size = _BlockSize;
+    static const difference_type __block_size;
 public:
     typedef _ValueType                  value_type;
     typedef random_access_iterator_tag  iterator_category;
@@ -287,7 +300,7 @@ public:
 
     template <class _Pp, class _Rp, class _MP>
     _LIBCPP_INLINE_VISIBILITY
-    __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, difference_type, __block_size>& __it,
+    __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, difference_type, _BS>& __it,
                 typename enable_if<is_convertible<_Pp, pointer>::value>::type* = 0) _NOEXCEPT
         : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {}
 
@@ -520,6 +533,12 @@ private:
                   __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
 };
 
+template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
+          class _DiffType, _DiffType _BlockSize>
+const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,
+                                 _DiffType, _BlockSize>::__block_size =
+    __deque_block_size<_ValueType, _DiffType>::value;
+
 // copy
 
 template <class _RAIter,
@@ -532,10 +551,11 @@ copy(_RAIter __f,
 {
     typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
     typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
+    const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size;
     while (__f != __l)
     {
         pointer __rb = __r.__ptr_;
-        pointer __re = *__r.__m_iter_ + _B2;
+        pointer __re = *__r.__m_iter_ + __block_size;
         difference_type __bs = __re - __rb;
         difference_type __n = __l - __f;
         _RAIter __m = __l;
@@ -560,11 +580,12 @@ copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
 {
     typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
     typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+    const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
     difference_type __n = __l - __f;
     while (__n > 0)
     {
         pointer __fb = __f.__ptr_;
-        pointer __fe = *__f.__m_iter_ + _B1;
+        pointer __fe = *__f.__m_iter_ + __block_size;
         difference_type __bs = __fe - __fb;
         if (__bs > __n)
         {
@@ -587,11 +608,12 @@ copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
 {
     typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
     typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+    const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
     difference_type __n = __l - __f;
     while (__n > 0)
     {
         pointer __fb = __f.__ptr_;
-        pointer __fe = *__f.__m_iter_ + _B1;
+        pointer __fe = *__f.__m_iter_ + __block_size;
         difference_type __bs = __fe - __fb;
         if (__bs > __n)
         {
@@ -705,10 +727,11 @@ move(_RAIter __f,
 {
     typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
     typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
+    const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size;
     while (__f != __l)
     {
         pointer __rb = __r.__ptr_;
-        pointer __re = *__r.__m_iter_ + _B2;
+        pointer __re = *__r.__m_iter_ + __block_size;
         difference_type __bs = __re - __rb;
         difference_type __n = __l - __f;
         _RAIter __m = __l;
@@ -733,11 +756,12 @@ move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
 {
     typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
     typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+    const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
     difference_type __n = __l - __f;
     while (__n > 0)
     {
         pointer __fb = __f.__ptr_;
-        pointer __fe = *__f.__m_iter_ + _B1;
+        pointer __fe = *__f.__m_iter_ + __block_size;
         difference_type __bs = __fe - __fb;
         if (__bs > __n)
         {
@@ -760,11 +784,12 @@ move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
 {
     typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
     typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
+    const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
     difference_type __n = __l - __f;
     while (__n > 0)
     {
         pointer __fb = __f.__ptr_;
-        pointer __fe = *__f.__m_iter_ + _B1;
+        pointer __fe = *__f.__m_iter_ + __block_size;
         difference_type __bs = __fe - __fb;
         if (__bs > __n)
         {
@@ -909,31 +934,19 @@ protected:
     typedef typename __alloc_traits::pointer         pointer;
     typedef typename __alloc_traits::const_pointer   const_pointer;
 
-    static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16;
+    static const difference_type __block_size;
 
-    typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<pointer>
-#else
-                rebind_alloc<pointer>::other
-#endif
-                                                         __pointer_allocator;
+    typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator;
     typedef allocator_traits<__pointer_allocator>        __map_traits;
     typedef typename __map_traits::pointer               __map_pointer;
-    typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<const_pointer>
-#else
-                rebind_alloc<const_pointer>::other
-#endif
-                                                         __const_pointer_allocator;
+    typedef typename __rebind_alloc_helper<__alloc_traits, const_pointer>::type __const_pointer_allocator;
     typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer;
     typedef __split_buffer<pointer, __pointer_allocator> __map;
 
     typedef __deque_iterator<value_type, pointer, reference, __map_pointer,
-                             difference_type, __block_size>    iterator;
+                             difference_type>    iterator;
     typedef __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer,
-                             difference_type, __block_size>    const_iterator;
+                             difference_type>    const_iterator;
 
     __map __map_;
     size_type __start_;
@@ -951,8 +964,10 @@ protected:
     _LIBCPP_INLINE_VISIBILITY
     const allocator_type& __alloc() const _NOEXCEPT {return __size_.second();}
 
+    _LIBCPP_INLINE_VISIBILITY
     __deque_base()
         _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+    _LIBCPP_INLINE_VISIBILITY
     explicit __deque_base(const allocator_type& __a);
 public:
     ~__deque_base();
@@ -965,8 +980,12 @@ public:
 
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     void swap(__deque_base& __c)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value);
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT;
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value);
+#endif
 protected:
     void clear() _NOEXCEPT;
 
@@ -1002,28 +1021,13 @@ private:
     _LIBCPP_INLINE_VISIBILITY
     void __move_assign_alloc(__deque_base&, false_type) _NOEXCEPT
         {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type& __x, allocator_type& __y)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value)
-        {__swap_alloc(__x, __y, integral_constant<bool,
-                      __alloc_traits::propagate_on_container_swap::value>());}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type)
-        _NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value)
-        {
-            using _VSTD::swap;
-            swap(__x, __y);
-        }
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type&, allocator_type&, false_type)
-        _NOEXCEPT
-        {}
 };
 
+template <class _Tp, class _Allocator>
+const typename __deque_base<_Tp, _Allocator>::difference_type
+    __deque_base<_Tp, _Allocator>::__block_size =
+        __deque_block_size<value_type, difference_type>::value;
+
 template <class _Tp, class _Allocator>
 bool
 __deque_base<_Tp, _Allocator>::__invariants() const
@@ -1088,13 +1092,13 @@ __deque_base<_Tp, _Allocator>::end() const _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __deque_base<_Tp, _Allocator>::__deque_base()
     _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
     : __start_(0), __size_(0) {}
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __deque_base<_Tp, _Allocator>::__deque_base(const allocator_type& __a)
     : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {}
 
@@ -1145,13 +1149,17 @@ __deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c, const allocator_
 template <class _Tp, class _Allocator>
 void
 __deque_base<_Tp, _Allocator>::swap(__deque_base& __c)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
-                   __is_nothrow_swappable<allocator_type>::value)
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value)
+#endif
 {
     __map_.swap(__c.__map_);
     _VSTD::swap(__start_, __c.__start_);
     _VSTD::swap(size(), __c.size());
-    __swap_alloc(__alloc(), __c.__alloc());
+    __swap_allocator(__alloc(), __c.__alloc());
 }
 
 template <class _Tp, class _Allocator>
@@ -1178,7 +1186,7 @@ __deque_base<_Tp, _Allocator>::clear() _NOEXCEPT
     }
 }
 
-template <class _Tp, class _Allocator = allocator<_Tp> >
+template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
 class _LIBCPP_TYPE_VIS_ONLY deque
     : private __deque_base<_Tp, _Allocator>
 {
@@ -1188,6 +1196,9 @@ public:
     typedef _Tp value_type;
     typedef _Allocator allocator_type;
 
+    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+                  "Allocator::value_type must be same type as value_type");
+
     typedef __deque_base<value_type, allocator_type> __base;
 
     typedef typename __base::__alloc_traits        __alloc_traits;
@@ -1235,8 +1246,11 @@ public:
 #endif   // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);
+    _LIBCPP_INLINE_VISIBILITY
     deque(deque&& __c, const allocator_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
     deque& operator=(deque&& __c)
         _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
                    is_nothrow_move_assignable<allocator_type>::value);
@@ -1255,6 +1269,7 @@ public:
     void assign(initializer_list<value_type> __il) {assign(__il.begin(), __il.end());}
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
+    _LIBCPP_INLINE_VISIBILITY
     allocator_type get_allocator() const _NOEXCEPT;
 
     // iterators:
@@ -1307,13 +1322,21 @@ public:
     bool empty() const _NOEXCEPT {return __base::size() == 0;}
 
     // element access:
+    _LIBCPP_INLINE_VISIBILITY
     reference operator[](size_type __i);
+    _LIBCPP_INLINE_VISIBILITY
     const_reference operator[](size_type __i) const;
+    _LIBCPP_INLINE_VISIBILITY
     reference at(size_type __i);
+    _LIBCPP_INLINE_VISIBILITY
     const_reference at(size_type __i) const;
+    _LIBCPP_INLINE_VISIBILITY
     reference front();
+    _LIBCPP_INLINE_VISIBILITY
     const_reference front() const;
+    _LIBCPP_INLINE_VISIBILITY
     reference back();
+    _LIBCPP_INLINE_VISIBILITY
     const_reference back() const;
 
     // 23.2.2.3 modifiers:
@@ -1332,11 +1355,15 @@ public:
     iterator insert(const_iterator __p, const value_type& __v);
     iterator insert(const_iterator __p, size_type __n, const value_type& __v);
     template <class _InputIter>
-        iterator insert (const_iterator __p, _InputIter __f, _InputIter __l,
+        iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
                          typename enable_if<__is_input_iterator<_InputIter>::value
-                                         &&!__is_bidirectional_iterator<_InputIter>::value>::type* = 0);
+                                         &&!__is_forward_iterator<_InputIter>::value>::type* = 0);
+    template <class _ForwardIterator>
+        iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
+                               typename enable_if<__is_forward_iterator<_ForwardIterator>::value
+                                         &&!__is_bidirectional_iterator<_ForwardIterator>::value>::type* = 0);
     template <class _BiIter>
-        iterator insert (const_iterator __p, _BiIter __f, _BiIter __l,
+        iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
                          typename enable_if<__is_bidirectional_iterator<_BiIter>::value>::type* = 0);
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     _LIBCPP_INLINE_VISIBILITY
@@ -1348,9 +1375,15 @@ public:
     iterator erase(const_iterator __p);
     iterator erase(const_iterator __f, const_iterator __l);
 
+    _LIBCPP_INLINE_VISIBILITY
     void swap(deque& __c)
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT;
+#else
         _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
                    __is_nothrow_swappable<allocator_type>::value);
+#endif
+    _LIBCPP_INLINE_VISIBILITY
     void clear() _NOEXCEPT;
 
     _LIBCPP_INLINE_VISIBILITY
@@ -1523,7 +1556,7 @@ deque<_Tp, _Allocator>::operator=(const deque& __c)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 deque<_Tp, _Allocator>::deque(deque&& __c)
     _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
     : __base(_VSTD::move(__c))
@@ -1531,7 +1564,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c)
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a)
     : __base(_VSTD::move(__c), __a)
 {
@@ -1543,7 +1576,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a)
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 deque<_Tp, _Allocator>&
 deque<_Tp, _Allocator>::operator=(deque&& __c)
         _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
@@ -1588,7 +1621,7 @@ deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,
 {
     iterator __i = __base::begin();
     iterator __e = __base::end();
-    for (; __f != __l && __i != __e; ++__f, ++__i)
+    for (; __f != __l && __i != __e; ++__f, (void) ++__i)
         *__i = *__f;
     if (__f != __l)
         __append(__f, __l);
@@ -1627,7 +1660,7 @@ deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v)
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _Allocator
 deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT
 {
@@ -1686,7 +1719,7 @@ deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename deque<_Tp, _Allocator>::reference
 deque<_Tp, _Allocator>::operator[](size_type __i)
 {
@@ -1695,7 +1728,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i)
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename deque<_Tp, _Allocator>::const_reference
 deque<_Tp, _Allocator>::operator[](size_type __i) const
 {
@@ -1704,7 +1737,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i) const
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename deque<_Tp, _Allocator>::reference
 deque<_Tp, _Allocator>::at(size_type __i)
 {
@@ -1715,7 +1748,7 @@ deque<_Tp, _Allocator>::at(size_type __i)
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename deque<_Tp, _Allocator>::const_reference
 deque<_Tp, _Allocator>::at(size_type __i) const
 {
@@ -1726,7 +1759,7 @@ deque<_Tp, _Allocator>::at(size_type __i) const
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename deque<_Tp, _Allocator>::reference
 deque<_Tp, _Allocator>::front()
 {
@@ -1735,7 +1768,7 @@ deque<_Tp, _Allocator>::front()
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename deque<_Tp, _Allocator>::const_reference
 deque<_Tp, _Allocator>::front() const
 {
@@ -1744,7 +1777,7 @@ deque<_Tp, _Allocator>::front() const
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename deque<_Tp, _Allocator>::reference
 deque<_Tp, _Allocator>::back()
 {
@@ -1753,7 +1786,7 @@ deque<_Tp, _Allocator>::back()
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename deque<_Tp, _Allocator>::const_reference
 deque<_Tp, _Allocator>::back() const
 {
@@ -2045,7 +2078,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
         if (__n > __front_spare())
             __add_front_capacity(__n - __front_spare());
         // __n <= __front_spare()
-        size_type __old_n = __n;
         iterator __old_begin = __base::begin();
         iterator __i = __old_begin;
         if (__n > __pos)
@@ -2070,7 +2102,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
         if (__n > __back_capacity)
             __add_back_capacity(__n - __back_capacity);
         // __n <= __back_capacity
-        size_type __old_n = __n;
         iterator __old_end = __base::end();
         iterator __i = __old_end;
         size_type __de = __base::size() - __pos;
@@ -2098,7 +2129,7 @@ template <class _InputIter>
 typename deque<_Tp, _Allocator>::iterator
 deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,
                                typename enable_if<__is_input_iterator<_InputIter>::value
-                                               &&!__is_bidirectional_iterator<_InputIter>::value>::type*)
+                                               &&!__is_forward_iterator<_InputIter>::value>::type*)
 {
     __split_buffer<value_type, allocator_type&> __buf(__base::__alloc());
     __buf.__construct_at_end(__f, __l);
@@ -2106,6 +2137,20 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __
     return insert(__p, move_iterator<__bi>(__buf.begin()), move_iterator<__bi>(__buf.end()));
 }
 
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
+                               typename enable_if<__is_forward_iterator<_ForwardIterator>::value
+                                               &&!__is_bidirectional_iterator<_ForwardIterator>::value>::type*)
+{
+    size_type __n = _VSTD::distance(__f, __l);
+    __split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc());
+    __buf.__construct_at_end(__f, __l);
+    typedef typename __split_buffer<value_type, allocator_type&>::iterator __fwd;
+    return insert(__p, move_iterator<__fwd>(__buf.begin()), move_iterator<__fwd>(__buf.end()));
+}
+
 template <class _Tp, class _Allocator>
 template <class _BiIter>
 typename deque<_Tp, _Allocator>::iterator
@@ -2121,7 +2166,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
         if (__n > __front_spare())
             __add_front_capacity(__n - __front_spare());
         // __n <= __front_spare()
-        size_type __old_n = __n;
         iterator __old_begin = __base::begin();
         iterator __i = __old_begin;
         _BiIter __m = __f;
@@ -2152,7 +2196,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
         if (__n > __back_capacity)
             __add_back_capacity(__n - __back_capacity);
         // __n <= __back_capacity
-        size_type __old_n = __n;
         iterator __old_end = __base::end();
         iterator __i = __old_end;
         _BiIter __m = __l;
@@ -2160,7 +2203,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
         if (__n > __de)
         {
             __m = __de < __n / 2 ? _VSTD::next(__f, __de) : _VSTD::prev(__l, __n - __de);
-            for (_BiIter __j = __m; __j != __l; ++__i, ++__j, ++__base::size())
+            for (_BiIter __j = __m; __j != __l; ++__i, (void) ++__j, ++__base::size())
                 __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__j);
             __n = __de;
         }
@@ -2200,7 +2243,7 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
     if (__n > __back_capacity)
         __add_back_capacity(__n - __back_capacity);
     // __n <= __back_capacity
-    for (iterator __i = __base::end(); __f != __l; ++__i, ++__f, ++__base::size())
+    for (iterator __i = __base::end(); __f != __l; ++__i, (void) ++__f, ++__base::size())
         __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__f);
 }
 
@@ -2269,19 +2312,14 @@ deque<_Tp, _Allocator>::__add_front_capacity()
         __split_buffer<pointer, typename __base::__pointer_allocator&>
             __buf(max<size_type>(2 * __base::__map_.capacity(), 1),
                   0, __base::__map_.__alloc());
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        try
-        {
-#endif  // _LIBCPP_NO_EXCEPTIONS
-            __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        }
-        catch (...)
-        {
-            __alloc_traits::deallocate(__a, __buf.front(), __base::__block_size);
-            throw;
-        }
-#endif  // _LIBCPP_NO_EXCEPTIONS
+
+        typedef __allocator_destructor<_Allocator> _Dp;
+        unique_ptr<pointer, _Dp> __hold(
+            __alloc_traits::allocate(__a, __base::__block_size),
+                _Dp(__a, __base::__block_size));
+        __buf.push_back(__hold.get());
+        __hold.release();
+    
         for (typename __base::__map_pointer __i = __base::__map_.begin();
                 __i != __base::__map_.end(); ++__i)
             __buf.push_back(*__i);
@@ -2417,19 +2455,14 @@ deque<_Tp, _Allocator>::__add_back_capacity()
             __buf(max<size_type>(2* __base::__map_.capacity(), 1),
                   __base::__map_.size(),
                   __base::__map_.__alloc());
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        try
-        {
-#endif  // _LIBCPP_NO_EXCEPTIONS
-            __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        }
-        catch (...)
-        {
-            __alloc_traits::deallocate(__a, __buf.back(), __base::__block_size);
-            throw;
-        }
-#endif  // _LIBCPP_NO_EXCEPTIONS
+
+        typedef __allocator_destructor<_Allocator> _Dp;
+        unique_ptr<pointer, _Dp> __hold(
+            __alloc_traits::allocate(__a, __base::__block_size),
+                _Dp(__a, __base::__block_size));
+        __buf.push_back(__hold.get());
+        __hold.release();
+
         for (typename __base::__map_pointer __i = __base::__map_.end();
                 __i != __base::__map_.begin();)
             __buf.push_front(*--__i);
@@ -2697,12 +2730,11 @@ template <class _Tp, class _Allocator>
 typename deque<_Tp, _Allocator>::iterator
 deque<_Tp, _Allocator>::erase(const_iterator __f)
 {
-    difference_type __n = 1;
     iterator __b = __base::begin();
     difference_type __pos = __f - __b;
     iterator __p = __b + __pos;
     allocator_type& __a = __base::__alloc();
-    if (__pos < (__base::size() - 1) / 2)
+    if (__pos <= (__base::size() - 1) / 2)
     {   // erase from front
         _VSTD::move_backward(__b, __p, _VSTD::next(__p));
         __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
@@ -2740,7 +2772,7 @@ deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
     if (__n > 0)
     {
         allocator_type& __a = __base::__alloc();
-        if (__pos < (__base::size() - __n) / 2)
+        if (__pos <= (__base::size() - __n) / 2)
         {   // erase from front
             iterator __i = _VSTD::move_backward(__b, __p, __p + __n);
             for (; __b != __i; ++__b)
@@ -2793,17 +2825,21 @@ deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f)
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 deque<_Tp, _Allocator>::swap(deque& __c)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value)
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value)
+#endif
 {
     __base::swap(__c);
 }
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 deque<_Tp, _Allocator>::clear() _NOEXCEPT
 {
diff --git a/system/include/libcxx/errno.h b/system/include/libcxx/errno.h
new file mode 100644
index 0000000000000..ee6429110cc12
--- /dev/null
+++ b/system/include/libcxx/errno.h
@@ -0,0 +1,398 @@
+// -*- C++ -*-
+//===-------------------------- errno.h -----------------------------------===//
+//
+//                     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_ERRNO_H
+#define _LIBCPP_ERRNO_H
+
+/*
+    errno.h synopsis
+
+Macros:
+
+    EDOM
+    EILSEQ  // C99
+    ERANGE
+    errno
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <errno.h>
+
+#ifdef __cplusplus
+
+#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
+
+#ifdef ELAST
+
+static const int __elast1 = ELAST+1;
+static const int __elast2 = ELAST+2;
+
+#else
+
+static const int __elast1 = 104;
+static const int __elast2 = 105;
+
+#endif
+
+#ifdef ENOTRECOVERABLE
+
+#define EOWNERDEAD __elast1
+
+#ifdef ELAST
+#undef ELAST
+#define ELAST EOWNERDEAD
+#endif
+
+#elif defined(EOWNERDEAD)
+
+#define ENOTRECOVERABLE __elast1
+#ifdef ELAST
+#undef ELAST
+#define ELAST ENOTRECOVERABLE
+#endif
+
+#else  // defined(EOWNERDEAD)
+
+#define EOWNERDEAD __elast1
+#define ENOTRECOVERABLE __elast2
+#ifdef ELAST
+#undef ELAST
+#define ELAST ENOTRECOVERABLE
+#endif
+
+#endif  // defined(EOWNERDEAD)
+
+#endif  // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
+
+//  supply errno values likely to be missing, particularly on Windows
+
+#ifndef EAFNOSUPPORT
+#define EAFNOSUPPORT 9901
+#endif
+
+#ifndef EADDRINUSE
+#define EADDRINUSE 9902
+#endif
+
+#ifndef EADDRNOTAVAIL
+#define EADDRNOTAVAIL 9903
+#endif
+
+#ifndef EISCONN
+#define EISCONN 9904
+#endif
+
+#ifndef EBADMSG
+#define EBADMSG 9905
+#endif
+
+#ifndef ECONNABORTED
+#define ECONNABORTED 9906
+#endif
+
+#ifndef EALREADY
+#define EALREADY 9907
+#endif
+
+#ifndef ECONNREFUSED
+#define ECONNREFUSED 9908
+#endif
+
+#ifndef ECONNRESET
+#define ECONNRESET 9909
+#endif
+
+#ifndef EDESTADDRREQ
+#define EDESTADDRREQ 9910
+#endif
+
+#ifndef EHOSTUNREACH
+#define EHOSTUNREACH 9911
+#endif
+
+#ifndef EIDRM
+#define EIDRM 9912
+#endif
+
+#ifndef EMSGSIZE
+#define EMSGSIZE 9913
+#endif
+
+#ifndef ENETDOWN
+#define ENETDOWN 9914
+#endif
+
+#ifndef ENETRESET
+#define ENETRESET 9915
+#endif
+
+#ifndef ENETUNREACH
+#define ENETUNREACH 9916
+#endif
+
+#ifndef ENOBUFS
+#define ENOBUFS 9917
+#endif
+
+#ifndef ENOLINK
+#define ENOLINK 9918
+#endif
+
+#ifndef ENODATA
+#define ENODATA 9919
+#endif
+
+#ifndef ENOMSG
+#define ENOMSG 9920
+#endif
+
+#ifndef ENOPROTOOPT
+#define ENOPROTOOPT 9921
+#endif
+
+#ifndef ENOSR
+#define ENOSR 9922
+#endif
+
+#ifndef ENOTSOCK
+#define ENOTSOCK 9923
+#endif
+
+#ifndef ENOSTR
+#define ENOSTR 9924
+#endif
+
+#ifndef ENOTCONN
+#define ENOTCONN 9925
+#endif
+
+#ifndef ENOTSUP
+#define ENOTSUP 9926
+#endif
+
+#ifndef ECANCELED
+#define ECANCELED 9927
+#endif
+
+#ifndef EINPROGRESS
+#define EINPROGRESS 9928
+#endif
+
+#ifndef EOPNOTSUPP
+#define EOPNOTSUPP 9929
+#endif
+
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK 9930
+#endif
+
+#ifndef EOWNERDEAD
+#define EOWNERDEAD  9931
+#endif
+
+#ifndef EPROTO
+#define EPROTO 9932
+#endif
+
+#ifndef EPROTONOSUPPORT
+#define EPROTONOSUPPORT 9933
+#endif
+
+#ifndef ENOTRECOVERABLE
+#define ENOTRECOVERABLE 9934
+#endif
+
+#ifndef ETIME
+#define ETIME 9935
+#endif
+
+#ifndef ETXTBSY
+#define ETXTBSY 9936
+#endif
+
+#ifndef ETIMEDOUT
+#define ETIMEDOUT 9938
+#endif
+
+#ifndef ELOOP
+#define ELOOP 9939
+#endif
+
+#ifndef EOVERFLOW
+#define EOVERFLOW 9940
+#endif
+
+#ifndef EPROTOTYPE
+#define EPROTOTYPE 9941
+#endif
+
+#ifndef ENOSYS
+#define ENOSYS 9942
+#endif
+
+#ifndef EINVAL
+#define EINVAL 9943
+#endif
+
+#ifndef ERANGE
+#define ERANGE 9944
+#endif
+
+#ifndef EILSEQ
+#define EILSEQ 9945
+#endif
+
+//  Windows Mobile doesn't appear to define these:
+
+#ifndef E2BIG
+#define E2BIG 9946
+#endif
+
+#ifndef EDOM
+#define EDOM 9947
+#endif
+
+#ifndef EFAULT
+#define EFAULT 9948
+#endif
+
+#ifndef EBADF
+#define EBADF 9949
+#endif
+
+#ifndef EPIPE
+#define EPIPE 9950
+#endif
+
+#ifndef EXDEV
+#define EXDEV 9951
+#endif
+
+#ifndef EBUSY
+#define EBUSY 9952
+#endif
+
+#ifndef ENOTEMPTY
+#define ENOTEMPTY 9953
+#endif
+
+#ifndef ENOEXEC
+#define ENOEXEC 9954
+#endif
+
+#ifndef EEXIST
+#define EEXIST 9955
+#endif
+
+#ifndef EFBIG
+#define EFBIG 9956
+#endif
+
+#ifndef ENAMETOOLONG
+#define ENAMETOOLONG 9957
+#endif
+
+#ifndef ENOTTY
+#define ENOTTY 9958
+#endif
+
+#ifndef EINTR
+#define EINTR 9959
+#endif
+
+#ifndef ESPIPE
+#define ESPIPE 9960
+#endif
+
+#ifndef EIO
+#define EIO 9961
+#endif
+
+#ifndef EISDIR
+#define EISDIR 9962
+#endif
+
+#ifndef ECHILD
+#define ECHILD 9963
+#endif
+
+#ifndef ENOLCK
+#define ENOLCK 9964
+#endif
+
+#ifndef ENOSPC
+#define ENOSPC 9965
+#endif
+
+#ifndef ENXIO
+#define ENXIO 9966
+#endif
+
+#ifndef ENODEV
+#define ENODEV 9967
+#endif
+
+#ifndef ENOENT
+#define ENOENT 9968
+#endif
+
+#ifndef ESRCH
+#define ESRCH 9969
+#endif
+
+#ifndef ENOTDIR
+#define ENOTDIR 9970
+#endif
+
+#ifndef ENOMEM
+#define ENOMEM 9971
+#endif
+
+#ifndef EPERM
+#define EPERM 9972
+#endif
+
+#ifndef EACCES
+#define EACCES 9973
+#endif
+
+#ifndef EROFS
+#define EROFS 9974
+#endif
+
+#ifndef EDEADLK
+#define EDEADLK 9975
+#endif
+
+#ifndef EAGAIN
+#define EAGAIN 9976
+#endif
+
+#ifndef ENFILE
+#define ENFILE 9977
+#endif
+
+#ifndef EMFILE
+#define EMFILE 9978
+#endif
+
+#ifndef EMLINK
+#define EMLINK 9979
+#endif
+
+#endif // __cplusplus
+
+#endif  // _LIBCPP_ERRNO_H
diff --git a/system/include/libcxx/exception b/system/include/libcxx/exception
index cad802e056a5f..686e4ecd05783 100644
--- a/system/include/libcxx/exception
+++ b/system/include/libcxx/exception
@@ -48,7 +48,8 @@ terminate_handler set_terminate(terminate_handler  f ) noexcept;
 terminate_handler get_terminate() noexcept;
 [[noreturn]] void terminate() noexcept;
 
-bool uncaught_exception() noexcept;
+bool uncaught_exception()  noexcept;
+int  uncaught_exceptions() noexcept;  // C++17
 
 typedef unspecified exception_ptr;
 
@@ -115,6 +116,7 @@ _LIBCPP_FUNC_VIS terminate_handler get_terminate() _NOEXCEPT;
 _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void terminate() _NOEXCEPT;
 
 _LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT;
+_LIBCPP_FUNC_VIS int uncaught_exceptions() _NOEXCEPT;
 
 class _LIBCPP_TYPE_VIS exception_ptr;
 
@@ -193,6 +195,7 @@ void
 throw_with_nested(_Tp&& __t, typename enable_if<
                   is_class<typename remove_reference<_Tp>::type>::value &&
                   !is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
+                  && !__libcpp_is_final<typename remove_reference<_Tp>::type>::value
                                     >::type* = 0)
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 throw_with_nested (_Tp& __t, typename enable_if<
@@ -212,6 +215,7 @@ void
 throw_with_nested(_Tp&& __t, typename enable_if<
                   !is_class<typename remove_reference<_Tp>::type>::value ||
                   is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
+                  || __libcpp_is_final<typename remove_reference<_Tp>::type>::value
                                     >::type* = 0)
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 throw_with_nested (_Tp& __t, typename enable_if<
@@ -231,7 +235,7 @@ rethrow_if_nested(const _Ep& __e, typename enable_if<
                                    is_polymorphic<_Ep>::value
                                                    >::type* = 0)
 {
-    const nested_exception* __nep = dynamic_cast<const nested_exception*>(&__e);
+    const nested_exception* __nep = dynamic_cast<const nested_exception*>(_VSTD::addressof(__e));
     if (__nep)
         __nep->rethrow_nested();
 }
diff --git a/system/include/libcxx/experimental/__config b/system/include/libcxx/experimental/__config
index 684a3b4d83d86..f64a3a90cd125 100644
--- a/system/include/libcxx/experimental/__config
+++ b/system/include/libcxx/experimental/__config
@@ -13,6 +13,10 @@
 
 #include <__config>
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
 #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL  } }
 #define _VSTD_EXPERIMENTAL std::experimental
@@ -21,4 +25,8 @@
 #define _LIBCPP_END_NAMESPACE_LFTS  } } }
 #define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
 
+#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD        \
+  namespace chrono { namespace experimental { inline namespace fundamentals_v1 {
+#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }
+
 #endif
diff --git a/system/include/libcxx/experimental/algorithm b/system/include/libcxx/experimental/algorithm
new file mode 100644
index 0000000000000..3902111c54ea3
--- /dev/null
+++ b/system/include/libcxx/experimental/algorithm
@@ -0,0 +1,120 @@
+// -*- C++ -*-
+//===-------------------------- algorithm ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_ALGORITHM
+#define _LIBCPP_EXPERIMENTAL_ALGORITHM
+
+/*
+   experimental/algorithm synopsis
+
+#include <algorithm>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+template <class ForwardIterator, class Searcher>
+ForwardIterator search(ForwardIterator first, ForwardIterator last,
+                       const Searcher &searcher);
+template <class PopulationIterator, class SampleIterator, class Distance,
+          class UniformRandomNumberGenerator>
+SampleIterator sample(PopulationIterator first, PopulationIterator last,
+                      SampleIterator out, Distance n,
+                      UniformRandomNumberGenerator &&g);
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+#include <algorithm>
+#include <type_traits>
+
+#include <__undef_min_max>
+
+#include <__debug>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+
+template <class _ForwardIterator, class _Searcher>
+_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>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator __sample(_PopulationIterator __first,
+                         _PopulationIterator __last, _SampleIterator __out,
+                         _Distance __n,
+                         _UniformRandomNumberGenerator &&__g,
+                         input_iterator_tag) {
+
+  _Distance __k = 0;
+  for (; __first != __last && __k < __n; ++__first, (void)++__k)
+    __out[__k] = *__first;
+  _Distance __sz = __k;
+  for (; __first != __last; ++__first, (void)++__k) {
+    _Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
+    if (__r < __sz)
+      __out[__r] = *__first;
+  }
+  return __out + _VSTD::min(__n, __k);
+}
+
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+          class _UniformRandomNumberGenerator>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator __sample(_PopulationIterator __first,
+                         _PopulationIterator __last, _SampleIterator __out,
+                         _Distance __n,
+                         _UniformRandomNumberGenerator &&__g,
+                         forward_iterator_tag) {
+  _Distance __unsampled_sz = _VSTD::distance(__first, __last);
+  for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
+    _Distance __r =
+        _VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
+    if (__r < __n) {
+      *__out++ = *__first;
+      --__n;
+    }
+  }
+  return __out;
+}
+
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+          class _UniformRandomNumberGenerator>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator sample(_PopulationIterator __first,
+                         _PopulationIterator __last, _SampleIterator __out,
+                         _Distance __n, _UniformRandomNumberGenerator &&__g) {
+  typedef typename iterator_traits<_PopulationIterator>::iterator_category
+        _PopCategory;
+  typedef typename iterator_traits<_PopulationIterator>::difference_type
+        _Difference;
+  typedef typename common_type<_Distance, _Difference>::type _CommonType;
+  _LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
+  return _VSTD_LFTS::__sample(
+      __first, __last, __out, _CommonType(__n),
+      _VSTD::forward<_UniformRandomNumberGenerator>(__g),
+      _PopCategory());
+}
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */
diff --git a/system/include/libcxx/experimental/any b/system/include/libcxx/experimental/any
new file mode 100644
index 0000000000000..4c732496c52b4
--- /dev/null
+++ b/system/include/libcxx/experimental/any
@@ -0,0 +1,592 @@
+// -*- C++ -*-
+//===------------------------------ any -----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#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>
+#include <cassert>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast
+{
+public:
+    virtual const char* what() const _NOEXCEPT;
+};
+
+#if _LIBCPP_STD_VER > 11                                            // C++ > 11
+
+_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY
+inline void __throw_bad_any_cast()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw bad_any_cast();
+#else
+    assert(!"bad_any_cast");
+#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_TYPE_VIS_ONLY _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_TYPE_VIS_ONLY _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
+_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
+_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
+_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
diff --git a/system/include/libcxx/experimental/chrono b/system/include/libcxx/experimental/chrono
new file mode 100644
index 0000000000000..ca9e5f852ea21
--- /dev/null
+++ b/system/include/libcxx/experimental/chrono
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+//===------------------------------ chrono ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
+#define _LIBCPP_EXPERIMENTAL_CHRONO
+
+/**
+    experimental/chrono synopsis
+
+// C++1y
+
+#include <chrono>
+
+namespace std {
+namespace chrono {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+  // See C++14 20.12.4, customization traits
+  template <class Rep> constexpr bool treat_as_floating_point_v
+    = treat_as_floating_point<Rep>::value;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace chrono
+} // namespace std
+
+ */
+
+#include <experimental/__config>
+#include <chrono>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 11
+
+_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+
+template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
+    = treat_as_floating_point<_Rep>::value;
+
+#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
+
+_LIBCPP_END_NAMESPACE_CHRONO_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_CHRONO */
diff --git a/system/include/libcxx/experimental/dynarray b/system/include/libcxx/experimental/dynarray
index 0bc8dfe2cb7ba..4a06908e11b16 100644
--- a/system/include/libcxx/experimental/dynarray
+++ b/system/include/libcxx/experimental/dynarray
@@ -104,6 +104,8 @@ public:
 #include <new>
 #include <algorithm>
 
+#include <__undef___deallocate>
+
 #if defined(_LIBCPP_NO_EXCEPTIONS)
     #include <cassert>
 #endif
@@ -135,7 +137,7 @@ public:
 private:
     size_t                  __size_;
     value_type *            __base_;
-    _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __base_(nullptr), __size_(0) {}
+    _LIBCPP_ALWAYS_INLINE dynarray () noexcept :  __size_(0), __base_(nullptr) {}
     
     static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
     {
@@ -157,9 +159,13 @@ private:
 
 public:
 
+    _LIBCPP_INLINE_VISIBILITY
     explicit dynarray(size_type __c);
+    _LIBCPP_INLINE_VISIBILITY
     dynarray(size_type __c, const value_type& __v);
+    _LIBCPP_INLINE_VISIBILITY
     dynarray(const dynarray& __d);
+    _LIBCPP_INLINE_VISIBILITY
     dynarray(initializer_list<value_type>);
 
 //  We're not implementing these right now.
@@ -174,6 +180,7 @@ public:
 //       dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list<value_type>);
 
     dynarray& operator=(const dynarray&) = delete;
+    _LIBCPP_INLINE_VISIBILITY
     ~dynarray();
 
     // iterators:
@@ -217,7 +224,7 @@ public:
 };
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 dynarray<_Tp>::dynarray(size_type __c) : dynarray ()
 {
     __base_ = __allocate (__c);
@@ -227,7 +234,7 @@ dynarray<_Tp>::dynarray(size_type __c) : dynarray ()
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray ()
 {
     __base_ = __allocate (__c);
@@ -237,7 +244,7 @@ dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray ()
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray ()
 {
     size_t sz = __il.size();
@@ -249,7 +256,7 @@ dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray ()
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray ()
 {
     size_t sz = __d.size();
@@ -261,7 +268,7 @@ dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray ()
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 dynarray<_Tp>::~dynarray()
 { 
     value_type *__data = data () + __size_;
diff --git a/system/include/libcxx/experimental/functional b/system/include/libcxx/experimental/functional
new file mode 100644
index 0000000000000..75fc8e99f3529
--- /dev/null
+++ b/system/include/libcxx/experimental/functional
@@ -0,0 +1,459 @@
+// -*- C++ -*-
+//===-------------------------- functional --------------------------------===//
+//
+//                     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_FUNCTIONAL
+#define _LIBCPP_EXPERIMENTAL_FUNCTIONAL
+
+/*
+   experimental/functional synopsis
+
+#include <algorithm>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+    // See C++14 20.9.9, Function object binders
+    template <class T> constexpr bool is_bind_expression_v
+      = is_bind_expression<T>::value;
+    template <class T> constexpr int is_placeholder_v
+      = is_placeholder<T>::value;
+
+    // 4.2, Class template function
+    template<class> class function; // undefined
+    template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
+
+    template<class R, class... ArgTypes>
+    void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
+
+    template<class R, class... ArgTypes>
+    bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
+    template<class R, class... ArgTypes>
+    bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
+    template<class R, class... ArgTypes>
+    bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
+    template<class R, class... ArgTypes>
+    bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
+
+    // 4.3, Searchers
+    template<class ForwardIterator, class BinaryPredicate = equal_to<>>
+      class default_searcher;
+
+    template<class RandomAccessIterator,
+             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
+             class BinaryPredicate = equal_to<>>
+      class boyer_moore_searcher;
+
+    template<class RandomAccessIterator,
+             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
+             class BinaryPredicate = equal_to<>>
+      class boyer_moore_horspool_searcher;
+
+    template<class ForwardIterator, class BinaryPredicate = equal_to<>>
+    default_searcher<ForwardIterator, BinaryPredicate>
+    make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last,
+                          BinaryPredicate pred = BinaryPredicate());
+
+    template<class RandomAccessIterator,
+             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
+             class BinaryPredicate = equal_to<>>
+    boyer_moore_searcher<RandomAccessIterator, Hash, BinaryPredicate>
+    make_boyer_moore_searcher(
+        RandomAccessIterator pat_first, RandomAccessIterator pat_last,
+        Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
+
+    template<class RandomAccessIterator,
+             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
+             class BinaryPredicate = equal_to<>>
+    boyer_moore_horspool_searcher<RandomAccessIterator, Hash, BinaryPredicate>
+    make_boyer_moore_horspool_searcher(
+        RandomAccessIterator pat_first, RandomAccessIterator pat_last,
+        Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
+
+  } // namespace fundamentals_v1
+  } // namespace experimental
+
+  template<class R, class... ArgTypes, class Alloc>
+  struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>;
+
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+#include <functional>
+
+#include <algorithm>
+#include <type_traits>
+#include <vector>
+#include <array>
+#include <unordered_map>
+
+#include <__undef_min_max>
+
+#include <__debug>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#if _LIBCPP_STD_VER > 11
+// default searcher
+template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
+_LIBCPP_TYPE_VIS
+class default_searcher {
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    default_searcher(_ForwardIterator __f, _ForwardIterator __l, 
+                       _BinaryPredicate __p = _BinaryPredicate())
+        : __first_(__f), __last_(__l), __pred_(__p) {}
+
+    template <typename _ForwardIterator2>
+    _LIBCPP_INLINE_VISIBILITY
+    pair<_ForwardIterator2, _ForwardIterator2>
+    operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
+    {
+        return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
+            typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(),
+            typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category());
+    }
+
+private:
+    _ForwardIterator __first_;
+    _ForwardIterator __last_;
+    _BinaryPredicate __pred_;
+    };
+
+template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
+_LIBCPP_INLINE_VISIBILITY
+default_searcher<_ForwardIterator, _BinaryPredicate>
+make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())
+{
+    return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p);
+}
+
+template<class _Key, class _Value, class _Hash, class _BinaryPredicate, bool /*useArray*/> class _BMSkipTable;
+
+//  General case for BM data searching; use a map
+template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>
+class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
+public: // TODO private:
+    typedef _Value value_type;
+    typedef _Key   key_type;
+
+    const _Value __default_value_;
+    std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table;
+    
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    _BMSkipTable(std::size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)
+        : __default_value_(__default), __table(__sz, __hf, __pred) {}
+    
+    _LIBCPP_INLINE_VISIBILITY
+    void insert(const key_type &__key, value_type __val)
+    {
+        __table [__key] = __val;    // Would skip_.insert (val) be better here?
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type operator [](const key_type & __key) const
+    {
+        auto __it = __table.find (__key);
+        return __it == __table.end() ? __default_value_ : __it->second;
+    }
+};
+    
+
+//  Special case small numeric values; use an array
+template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>
+class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> {
+private:
+    typedef _Value value_type;
+    typedef _Key   key_type;
+
+    typedef typename std::make_unsigned<key_type>::type unsigned_key_type;
+    typedef std::array<value_type, _VSTD::numeric_limits<unsigned_key_type>::max()> skip_map;
+    skip_map __table;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    _BMSkipTable(std::size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/)
+    {
+        std::fill_n(__table.begin(), __table.size(), __default);
+    }
+    
+    _LIBCPP_INLINE_VISIBILITY
+    void insert(key_type __key, value_type __val)
+    {
+        __table[static_cast<unsigned_key_type>(__key)] = __val;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type operator [](key_type __key) const
+    {
+        return __table[static_cast<unsigned_key_type>(__key)];
+    }
+};
+
+
+template <class _RandomAccessIterator1, 
+          class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, 
+          class _BinaryPredicate = equal_to<>>
+_LIBCPP_TYPE_VIS
+class boyer_moore_searcher {
+private:
+    typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
+    typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type      value_type;
+    typedef _BMSkipTable<value_type, difference_type, _Hash, _BinaryPredicate,
+                    _VSTD::is_integral<value_type>::value && // what about enums?
+                    sizeof(value_type) == 1 &&
+                    is_same<_Hash, hash<value_type>>::value &&
+                    is_same<_BinaryPredicate, equal_to<>>::value
+            > skip_table_type;
+    
+public:
+    boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, 
+                _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
+            : __first_(__f), __last_(__l), __pred_(__pred),
+              __pattern_length_(_VSTD::distance(__first_, __last_)),
+              __skip_{make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)},
+              __suffix_{make_shared<vector<difference_type>>(__pattern_length_ + 1)}
+        {
+    //  build the skip table
+        for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i )
+            __skip_->insert(*__f, __i);
+
+        this->__build_suffix_table ( __first_, __last_, __pred_ );
+        }
+        
+    template <typename _RandomAccessIterator2>
+    pair<_RandomAccessIterator2, _RandomAccessIterator2>
+    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
+                    >::value,
+                "Corpus and Pattern iterators must point to the same type" );
+
+        if (__f      == __l )    return make_pair(__l, __l); // empty corpus
+        if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
+
+    //  If the pattern is larger than the corpus, we can't find it!
+        if ( __pattern_length_ > _VSTD::distance (__f, __l)) 
+            return make_pair(__l, __l);
+
+    //  Do the search 
+        return this->__search(__f, __l);
+    }
+        
+public: // TODO private:
+    _RandomAccessIterator1               __first_;
+    _RandomAccessIterator1               __last_;
+    _BinaryPredicate                     __pred_;
+    difference_type                      __pattern_length_;
+    shared_ptr<skip_table_type>          __skip_;
+    shared_ptr<vector<difference_type>>  __suffix_;
+
+    template <typename _RandomAccessIterator2>
+    pair<_RandomAccessIterator2, _RandomAccessIterator2>
+    __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
+    {
+        _RandomAccessIterator2 __cur = __f;
+        const _RandomAccessIterator2 __last = __l - __pattern_length_;
+        const skip_table_type &         __skip   = *__skip_.get();
+        const vector<difference_type> & __suffix = *__suffix_.get();
+        
+        while (__cur <= __last)
+        {
+
+        //  Do we match right where we are?
+            difference_type __j = __pattern_length_;
+            while (__pred_(__first_ [__j-1], __cur [__j-1])) {
+                __j--;
+            //  We matched - we're done!
+                if ( __j == 0 )
+                    return make_pair(__cur, __cur + __pattern_length_);
+                }
+            
+        //  Since we didn't match, figure out how far to skip forward
+            difference_type __k = __skip[__cur [ __j - 1 ]];
+            difference_type __m = __j - __k - 1;
+            if (__k < __j && __m > __suffix[ __j ])
+                __cur += __m;
+            else
+                __cur += __suffix[ __j ];
+        }
+    
+        return make_pair(__l, __l);     // We didn't find anything
+    }
+
+
+    template<typename _Iterator, typename _Container>
+    void __compute_bm_prefix ( _Iterator __f, _Iterator __l, _BinaryPredicate __pred, _Container &__prefix )
+    {
+        const std::size_t __count = _VSTD::distance(__f, __l);
+                        
+        __prefix[0] = 0;
+        std::size_t __k = 0;
+        for ( std::size_t __i = 1; __i < __count; ++__i )
+        {
+            while ( __k > 0 && !__pred ( __f[__k], __f[__i] ))
+                __k = __prefix [ __k - 1 ];
+                
+            if ( __pred ( __f[__k], __f[__i] ))
+                __k++;
+            __prefix [ __i ] = __k;
+        }
+    }
+
+    void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, 
+                                                    _BinaryPredicate __pred)
+    {
+        const std::size_t __count = _VSTD::distance(__f, __l);
+        vector<difference_type> & __suffix = *__suffix_.get();
+        if (__count > 0)
+        {
+            _VSTD::vector<value_type> __scratch(__count);
+            
+            __compute_bm_prefix(__f, __l, __pred, __scratch);
+            for ( std::size_t __i = 0; __i <= __count; __i++ )
+                __suffix[__i] = __count - __scratch[__count-1];
+    
+            typedef _VSTD::reverse_iterator<_RandomAccessIterator1> _RevIter;
+            __compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch);
+     
+            for ( std::size_t __i = 0; __i < __count; __i++ )
+            {
+                const std::size_t     __j = __count - __scratch[__i];
+                const difference_type __k = __i     - __scratch[__i] + 1;
+     
+                if (__suffix[__j] > __k)
+                    __suffix[__j] = __k;
+            }
+        }
+    }
+
+};
+
+template<class _RandomAccessIterator, 
+         class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>, 
+         class _BinaryPredicate = equal_to<>>
+_LIBCPP_INLINE_VISIBILITY
+boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
+make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, 
+                    _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
+{
+    return boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p);
+}
+
+// boyer-moore-horspool
+template <class _RandomAccessIterator1, 
+          class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, 
+          class _BinaryPredicate = equal_to<>>
+_LIBCPP_TYPE_VIS
+class boyer_moore_horspool_searcher {
+private:
+    typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
+    typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type      value_type;
+    typedef _BMSkipTable<value_type, difference_type, _Hash, _BinaryPredicate,
+                    _VSTD::is_integral<value_type>::value && // what about enums?
+                    sizeof(value_type) == 1 &&
+                    is_same<_Hash, hash<value_type>>::value &&
+                    is_same<_BinaryPredicate, equal_to<>>::value
+            > skip_table_type;
+
+public:
+    boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, 
+                _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
+            : __first_(__f), __last_(__l), __pred_(__pred),
+              __pattern_length_(_VSTD::distance(__first_, __last_)),
+              __skip_{_VSTD::make_shared<skip_table_type>(__pattern_length_, __pattern_length_, __hf, __pred_)}
+        {
+    //  build the skip table
+            if ( __f != __l )
+            {
+                __l = __l - 1;
+                for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i )
+                    __skip_->insert(*__f, __pattern_length_ - 1 - __i);
+            }
+        }
+            
+    template <typename _RandomAccessIterator2>
+    pair<_RandomAccessIterator2, _RandomAccessIterator2>
+    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
+                    >::value,
+                "Corpus and Pattern iterators must point to the same type" );
+
+        if (__f      == __l )    return make_pair(__l, __l); // empty corpus
+        if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
+
+    //  If the pattern is larger than the corpus, we can't find it!
+        if ( __pattern_length_ > _VSTD::distance (__f, __l)) 
+            return make_pair(__l, __l);
+
+    //  Do the search 
+        return this->__search(__f, __l);
+    }
+        
+private:
+    _RandomAccessIterator1      __first_;
+    _RandomAccessIterator1      __last_;
+    _BinaryPredicate            __pred_;
+    difference_type             __pattern_length_;
+    shared_ptr<skip_table_type> __skip_;
+
+    template <typename _RandomAccessIterator2>
+    pair<_RandomAccessIterator2, _RandomAccessIterator2>
+    __search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const {
+        _RandomAccessIterator2 __cur = __f;
+        const _RandomAccessIterator2 __last = __l - __pattern_length_;
+        const skip_table_type & __skip = *__skip_.get();
+
+        while (__cur <= __last)
+        {
+        //  Do we match right where we are?
+            difference_type __j = __pattern_length_;
+            while (__pred_(__first_[__j-1], __cur[__j-1]))
+            {
+                __j--;
+            //  We matched - we're done!
+                if ( __j == 0 )
+                    return make_pair(__cur, __cur + __pattern_length_);
+            }
+            __cur += __skip[__cur[__pattern_length_-1]];
+        }
+        
+        return make_pair(__l, __l);
+    }
+};
+
+template<class _RandomAccessIterator, 
+         class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>, 
+         class _BinaryPredicate = equal_to<>>
+_LIBCPP_INLINE_VISIBILITY
+boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
+make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, 
+                    _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
+{
+    return boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p);
+}
+
+#endif // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */
diff --git a/system/include/libcxx/experimental/iterator b/system/include/libcxx/experimental/iterator
new file mode 100644
index 0000000000000..da593febe2b4f
--- /dev/null
+++ b/system/include/libcxx/experimental/iterator
@@ -0,0 +1,114 @@
+// -*- C++ -*-
+//===----------------------------- iterator -------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_ITERATOR
+#define _LIBCPP_EXPERIMENTAL_ITERATOR
+
+/*
+namespace std {
+  namespace experimental {
+    inline namespace fundamentals_v2 {
+
+    template <class DelimT, class charT = char, class traits = char_traits<charT>>
+        class ostream_joiner {
+        public:
+         typedef charT                        char_type;
+         typedef traits                       traits_type;
+         typedef basic_ostream<charT, traits> ostream_type;
+         typedef output_iterator_tag          iterator_category;
+         typedef void                         value_type;
+         typedef void                         difference_type;
+         typedef void                         pointer;
+         typedef void                         reference;
+      
+         ostream_joiner(ostream_type& s, const DelimT& delimiter);
+         ostream_joiner(ostream_type& s, DelimT&& delimiter);
+
+         template<typename T>  
+         ostream_joiner& operator=(const T& value);
+
+         ostream_joiner& operator*() noexcept;
+         ostream_joiner& operator++() noexcept;
+         ostream_joiner& operator++(int) noexcept;
+   private:
+      ostream_type* out_stream;   // exposition only 
+      DelimT delim;               // exposition only 
+      bool first_element;         // exposition only
+   };
+
+  template <class charT, class traits, class DelimT>
+    ostream_joiner<decay_t<DelimT>, charT, traits>
+    make_ostream_joiner(basic_ostream<charT, traits>& os, DelimT&& delimiter);
+
+    } // inline namespace fundamentals_v2
+  } // namespace experimental
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <iterator>
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>>
+class ostream_joiner {
+public:
+
+    typedef _CharT                               char_type;
+    typedef _Traits                              traits_type;
+    typedef basic_ostream<char_type,traits_type> ostream_type;
+    typedef output_iterator_tag                  iterator_category;
+    typedef void                                 value_type;
+    typedef void                                 difference_type;
+    typedef void                                 pointer;
+    typedef void                                 reference;
+
+    ostream_joiner(ostream_type& __os, _Delim&& __d)
+        : __out(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
+        
+    ostream_joiner(ostream_type& __os, const _Delim& __d)
+        : __out(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
+    
+
+    template<typename _Tp>
+    ostream_joiner& operator=(const _Tp& __v)
+    {
+        if (!__first)
+            *__out << __delim;
+        __first = false;
+        *__out << __v;
+        return *this;
+    }
+
+    ostream_joiner& operator*()     _NOEXCEPT { return *this; }
+    ostream_joiner& operator++()    _NOEXCEPT { return *this; }
+    ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
+
+private:
+    ostream_type*   __out;
+    _Delim          __delim;
+    bool            __first;
+};
+
+
+template <class _CharT, class _Traits, class _Delim>
+ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>
+make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d)
+{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); }
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif // _LIBCPP_EXPERIMENTAL_ITERATOR
diff --git a/system/include/libcxx/experimental/optional b/system/include/libcxx/experimental/optional
index 41d86b4a16954..a384882a1e129 100644
--- a/system/include/libcxx/experimental/optional
+++ b/system/include/libcxx/experimental/optional
@@ -16,131 +16,147 @@
 
 // C++1y
 
-#include <initializer_list>
-
-namespace std { namespace experimental {
-
-// optional for object types
-template <class T>
-class optional
-{
-public:
-    typedef T value_type;
-
-    // constructors
-    constexpr optional() noexcept;
-    constexpr optional(nullopt_t) noexcept;
-    optional(const optional&);
-    optional(optional&&) noexcept(is_nothrow_move_constructible<T>::value);
-    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&&...);
-
-    // destructor
-    ~optional();
-
-    // assignment
-    optional& operator=(nullopt_t) noexcept;
-    optional& operator=(const optional&);
-    optional& operator=(optional&&)
-        noexcept(is_nothrow_move_assignable<T>::value &&
-                 is_nothrow_move_constructible<T>::value);
-    template <class U> optional& operator=(U&&);
-    template <class... Args> void emplace(Args&&...);
-    template <class U, class... Args> void emplace(initializer_list<U>, Args&&...);
-
-    // swap
-    void swap(optional&)
-        noexcept(is_nothrow_move_constructible<T>::value &&
-                 noexcept(swap(declval<T&>(), declval<T&>())));
-
-    // observers
-    constexpr T const* operator->() const;
-    T* operator->();
-    constexpr T const& operator*() const;
-    T& operator*();
-    constexpr explicit operator bool() const noexcept;
-    constexpr T const& value() const;
-    T& value();
-    template <class U> constexpr T value_or(U&&) const&;
-    template <class U> T value_or(U&&) &&;
-};
-
-// In-place construction
-struct in_place_t{};
-constexpr in_place_t in_place{};
-
-// Disengaged state indicator
-struct nullopt_t{see below};
-constexpr nullopt_t nullopt(unspecified);
-
-// class bad_optional_access
-class bad_optional_access
-    : public logic_error
-{
-public:
-    explicit bad_optional_access(const string& what_arg);
-    explicit bad_optional_access(const char* what_arg);
-};
-
-// 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>&);
-
-// 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;
-
-// 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>&);
-
-// Specialized algorithms
-template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below);
-template <class T> constexpr optional<typename decay<T>::type> make_optional(T&&);
-
-// hash support
-template <class T> struct hash;
-template <class T> struct hash<optional<T>>;
-
-}}  // std::experimental
+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 <__config>
+#include <experimental/__config>
 #include <functional>
 #include <stdexcept>
 
-namespace std { namespace experimental {
-
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
 class _LIBCPP_EXCEPTION_ABI bad_optional_access
-    : public logic_error
+    : public std::logic_error
 {
 public:
-#if _LIBCPP_STD_VER > 11
-    _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const string& __arg)
-        : logic_error(__arg) {}
-    _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const char* __arg)
-        : logic_error(__arg) {}
-    _LIBCPP_INLINE_VISIBILITY bad_optional_access(const bad_optional_access&) noexcept = default;
-    _LIBCPP_INLINE_VISIBILITY bad_optional_access& operator=(const bad_optional_access&) noexcept = default;
-#else
-private:
-    bad_optional_access(const bad_optional_access&);
-    bad_optional_access& operator=(const bad_optional_access&);
-public:
-#endif  // _LIBCPP_STD_VER > 11
-    // Get the key function ~bad_optional_access() into the dylib even if not compiling for C++1y
+	bad_optional_access() : std::logic_error("Bad optional Access") {}
+
+//	Get the key function ~bad_optional_access() into the dylib
     virtual ~bad_optional_access() _NOEXCEPT;
 };
 
-}}  // std::experimental
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL
+
 
 #if _LIBCPP_STD_VER > 11
 
@@ -148,16 +164,14 @@ public:
 #include <type_traits>
 #include <new>
 #include <__functional_base>
-
 #include <__undef_min_max>
-
 #include <__debug>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-namespace std { namespace experimental { inline namespace __library_fundamentals_v1 {
+_LIBCPP_BEGIN_NAMESPACE_LFTS
 
 struct in_place_t {};
 constexpr in_place_t in_place{};
@@ -503,7 +517,7 @@ public:
     constexpr value_type const& value() const
     {
         if (!this->__engaged_)
-            throw bad_optional_access("optional<T>::value: not engaged");
+            throw bad_optional_access();
         return this->__val_;
     }
 
@@ -511,7 +525,7 @@ public:
     value_type& value()
     {
         if (!this->__engaged_)
-            throw bad_optional_access("optional<T>::value: not engaged");
+            throw bad_optional_access();
         return this->__val_;
     }
 
@@ -556,6 +570,7 @@ private:
     }
 };
 
+// Comparisons between optionals
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
 constexpr
@@ -569,6 +584,15 @@ 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)
+{
+    return !(__x == __y);
+}
+
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
 constexpr
@@ -579,9 +603,38 @@ operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
         return false;
     if (!static_cast<bool>(__x))
         return true;
-    return less<_Tp>{}(*__x, *__y);
+    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
@@ -600,6 +653,24 @@ 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
@@ -618,6 +689,61 @@ operator<(nullopt_t, const optional<_Tp>& __x) noexcept
     return static_cast<bool>(__x);
 }
 
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+    return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<=(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+    return true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+    return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+    return false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>=(const optional<_Tp>&, nullopt_t) noexcept
+{
+    return true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+    return !static_cast<bool>(__x);
+}
+
+// Comparisons with T
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
 constexpr
@@ -636,6 +762,24 @@ 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
@@ -654,6 +798,61 @@ 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
@@ -671,7 +870,7 @@ make_optional(_Tp&& __v)
     return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
 }
 
-}}}  // namespace std::experimental::__library_fundamentals_v1
+_LIBCPP_END_NAMESPACE_LFTS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -692,4 +891,4 @@ _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_STD_VER > 11
 
-#endif  // _LIBCPP_ARRAY
+#endif  // _LIBCPP_OPTIONAL
diff --git a/system/include/libcxx/experimental/ratio b/system/include/libcxx/experimental/ratio
new file mode 100644
index 0000000000000..757f24e086149
--- /dev/null
+++ b/system/include/libcxx/experimental/ratio
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//===------------------------------ ratio ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_RATIO
+#define _LIBCPP_EXPERIMENTAL_RATIO
+
+/**
+    experimental/ratio synopsis
+    C++1y
+#include <ratio>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+  // See C++14 20.11.5, ratio comparison
+  template <class R1, class R2> constexpr bool ratio_equal_v
+    = ratio_equal<R1, R2>::value;
+  template <class R1, class R2> constexpr bool ratio_not_equal_v
+    = ratio_not_equal<R1, R2>::value;
+  template <class R1, class R2> constexpr bool ratio_less_v
+    = ratio_less<R1, R2>::value;
+  template <class R1, class R2> constexpr bool ratio_less_equal_v
+    = ratio_less_equal<R1, R2>::value;
+  template <class R1, class R2> constexpr bool ratio_greater_v
+    = ratio_greater<R1, R2>::value;
+  template <class R1, class R2> constexpr bool ratio_greater_equal_v
+    = ratio_greater_equal<R1, R2>::value;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <ratio>
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_equal_v
+    = ratio_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_not_equal_v
+    = ratio_not_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_v
+    = ratio_less<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_equal_v
+    = ratio_less_equal<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_v
+    = ratio_greater<_R1, _R2>::value;
+
+template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
+    = ratio_greater_equal<_R1, _R2>::value;
+
+#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif // _LIBCPP_EXPERIMENTAL_RATIO
diff --git a/system/include/libcxx/experimental/string_view b/system/include/libcxx/experimental/string_view
index b0382e5d2570f..2a20d7caa6878 100644
--- a/system/include/libcxx/experimental/string_view
+++ b/system/include/libcxx/experimental/string_view
@@ -280,11 +280,8 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
         const_reference at(size_type __pos) const
         {
             return __pos >= size()
-                ? throw out_of_range("string_view::at")
+                ? (throw out_of_range("string_view::at"), __data[0])
                 : __data[__pos];
-//             if (__pos >= size())
-//                 throw out_of_range("string_view::at");
-//             return __data[__pos]; 
         }
 
         _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
@@ -313,8 +310,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
         _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
         void remove_prefix(size_type __n) _NOEXCEPT
         {
-            if (__n > __size)
-                __n = __size;
+            _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
             __data += __n;
             __size -= __n;
         }
@@ -322,8 +318,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
         _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
         void remove_suffix(size_type __n) _NOEXCEPT
         {
-            if (__n > __size)
-                __n = __size;
+            _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
             __size -= __n;
         }
 
@@ -349,7 +344,8 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 
         template<class _Allocator = allocator<_CharT> >
         _LIBCPP_INLINE_VISIBILITY
-        basic_string<_CharT, _Traits, _Allocator> to_string( const _Allocator& __a = _Allocator())
+        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
diff --git a/system/include/libcxx/experimental/system_error b/system/include/libcxx/experimental/system_error
new file mode 100644
index 0000000000000..2ec238544615e
--- /dev/null
+++ b/system/include/libcxx/experimental/system_error
@@ -0,0 +1,63 @@
+// -*- C++ -*-
+//===-------------------------- system_error ------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
+#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
+
+/**
+    experimental/system_error synopsis
+
+// C++1y
+
+#include <system_error>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+  // See C++14 19.5, System error support
+  template <class T> constexpr bool is_error_code_enum_v
+    = is_error_code_enum<T>::value;
+  template <class T> constexpr bool is_error_condition_enum_v
+    = is_error_condition_enum<T>::value;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+*/
+
+#include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <system_error>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_code_enum_v
+    = is_error_code_enum<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_condition_enum_v
+    = is_error_condition_enum<_Tp>::value;
+
+#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR */
diff --git a/system/include/libcxx/experimental/tuple b/system/include/libcxx/experimental/tuple
new file mode 100644
index 0000000000000..e00d2ec1a92fb
--- /dev/null
+++ b/system/include/libcxx/experimental/tuple
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+//===----------------------------- tuple ----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_TUPLE
+#define _LIBCPP_EXPERIMENTAL_TUPLE
+
+/*
+    experimental/tuple synopsis
+
+// C++1y
+
+#include <tuple>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+  // See C++14 20.4.2.5, tuple helper classes
+  template <class T> constexpr size_t tuple_size_v
+    = tuple_size<T>::value;
+
+  // 3.2.2, Calling a function with a tuple of arguments
+  template <class F, class Tuple>
+  constexpr decltype(auto) apply(F&& f, Tuple&& t);
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+ */
+
+# include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+# include <tuple>
+# include <utility>
+# include <__functional_base>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+template <class _Tp>
+_LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value;
+#endif
+
+template <class _Fn, class _Tuple, size_t ..._Id>
+inline _LIBCPP_INLINE_VISIBILITY
+_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 */
diff --git a/system/include/libcxx/experimental/type_traits b/system/include/libcxx/experimental/type_traits
new file mode 100644
index 0000000000000..ae49fc176c011
--- /dev/null
+++ b/system/include/libcxx/experimental/type_traits
@@ -0,0 +1,427 @@
+// -*- C++ -*-
+//===-------------------------- type_traits -------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
+#define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
+
+/**
+    experimental/type_traits synopsis
+
+// C++1y
+#include <type_traits>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+  // See C++14 20.10.4.1, primary type categories
+  template <class T> constexpr bool is_void_v
+    = is_void<T>::value;
+  template <class T> constexpr bool is_null_pointer_v
+    = is_null_pointer<T>::value;
+  template <class T> constexpr bool is_integral_v
+    = is_integral<T>::value;
+  template <class T> constexpr bool is_floating_point_v
+    = is_floating_point<T>::value;
+  template <class T> constexpr bool is_array_v
+    = is_array<T>::value;
+  template <class T> constexpr bool is_pointer_v
+    = is_pointer<T>::value;
+  template <class T> constexpr bool is_lvalue_reference_v
+    = is_lvalue_reference<T>::value;
+  template <class T> constexpr bool is_rvalue_reference_v
+    = is_rvalue_reference<T>::value;
+  template <class T> constexpr bool is_member_object_pointer_v
+    = is_member_object_pointer<T>::value;
+  template <class T> constexpr bool is_member_function_pointer_v
+    = is_member_function_pointer<T>::value;
+  template <class T> constexpr bool is_enum_v
+    = is_enum<T>::value;
+  template <class T> constexpr bool is_union_v
+    = is_union<T>::value;
+  template <class T> constexpr bool is_class_v
+    = is_class<T>::value;
+  template <class T> constexpr bool is_function_v
+    = is_function<T>::value;
+
+  // See C++14 20.10.4.2, composite type categories
+  template <class T> constexpr bool is_reference_v
+    = is_reference<T>::value;
+  template <class T> constexpr bool is_arithmetic_v
+    = is_arithmetic<T>::value;
+  template <class T> constexpr bool is_fundamental_v
+    = is_fundamental<T>::value;
+  template <class T> constexpr bool is_object_v
+    = is_object<T>::value;
+  template <class T> constexpr bool is_scalar_v
+    = is_scalar<T>::value;
+  template <class T> constexpr bool is_compound_v
+    = is_compound<T>::value;
+  template <class T> constexpr bool is_member_pointer_v
+    = is_member_pointer<T>::value;
+
+  // See C++14 20.10.4.3, type properties
+  template <class T> constexpr bool is_const_v
+    = is_const<T>::value;
+  template <class T> constexpr bool is_volatile_v
+    = is_volatile<T>::value;
+  template <class T> constexpr bool is_trivial_v
+    = is_trivial<T>::value;
+  template <class T> constexpr bool is_trivially_copyable_v
+    = is_trivially_copyable<T>::value;
+  template <class T> constexpr bool is_standard_layout_v
+    = is_standard_layout<T>::value;
+  template <class T> constexpr bool is_pod_v
+    = is_pod<T>::value;
+  template <class T> constexpr bool is_literal_type_v
+    = is_literal_type<T>::value;
+  template <class T> constexpr bool is_empty_v
+    = is_empty<T>::value;
+  template <class T> constexpr bool is_polymorphic_v
+    = is_polymorphic<T>::value;
+  template <class T> constexpr bool is_abstract_v
+    = is_abstract<T>::value;
+  template <class T> constexpr bool is_final_v
+    = is_final<T>::value;
+  template <class T> constexpr bool is_signed_v
+    = is_signed<T>::value;
+  template <class T> constexpr bool is_unsigned_v
+    = is_unsigned<T>::value;
+  template <class T, class... Args> constexpr bool is_constructible_v
+    = is_constructible<T, Args...>::value;
+  template <class T> constexpr bool is_default_constructible_v
+    = is_default_constructible<T>::value;
+  template <class T> constexpr bool is_copy_constructible_v
+    = is_copy_constructible<T>::value;
+  template <class T> constexpr bool is_move_constructible_v
+    = is_move_constructible<T>::value;
+  template <class T, class U> constexpr bool is_assignable_v
+    = is_assignable<T, U>::value;
+  template <class T> constexpr bool is_copy_assignable_v
+    = is_copy_assignable<T>::value;
+  template <class T> constexpr bool is_move_assignable_v
+    = is_move_assignable<T>::value;
+  template <class T> constexpr bool is_destructible_v
+    = is_destructible<T>::value;
+  template <class T, class... Args> constexpr bool is_trivially_constructible_v
+    = is_trivially_constructible<T, Args...>::value;
+  template <class T> constexpr bool is_trivially_default_constructible_v
+    = is_trivially_default_constructible<T>::value;
+  template <class T> constexpr bool is_trivially_copy_constructible_v
+    = is_trivially_copy_constructible<T>::value;
+  template <class T> constexpr bool is_trivially_move_constructible_v
+    = is_trivially_move_constructible<T>::value;
+  template <class T, class U> constexpr bool is_trivially_assignable_v
+    = is_trivially_assignable<T, U>::value;
+  template <class T> constexpr bool is_trivially_copy_assignable_v
+    = is_trivially_copy_assignable<T>::value;
+  template <class T> constexpr bool is_trivially_move_assignable_v
+    = is_trivially_move_assignable<T>::value;
+  template <class T> constexpr bool is_trivially_destructible_v
+    = is_trivially_destructible<T>::value;
+  template <class T, class... Args> constexpr bool is_nothrow_constructible_v
+    = is_nothrow_constructible<T, Args...>::value;
+  template <class T> constexpr bool is_nothrow_default_constructible_v
+    = is_nothrow_default_constructible<T>::value;
+  template <class T> constexpr bool is_nothrow_copy_constructible_v
+    = is_nothrow_copy_constructible<T>::value;
+  template <class T> constexpr bool is_nothrow_move_constructible_v
+    = is_nothrow_move_constructible<T>::value;
+  template <class T, class U> constexpr bool is_nothrow_assignable_v
+    = is_nothrow_assignable<T, U>::value;
+  template <class T> constexpr bool is_nothrow_copy_assignable_v
+    = is_nothrow_copy_assignable<T>::value;
+  template <class T> constexpr bool is_nothrow_move_assignable_v
+    = is_nothrow_move_assignable<T>::value;
+  template <class T> constexpr bool is_nothrow_destructible_v
+    = is_nothrow_destructible<T>::value;
+  template <class T> constexpr bool has_virtual_destructor_v
+    = has_virtual_destructor<T>::value;
+
+  // See C++14 20.10.5, type property queries
+  template <class T> constexpr size_t alignment_of_v
+    = alignment_of<T>::value;
+  template <class T> constexpr size_t rank_v
+    = rank<T>::value;
+  template <class T, unsigned I = 0> constexpr size_t extent_v
+    = extent<T, I>::value;
+
+  // See C++14 20.10.6, type relations
+  template <class T, class U> constexpr bool is_same_v
+    = is_same<T, U>::value;
+  template <class Base, class Derived> constexpr bool is_base_of_v
+    = is_base_of<Base, Derived>::value;
+  template <class From, class To> constexpr bool is_convertible_v
+    = is_convertible<From, To>::value;
+
+  // 3.3.2, Other type transformations
+  template <class> class invocation_type; // not defined
+  template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
+  template <class> class raw_invocation_type; // not defined
+  template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>;
+
+  template <class T>
+    using invocation_type_t = typename invocation_type<T>::type;
+  template <class T>
+    using raw_invocation_type_t = typename raw_invocation_type<T>::type;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+ */
+
+#include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+
+// C++14 20.10.4.1, primary type categories
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
+    = is_void<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
+    = is_null_pointer<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
+    = is_integral<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
+    = is_floating_point<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
+    = is_array<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
+    = is_pointer<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
+    = is_lvalue_reference<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
+    = is_rvalue_reference<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
+    = is_member_object_pointer<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
+    = is_member_function_pointer<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
+    = is_enum<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
+    = is_union<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
+    = is_class<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
+    = is_function<_Tp>::value;
+
+// C++14 20.10.4.2,  composite type categories
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
+    = is_reference<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
+    = is_arithmetic<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
+    = is_fundamental<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
+    = is_object<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
+    = is_scalar<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
+    = is_compound<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
+    = is_member_pointer<_Tp>::value;
+
+// C++14 20.10.4.3, type properties
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
+    = is_const<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
+    = is_volatile<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
+    = is_trivial<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
+    = is_trivially_copyable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
+    = is_standard_layout<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
+    = is_pod<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
+    = is_literal_type<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
+    = is_empty<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
+    = is_polymorphic<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
+    = is_abstract<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
+    = is_final<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
+    = is_signed<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
+    = is_unsigned<_Tp>::value;
+
+template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v
+    = is_constructible<_Tp, _Ts...>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
+    = is_default_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
+    = is_copy_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
+    = is_move_constructible<_Tp>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v
+    = is_assignable<_Tp, _Up>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
+    = is_copy_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
+    = is_move_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
+    = is_destructible<_Tp>::value;
+
+template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
+    = is_trivially_constructible<_Tp, _Ts...>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
+    = is_trivially_default_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
+    = is_trivially_copy_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
+    = is_trivially_move_constructible<_Tp>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
+    = is_trivially_assignable<_Tp, _Up>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
+    = is_trivially_copy_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
+    = is_trivially_move_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
+    = is_trivially_destructible<_Tp>::value;
+
+template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
+    = is_nothrow_constructible<_Tp, _Ts...>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
+    = is_nothrow_default_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
+    = is_nothrow_copy_constructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
+    = is_nothrow_move_constructible<_Tp>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
+    = is_nothrow_assignable<_Tp, _Up>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
+    = is_nothrow_copy_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
+    = is_nothrow_move_assignable<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
+    = is_nothrow_destructible<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
+    = has_virtual_destructor<_Tp>::value;
+
+// C++14 20.10.5, type properties queries
+
+template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
+    = alignment_of<_Tp>::value;
+
+template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
+    = rank<_Tp>::value;
+
+template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v
+    = extent<_Tp, _Id>::value;
+
+// C++14 20.10.6, type relations
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
+    = is_same<_Tp, _Up>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
+    = is_base_of<_Tp, _Up>::value;
+
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
+    = is_convertible<_Tp, _Up>::value;
+
+#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
+
+// 3.3.2, Other type transformations
+/*
+template <class>
+class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type;
+
+template <class _Fn, class ..._Args>
+class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>;
+
+template <class>
+class _LIBCPP_TYPE_VIS_ONLY invokation_type;
+
+template <class _Fn, class ..._Args>
+class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>;
+
+template <class _Tp>
+using invokation_type_t = typename invokation_type<_Tp>::type;
+
+template <class _Tp>
+using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
+*/
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */
diff --git a/system/include/libcxx/experimental/utility b/system/include/libcxx/experimental/utility
index 84e461af073f3..b5fca6c775bc8 100644
--- a/system/include/libcxx/experimental/utility
+++ b/system/include/libcxx/experimental/utility
@@ -31,9 +31,12 @@ inline namespace fundamentals_v1 {
 
  */
 
-# include <experimental/__config>
+#include <experimental/__config>
+#include <utility>
 
-# include <utility>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
 
 _LIBCPP_BEGIN_NAMESPACE_LFTS
 
diff --git a/system/include/libcxx/ext/hash_map b/system/include/libcxx/ext/hash_map
index 36cd595e0343b..5e1e9f542b179 100644
--- a/system/include/libcxx/ext/hash_map
+++ b/system/include/libcxx/ext/hash_map
@@ -203,6 +203,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
 #include <__hash_table>
 #include <functional>
 #include <stdexcept>
+#include <type_traits>
 #include <ext/__hash>
 
 #if __DEPRECATED
@@ -213,16 +214,16 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
 #endif
 #endif
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
+#endif
 
 namespace __gnu_cxx {
 
 using namespace std;
 
-template <class _Tp, class _Hash, bool = is_empty<_Hash>::value
-#if __has_feature(is_final)
-                                         && !__is_final(_Hash)
-#endif
+template <class _Tp, class _Hash,
+          bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value
         >
 class __hash_map_hasher
     : private _Hash
@@ -255,10 +256,8 @@ public:
         {return __hash_(__x);}
 };
 
-template <class _Tp, class _Pred, bool = is_empty<_Pred>::value
-#if __has_feature(is_final)
-                                         && !__is_final(_Pred)
-#endif
+template <class _Tp, class _Pred,
+          bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
          >
 class __hash_map_equal
     : private _Pred
@@ -310,7 +309,7 @@ class __hash_map_node_destructor
 {
     typedef _Alloc                              allocator_type;
     typedef allocator_traits<allocator_type>    __alloc_traits;
-    typedef typename __alloc_traits::value_type::value_type value_type;
+    typedef typename __alloc_traits::value_type::__node_value_type value_type;
 public:
     typedef typename __alloc_traits::pointer    pointer;
 private:
@@ -369,7 +368,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator
 {
     _HashIterator __i_;
 
-    typedef pointer_traits<typename _HashIterator::pointer>      __pointer_traits;
     typedef const typename _HashIterator::value_type::first_type key_type;
     typedef typename _HashIterator::value_type::second_type      mapped_type;
 public:
@@ -377,13 +375,8 @@ public:
     typedef pair<key_type, mapped_type>                          value_type;
     typedef typename _HashIterator::difference_type              difference_type;
     typedef value_type&                                          reference;
-    typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<value_type>
-#else
-            rebind<value_type>::other
-#endif
-                                                                 pointer;
+    typedef typename __rebind_pointer<typename _HashIterator::pointer, value_type>::type
+        pointer;
 
     _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}
 
@@ -420,7 +413,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator
 {
     _HashIterator __i_;
 
-    typedef pointer_traits<typename _HashIterator::pointer>      __pointer_traits;
     typedef const typename _HashIterator::value_type::first_type key_type;
     typedef typename _HashIterator::value_type::second_type      mapped_type;
 public:
@@ -428,13 +420,8 @@ public:
     typedef pair<key_type, mapped_type>                          value_type;
     typedef typename _HashIterator::difference_type              difference_type;
     typedef const value_type&                                    reference;
-    typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const value_type>
-#else
-            rebind<const value_type>::other
-#endif
-                                                                 pointer;
+    typedef typename __rebind_pointer<typename _HashIterator::pointer, const value_type>::type
+        pointer;
 
     _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}
 
@@ -493,13 +480,7 @@ private:
     typedef pair<key_type, mapped_type>                    __value_type;
     typedef __hash_map_hasher<__value_type, hasher>   __hasher;
     typedef __hash_map_equal<__value_type, key_equal> __key_equal;
-    typedef typename allocator_traits<allocator_type>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__value_type>
-#else
-            rebind_alloc<__value_type>::other
-#endif
-                                                           __allocator_type;
+    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
 
     typedef __hash_table<__value_type, __hasher,
                          __key_equal,  __allocator_type>   __table;
@@ -568,6 +549,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
     template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
         void insert(_InputIterator __first, _InputIterator __last);
 
     _LIBCPP_INLINE_VISIBILITY
@@ -688,12 +670,12 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
     __h.get_deleter().__first_constructed = true;
     __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
     __h.get_deleter().__second_constructed = true;
-    return _VSTD::move(__h);  // explicitly moved for C++03
+    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
                                                        _InputIterator __last)
@@ -772,13 +754,7 @@ private:
     typedef pair<key_type, mapped_type>                    __value_type;
     typedef __hash_map_hasher<__value_type, hasher>   __hasher;
     typedef __hash_map_equal<__value_type, key_equal> __key_equal;
-    typedef typename allocator_traits<allocator_type>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__value_type>
-#else
-            rebind_alloc<__value_type>::other
-#endif
-                                                           __allocator_type;
+    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
 
     typedef __hash_table<__value_type, __hasher,
                          __key_equal,  __allocator_type>   __table;
@@ -845,6 +821,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
     template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
         void insert(_InputIterator __first, _InputIterator __last);
 
     _LIBCPP_INLINE_VISIBILITY
@@ -952,7 +929,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
                                                             _InputIterator __last)
diff --git a/system/include/libcxx/ext/hash_set b/system/include/libcxx/ext/hash_set
index c4bb89843d552..91850b566d5b1 100644
--- a/system/include/libcxx/ext/hash_set
+++ b/system/include/libcxx/ext/hash_set
@@ -282,6 +282,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
     template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
         void insert(_InputIterator __first, _InputIterator __last);
 
     _LIBCPP_INLINE_VISIBILITY
@@ -385,7 +386,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
                                                     _InputIterator __last)
@@ -502,6 +503,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
     template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
         void insert(_InputIterator __first, _InputIterator __last);
 
     _LIBCPP_INLINE_VISIBILITY
@@ -606,7 +608,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
                                                          _InputIterator __last)
diff --git a/system/include/libcxx/float.h b/system/include/libcxx/float.h
new file mode 100644
index 0000000000000..1acfdc6188f27
--- /dev/null
+++ b/system/include/libcxx/float.h
@@ -0,0 +1,83 @@
+// -*- C++ -*-
+//===--------------------------- float.h ----------------------------------===//
+//
+//                     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_FLOAT_H
+#define _LIBCPP_FLOAT_H
+
+/*
+    float.h synopsis
+
+Macros:
+
+    FLT_ROUNDS
+    FLT_EVAL_METHOD     // C99
+    FLT_RADIX
+
+    FLT_MANT_DIG
+    DBL_MANT_DIG
+    LDBL_MANT_DIG
+
+    DECIMAL_DIG         // C99
+
+    FLT_DIG
+    DBL_DIG
+    LDBL_DIG
+
+    FLT_MIN_EXP
+    DBL_MIN_EXP
+    LDBL_MIN_EXP
+
+    FLT_MIN_10_EXP
+    DBL_MIN_10_EXP
+    LDBL_MIN_10_EXP
+
+    FLT_MAX_EXP
+    DBL_MAX_EXP
+    LDBL_MAX_EXP
+
+    FLT_MAX_10_EXP
+    DBL_MAX_10_EXP
+    LDBL_MAX_10_EXP
+
+    FLT_MAX
+    DBL_MAX
+    LDBL_MAX
+
+    FLT_EPSILON
+    DBL_EPSILON
+    LDBL_EPSILON
+
+    FLT_MIN
+    DBL_MIN
+    LDBL_MIN
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <float.h>
+
+#ifdef __cplusplus
+
+#ifndef FLT_EVAL_METHOD
+#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
+#endif
+
+#ifndef DECIMAL_DIG
+#define DECIMAL_DIG __DECIMAL_DIG__
+#endif
+
+#endif // __cplusplus
+
+#endif  // _LIBCPP_FLOAT_H
diff --git a/system/include/libcxx/forward_list b/system/include/libcxx/forward_list
index a83b19520e284..18b300d847037 100644
--- a/system/include/libcxx/forward_list
+++ b/system/include/libcxx/forward_list
@@ -107,8 +107,7 @@ public:
     iterator erase_after(const_iterator first, const_iterator last);
 
     void swap(forward_list& x)
-        noexcept(!allocator_type::propagate_on_container_swap::value ||
-                 __is_nothrow_swappable<allocator_type>::value);
+        noexcept(allocator_traits<allocator_type>::is_always_equal::value);  // C++17
 
     void resize(size_type n);
     void resize(size_type n, const value_type& v);
@@ -184,29 +183,77 @@ template <class T, class Allocator>
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp, class _VoidPtr> struct __forward_list_node;
+template <class _NodePtr> struct __forward_begin_node;
+
+
+template <class>
+struct __forward_list_node_value_type;
+
+template <class _Tp, class _VoidPtr>
+struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > {
+  typedef _Tp type;
+};
+
+template <class _NodePtr>
+struct __forward_node_traits {
+
+  typedef typename remove_cv<
+        typename pointer_traits<_NodePtr>::element_type>::type  __node;
+  typedef typename __forward_list_node_value_type<__node>::type __node_value_type;
+  typedef _NodePtr                                              __node_pointer;
+  typedef __forward_begin_node<_NodePtr>                        __begin_node;
+  typedef typename __rebind_pointer<_NodePtr, __begin_node>::type
+                                                                __begin_node_pointer;
+  typedef typename __rebind_pointer<_NodePtr, void>::type       __void_pointer;
+
+#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB)
+  typedef __begin_node_pointer __iter_node_pointer;
+#else
+  typedef typename conditional<
+          is_pointer<__void_pointer>::value,
+          __begin_node_pointer,
+          __node_pointer
+    >::type __iter_node_pointer;
+#endif
+
+  typedef typename conditional<
+          is_same<__iter_node_pointer, __node_pointer>::value,
+          __begin_node_pointer,
+          __node_pointer
+    >::type __non_iter_node_pointer;
+
+  _LIBCPP_INLINE_VISIBILITY
+  static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) {
+      return __p;
+  }
+  _LIBCPP_INLINE_VISIBILITY
+  static __iter_node_pointer __as_iter_node(__non_iter_node_pointer __p) {
+      return static_cast<__iter_node_pointer>(static_cast<__void_pointer>(__p));
+  }
+};
 
 template <class _NodePtr>
 struct __forward_begin_node
 {
     typedef _NodePtr pointer;
+    typedef typename __rebind_pointer<_NodePtr, __forward_begin_node>::type __begin_node_pointer;
 
     pointer __next_;
 
-     _LIBCPP_INLINE_VISIBILITY __forward_begin_node() : __next_(nullptr) {}
+    _LIBCPP_INLINE_VISIBILITY __forward_begin_node() : __next_(nullptr) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __begin_node_pointer __next_as_begin() const {
+        return static_cast<__begin_node_pointer>(__next_);
+    }
 };
 
 template <class _Tp, class _VoidPtr>
 struct _LIBCPP_HIDDEN __begin_node_of
 {
-    typedef __forward_begin_node
-        <
-             typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                 rebind<__forward_list_node<_Tp, _VoidPtr> >
-#else
-                 rebind<__forward_list_node<_Tp, _VoidPtr> >::other
-#endif
-         > type;
+    typedef __forward_begin_node<
+        typename __rebind_pointer<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> >::type
+    > type;
 };
 
 template <class _Tp, class _VoidPtr>
@@ -218,49 +265,68 @@ struct __forward_list_node
     value_type __value_;
 };
 
-template<class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS_ONLY forward_list;
+
+template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TYPE_VIS_ONLY forward_list;
 template<class _NodeConstPtr> class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator;
 
 template <class _NodePtr>
 class _LIBCPP_TYPE_VIS_ONLY __forward_list_iterator
 {
-    typedef _NodePtr __node_pointer;
+    typedef __forward_node_traits<_NodePtr>         __traits;
+    typedef typename __traits::__node_pointer       __node_pointer;
+    typedef typename __traits::__begin_node_pointer __begin_node_pointer;
+    typedef typename __traits::__iter_node_pointer  __iter_node_pointer;
+    typedef typename __traits::__void_pointer       __void_pointer;
+
+    __iter_node_pointer __ptr_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __begin_node_pointer __get_begin() const {
+        return static_cast<__begin_node_pointer>(
+                static_cast<__void_pointer>(__ptr_));
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __node_pointer __get_unsafe_node_pointer() const {
+        return static_cast<__node_pointer>(
+                static_cast<__void_pointer>(__ptr_));
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __forward_list_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}
 
-    __node_pointer __ptr_;
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT
+        : __ptr_(__traits::__as_iter_node(__p)) {}
 
     _LIBCPP_INLINE_VISIBILITY
-    explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+    explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT
+        : __ptr_(__traits::__as_iter_node(__p)) {}
 
     template<class, class> friend class _LIBCPP_TYPE_VIS_ONLY forward_list;
     template<class> friend class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator;
 
 public:
     typedef forward_iterator_tag                              iterator_category;
-    typedef typename pointer_traits<__node_pointer>::element_type::value_type
-                                                              value_type;
+    typedef typename __traits::__node_value_type              value_type;
     typedef value_type&                                       reference;
     typedef typename pointer_traits<__node_pointer>::difference_type
                                                               difference_type;
-    typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<value_type>
-#else
-            rebind<value_type>::other
-#endif
-                                                              pointer;
+    typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer;
 
     _LIBCPP_INLINE_VISIBILITY
     __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
 
     _LIBCPP_INLINE_VISIBILITY
-    reference operator*() const {return __ptr_->__value_;}
+    reference operator*() const {return __get_unsafe_node_pointer()->__value_;}
     _LIBCPP_INLINE_VISIBILITY
-    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
+    pointer operator->() const {
+        return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__value_);
+    }
 
     _LIBCPP_INLINE_VISIBILITY
     __forward_list_iterator& operator++()
     {
-        __ptr_ = __ptr_->__next_;
+        __ptr_ = __traits::__as_iter_node(__ptr_->__next_);
         return *this;
     }
     _LIBCPP_INLINE_VISIBILITY
@@ -284,40 +350,49 @@ public:
 template <class _NodeConstPtr>
 class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator
 {
-    typedef _NodeConstPtr __node_const_pointer;
+    static_assert((!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value), "");
+    typedef _NodeConstPtr _NodePtr;
+
+    typedef __forward_node_traits<_NodePtr>         __traits;
+    typedef typename __traits::__node               __node;
+    typedef typename __traits::__node_pointer       __node_pointer;
+    typedef typename __traits::__begin_node_pointer __begin_node_pointer;
+    typedef typename __traits::__iter_node_pointer  __iter_node_pointer;
+    typedef typename __traits::__void_pointer       __void_pointer;
+
+    __iter_node_pointer __ptr_;
 
-    __node_const_pointer __ptr_;
+    __begin_node_pointer __get_begin() const {
+        return static_cast<__begin_node_pointer>(
+                static_cast<__void_pointer>(__ptr_));
+    }
+    __node_pointer __get_unsafe_node_pointer() const {
+        return static_cast<__node_pointer>(
+                static_cast<__void_pointer>(__ptr_));
+    }
 
     _LIBCPP_INLINE_VISIBILITY
-    explicit __forward_list_const_iterator(__node_const_pointer __p) _NOEXCEPT
-        : __ptr_(__p) {}
+    explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT
+        : __ptr_(nullptr) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT
+        : __ptr_(__traits::__as_iter_node(__p)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __forward_list_const_iterator(__node_pointer __p) _NOEXCEPT
+        : __ptr_(__traits::__as_iter_node(__p)) {}
 
-    typedef typename remove_const
-        <
-            typename pointer_traits<__node_const_pointer>::element_type
-        >::type                                               __node;
-    typedef typename pointer_traits<__node_const_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<__node>
-#else
-            rebind<__node>::other
-#endif
-                                                              __node_pointer;
 
     template<class, class> friend class forward_list;
 
 public:
     typedef forward_iterator_tag                              iterator_category;
-    typedef typename __node::value_type                       value_type;
+    typedef typename __traits::__node_value_type              value_type;
     typedef const value_type&                                 reference;
-    typedef typename pointer_traits<__node_const_pointer>::difference_type
+    typedef typename pointer_traits<__node_pointer>::difference_type
                                                               difference_type;
-    typedef typename pointer_traits<__node_const_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const value_type>
-#else
-            rebind<const value_type>::other
-#endif
+    typedef typename __rebind_pointer<__node_pointer, const value_type>::type
                                                               pointer;
 
     _LIBCPP_INLINE_VISIBILITY
@@ -327,14 +402,15 @@ public:
         : __ptr_(__p.__ptr_) {}
 
     _LIBCPP_INLINE_VISIBILITY
-    reference operator*() const {return __ptr_->__value_;}
+    reference operator*() const {return __get_unsafe_node_pointer()->__value_;}
     _LIBCPP_INLINE_VISIBILITY
-    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
+    pointer operator->() const {return pointer_traits<pointer>::pointer_to(
+                __get_unsafe_node_pointer()->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
     __forward_list_const_iterator& operator++()
     {
-        __ptr_ = __ptr_->__next_;
+        __ptr_ = __traits::__as_iter_node(__ptr_->__next_);
         return *this;
     }
     _LIBCPP_INLINE_VISIBILITY
@@ -365,36 +441,24 @@ protected:
     typedef typename allocator_traits<allocator_type>::void_pointer  void_pointer;
     typedef __forward_list_node<value_type, void_pointer>            __node;
     typedef typename __begin_node_of<value_type, void_pointer>::type __begin_node;
-    typedef typename allocator_traits<allocator_type>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<__node>
-#else
-                rebind_alloc<__node>::other
-#endif
-                                                      __node_allocator;
+    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __node>::type __node_allocator;
     typedef allocator_traits<__node_allocator>        __node_traits;
     typedef typename __node_traits::pointer           __node_pointer;
-    typedef typename __node_traits::pointer           __node_const_pointer;
 
-    typedef typename allocator_traits<allocator_type>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<__begin_node>
-#else
-                rebind_alloc<__begin_node>::other
-#endif
-                                                      __begin_node_allocator;
-    typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer;
+    typedef typename __rebind_alloc_helper<
+        allocator_traits<allocator_type>, __begin_node
+    >::type                                           __begin_node_allocator;
+    typedef typename allocator_traits<__begin_node_allocator>::pointer
+                                                      __begin_node_pointer;
 
     __compressed_pair<__begin_node, __node_allocator> __before_begin_;
 
     _LIBCPP_INLINE_VISIBILITY
-    __node_pointer        __before_begin() _NOEXCEPT
-        {return static_cast<__node_pointer>(pointer_traits<__begin_node_pointer>::
-                                        pointer_to(__before_begin_.first()));}
+    __begin_node_pointer        __before_begin() _NOEXCEPT
+        {return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_.first());}
     _LIBCPP_INLINE_VISIBILITY
-    __node_const_pointer  __before_begin() const _NOEXCEPT
-        {return static_cast<__node_const_pointer>(pointer_traits<__begin_node_pointer>::
-                                        pointer_to(const_cast<__begin_node&>(__before_begin_.first())));}
+    __begin_node_pointer __before_begin() const _NOEXCEPT
+        {return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_.first()));}
 
     _LIBCPP_INLINE_VISIBILITY
           __node_allocator& __alloc() _NOEXCEPT
@@ -416,8 +480,10 @@ protected:
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 public:
+    _LIBCPP_INLINE_VISIBILITY
     __forward_list_base(__forward_list_base&& __x)
         _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
+    _LIBCPP_INLINE_VISIBILITY
     __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
@@ -442,9 +508,14 @@ protected:
               __node_traits::propagate_on_container_move_assignment::value>());}
 
 public:
+    _LIBCPP_INLINE_VISIBILITY
     void swap(__forward_list_base& __x)
-        _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<__node_allocator>::value);
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT;
+#else
+        _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value || 
+                    __is_nothrow_swappable<__node_allocator>::value);
+#endif
 protected:
     void clear() _NOEXCEPT;
 
@@ -466,32 +537,12 @@ private:
     void __move_assign_alloc(__forward_list_base& __x, true_type)
         _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
         {__alloc() = _VSTD::move(__x.__alloc());}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y)
-        _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<__node_allocator>::value)
-        {__swap_alloc(__x, __y, integral_constant<bool,
-                         __node_traits::propagate_on_container_swap::value>());}
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y,
-                                                                     false_type)
-        _NOEXCEPT
-        {}
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y,
-                                                                      true_type)
-        _NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value)
-        {
-            using _VSTD::swap;
-            swap(__x, __y);
-        }
 };
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x)
         _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
     : __before_begin_(_VSTD::move(__x.__before_begin_))
@@ -500,7 +551,7 @@ __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x,
                                                       const allocator_type& __a)
     : __before_begin_(__begin_node(), __node_allocator(__a))
@@ -521,13 +572,18 @@ __forward_list_base<_Tp, _Alloc>::~__forward_list_base()
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
-        _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<__node_allocator>::value)
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT
+#else
+        _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value || 
+                    __is_nothrow_swappable<__node_allocator>::value)
+#endif
 {
-    __swap_alloc(__alloc(), __x.__alloc());
+    __swap_allocator(__alloc(), __x.__alloc(), 
+            integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
     using _VSTD::swap;
     swap(__before_begin()->__next_, __x.__before_begin()->__next_);
 }
@@ -547,20 +603,24 @@ __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT
     __before_begin()->__next_ = nullptr;
 }
 
-template <class _Tp, class _Alloc = allocator<_Tp> >
+template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
 class _LIBCPP_TYPE_VIS_ONLY forward_list
     : private __forward_list_base<_Tp, _Alloc>
 {
     typedef __forward_list_base<_Tp, _Alloc> base;
     typedef typename base::__node_allocator  __node_allocator;
-    typedef typename base::__node            __node;
-    typedef typename base::__node_traits     __node_traits;
-    typedef typename base::__node_pointer    __node_pointer;
+    typedef typename base::__node               __node;
+    typedef typename base::__node_traits        __node_traits;
+    typedef typename base::__node_pointer       __node_pointer;
+    typedef typename base::__begin_node_pointer __begin_node_pointer;
 
 public:
     typedef _Tp    value_type;
     typedef _Alloc allocator_type;
 
+    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+                  "Allocator::value_type must be same type as value_type");
+
     typedef value_type&                                                reference;
     typedef const value_type&                                          const_reference;
     typedef typename allocator_traits<allocator_type>::pointer         pointer;
@@ -575,6 +635,7 @@ public:
     forward_list()
         _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
         {} // = default;
+    _LIBCPP_INLINE_VISIBILITY
     explicit forward_list(const allocator_type& __a);
     explicit forward_list(size_type __n);
 #if _LIBCPP_STD_VER > 11
@@ -611,12 +672,14 @@ public:
 
     forward_list& operator=(const forward_list& __x);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     forward_list& operator=(forward_list&& __x)
         _NOEXCEPT_(
              __node_traits::propagate_on_container_move_assignment::value &&
              is_nothrow_move_assignable<allocator_type>::value);
 #endif
 #ifndef  _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
     forward_list& operator=(initializer_list<value_type> __il);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
@@ -629,6 +692,7 @@ public:
         assign(_InputIterator __f, _InputIterator __l);
     void assign(size_type __n, const value_type& __v);
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
     void assign(initializer_list<value_type> __il);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
@@ -715,8 +779,12 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     void swap(forward_list& __x)
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT
+#else
         _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
                    __is_nothrow_swappable<__node_allocator>::value)
+#endif
         {base::swap(__x);}
 
     void resize(size_type __n);
@@ -755,7 +823,7 @@ public:
     template <class _Compare> void merge(forward_list& __x, _Compare __comp);
     _LIBCPP_INLINE_VISIBILITY
     void sort() {sort(__less<value_type>());}
-    template <class _Compare> void sort(_Compare __comp);
+    template <class _Compare> _LIBCPP_INLINE_VISIBILITY void sort(_Compare __comp);
     void reverse() _NOEXCEPT;
 
 private:
@@ -778,7 +846,7 @@ private:
 };
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a)
     : base(__a)
 {
@@ -792,8 +860,8 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n)
         __node_allocator& __a = base::__alloc();
         typedef __allocator_destructor<__node_allocator> _Dp;
         unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
-        for (__node_pointer __p = base::__before_begin(); __n > 0; --__n,
-                                                             __p = __p->__next_)
+        for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n,
+                                                             __p = __p->__next_as_begin())
         {
             __h.reset(__node_traits::allocate(__a, 1));
             __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
@@ -813,8 +881,8 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a
         __node_allocator& __a = base::__alloc();
         typedef __allocator_destructor<__node_allocator> _Dp;
         unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
-        for (__node_pointer __p = base::__before_begin(); __n > 0; --__n,
-                                                             __p = __p->__next_)
+        for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n,
+                                                             __p = __p->__next_as_begin())
         {
             __h.reset(__node_traits::allocate(__a, 1));
             __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
@@ -952,7 +1020,7 @@ forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 forward_list<_Tp, _Alloc>&
 forward_list<_Tp, _Alloc>::operator=(forward_list&& __x)
     _NOEXCEPT_(
@@ -969,7 +1037,7 @@ forward_list<_Tp, _Alloc>::operator=(forward_list&& __x)
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 forward_list<_Tp, _Alloc>&
 forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
 {
@@ -991,7 +1059,7 @@ forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)
     iterator __i = before_begin();
     iterator __j = _VSTD::next(__i);
     iterator __e = end();
-    for (; __j != __e && __f != __l; ++__i, ++__j, ++__f)
+    for (; __j != __e && __f != __l; ++__i, (void) ++__j, ++__f)
         *__j = *__f;
     if (__j == __e)
         insert_after(__i, __f, __l);
@@ -1017,7 +1085,7 @@ forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v)
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il)
 {
@@ -1090,7 +1158,7 @@ template <class... _Args>
 typename forward_list<_Tp, _Alloc>::iterator
 forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args)
 {
-    __node_pointer const __r = __p.__ptr_;
+    __begin_node_pointer const __r = __p.__get_begin();
     __node_allocator& __a = base::__alloc();
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
@@ -1107,7 +1175,7 @@ template <class _Tp, class _Alloc>
 typename forward_list<_Tp, _Alloc>::iterator
 forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v)
 {
-    __node_pointer const __r = __p.__ptr_;
+    __begin_node_pointer const __r = __p.__get_begin();
     __node_allocator& __a = base::__alloc();
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
@@ -1123,7 +1191,7 @@ template <class _Tp, class _Alloc>
 typename forward_list<_Tp, _Alloc>::iterator
 forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v)
 {
-    __node_pointer const __r = __p.__ptr_;
+    __begin_node_pointer const __r = __p.__get_begin();
     __node_allocator& __a = base::__alloc();
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
@@ -1138,7 +1206,7 @@ typename forward_list<_Tp, _Alloc>::iterator
 forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
                                         const value_type& __v)
 {
-    __node_pointer __r = __p.__ptr_;
+    __begin_node_pointer __r = __p.__get_begin();
     if (__n > 0)
     {
         __node_allocator& __a = base::__alloc();
@@ -1173,7 +1241,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
 #endif  // _LIBCPP_NO_EXCEPTIONS
         __last->__next_ = __r->__next_;
         __r->__next_ = __first;
-        __r = __last;
+        __r = static_cast<__begin_node_pointer>(__last);
     }
     return iterator(__r);
 }
@@ -1188,7 +1256,7 @@ typename enable_if
 forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
                                         _InputIterator __f, _InputIterator __l)
 {
-    __node_pointer __r = __p.__ptr_;
+    __begin_node_pointer __r = __p.__get_begin();
     if (__f != __l)
     {
         __node_allocator& __a = base::__alloc();
@@ -1201,7 +1269,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
         try
         {
 #endif  // _LIBCPP_NO_EXCEPTIONS
-            for (++__f; __f != __l; ++__f, __last = __last->__next_)
+            for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_)))
             {
                 __h.reset(__node_traits::allocate(__a, 1));
                 __node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f);
@@ -1223,7 +1291,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
 #endif  // _LIBCPP_NO_EXCEPTIONS
         __last->__next_ = __r->__next_;
         __r->__next_ = __first;
-        __r = __last;
+        __r = static_cast<__begin_node_pointer>(__last);
     }
     return iterator(__r);
 }
@@ -1232,7 +1300,7 @@ template <class _Tp, class _Alloc>
 typename forward_list<_Tp, _Alloc>::iterator
 forward_list<_Tp, _Alloc>::erase_after(const_iterator __f)
 {
-    __node_pointer __p = __f.__ptr_;
+    __begin_node_pointer __p = __f.__get_begin();
     __node_pointer __n = __p->__next_;
     __p->__next_ = __n->__next_;
     __node_allocator& __a = base::__alloc();
@@ -1245,21 +1313,22 @@ template <class _Tp, class _Alloc>
 typename forward_list<_Tp, _Alloc>::iterator
 forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l)
 {
-    __node_pointer __e = __l.__ptr_;
+    __node_pointer __e = __l.__get_unsafe_node_pointer();
     if (__f != __l)
     {
-        __node_pointer __p = __f.__ptr_;
-        __node_pointer __n = __p->__next_;
+        __begin_node_pointer __bp = __f.__get_begin();
+
+        __node_pointer __n = __bp->__next_;
         if (__n != __e)
         {
-            __p->__next_ = __e;
+            __bp->__next_ = __e;
             __node_allocator& __a = base::__alloc();
             do
             {
-                __p = __n->__next_;
+                __node_pointer __tmp = __n->__next_;
                 __node_traits::destroy(__a, _VSTD::addressof(__n->__value_));
                 __node_traits::deallocate(__a, __n, 1);
-                __n = __p;
+                __n = __tmp;
             } while (__n != __e);
         }
     }
@@ -1286,8 +1355,8 @@ forward_list<_Tp, _Alloc>::resize(size_type __n)
             __node_allocator& __a = base::__alloc();
             typedef __allocator_destructor<__node_allocator> _Dp;
             unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
-            for (__node_pointer __ptr = __p.__ptr_; __n > 0; --__n,
-                                                         __ptr = __ptr->__next_)
+            for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n,
+                                                         __ptr = __ptr->__next_as_begin())
             {
                 __h.reset(__node_traits::allocate(__a, 1));
                 __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
@@ -1318,8 +1387,8 @@ forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v)
             __node_allocator& __a = base::__alloc();
             typedef __allocator_destructor<__node_allocator> _Dp;
             unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
-            for (__node_pointer __ptr = __p.__ptr_; __n > 0; --__n,
-                                                         __ptr = __ptr->__next_)
+            for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n,
+                                                         __ptr = __ptr->__next_as_begin())
             {
                 __h.reset(__node_traits::allocate(__a, 1));
                 __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
@@ -1337,14 +1406,14 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
 {
     if (!__x.empty())
     {
-        if (__p.__ptr_->__next_ != nullptr)
+        if (__p.__get_begin()->__next_ != nullptr)
         {
             const_iterator __lm1 = __x.before_begin();
-            while (__lm1.__ptr_->__next_ != nullptr)
+            while (__lm1.__get_begin()->__next_ != nullptr)
                 ++__lm1;
-            __lm1.__ptr_->__next_ = __p.__ptr_->__next_;
+            __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
         }
-        __p.__ptr_->__next_ = __x.__before_begin()->__next_;
+        __p.__get_begin()->__next_ = __x.__before_begin()->__next_;
         __x.__before_begin()->__next_ = nullptr;
     }
 }
@@ -1358,9 +1427,9 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
     const_iterator __lm1 = _VSTD::next(__i);
     if (__p != __i && __p != __lm1)
     {
-        __i.__ptr_->__next_ = __lm1.__ptr_->__next_;
-        __lm1.__ptr_->__next_ = __p.__ptr_->__next_;
-        __p.__ptr_->__next_ = __lm1.__ptr_;
+        __i.__get_begin()->__next_ = __lm1.__get_begin()->__next_;
+        __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
+        __p.__get_begin()->__next_ = __lm1.__get_unsafe_node_pointer();
     }
 }
 
@@ -1373,13 +1442,13 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
     if (__f != __l && __p != __f)
     {
         const_iterator __lm1 = __f;
-        while (__lm1.__ptr_->__next_ != __l.__ptr_)
+        while (__lm1.__get_begin()->__next_ != __l.__get_begin())
             ++__lm1;
         if (__f != __lm1)
         {
-            __lm1.__ptr_->__next_ = __p.__ptr_->__next_;
-            __p.__ptr_->__next_ = __f.__ptr_->__next_;
-            __f.__ptr_->__next_ = __l.__ptr_;
+            __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
+            __p.__get_begin()->__next_ = __f.__get_begin()->__next_;
+            __f.__get_begin()->__next_ = __l.__get_unsafe_node_pointer();
         }
     }
 }
@@ -1423,14 +1492,14 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v)
 {
     forward_list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing
     iterator __e = end();
-    for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;)
+    for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
     {
-        if (__i.__ptr_->__next_->__value_ == __v)
+        if (__i.__get_begin()->__next_->__value_ == __v)
         {
             iterator __j = _VSTD::next(__i, 2);
             for (; __j != __e && *__j == __v; ++__j)
                 ;
-			__deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
+            __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
             if (__j == __e)
                 break;
             __i = __j;
@@ -1446,9 +1515,9 @@ void
 forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred)
 {
     iterator __e = end();
-    for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;)
+    for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
     {
-        if (__pred(__i.__ptr_->__next_->__value_))
+        if (__pred(__i.__get_begin()->__next_->__value_))
         {
             iterator __j = _VSTD::next(__i, 2);
             for (; __j != __e && __pred(*__j); ++__j)
@@ -1473,7 +1542,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)
         iterator __j = _VSTD::next(__i);
         for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
             ;
-        if (__i.__ptr_->__next_ != __j.__ptr_)
+        if (__i.__get_begin()->__next_ != __j.__get_unsafe_node_pointer())
             erase_after(__i, __j);
         __i = __j;
     }
@@ -1540,7 +1609,7 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2,
 
 template <class _Tp, class _Alloc>
 template <class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 forward_list<_Tp, _Alloc>::sort(_Compare __comp)
 {
@@ -1571,7 +1640,7 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz,
     }
     difference_type __sz1 = __sz / 2;
     difference_type __sz2 = __sz - __sz1;
-    __node_pointer __t = _VSTD::next(iterator(__f1), __sz1 - 1).__ptr_;
+    __node_pointer __t = _VSTD::next(iterator(__f1), __sz1 - 1).__get_unsafe_node_pointer();
     __node_pointer __f2 = __t->__next_;
     __t->__next_ = nullptr;
     return __merge(__sort(__f1, __sz1, __comp),
diff --git a/system/include/libcxx/fstream b/system/include/libcxx/fstream
index 38778c6779aa4..d51da45d874c5 100644
--- a/system/include/libcxx/fstream
+++ b/system/include/libcxx/fstream
@@ -200,14 +200,19 @@ public:
 
     // 27.9.1.3 Assign/swap:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     basic_filebuf& operator=(basic_filebuf&& __rhs);
 #endif
     void swap(basic_filebuf& __rhs);
 
     // 27.9.1.4 Members:
+    _LIBCPP_INLINE_VISIBILITY
     bool is_open() const;
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
     basic_filebuf* open(const char* __s, ios_base::openmode __mode);
+    _LIBCPP_INLINE_VISIBILITY
     basic_filebuf* open(const string& __s, ios_base::openmode __mode);
+#endif
     basic_filebuf* close();
 
 protected:
@@ -338,7 +343,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_filebuf<_CharT, _Traits>&
 basic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs)
 {
@@ -456,13 +461,14 @@ swap(basic_filebuf<_CharT, _Traits>& __x, basic_filebuf<_CharT, _Traits>& __y)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 basic_filebuf<_CharT, _Traits>::is_open() const
 {
     return __file_ != 0;
 }
 
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 template <class _CharT, class _Traits>
 basic_filebuf<_CharT, _Traits>*
 basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
@@ -544,12 +550,13 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_filebuf<_CharT, _Traits>*
 basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
 {
     return open(__s.c_str(), __mode);
 }
+#endif
 
 template <class _CharT, class _Traits>
 basic_filebuf<_CharT, _Traits>*
@@ -807,7 +814,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
     default:
         return pos_type(off_type(-1));
     }
-#if _WIN32
+#if defined(_WIN32) || defined(_NEWLIB_VERSION)
     if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
         return pos_type(off_type(-1));
     pos_type __r = ftell(__file_);
@@ -826,7 +833,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
 {
     if (__file_ == 0 || sync())
         return pos_type(off_type(-1));
-#if _WIN32
+#if defined(_WIN32) || defined(_NEWLIB_VERSION)
     if (fseek(__file_, __sp, SEEK_SET))
         return pos_type(off_type(-1));
 #else
@@ -891,7 +898,7 @@ basic_filebuf<_CharT, _Traits>::sync()
                 }
             }
         }
-#if _WIN32
+#if defined(_WIN32) || defined(_NEWLIB_VERSION)
         if (fseek(__file_, -__c, SEEK_CUR))
             return -1;
 #else
@@ -1004,22 +1011,35 @@ public:
     typedef typename traits_type::pos_type pos_type;
     typedef typename traits_type::off_type off_type;
 
+    _LIBCPP_INLINE_VISIBILITY
     basic_ifstream();
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+    _LIBCPP_INLINE_VISIBILITY
     explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
+    _LIBCPP_INLINE_VISIBILITY
     explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
+#endif
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     basic_ifstream(basic_ifstream&& __rhs);
 #endif
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     basic_ifstream& operator=(basic_ifstream&& __rhs);
 #endif
+    _LIBCPP_INLINE_VISIBILITY
     void swap(basic_ifstream& __rhs);
 
+    _LIBCPP_INLINE_VISIBILITY
     basic_filebuf<char_type, traits_type>* rdbuf() const;
+    _LIBCPP_INLINE_VISIBILITY
     bool is_open() const;
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
     void open(const char* __s, ios_base::openmode __mode = ios_base::in);
     void open(const string& __s, ios_base::openmode __mode = ios_base::in);
+#endif
+    _LIBCPP_INLINE_VISIBILITY
     void close();
 
 private:
@@ -1027,14 +1047,15 @@ private:
 };
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ifstream<_CharT, _Traits>::basic_ifstream()
     : basic_istream<char_type, traits_type>(&__sb_)
 {
 }
 
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
     : basic_istream<char_type, traits_type>(&__sb_)
 {
@@ -1043,18 +1064,19 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openm
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
     : basic_istream<char_type, traits_type>(&__sb_)
 {
     if (__sb_.open(__s, __mode | ios_base::in) == 0)
         this->setstate(ios_base::failbit);
 }
+#endif
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
     : basic_istream<char_type, traits_type>(_VSTD::move(__rhs)),
       __sb_(_VSTD::move(__rhs.__sb_))
@@ -1063,7 +1085,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ifstream<_CharT, _Traits>&
 basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
 {
@@ -1075,7 +1097,7 @@ basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_ifstream<_CharT, _Traits>::swap(basic_ifstream& __rhs)
 {
@@ -1092,7 +1114,7 @@ swap(basic_ifstream<_CharT, _Traits>& __x, basic_ifstream<_CharT, _Traits>& __y)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_filebuf<_CharT, _Traits>*
 basic_ifstream<_CharT, _Traits>::rdbuf() const
 {
@@ -1100,13 +1122,14 @@ basic_ifstream<_CharT, _Traits>::rdbuf() const
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 basic_ifstream<_CharT, _Traits>::is_open() const
 {
     return __sb_.is_open();
 }
 
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 template <class _CharT, class _Traits>
 void
 basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
@@ -1126,9 +1149,10 @@ basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo
     else
         this->setstate(ios_base::failbit);
 }
+#endif
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_ifstream<_CharT, _Traits>::close()
 {
@@ -1149,22 +1173,33 @@ public:
     typedef typename traits_type::pos_type pos_type;
     typedef typename traits_type::off_type off_type;
 
+    _LIBCPP_INLINE_VISIBILITY
     basic_ofstream();
+    _LIBCPP_INLINE_VISIBILITY
     explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
+    _LIBCPP_INLINE_VISIBILITY
     explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     basic_ofstream(basic_ofstream&& __rhs);
 #endif
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     basic_ofstream& operator=(basic_ofstream&& __rhs);
 #endif
+    _LIBCPP_INLINE_VISIBILITY
     void swap(basic_ofstream& __rhs);
 
+    _LIBCPP_INLINE_VISIBILITY
     basic_filebuf<char_type, traits_type>* rdbuf() const;
+    _LIBCPP_INLINE_VISIBILITY
     bool is_open() const;
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
     void open(const char* __s, ios_base::openmode __mode = ios_base::out);
     void open(const string& __s, ios_base::openmode __mode = ios_base::out);
+#endif
+    _LIBCPP_INLINE_VISIBILITY
     void close();
 
 private:
@@ -1172,14 +1207,15 @@ private:
 };
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ofstream<_CharT, _Traits>::basic_ofstream()
     : basic_ostream<char_type, traits_type>(&__sb_)
 {
 }
 
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
     : basic_ostream<char_type, traits_type>(&__sb_)
 {
@@ -1188,18 +1224,19 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openm
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
     : basic_ostream<char_type, traits_type>(&__sb_)
 {
     if (__sb_.open(__s, __mode | ios_base::out) == 0)
         this->setstate(ios_base::failbit);
 }
+#endif
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
     : basic_ostream<char_type, traits_type>(_VSTD::move(__rhs)),
       __sb_(_VSTD::move(__rhs.__sb_))
@@ -1208,7 +1245,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ofstream<_CharT, _Traits>&
 basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
 {
@@ -1220,7 +1257,7 @@ basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_ofstream<_CharT, _Traits>::swap(basic_ofstream& __rhs)
 {
@@ -1237,7 +1274,7 @@ swap(basic_ofstream<_CharT, _Traits>& __x, basic_ofstream<_CharT, _Traits>& __y)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_filebuf<_CharT, _Traits>*
 basic_ofstream<_CharT, _Traits>::rdbuf() const
 {
@@ -1245,13 +1282,14 @@ basic_ofstream<_CharT, _Traits>::rdbuf() const
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 basic_ofstream<_CharT, _Traits>::is_open() const
 {
     return __sb_.is_open();
 }
 
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 template <class _CharT, class _Traits>
 void
 basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
@@ -1271,9 +1309,10 @@ basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo
     else
         this->setstate(ios_base::failbit);
 }
+#endif
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_ofstream<_CharT, _Traits>::close()
 {
@@ -1294,22 +1333,35 @@ public:
     typedef typename traits_type::pos_type pos_type;
     typedef typename traits_type::off_type off_type;
 
+    _LIBCPP_INLINE_VISIBILITY
     basic_fstream();
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+    _LIBCPP_INLINE_VISIBILITY
     explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+    _LIBCPP_INLINE_VISIBILITY
     explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+#endif
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     basic_fstream(basic_fstream&& __rhs);
 #endif
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     basic_fstream& operator=(basic_fstream&& __rhs);
 #endif
+    _LIBCPP_INLINE_VISIBILITY
     void swap(basic_fstream& __rhs);
 
+    _LIBCPP_INLINE_VISIBILITY
     basic_filebuf<char_type, traits_type>* rdbuf() const;
+    _LIBCPP_INLINE_VISIBILITY
     bool is_open() const;
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
     void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
     void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+#endif
+    _LIBCPP_INLINE_VISIBILITY
     void close();
 
 private:
@@ -1317,14 +1369,15 @@ private:
 };
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_fstream<_CharT, _Traits>::basic_fstream()
     : basic_iostream<char_type, traits_type>(&__sb_)
 {
 }
 
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
     : basic_iostream<char_type, traits_type>(&__sb_)
 {
@@ -1333,18 +1386,19 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmod
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
     : basic_iostream<char_type, traits_type>(&__sb_)
 {
     if (__sb_.open(__s, __mode) == 0)
         this->setstate(ios_base::failbit);
 }
+#endif
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
     : basic_iostream<char_type, traits_type>(_VSTD::move(__rhs)),
       __sb_(_VSTD::move(__rhs.__sb_))
@@ -1353,7 +1407,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_fstream<_CharT, _Traits>&
 basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
 {
@@ -1365,7 +1419,7 @@ basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_fstream<_CharT, _Traits>::swap(basic_fstream& __rhs)
 {
@@ -1382,7 +1436,7 @@ swap(basic_fstream<_CharT, _Traits>& __x, basic_fstream<_CharT, _Traits>& __y)
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_filebuf<_CharT, _Traits>*
 basic_fstream<_CharT, _Traits>::rdbuf() const
 {
@@ -1390,13 +1444,14 @@ basic_fstream<_CharT, _Traits>::rdbuf() const
 }
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bool
 basic_fstream<_CharT, _Traits>::is_open() const
 {
     return __sb_.is_open();
 }
 
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 template <class _CharT, class _Traits>
 void
 basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
@@ -1416,9 +1471,10 @@ basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mod
     else
         this->setstate(ios_base::failbit);
 }
+#endif
 
 template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_fstream<_CharT, _Traits>::close()
 {
diff --git a/system/include/libcxx/functional b/system/include/libcxx/functional
index 416a9a97f71e1..4fcd4b5a7aca5 100644
--- a/system/include/libcxx/functional
+++ b/system/include/libcxx/functional
@@ -407,7 +407,7 @@ public:
     // function modifiers:
     void swap(function&) noexcept;
     template<class F, class Alloc>
-      void assign(F&&, const Alloc&);
+      void assign(F&&, const Alloc&);                 // Removed in C++17
 
     // function capacity:
     explicit operator bool() const noexcept;
@@ -504,7 +504,9 @@ struct _LIBCPP_TYPE_VIS_ONLY plus<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -529,7 +531,9 @@ struct _LIBCPP_TYPE_VIS_ONLY minus<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -554,7 +558,9 @@ struct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -579,7 +585,9 @@ struct _LIBCPP_TYPE_VIS_ONLY divides<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -604,7 +612,9 @@ struct _LIBCPP_TYPE_VIS_ONLY modulus<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -629,7 +639,9 @@ struct _LIBCPP_TYPE_VIS_ONLY negate<void>
     template <class _Tp>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_Tp&& __x) const
-        { return -_VSTD::forward<_Tp>(__x); }
+    _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
+    -> decltype        (- _VSTD::forward<_Tp>(__x))
+        { return        - _VSTD::forward<_Tp>(__x); }
     typedef void is_transparent;
 };
 #endif
@@ -654,7 +666,9 @@ struct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -679,7 +693,9 @@ struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -704,7 +720,9 @@ struct _LIBCPP_TYPE_VIS_ONLY greater<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -731,7 +749,9 @@ struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -756,7 +776,9 @@ struct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -781,7 +803,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -806,7 +830,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -831,7 +857,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
     template <class _Tp>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_Tp&& __x) const
-        { return !_VSTD::forward<_Tp>(__x); }
+    _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
+    -> decltype        (!_VSTD::forward<_Tp>(__x))
+        { return        !_VSTD::forward<_Tp>(__x); }
     typedef void is_transparent;
 };
 #endif
@@ -856,7 +884,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -881,7 +911,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -906,7 +938,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
     template <class _T1, class _T2>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_T1&& __t, _T2&& __u) const
-        { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
+    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
+    -> decltype        (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
+        { return        _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
     typedef void is_transparent;
 };
 #endif
@@ -927,7 +961,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
     template <class _Tp>
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     auto operator()(_Tp&& __x) const
-        { return ~_VSTD::forward<_Tp>(__x); }
+    _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
+    -> decltype        (~_VSTD::forward<_Tp>(__x))
+        { return        ~_VSTD::forward<_Tp>(__x); }
     typedef void is_transparent;
 };
 #endif
@@ -1198,11 +1234,9 @@ const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
 mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
     {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
 
-#ifdef _LIBCPP_HAS_NO_VARIADICS
-
-#include <__functional_03>
-
-#else  // _LIBCPP_HAS_NO_VARIADICS
+////////////////////////////////////////////////////////////////////////////////
+//                                MEMFUN
+//==============================================================================
 
 template <class _Tp>
 class __mem_fn
@@ -1215,26 +1249,130 @@ private:
     type __f_;
 
 public:
-    _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}
+    _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
 
+#ifndef _LIBCPP_HAS_NO_VARIADICS
     // invoke
     template <class... _ArgTypes>
-       _LIBCPP_INLINE_VISIBILITY
-       typename __invoke_return<type, _ArgTypes...>::type
-          operator() (_ArgTypes&&... __args) const
-          {
-              return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
-          }
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return<type, _ArgTypes...>::type
+    operator() (_ArgTypes&&... __args) const {
+        return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
+    }
+#else
+
+    template <class _A0>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return0<type, _A0>::type
+    operator() (_A0& __a0) const {
+        return __invoke(__f_, __a0);
+    }
+
+    template <class _A0>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return0<type, _A0 const>::type
+    operator() (_A0 const& __a0) const {
+        return __invoke(__f_, __a0);
+    }
+
+    template <class _A0, class _A1>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return1<type, _A0, _A1>::type
+    operator() (_A0& __a0, _A1& __a1) const {
+        return __invoke(__f_, __a0, __a1);
+    }
+
+    template <class _A0, class _A1>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return1<type, _A0 const, _A1>::type
+    operator() (_A0 const& __a0, _A1& __a1) const {
+        return __invoke(__f_, __a0, __a1);
+    }
+
+    template <class _A0, class _A1>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return1<type, _A0, _A1 const>::type
+    operator() (_A0& __a0, _A1 const& __a1) const {
+        return __invoke(__f_, __a0, __a1);
+    }
+
+    template <class _A0, class _A1>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return1<type, _A0 const, _A1 const>::type
+    operator() (_A0 const& __a0, _A1 const& __a1) const {
+        return __invoke(__f_, __a0, __a1);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0, _A1, _A2>::type
+    operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
+        return __invoke(__f_, __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0 const, _A1, _A2>::type
+    operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
+        return __invoke(__f_, __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0, _A1 const, _A2>::type
+    operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
+        return __invoke(__f_, __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0, _A1, _A2 const>::type
+    operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
+        return __invoke(__f_, __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
+    operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
+        return __invoke(__f_, __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
+    operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
+        return __invoke(__f_, __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
+    operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
+        return __invoke(__f_, __a0, __a1, __a2);
+    }
+
+    template <class _A0, class _A1, class _A2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
+    operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
+        return __invoke(__f_, __a0, __a1, __a2);
+    }
+#endif
 };
 
 template<class _Rp, class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
 __mem_fn<_Rp _Tp::*>
-mem_fn(_Rp _Tp::* __pm)
+mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
 {
     return __mem_fn<_Rp _Tp::*>(__pm);
 }
 
+////////////////////////////////////////////////////////////////////////////////
+//                                FUNCTION
+//==============================================================================
+
 // bad_function_call
 
 class _LIBCPP_EXCEPTION_ABI bad_function_call
@@ -1247,7 +1385,7 @@ template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
 namespace __function
 {
 
-template<class _Rp, class ..._ArgTypes>
+template<class _Rp>
 struct __maybe_derive_from_unary_function
 {
 };
@@ -1258,7 +1396,7 @@ struct __maybe_derive_from_unary_function<_Rp(_A1)>
 {
 };
 
-template<class _Rp, class ..._ArgTypes>
+template<class _Rp>
 struct __maybe_derive_from_binary_function
 {
 };
@@ -1269,6 +1407,28 @@ struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
 {
 };
 
+template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(_Fp const&) { return true; }
+
+template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(_Fp* __ptr) { return __ptr; }
+
+template <class _Ret, class _Class>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(_Ret _Class::*__ptr) { return __ptr; }
+
+template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(function<_Fp> const& __f) { return !!__f; }
+
+} // namespace __function
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+namespace __function {
+
 template<class _Fp> class __base;
 
 template<class _Rp, class ..._ArgTypes>
@@ -1331,7 +1491,8 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
 __base<_Rp(_ArgTypes...)>*
 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     typedef __allocator_destructor<_Ap> _Dp;
     unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1357,7 +1518,8 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
 void
 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
 {
-    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
     _Ap __a(__f_.second());
     __f_.~__compressed_pair<_Fp, _Alloc>();
     __a.deallocate(this, 1);
@@ -1367,7 +1529,8 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
 _Rp
 __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
 {
-    return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
+    typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+    return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
 }
 
 #ifndef _LIBCPP_NO_RTTI
@@ -1401,27 +1564,9 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
     typename aligned_storage<3*sizeof(void*)>::type __buf_;
     __base* __f_;
 
-    template <class _Fp>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const _Fp&) {return true;}
-    template <class _R2, class ..._Ap>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;}
-    template <class _R2, class _Cp, class ..._Ap>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;}
-    template <class _R2, class _Cp, class ..._Ap>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;}
-    template <class _R2, class _Cp, class ..._Ap>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;}
-    template <class _R2, class _Cp, class ..._Ap>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;}
-    template <class _R2, class ..._Ap>
-        _LIBCPP_INLINE_VISIBILITY
-        static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;}
+    _LIBCPP_NO_CFI static __base *__as_base(void *p) {
+      return reinterpret_cast<__base*>(p);
+    }
 
     template <class _Fp, bool = !is_same<_Fp, function>::value &&
                                 __invokable<_Fp&, _ArgTypes...>::value>
@@ -1429,7 +1574,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
     template <class _Fp>
         struct __callable<_Fp, true>
         {
-            static const bool value =
+            static const bool value = is_same<void, _Rp>::value ||
                 is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
                                _Rp>::value;
         };
@@ -1485,10 +1630,13 @@ public:
 
     // function modifiers:
     void swap(function&) _NOEXCEPT;
+
+#if _LIBCPP_STD_VER <= 14
     template<class _Fp, class _Alloc>
       _LIBCPP_INLINE_VISIBILITY
       void assign(_Fp&& __f, const _Alloc& __a)
         {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
+#endif
 
     // function capacity:
     _LIBCPP_INLINE_VISIBILITY
@@ -1516,9 +1664,9 @@ function<_Rp(_ArgTypes...)>::function(const function& __f)
 {
     if (__f.__f_ == 0)
         __f_ = 0;
-    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    else if ((void *)__f.__f_ == &__f.__buf_)
     {
-        __f_ = (__base*)&__buf_;
+        __f_ = __as_base(&__buf_);
         __f.__f_->__clone(__f_);
     }
     else
@@ -1532,9 +1680,9 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
 {
     if (__f.__f_ == 0)
         __f_ = 0;
-    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    else if ((void *)__f.__f_ == &__f.__buf_)
     {
-        __f_ = (__base*)&__buf_;
+        __f_ = __as_base(&__buf_);
         __f.__f_->__clone(__f_);
     }
     else
@@ -1546,9 +1694,9 @@ function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
 {
     if (__f.__f_ == 0)
         __f_ = 0;
-    else if (__f.__f_ == (__base*)&__f.__buf_)
+    else if ((void *)__f.__f_ == &__f.__buf_)
     {
-        __f_ = (__base*)&__buf_;
+        __f_ = __as_base(&__buf_);
         __f.__f_->__clone(__f_);
     }
     else
@@ -1565,9 +1713,9 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
 {
     if (__f.__f_ == 0)
         __f_ = 0;
-    else if (__f.__f_ == (__base*)&__f.__buf_)
+    else if ((void *)__f.__f_ == &__f.__buf_)
     {
-        __f_ = (__base*)&__buf_;
+        __f_ = __as_base(&__buf_);
         __f.__f_->__clone(__f_);
     }
     else
@@ -1587,13 +1735,12 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f,
                                      >::type*)
     : __f_(0)
 {
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
         if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
         {
-            __f_ = (__base*)&__buf_;
-            ::new (__f_) _FF(_VSTD::move(__f));
+            __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f));
         }
         else
         {
@@ -1614,22 +1761,15 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
     : __f_(0)
 {
     typedef allocator_traits<_Alloc> __alloc_traits;
-    if (__not_null(__f))
+    if (__function::__not_null(__f))
     {
         typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
-        typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<_FF>
-#else
-            rebind_alloc<_FF>::other
-#endif
-            _Ap;
+        typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
         _Ap __a(__a0);
         if (sizeof(_FF) <= sizeof(__buf_) && 
             is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
         {
-            __f_ = (__base*)&__buf_;
-            ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));
+            __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a));
         }
         else
         {
@@ -1653,16 +1793,16 @@ template<class _Rp, class ..._ArgTypes>
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
 {
-    if (__f_ == (__base*)&__buf_)
+    if ((void *)__f_ == &__buf_)
         __f_->destroy();
     else if (__f_)
         __f_->destroy_deallocate();
     __f_ = 0;
     if (__f.__f_ == 0)
         __f_ = 0;
-    else if (__f.__f_ == (__base*)&__f.__buf_)
+    else if ((void *)__f.__f_ == &__f.__buf_)
     {
-        __f_ = (__base*)&__buf_;
+        __f_ = __as_base(&__buf_);
         __f.__f_->__clone(__f_);
     }
     else
@@ -1677,7 +1817,7 @@ template<class _Rp, class ..._ArgTypes>
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
 {
-    if (__f_ == (__base*)&__buf_)
+    if ((void *)__f_ == &__buf_)
         __f_->destroy();
     else if (__f_)
         __f_->destroy_deallocate();
@@ -1702,7 +1842,7 @@ function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
 template<class _Rp, class ..._ArgTypes>
 function<_Rp(_ArgTypes...)>::~function()
 {
-    if (__f_ == (__base*)&__buf_)
+    if ((void *)__f_ == &__buf_)
         __f_->destroy();
     else if (__f_)
         __f_->destroy_deallocate();
@@ -1712,34 +1852,34 @@ template<class _Rp, class ..._ArgTypes>
 void
 function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
 {
-    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+    if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_)
     {
         typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
-        __base* __t = (__base*)&__tempbuf;
+        __base* __t = __as_base(&__tempbuf);
         __f_->__clone(__t);
         __f_->destroy();
         __f_ = 0;
-        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->__clone(__as_base(&__buf_));
         __f.__f_->destroy();
         __f.__f_ = 0;
-        __f_ = (__base*)&__buf_;
-        __t->__clone((__base*)&__f.__buf_);
+        __f_ = __as_base(&__buf_);
+        __t->__clone(__as_base(&__f.__buf_));
         __t->destroy();
-        __f.__f_ = (__base*)&__f.__buf_;
+        __f.__f_ = __as_base(&__f.__buf_);
     }
-    else if (__f_ == (__base*)&__buf_)
+    else if ((void *)__f_ == &__buf_)
     {
-        __f_->__clone((__base*)&__f.__buf_);
+        __f_->__clone(__as_base(&__f.__buf_));
         __f_->destroy();
         __f_ = __f.__f_;
-        __f.__f_ = (__base*)&__f.__buf_;
+        __f.__f_ = __as_base(&__f.__buf_);
     }
-    else if (__f.__f_ == (__base*)&__f.__buf_)
+    else if ((void *)__f.__f_ == &__f.__buf_)
     {
-        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->__clone(__as_base(&__buf_));
         __f.__f_->destroy();
         __f.__f_ = __f_;
-        __f_ = (__base*)&__buf_;
+        __f_ = __as_base(&__buf_);
     }
     else
         _VSTD::swap(__f_, __f.__f_);
@@ -1815,6 +1955,16 @@ void
 swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
 {return __x.swap(__y);}
 
+#else // _LIBCPP_HAS_NO_VARIADICS
+
+#include <__functional_03>
+
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+//                                  BIND
+//==============================================================================
+
 template<class _Tp> struct __is_bind_expression : public false_type {};
 template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
     : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
@@ -1845,6 +1995,9 @@ template<int _Np>
 struct __is_placeholder<placeholders::__ph<_Np> >
     : public integral_constant<int, _Np> {};
 
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
 template <class _Tp, class _Uj>
 inline _LIBCPP_INLINE_VISIBILITY
 _Tp&
@@ -1863,10 +2016,10 @@ __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
 
 template <class _Ti, class ..._Uj>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
+typename __lazy_enable_if
 <
     is_bind_expression<_Ti>::value,
-    typename __invoke_of<_Ti&, _Uj...>::type
+    __invoke_of<_Ti&, _Uj...>
 >::type
 __mu(_Ti& __ti, tuple<_Uj...>& __uj)
 {
@@ -1963,27 +2116,27 @@ struct __mu_return
 };
 
 template <class _Fp, class _BoundArgs, class _TupleUj>
-struct _is_valid_bind_return
+struct __is_valid_bind_return
 {
     static const bool value = false;
 };
 
 template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
+struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
 {
     static const bool value = __invokable<_Fp,
                     typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
 };
 
 template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
+struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
 {
     static const bool value = __invokable<_Fp,
                     typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
 };
 
 template <class _Fp, class _BoundArgs, class _TupleUj,
-          bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
+          bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
 struct __bind_return;
 
 template <class _Fp, class ..._BoundArgs, class _TupleUj>
@@ -2153,12 +2306,13 @@ public:
         typename enable_if
         <
             is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
-                           result_type>::value,
+                           result_type>::value || is_void<_Rp>::value,
             result_type
         >::type
         operator()(_Args&& ...__args)
         {
-            return base::operator()(_VSTD::forward<_Args>(__args)...);
+            typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+            return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
         }
 
     template <class ..._Args>
@@ -2166,12 +2320,13 @@ public:
         typename enable_if
         <
             is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
-                           result_type>::value,
+                           result_type>::value || is_void<_Rp>::value,
             result_type
         >::type
         operator()(_Args&& ...__args) const
         {
-            return base::operator()(_VSTD::forward<_Args>(__args)...);
+            typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+            return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
         }
 };
 
@@ -2318,6 +2473,22 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
 {
 };
 
+#ifndef _LIBCPP_HAS_NO_INT128
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<__int128_t>
+    : public __scalar_hash<__int128_t>
+{
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<__uint128_t>
+    : public __scalar_hash<__uint128_t>
+{
+};
+
+#endif
+
 template <>
 struct _LIBCPP_TYPE_VIS_ONLY hash<float>
     : public __scalar_hash<float>
@@ -2367,14 +2538,14 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
                 size_t __b;
                 size_t __c;
                 size_t __d;
-            };
+            } __s;
         } __u;
-        __u.__a = 0;
-        __u.__b = 0;
-        __u.__c = 0;
-        __u.__d = 0;
+        __u.__s.__a = 0;
+        __u.__s.__b = 0;
+        __u.__s.__c = 0;
+        __u.__s.__d = 0;
         __u.__t = __v;
-        return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d;
+        return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
 #elif defined(__x86_64__)
         // Zero out padding bits
         union
@@ -2384,12 +2555,12 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
             {
                 size_t __a;
                 size_t __b;
-            };
+            } __s;
         } __u;
-        __u.__a = 0;
-        __u.__b = 0;
+        __u.__s.__a = 0;
+        __u.__s.__b = 0;
         __u.__t = __v;
-        return __u.__a ^ __u.__b;
+        return __u.__s.__a ^ __u.__s.__b;
 #else
         return __scalar_hash<long double>::operator()(__v);
 #endif
@@ -2412,6 +2583,15 @@ struct _LIBCPP_TYPE_VIS_ONLY hash
 };
 #endif
 
+
+#if _LIBCPP_STD_VER > 14
+template <class _Fn, class ..._Args>
+result_of_t<_Fn&&(_Args&&...)>
+invoke(_Fn&& __f, _Args&&... __args) {
+    return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
+}
+#endif
+
 // struct hash<T*> in <memory>
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/system/include/libcxx/future b/system/include/libcxx/future
index 83513fa693d68..ce15eafbf7e4c 100644
--- a/system/include/libcxx/future
+++ b/system/include/libcxx/future
@@ -329,7 +329,7 @@ public:
     template <class F>
         explicit packaged_task(F&& f);
     template <class F, class Allocator>
-        explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
+        packaged_task(allocator_arg_t, const Allocator& a, F&& f);
     ~packaged_task();
 
     // no copy
@@ -512,6 +512,16 @@ public:
     virtual ~future_error() _NOEXCEPT;
 };
 
+inline _LIBCPP_ALWAYS_INLINE
+void __throw_future_error(future_errc _Ev)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw future_error(make_error_code(_Ev));
+#else
+    assert(!"future_error");
+#endif
+}
+
 class _LIBCPP_TYPE_VIS __assoc_sub_state
     : public __shared_count
 {
@@ -566,6 +576,7 @@ public:
     void wait();
     template <class _Rep, class _Period>
         future_status
+        _LIBCPP_INLINE_VISIBILITY
         wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const;
     template <class _Clock, class _Duration>
         future_status
@@ -589,7 +600,7 @@ __assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs
 }
 
 template <class _Rep, class _Period>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 future_status
 __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
 {
@@ -645,13 +656,10 @@ __assoc_state<_Rp>::set_value(_Arg& __arg)
 #endif
 {
     unique_lock<mutex> __lk(this->__mut_);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (this->__has_value())
-        throw future_error(make_error_code(future_errc::promise_already_satisfied));
-#endif
+        __throw_future_error(future_errc::promise_already_satisfied);
     ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
     this->__state_ |= base::__constructed | base::ready;
-    __lk.unlock();
     __cv_.notify_all();
 }
 
@@ -665,14 +673,11 @@ __assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg)
 #endif
 {
     unique_lock<mutex> __lk(this->__mut_);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (this->__has_value())
-        throw future_error(make_error_code(future_errc::promise_already_satisfied));
-#endif
+        __throw_future_error(future_errc::promise_already_satisfied);
     ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
     this->__state_ |= base::__constructed;
     __thread_local_data()->__make_ready_at_thread_exit(this);
-    __lk.unlock();
 }
 
 template <class _Rp>
@@ -727,13 +732,10 @@ void
 __assoc_state<_Rp&>::set_value(_Rp& __arg)
 {
     unique_lock<mutex> __lk(this->__mut_);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (this->__has_value())
-        throw future_error(make_error_code(future_errc::promise_already_satisfied));
-#endif
+        __throw_future_error(future_errc::promise_already_satisfied);
     __value_ = _VSTD::addressof(__arg);
     this->__state_ |= base::__constructed | base::ready;
-    __lk.unlock();
     __cv_.notify_all();
 }
 
@@ -742,14 +744,11 @@ void
 __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg)
 {
     unique_lock<mutex> __lk(this->__mut_);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (this->__has_value())
-        throw future_error(make_error_code(future_errc::promise_already_satisfied));
-#endif
+        __throw_future_error(future_errc::promise_already_satisfied);
     __value_ = _VSTD::addressof(__arg);
     this->__state_ |= base::__constructed;
     __thread_local_data()->__make_ready_at_thread_exit(this);
-    __lk.unlock();
 }
 
 template <class _Rp>
@@ -783,9 +782,12 @@ __assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT
 {
     if (this->__state_ & base::__constructed)
         reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp();
-    typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_);
+    typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al;
+    typedef allocator_traits<_Al> _ATraits;
+    typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+    _Al __a(__alloc_);
     this->~__assoc_state_alloc();
-    __a.deallocate(this, 1);
+    __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
 template <class _Rp, class _Alloc>
@@ -806,9 +808,12 @@ template <class _Rp, class _Alloc>
 void
 __assoc_state_alloc<_Rp&, _Alloc>::__on_zero_shared() _NOEXCEPT
 {
-    typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_);
+    typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al;
+    typedef allocator_traits<_Al> _ATraits;
+    typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+    _Al __a(__alloc_);
     this->~__assoc_state_alloc();
-    __a.deallocate(this, 1);
+    __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
 template <class _Alloc>
@@ -829,9 +834,12 @@ template <class _Alloc>
 void
 __assoc_sub_state_alloc<_Alloc>::__on_zero_shared() _NOEXCEPT
 {
-    typename _Alloc::template rebind<__assoc_sub_state_alloc>::other __a(__alloc_);
+    typedef typename __allocator_traits_rebind<_Alloc, __assoc_sub_state_alloc>::type _Al;
+    typedef allocator_traits<_Al> _ATraits;
+    typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+    _Al __a(__alloc_);
     this->~__assoc_sub_state_alloc();
-    __a.deallocate(this, 1);
+    __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
 template <class _Rp, class _Fp>
@@ -844,6 +852,7 @@ class __deferred_assoc_state
 
 public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     explicit __deferred_assoc_state(_Fp&& __f);
 #endif
 
@@ -853,7 +862,7 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Rp, class _Fp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)
     : __func_(_VSTD::forward<_Fp>(__f))
 {
@@ -890,6 +899,7 @@ class __deferred_assoc_state<void, _Fp>
 
 public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     explicit __deferred_assoc_state(_Fp&& __f);
 #endif
 
@@ -899,7 +909,7 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Fp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)
     : __func_(_VSTD::forward<_Fp>(__f))
 {
@@ -938,6 +948,7 @@ class __async_assoc_state
     virtual void __on_zero_shared() _NOEXCEPT;
 public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     explicit __async_assoc_state(_Fp&& __f);
 #endif
 
@@ -947,7 +958,7 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Rp, class _Fp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)
     : __func_(_VSTD::forward<_Fp>(__f))
 {
@@ -992,6 +1003,7 @@ class __async_assoc_state<void, _Fp>
     virtual void __on_zero_shared() _NOEXCEPT;
 public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     explicit __async_assoc_state(_Fp&& __f);
 #endif
 
@@ -1001,7 +1013,7 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Fp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)
     : __func_(_VSTD::forward<_Fp>(__f))
 {
@@ -1103,6 +1115,7 @@ private:
 public:
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     ~future();
+    _LIBCPP_INLINE_VISIBILITY
     shared_future<_Rp> share();
 
     // retrieving the value
@@ -1133,10 +1146,8 @@ template <class _Rp>
 future<_Rp>::future(__assoc_state<_Rp>* __state)
     : __state_(__state)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_->__has_future_attached())
-        throw future_error(make_error_code(future_errc::future_already_retrieved));
-#endif
+        __throw_future_error(future_errc::future_already_retrieved);
     __state_->__add_shared();
     __state_->__set_future_attached();
 }
@@ -1207,6 +1218,7 @@ private:
 public:
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     ~future();
+    _LIBCPP_INLINE_VISIBILITY
     shared_future<_Rp&> share();
 
     // retrieving the value
@@ -1237,10 +1249,8 @@ template <class _Rp>
 future<_Rp&>::future(__assoc_state<_Rp&>* __state)
     : __state_(__state)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_->__has_future_attached())
-        throw future_error(make_error_code(future_errc::future_already_retrieved));
-#endif
+        __throw_future_error(future_errc::future_already_retrieved);
     __state_->__add_shared();
     __state_->__set_future_attached();
 }
@@ -1306,6 +1316,7 @@ private:
 public:
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     ~future();
+    _LIBCPP_INLINE_VISIBILITY
     shared_future<void> share();
 
     // retrieving the value
@@ -1414,12 +1425,13 @@ template <class _Rp>
 template <class _Alloc>
 promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0)
 {
-    typedef typename _Alloc::template rebind<__assoc_state_alloc<_Rp, _Alloc> >::other _A2;
+    typedef __assoc_state_alloc<_Rp, _Alloc> _State;
+    typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
     typedef __allocator_destructor<_A2> _D2;
     _A2 __a(__a0);
-    unique_ptr<__assoc_state_alloc<_Rp, _Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1));
-    ::new(__hold.get()) __assoc_state_alloc<_Rp, _Alloc>(__a0);
-    __state_ = __hold.release();
+    unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
+    ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
+    __state_ = _VSTD::addressof(*__hold.release());
 }
 
 template <class _Rp>
@@ -1439,10 +1451,8 @@ template <class _Rp>
 future<_Rp>
 promise<_Rp>::get_future()
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     return future<_Rp>(__state_);
 }
 
@@ -1450,10 +1460,8 @@ template <class _Rp>
 void
 promise<_Rp>::set_value(const _Rp& __r)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_value(__r);
 }
 
@@ -1463,10 +1471,8 @@ template <class _Rp>
 void
 promise<_Rp>::set_value(_Rp&& __r)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_value(_VSTD::move(__r));
 }
 
@@ -1476,10 +1482,8 @@ template <class _Rp>
 void
 promise<_Rp>::set_exception(exception_ptr __p)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_exception(__p);
 }
 
@@ -1487,10 +1491,8 @@ template <class _Rp>
 void
 promise<_Rp>::set_value_at_thread_exit(const _Rp& __r)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_value_at_thread_exit(__r);
 }
 
@@ -1500,10 +1502,8 @@ template <class _Rp>
 void
 promise<_Rp>::set_value_at_thread_exit(_Rp&& __r)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_value_at_thread_exit(_VSTD::move(__r));
 }
 
@@ -1513,10 +1513,8 @@ template <class _Rp>
 void
 promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_exception_at_thread_exit(__p);
 }
 
@@ -1587,12 +1585,13 @@ template <class _Rp>
 template <class _Alloc>
 promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0)
 {
-    typedef typename _Alloc::template rebind<__assoc_state_alloc<_Rp&, _Alloc> >::other _A2;
+    typedef __assoc_state_alloc<_Rp&, _Alloc> _State;
+    typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
     typedef __allocator_destructor<_A2> _D2;
     _A2 __a(__a0);
-    unique_ptr<__assoc_state_alloc<_Rp&, _Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1));
-    ::new(__hold.get()) __assoc_state_alloc<_Rp&, _Alloc>(__a0);
-    __state_ = __hold.release();
+    unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
+    ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
+    __state_ = _VSTD::addressof(*__hold.release());
 }
 
 template <class _Rp>
@@ -1612,10 +1611,8 @@ template <class _Rp>
 future<_Rp&>
 promise<_Rp&>::get_future()
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     return future<_Rp&>(__state_);
 }
 
@@ -1623,10 +1620,8 @@ template <class _Rp>
 void
 promise<_Rp&>::set_value(_Rp& __r)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_value(__r);
 }
 
@@ -1634,10 +1629,8 @@ template <class _Rp>
 void
 promise<_Rp&>::set_exception(exception_ptr __p)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_exception(__p);
 }
 
@@ -1645,10 +1638,8 @@ template <class _Rp>
 void
 promise<_Rp&>::set_value_at_thread_exit(_Rp& __r)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_value_at_thread_exit(__r);
 }
 
@@ -1656,10 +1647,8 @@ template <class _Rp>
 void
 promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
-#endif
+        __throw_future_error(future_errc::no_state);
     __state_->set_exception_at_thread_exit(__p);
 }
 
@@ -1723,12 +1712,13 @@ public:
 template <class _Alloc>
 promise<void>::promise(allocator_arg_t, const _Alloc& __a0)
 {
-    typedef typename _Alloc::template rebind<__assoc_sub_state_alloc<_Alloc> >::other _A2;
+    typedef __assoc_sub_state_alloc<_Alloc> _State;
+    typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
     typedef __allocator_destructor<_A2> _D2;
     _A2 __a(__a0);
-    unique_ptr<__assoc_sub_state_alloc<_Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1));
-    ::new(__hold.get()) __assoc_sub_state_alloc<_Alloc>(__a0);
-    __state_ = __hold.release();
+    unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
+    ::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
+    __state_ = _VSTD::addressof(*__hold.release());
 }
 
 template <class _Rp>
@@ -1808,10 +1798,12 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
 void
 __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate()
 {
-    typedef typename _Alloc::template rebind<__packaged_task_func>::other _Ap;
+    typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap;
+    typedef allocator_traits<_Ap> _ATraits;
+    typedef pointer_traits<typename _ATraits::pointer> _PTraits;
     _Ap __a(__f_.second());
     __f_.~__compressed_pair<_Fp, _Alloc>();
-    __a.deallocate(this, 1);
+    __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
 template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
@@ -1851,6 +1843,7 @@ public:
 
     void swap(__packaged_task_function&) _NOEXCEPT;
 
+    _LIBCPP_INLINE_VISIBILITY
     _Rp operator()(_ArgTypes...) const;
 };
 
@@ -1900,7 +1893,6 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
                                   allocator_arg_t, const _Alloc& __a0, _Fp&& __f)
     : __f_(nullptr)
 {
-    typedef allocator_traits<_Alloc> __alloc_traits;
     typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
     typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
     if (sizeof(_FF) <= sizeof(__buf_))
@@ -1910,18 +1902,13 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
     }
     else
     {
-        typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<_FF>
-#else
-            rebind_alloc<_FF>::other
-#endif
-                                                     _Ap;
+        typedef typename __allocator_traits_rebind<_Alloc, _FF>::type _Ap;
         _Ap __a(__a0);
         typedef __allocator_destructor<_Ap> _Dp;
         unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-        ::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));
-        __f_ = __hold.release();
+        ::new (static_cast<void*>(_VSTD::addressof(*__hold.get())))
+            _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));
+        __f_ = _VSTD::addressof(*__hold.release());
     }
 }
 
@@ -1996,7 +1983,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f)
 }
 
 template<class _Rp, class ..._ArgTypes>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _Rp
 __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
 {
@@ -2038,7 +2025,7 @@ public:
                   >::type
               >
         _LIBCPP_INLINE_VISIBILITY
-        explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
+        packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
              : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
                __p_(allocator_arg, __a) {}
     // ~packaged_task() = default;
@@ -2083,11 +2070,11 @@ template<class _Rp, class ..._ArgTypes>
 void
 packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__p_.__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
+        __throw_future_error(future_errc::no_state);
     if (__p_.__state_->__has_value())
-        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+        __throw_future_error(future_errc::promise_already_satisfied);
+#ifndef _LIBCPP_NO_EXCEPTIONS
     try
     {
 #endif  // _LIBCPP_NO_EXCEPTIONS
@@ -2105,11 +2092,11 @@ template<class _Rp, class ..._ArgTypes>
 void
 packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__p_.__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
+        __throw_future_error(future_errc::no_state);
     if (__p_.__state_->__has_value())
-        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+        __throw_future_error(future_errc::promise_already_satisfied);
+#ifndef _LIBCPP_NO_EXCEPTIONS
     try
     {
 #endif  // _LIBCPP_NO_EXCEPTIONS
@@ -2127,10 +2114,8 @@ template<class _Rp, class ..._ArgTypes>
 void
 packaged_task<_Rp(_ArgTypes...)>::reset()
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (!valid())
-        throw future_error(make_error_code(future_errc::no_state));
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_future_error(future_errc::no_state);
     __p_ = promise<result_type>();
 }
 
@@ -2169,7 +2154,7 @@ public:
                   >::type
               >    
         _LIBCPP_INLINE_VISIBILITY
-        explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
+        packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
              : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
                __p_(allocator_arg, __a) {}
     // ~packaged_task() = default;
@@ -2214,11 +2199,11 @@ template<class ..._ArgTypes>
 void
 packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__p_.__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
+        __throw_future_error(future_errc::no_state);
     if (__p_.__state_->__has_value())
-        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+        __throw_future_error(future_errc::promise_already_satisfied);
+#ifndef _LIBCPP_NO_EXCEPTIONS
     try
     {
 #endif  // _LIBCPP_NO_EXCEPTIONS
@@ -2237,11 +2222,11 @@ template<class ..._ArgTypes>
 void
 packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__p_.__state_ == nullptr)
-        throw future_error(make_error_code(future_errc::no_state));
+        __throw_future_error(future_errc::no_state);
     if (__p_.__state_->__has_value())
-        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+        __throw_future_error(future_errc::promise_already_satisfied);
+#ifndef _LIBCPP_NO_EXCEPTIONS
     try
     {
 #endif  // _LIBCPP_NO_EXCEPTIONS
@@ -2260,10 +2245,8 @@ template<class ..._ArgTypes>
 void
 packaged_task<void(_ArgTypes...)>::reset()
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (!valid())
-        throw future_error(make_error_code(future_errc::no_state));
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_future_error(future_errc::no_state);
     __p_ = promise<result_type>();
 }
 
@@ -2588,7 +2571,7 @@ swap(shared_future<_Rp>& __x, shared_future<_Rp>& __y) _NOEXCEPT
 }
 
 template <class _Rp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_future<_Rp>
 future<_Rp>::share()
 {
@@ -2596,7 +2579,7 @@ future<_Rp>::share()
 }
 
 template <class _Rp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_future<_Rp&>
 future<_Rp&>::share()
 {
@@ -2605,7 +2588,7 @@ future<_Rp&>::share()
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_future<void>
 future<void>::share()
 {
diff --git a/system/include/libcxx/inttypes.h b/system/include/libcxx/inttypes.h
new file mode 100644
index 0000000000000..5c5618bef884f
--- /dev/null
+++ b/system/include/libcxx/inttypes.h
@@ -0,0 +1,251 @@
+// -*- C++ -*-
+//===--------------------------- inttypes.h -------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_INTTYPES_H
+#define _LIBCPP_INTTYPES_H
+
+/*
+    inttypes.h synopsis
+
+This entire header is C99 / C++0X
+
+#include <stdint.h>  // <cinttypes> includes <cstdint>
+
+Macros:
+
+    PRId8
+    PRId16
+    PRId32
+    PRId64
+
+    PRIdLEAST8
+    PRIdLEAST16
+    PRIdLEAST32
+    PRIdLEAST64
+
+    PRIdFAST8
+    PRIdFAST16
+    PRIdFAST32
+    PRIdFAST64
+
+    PRIdMAX
+    PRIdPTR
+
+    PRIi8
+    PRIi16
+    PRIi32
+    PRIi64
+
+    PRIiLEAST8
+    PRIiLEAST16
+    PRIiLEAST32
+    PRIiLEAST64
+
+    PRIiFAST8
+    PRIiFAST16
+    PRIiFAST32
+    PRIiFAST64
+
+    PRIiMAX
+    PRIiPTR
+
+    PRIo8
+    PRIo16
+    PRIo32
+    PRIo64
+
+    PRIoLEAST8
+    PRIoLEAST16
+    PRIoLEAST32
+    PRIoLEAST64
+
+    PRIoFAST8
+    PRIoFAST16
+    PRIoFAST32
+    PRIoFAST64
+
+    PRIoMAX
+    PRIoPTR
+
+    PRIu8
+    PRIu16
+    PRIu32
+    PRIu64
+
+    PRIuLEAST8
+    PRIuLEAST16
+    PRIuLEAST32
+    PRIuLEAST64
+
+    PRIuFAST8
+    PRIuFAST16
+    PRIuFAST32
+    PRIuFAST64
+
+    PRIuMAX
+    PRIuPTR
+
+    PRIx8
+    PRIx16
+    PRIx32
+    PRIx64
+
+    PRIxLEAST8
+    PRIxLEAST16
+    PRIxLEAST32
+    PRIxLEAST64
+
+    PRIxFAST8
+    PRIxFAST16
+    PRIxFAST32
+    PRIxFAST64
+
+    PRIxMAX
+    PRIxPTR
+
+    PRIX8
+    PRIX16
+    PRIX32
+    PRIX64
+
+    PRIXLEAST8
+    PRIXLEAST16
+    PRIXLEAST32
+    PRIXLEAST64
+
+    PRIXFAST8
+    PRIXFAST16
+    PRIXFAST32
+    PRIXFAST64
+
+    PRIXMAX
+    PRIXPTR
+
+    SCNd8
+    SCNd16
+    SCNd32
+    SCNd64
+
+    SCNdLEAST8
+    SCNdLEAST16
+    SCNdLEAST32
+    SCNdLEAST64
+
+    SCNdFAST8
+    SCNdFAST16
+    SCNdFAST32
+    SCNdFAST64
+
+    SCNdMAX
+    SCNdPTR
+
+    SCNi8
+    SCNi16
+    SCNi32
+    SCNi64
+
+    SCNiLEAST8
+    SCNiLEAST16
+    SCNiLEAST32
+    SCNiLEAST64
+
+    SCNiFAST8
+    SCNiFAST16
+    SCNiFAST32
+    SCNiFAST64
+
+    SCNiMAX
+    SCNiPTR
+
+    SCNo8
+    SCNo16
+    SCNo32
+    SCNo64
+
+    SCNoLEAST8
+    SCNoLEAST16
+    SCNoLEAST32
+    SCNoLEAST64
+
+    SCNoFAST8
+    SCNoFAST16
+    SCNoFAST32
+    SCNoFAST64
+
+    SCNoMAX
+    SCNoPTR
+
+    SCNu8
+    SCNu16
+    SCNu32
+    SCNu64
+
+    SCNuLEAST8
+    SCNuLEAST16
+    SCNuLEAST32
+    SCNuLEAST64
+
+    SCNuFAST8
+    SCNuFAST16
+    SCNuFAST32
+    SCNuFAST64
+
+    SCNuMAX
+    SCNuPTR
+
+    SCNx8
+    SCNx16
+    SCNx32
+    SCNx64
+
+    SCNxLEAST8
+    SCNxLEAST16
+    SCNxLEAST32
+    SCNxLEAST64
+
+    SCNxFAST8
+    SCNxFAST16
+    SCNxFAST32
+    SCNxFAST64
+
+    SCNxMAX
+    SCNxPTR
+
+Types:
+
+    imaxdiv_t
+
+intmax_t  imaxabs(intmax_t j);
+imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
+intmax_t  strtoimax(const char* restrict nptr, char** restrict endptr, int base);
+uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base);
+intmax_t  wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <inttypes.h>
+
+#ifdef __cplusplus
+
+#include <stdint.h>
+
+#undef imaxabs
+#undef imaxdiv
+
+#endif // __cplusplus
+
+#endif  // _LIBCPP_INTTYPES_H
diff --git a/system/include/libcxx/ios b/system/include/libcxx/ios
index ff79998b0bbf9..cbea478a74a88 100644
--- a/system/include/libcxx/ios
+++ b/system/include/libcxx/ios
@@ -114,9 +114,9 @@ class basic_ios
 public:
     // types:
     typedef charT char_type;
-    typedef typename traits::int_type int_type;
-    typedef typename traits::pos_type pos_type;
-    typedef typename traits::off_type off_type;
+    typedef typename traits::int_type int_type;  // removed in C++17
+    typedef typename traits::pos_type pos_type;  // removed in C++17
+    typedef typename traits::off_type off_type;  // removed in C++17
     typedef traits traits_type;
 
     operator unspecified-bool-type() const;
@@ -216,7 +216,7 @@ storage-class-specifier const error_category& iostream_category() noexcept;
 #include <__locale>
 #include <system_error>
 
-#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 #include <atomic>     // for __xindex_
 #endif
 
@@ -231,7 +231,7 @@ typedef ptrdiff_t streamsize;
 class _LIBCPP_TYPE_VIS ios_base
 {
 public:
-    class _LIBCPP_TYPE_VIS failure;
+    class _LIBCPP_EXCEPTION_ABI failure;
 
     typedef unsigned int fmtflags;
     static const fmtflags boolalpha   = 0x0001;
@@ -254,14 +254,12 @@ public:
     static const fmtflags floatfield  = scientific | fixed;
 
     typedef unsigned int iostate;
-    typedef iostate      io_state;
     static const iostate badbit  = 0x1;
     static const iostate eofbit  = 0x2;
     static const iostate failbit = 0x4;
     static const iostate goodbit = 0x0;
 
     typedef unsigned int openmode;
-    typedef openmode     open_mode;
     static const openmode app    = 0x01;
     static const openmode ate    = 0x02;
     static const openmode binary = 0x04;
@@ -270,10 +268,15 @@ public:
     static const openmode trunc  = 0x20;
 
     enum seekdir {beg, cur, end};
-    typedef seekdir seek_dir;
+
+#if _LIBCPP_STD_VER <= 14
+    typedef iostate      io_state;
+    typedef openmode     open_mode;
+    typedef seekdir      seek_dir;
 
     typedef _VSTD::streamoff streamoff;
     typedef _VSTD::streampos streampos;
+#endif
 
     class _LIBCPP_TYPE_VIS Init;
 
@@ -367,7 +370,9 @@ private:
     int*            __index_;
     size_t          __event_size_;
     size_t          __event_cap_;
-#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
+// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
+// enabled with clang.
+#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
     static atomic<int> __xindex_;
 #else
     static int      __xindex_;
diff --git a/system/include/libcxx/iosfwd b/system/include/libcxx/iosfwd
index d24c227bef798..e4149ef22378d 100644
--- a/system/include/libcxx/iosfwd
+++ b/system/include/libcxx/iosfwd
@@ -180,7 +180,12 @@ typedef fpos<mbstate_t>    u16streampos;
 typedef fpos<mbstate_t>    u32streampos;
 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
 
+#if defined(_NEWLIB_VERSION)
+// On newlib, off_t is 'long int'
+typedef long int streamoff;         // for char_traits in <string>
+#else
 typedef long long streamoff;        // for char_traits in <string>
+#endif
 
 template <class _CharT,             // for <stdexcept>
           class _Traits = char_traits<_CharT>,
@@ -189,6 +194,11 @@ template <class _CharT,             // for <stdexcept>
 typedef basic_string<char, char_traits<char>, allocator<char> > string;
 typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
 
+
+// Include other forward declarations here
+template <class _Tp, class _Alloc = allocator<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY vector;
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_IOSFWD
diff --git a/system/include/libcxx/iostream b/system/include/libcxx/iostream
index ddf2484114485..136a849777fed 100644
--- a/system/include/libcxx/iostream
+++ b/system/include/libcxx/iostream
@@ -46,13 +46,17 @@ extern wostream wclog;
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#ifndef _LIBCPP_HAS_NO_STDIN
 extern _LIBCPP_FUNC_VIS istream cin;
-extern _LIBCPP_FUNC_VIS ostream cout;
-extern _LIBCPP_FUNC_VIS ostream cerr;
-extern _LIBCPP_FUNC_VIS ostream clog;
 extern _LIBCPP_FUNC_VIS wistream wcin;
+#endif
+#ifndef _LIBCPP_HAS_NO_STDOUT
+extern _LIBCPP_FUNC_VIS ostream cout;
 extern _LIBCPP_FUNC_VIS wostream wcout;
+#endif
+extern _LIBCPP_FUNC_VIS ostream cerr;
 extern _LIBCPP_FUNC_VIS wostream wcerr;
+extern _LIBCPP_FUNC_VIS ostream clog;
 extern _LIBCPP_FUNC_VIS wostream wclog;
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/system/include/libcxx/istream b/system/include/libcxx/istream
index 168a4d0635f6f..0bcc7eeaf6398 100644
--- a/system/include/libcxx/istream
+++ b/system/include/libcxx/istream
@@ -1407,6 +1407,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
     try
     {
 #endif  // _LIBCPP_NO_EXCEPTIONS
+        this->clear(this->rdstate() & ~ios_base::eofbit);
         sentry __sen(*this, true);
         if (__sen)
         {
diff --git a/system/include/libcxx/iterator b/system/include/libcxx/iterator
index 88e615a32539b..0e60aa9b38bb4 100644
--- a/system/include/libcxx/iterator
+++ b/system/include/libcxx/iterator
@@ -214,7 +214,7 @@ public:
     typedef traits traits_type;
     typedef basic_istream<charT,traits> istream_type;
 
-    istream_iterator();
+    constexpr istream_iterator();
     istream_iterator(istream_type& s);
     istream_iterator(const istream_iterator& x);
     ~istream_iterator();
@@ -324,15 +324,26 @@ template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]);        //
 template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c));      // C++14
 template <class C> auto crend(const C& c) -> decltype(std::rend(c));          // C++14
 
+// 24.8, container access:
+template <class C> constexpr auto size(const C& c) -> decltype(c.size());         // C++17
+template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
+template <class C> constexpr auto empty(const C& c) -> decltype(c.empty());       // C++17
+template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept;  // C++17
+template <class E> constexpr bool empty(initializer_list<E> il) noexcept;         // C++17
+template <class C> constexpr auto data(C& c) -> decltype(c.data());               // C++17
+template <class C> constexpr auto data(const C& c) -> decltype(c.data());         // C++17
+template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept;           // C++17
+template <class E> constexpr const E* data(initializer_list<E> il) noexcept;      // C++17
+
 }  // std
 
 */
 
 #include <__config>
+#include <iosfwd> // for forward declarations of vector and string.
 #include <__functional_base>
 #include <type_traits>
 #include <cstddef>
-#include <iosfwd>
 #include <initializer_list>
 #ifdef __APPLE__
 #include <Availability.h>
@@ -426,6 +437,12 @@ struct __is_bidirectional_iterator : public __has_iterator_category_convertible_
 template <class _Tp>
 struct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
 
+template <class _Tp>
+struct __is_exactly_input_iterator
+    : public integral_constant<bool, 
+    	 __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value && 
+    	!__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
+
 template<class _Category, class _Tp, class _Distance = ptrdiff_t,
          class _Pointer = _Tp*, class _Reference = _Tp&>
 struct _LIBCPP_TYPE_VIS_ONLY iterator
@@ -502,12 +519,12 @@ distance(_InputIter __first, _InputIter __last)
     return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
 }
 
-template <class _ForwardIter>
+template <class _InputIter>
 inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIter
-next(_ForwardIter __x,
-     typename iterator_traits<_ForwardIter>::difference_type __n = 1,
-     typename enable_if<__is_forward_iterator<_ForwardIter>::value>::type* = 0)
+_InputIter
+next(_InputIter __x,
+     typename iterator_traits<_InputIter>::difference_type __n = 1,
+     typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0)
 {
     _VSTD::advance(__x, __n);
     return __x;
@@ -564,7 +581,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator-=(difference_type __n)
         {current += __n; return *this;}
     _LIBCPP_INLINE_VISIBILITY reference         operator[](difference_type __n) const
-        {return current[-__n-1];}
+        {return *(*this + __n);}
 };
 
 template <class _Iter1, class _Iter2>
@@ -754,7 +771,7 @@ private:
     istream_type* __in_stream_;
     _Tp __value_;
 public:
-    _LIBCPP_INLINE_VISIBILITY istream_iterator() : __in_stream_(0) {}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}
     _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(&__s)
         {
             if (!(*__in_stream_ >> __value_))
@@ -932,9 +949,14 @@ public:
     typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
     typedef typename iterator_traits<iterator_type>::value_type value_type;
     typedef typename iterator_traits<iterator_type>::difference_type difference_type;
-    typedef typename iterator_traits<iterator_type>::pointer pointer;
+    typedef iterator_type pointer;
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    typedef value_type&& reference;
+    typedef typename iterator_traits<iterator_type>::reference __reference;
+    typedef typename conditional<
+            is_reference<__reference>::value,
+            typename remove_reference<__reference>::type&&,
+            __reference
+        >::type reference;
 #else
     typedef typename iterator_traits<iterator_type>::reference reference;
 #endif
@@ -947,10 +969,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY reference operator*() const {
       return static_cast<reference>(*__i);
     }
-    _LIBCPP_INLINE_VISIBILITY pointer  operator->() const {
-      typename iterator_traits<iterator_type>::reference __ref = *__i;
-      return &__ref;
-    }
+    _LIBCPP_INLINE_VISIBILITY pointer  operator->() const { return __i;}
     _LIBCPP_INLINE_VISIBILITY move_iterator& operator++() {++__i; return *this;}
     _LIBCPP_INLINE_VISIBILITY move_iterator  operator++(int)
         {move_iterator __tmp(*this); ++__i; return __tmp;}
@@ -1168,7 +1187,7 @@ public:
         _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
                        "Attempted to dereference a non-dereferenceable iterator");
 #endif
-        return (pointer)&reinterpret_cast<const volatile char&>(*__i);
+        return (pointer)_VSTD::addressof(*__i);
     }
     _LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT
     {
@@ -1230,7 +1249,7 @@ private:
 
     template <class _Up> friend class __wrap_iter;
     template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
-    template <class _Tp, class _Alloc> friend class vector;
+    template <class _Tp, class _Alloc> friend class _LIBCPP_TYPE_VIS_ONLY vector;
 
     template <class _Iter1, class _Iter2>
     friend
@@ -1393,6 +1412,23 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n,
     return __x;
 }
 
+template <class _Iter>
+struct __libcpp_is_trivial_iterator
+	: public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {};
+	
+template <class _Iter>
+struct __libcpp_is_trivial_iterator<move_iterator<_Iter> >
+	: public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
+
+template <class _Iter>
+struct __libcpp_is_trivial_iterator<reverse_iterator<_Iter> >
+	: public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
+
+template <class _Iter>
+struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> >
+	: public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
+
+
 template <class _Tp, size_t _Np>
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp*
@@ -1568,6 +1604,36 @@ end(const _Cp& __c)
 
 #endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN)
 
+#if _LIBCPP_STD_VER > 14
+template <class _Cont>
+constexpr auto size(const _Cont& __c) -> decltype(__c.size()) { return __c.size(); }
+
+template <class _Tp, size_t _Sz>
+constexpr size_t size(const _Tp (&__array)[_Sz]) noexcept { return _Sz; }
+
+template <class _Cont>
+constexpr auto empty(const _Cont& __c) -> decltype(__c.empty()) { return __c.empty(); }
+
+template <class _Tp, size_t _Sz>
+constexpr bool empty(const _Tp (&__array)[_Sz]) noexcept { return false; }
+
+template <class _Ep>
+constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
+
+template <class _Cont> constexpr
+auto data(_Cont& __c) -> decltype(__c.data()) { return __c.data(); }
+
+template <class _Cont> constexpr
+auto data(const _Cont& __c) -> decltype(__c.data()) { return __c.data(); }
+
+template <class _Tp, size_t _Sz>
+constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
+
+template <class _Ep>
+constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
+#endif
+
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_ITERATOR
diff --git a/system/include/libcxx/limits b/system/include/libcxx/limits
index 1acf03e30b601..80a1be40fe478 100644
--- a/system/include/libcxx/limits
+++ b/system/include/libcxx/limits
@@ -237,7 +237,8 @@ protected:
     static _LIBCPP_CONSTEXPR const bool is_bounded = true;
     static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value;
 
-#if __i386__ || __x86_64__
+#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
+    defined(__wasm__)
     static _LIBCPP_CONSTEXPR const bool traps = true;
 #else
     static _LIBCPP_CONSTEXPR const bool traps = false;
diff --git a/system/include/libcxx/list b/system/include/libcxx/list
index 13f8a53bf25fd..cff0a853eff9c 100644
--- a/system/include/libcxx/list
+++ b/system/include/libcxx/list
@@ -118,8 +118,7 @@ public:
     void resize(size_type sz, const value_type& c);
 
     void swap(list&)
-        noexcept(!allocator_type::propagate_on_container_swap::value ||
-                 __is_nothrow_swappable<allocator_type>::value);
+        noexcept(allocator_traits<allocator_type>::is_always_equal::value);  // C++17
     void clear() noexcept;
 
     void splice(const_iterator position, list& x);
@@ -176,6 +175,7 @@ template <class T, class Alloc>
 #include <initializer_list>
 #include <iterator>
 #include <algorithm>
+#include <type_traits>
 
 #include <__undef_min_max>
 
@@ -188,34 +188,66 @@ template <class T, class Alloc>
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp, class _VoidPtr> struct __list_node;
+template <class _Tp, class _VoidPtr> struct __list_node_base;
 
 template <class _Tp, class _VoidPtr>
-struct __list_node_base
-{
-    typedef typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-        rebind<__list_node<_Tp, _VoidPtr> > pointer;
+struct __list_node_pointer_traits {
+  typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type
+        __node_pointer;
+  typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type
+        __base_pointer;
+
+#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
+  typedef __base_pointer __link_pointer;
 #else
-        rebind<__list_node<_Tp, _VoidPtr> >::other pointer;
+  typedef typename conditional<
+          is_pointer<_VoidPtr>::value,
+          __base_pointer,
+          __node_pointer
+  >::type __link_pointer;
 #endif
 
-    typedef typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-        rebind<__list_node_base> __base_pointer;
-#else
-        rebind<__list_node_base>::other __base_pointer;
-#endif
+  typedef typename conditional<
+          is_same<__link_pointer, __node_pointer>::value,
+          __base_pointer,
+          __node_pointer
+  >::type __non_link_pointer;
+
+  static _LIBCPP_INLINE_VISIBILITY
+  __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) {
+      return __p;
+  }
+
+  static _LIBCPP_INLINE_VISIBILITY
+  __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) {
+      return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p));
+  }
+
+};
+
+template <class _Tp, class _VoidPtr>
+struct __list_node_base
+{
+    typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+    typedef typename _NodeTraits::__node_pointer __node_pointer;
+    typedef typename _NodeTraits::__base_pointer __base_pointer;
+    typedef typename _NodeTraits::__link_pointer __link_pointer;
 
-    pointer __prev_;
-    pointer __next_;
+    __link_pointer __prev_;
+    __link_pointer __next_;
 
     _LIBCPP_INLINE_VISIBILITY
-    __list_node_base() : __prev_(__self()), __next_(__self()) {}
+    __list_node_base() : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())),
+                         __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {}
 
     _LIBCPP_INLINE_VISIBILITY
-    pointer __self()
-    {
-        return static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this));
+    __base_pointer __self() {
+        return pointer_traits<__base_pointer>::pointer_to(*this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __node_pointer __as_node() {
+        return static_cast<__node_pointer>(__self());
     }
 };
 
@@ -224,34 +256,38 @@ struct __list_node
     : public __list_node_base<_Tp, _VoidPtr>
 {
     _Tp __value_;
+
+    typedef __list_node_base<_Tp, _VoidPtr> __base;
+    typedef typename __base::__link_pointer __link_pointer;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __link_pointer __as_link() {
+        return static_cast<__link_pointer>(__base::__self());
+    }
 };
 
-template <class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS_ONLY list;
+template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TYPE_VIS_ONLY list;
 template <class _Tp, class _Alloc> class __list_imp;
 template <class _Tp, class _VoidPtr> class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator;
 
 template <class _Tp, class _VoidPtr>
 class _LIBCPP_TYPE_VIS_ONLY __list_iterator
 {
-    typedef typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-        rebind<__list_node<_Tp, _VoidPtr> > __node_pointer;
-#else
-        rebind<__list_node<_Tp, _VoidPtr> >::other __node_pointer;
-#endif
+    typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+    typedef typename _NodeTraits::__link_pointer __link_pointer;
 
-    __node_pointer __ptr_;
+    __link_pointer __ptr_;
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
     _LIBCPP_INLINE_VISIBILITY
-    explicit __list_iterator(__node_pointer __p, const void* __c) _NOEXCEPT
+    explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
         : __ptr_(__p)
     {
         __get_db()->__insert_ic(this, __c);
     }
 #else
     _LIBCPP_INLINE_VISIBILITY
-    explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+    explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
 #endif
 
 
@@ -263,13 +299,7 @@ public:
     typedef bidirectional_iterator_tag       iterator_category;
     typedef _Tp                              value_type;
     typedef value_type&                      reference;
-    typedef typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<value_type>
-#else
-            rebind<value_type>::other
-#endif
-                                             pointer;
+    typedef typename __rebind_pointer<_VoidPtr, value_type>::type pointer;
     typedef typename pointer_traits<pointer>::difference_type difference_type;
 
     _LIBCPP_INLINE_VISIBILITY
@@ -315,7 +345,7 @@ public:
         _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
                        "Attempted to dereference a non-dereferenceable list::iterator");
 #endif
-        return __ptr_->__value_;
+        return __ptr_->__as_node()->__value_;
     }
     _LIBCPP_INLINE_VISIBILITY
     pointer operator->() const
@@ -324,7 +354,7 @@ public:
         _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
                        "Attempted to dereference a non-dereferenceable list::iterator");
 #endif
-        return pointer_traits<pointer>::pointer_to(__ptr_->__value_);
+        return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_);
     }
 
     _LIBCPP_INLINE_VISIBILITY
@@ -366,25 +396,21 @@ public:
 template <class _Tp, class _VoidPtr>
 class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator
 {
-    typedef typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-        rebind<__list_node<_Tp, _VoidPtr> > __node_pointer;
-#else
-        rebind<__list_node<_Tp, _VoidPtr> >::other __node_pointer;
-#endif
+    typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+    typedef typename _NodeTraits::__link_pointer __link_pointer;
 
-    __node_pointer __ptr_;
+    __link_pointer __ptr_;
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
     _LIBCPP_INLINE_VISIBILITY
-    explicit __list_const_iterator(__node_pointer __p, const void* __c) _NOEXCEPT
+    explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
         : __ptr_(__p)
     {
         __get_db()->__insert_ic(this, __c);
     }
 #else
     _LIBCPP_INLINE_VISIBILITY
-    explicit __list_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+    explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
 #endif
 
     template<class, class> friend class list;
@@ -393,13 +419,7 @@ public:
     typedef bidirectional_iterator_tag       iterator_category;
     typedef _Tp                              value_type;
     typedef const value_type&                reference;
-    typedef typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const value_type>
-#else
-            rebind<const value_type>::other
-#endif
-                                             pointer;
+    typedef typename __rebind_pointer<_VoidPtr, const value_type>::type pointer;
     typedef typename pointer_traits<pointer>::difference_type difference_type;
 
     _LIBCPP_INLINE_VISIBILITY
@@ -452,7 +472,7 @@ public:
         _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
                        "Attempted to dereference a non-dereferenceable list::const_iterator");
 #endif
-        return __ptr_->__value_;
+        return __ptr_->__as_node()->__value_;
     }
     _LIBCPP_INLINE_VISIBILITY
     pointer operator->() const
@@ -461,7 +481,7 @@ public:
         _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
                        "Attempted to dereference a non-dereferenceable list::iterator");
 #endif
-        return pointer_traits<pointer>::pointer_to(__ptr_->__value_);
+        return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_);
     }
 
     _LIBCPP_INLINE_VISIBILITY
@@ -515,32 +535,29 @@ protected:
     typedef __list_const_iterator<value_type, __void_pointer>       const_iterator;
     typedef __list_node_base<value_type, __void_pointer>            __node_base;
     typedef __list_node<value_type, __void_pointer>                 __node;
-    typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<__node>
-#else
-                rebind_alloc<__node>::other
-#endif
-                                                                     __node_allocator;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
     typedef allocator_traits<__node_allocator>                       __node_alloc_traits;
     typedef typename __node_alloc_traits::pointer                    __node_pointer;
     typedef typename __node_alloc_traits::pointer                    __node_const_pointer;
+    typedef __list_node_pointer_traits<value_type, __void_pointer> __node_pointer_traits;
+    typedef typename __node_pointer_traits::__link_pointer __link_pointer;
+    typedef __link_pointer __link_const_pointer;
     typedef typename __alloc_traits::pointer                         pointer;
     typedef typename __alloc_traits::const_pointer                   const_pointer;
     typedef typename __alloc_traits::difference_type                 difference_type;
 
-    typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<__node_base>
-#else
-                rebind_alloc<__node_base>::other
-#endif
-                                                                     __node_base_allocator;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __node_base>::type __node_base_allocator;
     typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
 
     __node_base __end_;
     __compressed_pair<size_type, __node_allocator> __size_alloc_;
 
+    _LIBCPP_INLINE_VISIBILITY
+    __link_pointer __end_as_link() const _NOEXCEPT {
+        return __node_pointer_traits::__unsafe_link_pointer_cast(
+                const_cast<__node_base&>(__end_).__self());
+    }
+
     _LIBCPP_INLINE_VISIBILITY
           size_type& __sz() _NOEXCEPT {return __size_alloc_.first();}
     _LIBCPP_INLINE_VISIBILITY
@@ -553,10 +570,13 @@ protected:
     const __node_allocator& __node_alloc() const _NOEXCEPT
         {return __size_alloc_.second();}
 
-    static void __unlink_nodes(__node_pointer __f, __node_pointer __l) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT;
 
+    _LIBCPP_INLINE_VISIBILITY
     __list_imp()
         _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
+    _LIBCPP_INLINE_VISIBILITY
     __list_imp(const allocator_type& __a);
     ~__list_imp();
     void clear() _NOEXCEPT;
@@ -585,28 +605,28 @@ protected:
     iterator end() _NOEXCEPT
     {
 #if _LIBCPP_DEBUG_LEVEL >= 2
-        return iterator(static_cast<__node_pointer>(
-                pointer_traits<__node_base_pointer>::pointer_to(__end_)), this);
+        return iterator(__end_as_link(), this);
 #else
-        return iterator(static_cast<__node_pointer>(
-                      pointer_traits<__node_base_pointer>::pointer_to(__end_)));
+        return iterator(__end_as_link());
 #endif
     }
     _LIBCPP_INLINE_VISIBILITY
     const_iterator end() const _NOEXCEPT
     {
 #if _LIBCPP_DEBUG_LEVEL >= 2
-        return const_iterator(static_cast<__node_const_pointer>(
-        pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_))), this);
+        return const_iterator(__end_as_link(), this);
 #else
-        return const_iterator(static_cast<__node_const_pointer>(
-        pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_))));
+        return const_iterator(__end_as_link());
 #endif
     }
 
     void swap(__list_imp& __c)
-        _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<__node_allocator>::value);
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT;
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value);
+#endif
 
     _LIBCPP_INLINE_VISIBILITY
     void __copy_assign_alloc(const __list_imp& __c)
@@ -622,24 +642,6 @@ protected:
                       __node_alloc_traits::propagate_on_container_move_assignment::value>());}
 
 private:
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y)
-        _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<__node_allocator>::value)
-        {__swap_alloc(__x, __y, integral_constant<bool,
-                      __node_alloc_traits::propagate_on_container_swap::value>());}
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type)
-        _NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value)
-        {
-            using _VSTD::swap;
-            swap(__x, __y);
-        }
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type)
-        _NOEXCEPT
-        {}
-
     _LIBCPP_INLINE_VISIBILITY
     void __copy_assign_alloc(const __list_imp& __c, true_type)
         {
@@ -667,9 +669,9 @@ private:
 
 // Unlink nodes [__f, __l]
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
-__list_imp<_Tp, _Alloc>::__unlink_nodes(__node_pointer __f, __node_pointer __l)
+__list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l)
     _NOEXCEPT
 {
     __f->__prev_->__next_ = __l->__next_;
@@ -677,7 +679,7 @@ __list_imp<_Tp, _Alloc>::__unlink_nodes(__node_pointer __f, __node_pointer __l)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __list_imp<_Tp, _Alloc>::__list_imp()
         _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
     : __size_alloc_(0)
@@ -685,7 +687,7 @@ __list_imp<_Tp, _Alloc>::__list_imp()
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
     : __size_alloc_(0, __node_allocator(__a))
 {
@@ -707,17 +709,16 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
     if (!empty())
     {
         __node_allocator& __na = __node_alloc();
-        __node_pointer __f = __end_.__next_;
-        __node_pointer __l = static_cast<__node_pointer>(
-                       pointer_traits<__node_base_pointer>::pointer_to(__end_));
+        __link_pointer __f = __end_.__next_;
+        __link_pointer __l = __end_as_link();
         __unlink_nodes(__f, __l->__prev_);
         __sz() = 0;
         while (__f != __l)
         {
-            __node_pointer __n = __f;
+            __node_pointer __np = __f->__as_node();
             __f = __f->__next_;
-            __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
-            __node_alloc_traits::deallocate(__na, __n, 1);
+            __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+            __node_alloc_traits::deallocate(__na, __np, 1);
         }
 #if _LIBCPP_DEBUG_LEVEL >= 2
         __c_node* __c = __get_db()->__find_c_and_lock(this);
@@ -740,25 +741,29 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
 template <class _Tp, class _Alloc>
 void
 __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
-        _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<__node_allocator>::value)
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value)
+#endif
 {
     _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
                    this->__node_alloc() == __c.__node_alloc(),
                    "list::swap: Either propagate_on_container_swap must be true"
                    " or the allocators must compare equal");
     using _VSTD::swap;
-    __swap_alloc(__node_alloc(), __c.__node_alloc());
+    __swap_allocator(__node_alloc(), __c.__node_alloc());
     swap(__sz(), __c.__sz());
     swap(__end_, __c.__end_);
     if (__sz() == 0)
-        __end_.__next_ = __end_.__prev_ = __end_.__self();
+        __end_.__next_ = __end_.__prev_ = __end_as_link();
     else
-        __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_.__self();
+        __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link();
     if (__c.__sz() == 0)
-        __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_.__self();
+        __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link();
     else
-        __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_.__self();
+        __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
     __libcpp_db* __db = __get_db();
@@ -771,8 +776,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
     {
         --__p;
         const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
-        if (__i->__ptr_ == static_cast<__node_pointer>(
-                       pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)))
+        if (__i->__ptr_ == __c.__end_as_link())
         {
             __cn2->__add(*__p);
             if (--__cn1->end_ != __p)
@@ -785,8 +789,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
     {
         --__p;
         const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
-        if (__i->__ptr_ == static_cast<__node_pointer>(
-                       pointer_traits<__node_base_pointer>::pointer_to(__end_)))
+        if (__i->__ptr_ == __end_as_link())
         {
             __cn1->__add(*__p);
             if (--__cn2->end_ != __p)
@@ -799,7 +802,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
 #endif
 }
 
-template <class _Tp, class _Alloc = allocator<_Tp> >
+template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
 class _LIBCPP_TYPE_VIS_ONLY list
     : private __list_imp<_Tp, _Alloc>
 {
@@ -810,6 +813,7 @@ class _LIBCPP_TYPE_VIS_ONLY list
     typedef typename base::__node_alloc_traits __node_alloc_traits;
     typedef typename base::__node_base         __node_base;
     typedef typename base::__node_base_pointer __node_base_pointer;
+    typedef typename base::__link_pointer __link_pointer;
 
 public:
     typedef _Tp                                      value_type;
@@ -857,15 +861,19 @@ public:
 
     list(const list& __c);
     list(const list& __c, const allocator_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
     list& operator=(const list& __c);
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     list(initializer_list<value_type> __il);
     list(initializer_list<value_type> __il, const allocator_type& __a);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     list(list&& __c)
         _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
+    _LIBCPP_INLINE_VISIBILITY
     list(list&& __c, const allocator_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
     list& operator=(list&& __c)
         _NOEXCEPT_(
             __node_alloc_traits::propagate_on_container_move_assignment::value &&
@@ -887,6 +895,7 @@ public:
         {assign(__il.begin(), __il.end());}
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
+    _LIBCPP_INLINE_VISIBILITY
     allocator_type get_allocator() const _NOEXCEPT;
 
     _LIBCPP_INLINE_VISIBILITY
@@ -933,25 +942,25 @@ public:
     reference front()
     {
         _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
-        return base::__end_.__next_->__value_;
+        return base::__end_.__next_->__as_node()->__value_;
     }
     _LIBCPP_INLINE_VISIBILITY
     const_reference front() const
     {
         _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
-        return base::__end_.__next_->__value_;
+        return base::__end_.__next_->__as_node()->__value_;
     }
     _LIBCPP_INLINE_VISIBILITY
     reference back()
     {
         _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
-        return base::__end_.__prev_->__value_;
+        return base::__end_.__prev_->__as_node()->__value_;
     }
     _LIBCPP_INLINE_VISIBILITY
     const_reference back() const
     {
         _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
-        return base::__end_.__prev_->__value_;
+        return base::__end_.__prev_->__as_node()->__value_;
     }
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -984,8 +993,12 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     void swap(list& __c)
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT
+#else
         _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
                    __is_nothrow_swappable<__node_allocator>::value)
+#endif
         {base::swap(__c);}
     _LIBCPP_INLINE_VISIBILITY
     void clear() _NOEXCEPT {base::clear();}
@@ -1019,9 +1032,11 @@ public:
 
     void remove(const value_type& __x);
     template <class _Pred> void remove_if(_Pred __pred);
+    _LIBCPP_INLINE_VISIBILITY
     void unique();
     template <class _BinaryPred>
         void unique(_BinaryPred __binary_pred);
+    _LIBCPP_INLINE_VISIBILITY
     void merge(list& __c);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
@@ -1034,8 +1049,10 @@ public:
     _LIBCPP_INLINE_VISIBILITY
         void merge(list&& __c, _Comp __comp) {merge(__c, __comp);}
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     void sort();
     template <class _Comp>
+        _LIBCPP_INLINE_VISIBILITY
         void sort(_Comp __comp);
 
     void reverse() _NOEXCEPT;
@@ -1052,9 +1069,12 @@ public:
 #endif  // _LIBCPP_DEBUG_LEVEL >= 2
 
 private:
-    static void __link_nodes  (__node_pointer __p, __node_pointer __f, __node_pointer __l);
-    void __link_nodes_at_front(__node_pointer __f, __node_pointer __l);
-    void __link_nodes_at_back (__node_pointer __f, __node_pointer __l);
+    _LIBCPP_INLINE_VISIBILITY
+    static void __link_nodes  (__link_pointer __p, __link_pointer __f, __link_pointer __l);
+    _LIBCPP_INLINE_VISIBILITY
+    void __link_nodes_at_front(__link_pointer __f, __link_pointer __l);
+    _LIBCPP_INLINE_VISIBILITY
+    void __link_nodes_at_back (__link_pointer __f, __link_pointer __l);
     iterator __iterator(size_type __n);
     template <class _Comp>
         static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
@@ -1066,9 +1086,9 @@ private:
 
 // Link in nodes [__f, __l] just prior to __p
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
-list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l)
+list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l)
 {
     __p->__prev_->__next_ = __f;
     __f->__prev_ = __p->__prev_;
@@ -1078,11 +1098,11 @@ list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_p
 
 // Link in nodes [__f, __l] at the front of the list
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
-list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l)
+list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l)
 {
-    __f->__prev_ = base::__end_.__self();
+    __f->__prev_ = base::__end_as_link();
     __l->__next_ = base::__end_.__next_;
     __l->__next_->__prev_ = __l;
     base::__end_.__next_ = __f;
@@ -1090,11 +1110,11 @@ list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l)
 
 // Link in nodes [__f, __l] at the front of the list
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
-list<_Tp, _Alloc>::__link_nodes_at_back(__node_pointer __f, __node_pointer __l)
+list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l)
 {
-    __l->__next_ = base::__end_.__self();
+    __l->__next_ = base::__end_as_link();
     __f->__prev_ = base::__end_.__prev_;
     __f->__prev_->__next_ = __f;
     base::__end_.__prev_ = __l;
@@ -1102,7 +1122,7 @@ list<_Tp, _Alloc>::__link_nodes_at_back(__node_pointer __f, __node_pointer __l)
 
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename list<_Tp, _Alloc>::iterator
 list<_Tp, _Alloc>::__iterator(size_type __n)
 {
@@ -1238,7 +1258,7 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il)
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 list<_Tp, _Alloc>&
 list<_Tp, _Alloc>::operator=(const list& __c)
 {
@@ -1253,7 +1273,7 @@ list<_Tp, _Alloc>::operator=(const list& __c)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 list<_Tp, _Alloc>::list(list&& __c)
     _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
     : base(allocator_type(_VSTD::move(__c.__node_alloc())))
@@ -1265,7 +1285,7 @@ list<_Tp, _Alloc>::list(list&& __c)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
     : base(__a)
 {
@@ -1282,7 +1302,7 @@ list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 list<_Tp, _Alloc>&
 list<_Tp, _Alloc>::operator=(list&& __c)
         _NOEXCEPT_(
@@ -1350,7 +1370,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _Alloc
 list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT
 {
@@ -1371,12 +1391,12 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __hold->__prev_ = 0;
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
-    __link_nodes(__p.__ptr_, __hold.get(), __hold.get());
+    __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
     ++base::__sz();
 #if _LIBCPP_DEBUG_LEVEL >= 2
-    return iterator(__hold.release(), this);
+    return iterator(__hold.release()->__as_link(), this);
 #else
-    return iterator(__hold.release());
+    return iterator(__hold.release()->__as_link());
 #endif
 }
 
@@ -1402,9 +1422,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
         __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
         ++__ds;
 #if _LIBCPP_DEBUG_LEVEL >= 2
-        __r = iterator(__hold.get(), this);
+        __r = iterator(__hold->__as_link(), this);
 #else
-        __r = iterator(__hold.get());
+        __r = iterator(__hold->__as_link());
 #endif
         __hold.release();
         iterator __e = __r;
@@ -1416,7 +1436,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
             {
                 __hold.reset(__node_alloc_traits::allocate(__na, 1));
                 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
-                __e.__ptr_->__next_ = __hold.get();
+                __e.__ptr_->__next_ = __hold->__as_link();
                 __hold->__prev_ = __e.__ptr_;
                 __hold.release();
             }
@@ -1427,8 +1447,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
             while (true)
             {
                 __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
-                __node_pointer __prev = __e.__ptr_->__prev_;
-                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
+                __link_pointer __prev = __e.__ptr_->__prev_;
+                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
                 if (__prev == 0)
                     break;
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1470,9 +1490,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
         __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
         ++__ds;
 #if _LIBCPP_DEBUG_LEVEL >= 2
-        __r = iterator(__hold.get(), this);
+        __r = iterator(__hold.get()->__as_link(), this);
 #else
-        __r = iterator(__hold.get());
+        __r = iterator(__hold.get()->__as_link());
 #endif
         __hold.release();
         iterator __e = __r;
@@ -1480,11 +1500,11 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
         try
         {
 #endif  // _LIBCPP_NO_EXCEPTIONS
-            for (++__f; __f != __l; ++__f, ++__e, ++__ds)
+            for (++__f; __f != __l; ++__f, (void) ++__e, (void) ++__ds)
             {
                 __hold.reset(__node_alloc_traits::allocate(__na, 1));
                 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
-                __e.__ptr_->__next_ = __hold.get();
+                __e.__ptr_->__next_ = __hold.get()->__as_link();
                 __hold->__prev_ = __e.__ptr_;
                 __hold.release();
             }
@@ -1495,8 +1515,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
             while (true)
             {
                 __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
-                __node_pointer __prev = __e.__ptr_->__prev_;
-                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
+                __link_pointer __prev = __e.__ptr_->__prev_;
+                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
                 if (__prev == 0)
                     break;
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1522,7 +1542,8 @@ list<_Tp, _Alloc>::push_front(const value_type& __x)
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
-    __link_nodes_at_front(__hold.get(), __hold.get());
+    __link_pointer __nl = __hold->__as_link();
+    __link_nodes_at_front(__nl, __nl);
     ++base::__sz();
     __hold.release();
 }
@@ -1535,7 +1556,7 @@ list<_Tp, _Alloc>::push_back(const value_type& __x)
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
-    __link_nodes_at_back(__hold.get(), __hold.get());
+    __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link());
     ++base::__sz();
     __hold.release();
 }
@@ -1550,7 +1571,7 @@ list<_Tp, _Alloc>::push_front(value_type&& __x)
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
-    __link_nodes_at_front(__hold.get(), __hold.get());
+    __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
     ++base::__sz();
     __hold.release();
 }
@@ -1563,7 +1584,7 @@ list<_Tp, _Alloc>::push_back(value_type&& __x)
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
-    __link_nodes_at_back(__hold.get(), __hold.get());
+    __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link());
     ++base::__sz();
     __hold.release();
 }
@@ -1579,7 +1600,7 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
-    __link_nodes_at_front(__hold.get(), __hold.get());
+    __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
     ++base::__sz();
     __hold.release();
 }
@@ -1593,7 +1614,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
     typedef __allocator_destructor<__node_allocator> _Dp;
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
-    __link_nodes_at_back(__hold.get(), __hold.get());
+    __link_pointer __nl = __hold->__as_link();
+    __link_nodes_at_back(__nl, __nl);
     ++base::__sz();
     __hold.release();
 }
@@ -1613,12 +1635,14 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __hold->__prev_ = 0;
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
-    __link_nodes(__p.__ptr_, __hold.get(), __hold.get());
+    __link_pointer __nl = __hold.get()->__as_link();
+    __link_nodes(__p.__ptr_, __nl, __nl);
     ++base::__sz();
+    __hold.release();
 #if _LIBCPP_DEBUG_LEVEL >= 2
-    return iterator(__hold.release(), this);
+    return iterator(__nl, this);
 #else
-    return iterator(__hold.release());
+    return iterator(__nl);
 #endif
 }
 
@@ -1638,12 +1662,14 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
     unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
     __hold->__prev_ = 0;
     __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
-    __link_nodes(__p.__ptr_, __hold.get(), __hold.get());
+    __link_pointer __nl = __hold->__as_link();
+    __link_nodes(__p.__ptr_, __nl, __nl);
     ++base::__sz();
+    __hold.release();
 #if _LIBCPP_DEBUG_LEVEL >= 2
-    return iterator(__hold.release(), this);
+    return iterator(__nl, this);
 #else
-    return iterator(__hold.release());
+    return iterator(__nl);
 #endif
 }
 
@@ -1655,7 +1681,7 @@ list<_Tp, _Alloc>::pop_front()
 {
     _LIBCPP_ASSERT(!empty(), "list::pop_front() called with empty list");
     __node_allocator& __na = base::__node_alloc();
-    __node_pointer __n = base::__end_.__next_;
+    __link_pointer __n = base::__end_.__next_;
     base::__unlink_nodes(__n, __n);
     --base::__sz();
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1673,8 +1699,9 @@ list<_Tp, _Alloc>::pop_front()
     }
     __get_db()->unlock();
 #endif
-    __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
-    __node_alloc_traits::deallocate(__na, __n, 1);
+    __node_pointer __np = __n->__as_node();
+    __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+    __node_alloc_traits::deallocate(__na, __np, 1);
 }
 
 template <class _Tp, class _Alloc>
@@ -1683,7 +1710,7 @@ list<_Tp, _Alloc>::pop_back()
 {
     _LIBCPP_ASSERT(!empty(), "list::pop_back() called with empty list");
     __node_allocator& __na = base::__node_alloc();
-    __node_pointer __n = base::__end_.__prev_;
+    __link_pointer __n = base::__end_.__prev_;
     base::__unlink_nodes(__n, __n);
     --base::__sz();
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1701,8 +1728,9 @@ list<_Tp, _Alloc>::pop_back()
     }
     __get_db()->unlock();
 #endif
-    __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
-    __node_alloc_traits::deallocate(__na, __n, 1);
+    __node_pointer __np = __n->__as_node();
+    __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+    __node_alloc_traits::deallocate(__na, __np, 1);
 }
 
 template <class _Tp, class _Alloc>
@@ -1717,8 +1745,8 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
     _LIBCPP_ASSERT(__p != end(),
         "list::erase(iterator) called with a non-dereferenceable iterator");
     __node_allocator& __na = base::__node_alloc();
-    __node_pointer __n = __p.__ptr_;
-    __node_pointer __r = __n->__next_;
+    __link_pointer __n = __p.__ptr_;
+    __link_pointer __r = __n->__next_;
     base::__unlink_nodes(__n, __n);
     --base::__sz();
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1736,8 +1764,9 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
     }
     __get_db()->unlock();
 #endif
-    __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
-    __node_alloc_traits::deallocate(__na, __n, 1);
+    __node_pointer __np = __n->__as_node();
+    __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+    __node_alloc_traits::deallocate(__na, __np, 1);
 #if _LIBCPP_DEBUG_LEVEL >= 2
     return iterator(__r, this);
 #else
@@ -1760,7 +1789,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
         base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
         while (__f != __l)
         {
-            __node_pointer __n = __f.__ptr_;
+            __link_pointer __n = __f.__ptr_;
             ++__f;
             --base::__sz();
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1778,8 +1807,9 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
             }
             __get_db()->unlock();
 #endif
-            __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
-            __node_alloc_traits::deallocate(__na, __n, 1);
+            __node_pointer __np = __n->__as_node();
+            __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+            __node_alloc_traits::deallocate(__na, __np, 1);
         }
     }
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1806,9 +1836,9 @@ list<_Tp, _Alloc>::resize(size_type __n)
         __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
         ++__ds;
 #if _LIBCPP_DEBUG_LEVEL >= 2
-        iterator __r = iterator(__hold.release(), this);
+        iterator __r = iterator(__hold.release()->__as_link(), this);
 #else
-        iterator __r = iterator(__hold.release());
+        iterator __r = iterator(__hold.release()->__as_link());
 #endif
         iterator __e = __r;
 #ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1819,7 +1849,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
             {
                 __hold.reset(__node_alloc_traits::allocate(__na, 1));
                 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
-                __e.__ptr_->__next_ = __hold.get();
+                __e.__ptr_->__next_ = __hold.get()->__as_link();
                 __hold->__prev_ = __e.__ptr_;
                 __hold.release();
             }
@@ -1830,8 +1860,8 @@ list<_Tp, _Alloc>::resize(size_type __n)
             while (true)
             {
                 __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
-                __node_pointer __prev = __e.__ptr_->__prev_;
-                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
+                __link_pointer __prev = __e.__ptr_->__prev_;
+                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
                 if (__prev == 0)
                     break;
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1864,10 +1894,11 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
         __hold->__prev_ = 0;
         __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
         ++__ds;
+        __link_pointer __nl = __hold.release()->__as_link();
 #if _LIBCPP_DEBUG_LEVEL >= 2
-        iterator __r = iterator(__hold.release(), this);
+        iterator __r = iterator(__nl, this);
 #else
-        iterator __r = iterator(__hold.release());
+        iterator __r = iterator(__nl);
 #endif
         iterator __e = __r;
 #ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1878,7 +1909,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
             {
                 __hold.reset(__node_alloc_traits::allocate(__na, 1));
                 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
-                __e.__ptr_->__next_ = __hold.get();
+                __e.__ptr_->__next_ = __hold.get()->__as_link();
                 __hold->__prev_ = __e.__ptr_;
                 __hold.release();
             }
@@ -1889,8 +1920,8 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
             while (true)
             {
                 __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
-                __node_pointer __prev = __e.__ptr_->__prev_;
-                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
+                __link_pointer __prev = __e.__ptr_->__prev_;
+                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
                 if (__prev == 0)
                     break;
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1902,8 +1933,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
             throw;
         }
 #endif  // _LIBCPP_NO_EXCEPTIONS
-        __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
-                         pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_);
+        __link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_);
         base::__sz() += __ds;
     }
 }
@@ -1921,8 +1951,8 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
 #endif
     if (!__c.empty())
     {
-        __node_pointer __f = __c.__end_.__next_;
-        __node_pointer __l = __c.__end_.__prev_;
+        __link_pointer __f = __c.__end_.__next_;
+        __link_pointer __l = __c.__end_.__prev_;
         base::__unlink_nodes(__f, __l);
         __link_nodes(__p.__ptr_, __f, __l);
         base::__sz() += __c.__sz();
@@ -1935,8 +1965,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
         {
             --__p;
             iterator* __i = static_cast<iterator*>((*__p)->__i_);
-            if (__i->__ptr_ != static_cast<__node_pointer>(
-                       pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)))
+            if (__i->__ptr_ != __c.__end_as_link())
             {
                 __cn1->__add(*__p);
                 (*__p)->__c_ = __cn1;
@@ -1966,7 +1995,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
 #endif
     if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
     {
-        __node_pointer __f = __i.__ptr_;
+        __link_pointer __f = __i.__ptr_;
         base::__unlink_nodes(__f, __f);
         __link_nodes(__p.__ptr_, __f, __f);
         --__c.__sz();
@@ -2020,9 +2049,9 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
             __c.__sz() -= __s;
             base::__sz() += __s;
         }
-        __node_pointer __first = __f.__ptr_;
+        __link_pointer __first = __f.__ptr_;
         --__l;
-        __node_pointer __last = __l.__ptr_;
+        __link_pointer __last = __l.__ptr_;
         base::__unlink_nodes(__first, __last);
         __link_nodes(__p.__ptr_, __first, __last);
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -2033,7 +2062,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
         {
             --__p;
             iterator* __j = static_cast<iterator*>((*__p)->__i_);
-            for (__node_pointer __k = __f.__ptr_;
+            for (__link_pointer __k = __f.__ptr_;
                                           __k != __l.__ptr_; __k = __k->__next_)
             {
                 if (__j->__ptr_ == __k)
@@ -2094,7 +2123,7 @@ list<_Tp, _Alloc>::remove_if(_Pred __pred)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 list<_Tp, _Alloc>::unique()
 {
@@ -2117,7 +2146,7 @@ list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 list<_Tp, _Alloc>::merge(list& __c)
 {
@@ -2145,8 +2174,8 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
                     ;
                 base::__sz() += __ds;
                 __c.__sz() -= __ds;
-                __node_pointer __f = __f2.__ptr_;
-                __node_pointer __l = __m2.__ptr_->__prev_;
+                __link_pointer __f = __f2.__ptr_;
+                __link_pointer __l = __m2.__ptr_->__prev_;
                 __f2 = __m2;
                 base::__unlink_nodes(__f, __l);
                 __m2 = _VSTD::next(__f1);
@@ -2165,8 +2194,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
         {
             --__p;
             iterator* __i = static_cast<iterator*>((*__p)->__i_);
-            if (__i->__ptr_ != static_cast<__node_pointer>(
-                       pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)))
+            if (__i->__ptr_ != __c.__end_as_link())
             {
                 __cn1->__add(*__p);
                 (*__p)->__c_ = __cn1;
@@ -2180,7 +2208,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
 }
 
 template <class _Tp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 list<_Tp, _Alloc>::sort()
 {
@@ -2189,7 +2217,7 @@ list<_Tp, _Alloc>::sort()
 
 template <class _Tp, class _Alloc>
 template <class _Comp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 list<_Tp, _Alloc>::sort(_Comp __comp)
 {
@@ -2209,7 +2237,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
     case 2:
         if (__comp(*--__e2, *__f1))
         {
-            __node_pointer __f = __e2.__ptr_;
+            __link_pointer __f = __e2.__ptr_;
             base::__unlink_nodes(__f, __f);
             __link_nodes(__f1.__ptr_, __f, __f);
             return __e2;
@@ -2225,8 +2253,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
         iterator __m2 = _VSTD::next(__f2);
         for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
             ;
-        __node_pointer __f = __f2.__ptr_;
-        __node_pointer __l = __m2.__ptr_->__prev_;
+        __link_pointer __f = __f2.__ptr_;
+        __link_pointer __l = __m2.__ptr_->__prev_;
         __r = __f2;
         __e1 = __f2 = __m2;
         base::__unlink_nodes(__f, __l);
@@ -2243,8 +2271,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
             iterator __m2 = _VSTD::next(__f2);
             for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
                 ;
-            __node_pointer __f = __f2.__ptr_;
-            __node_pointer __l = __m2.__ptr_->__prev_;
+            __link_pointer __f = __f2.__ptr_;
+            __link_pointer __l = __m2.__ptr_->__prev_;
             if (__e1 == __f2)
                 __e1 = __m2;
             __f2 = __m2;
@@ -2288,8 +2316,7 @@ template <class _Tp, class _Alloc>
 bool
 list<_Tp, _Alloc>::__dereferenceable(const const_iterator* __i) const
 {
-    return __i->__ptr_ != static_cast<__node_pointer>(
-                       pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(this->__end_)));
+    return __i->__ptr_ != this->__end_as_link();
 }
 
 template <class _Tp, class _Alloc>
diff --git a/system/include/libcxx/locale b/system/include/libcxx/locale
index 78f85d8d0700f..b1cac28fb840c 100644
--- a/system/include/libcxx/locale
+++ b/system/include/libcxx/locale
@@ -198,7 +198,8 @@ template <class charT> class messages_byname;
 // include of <sys/cdefs.h> once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html
 // has had a chance to bake for a bit
 #include <support/newlib/xlocale.h>
-#elif !defined(__ANDROID__)
+#endif
+#ifdef _LIBCPP_HAS_CATOPEN
 #include <nl_types.h>
 #endif
 
@@ -212,11 +213,17 @@ template <class charT> class messages_byname;
 #pragma GCC system_header
 #endif
 
+#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
+#include <__bsd_locale_defaults.h>
+#else
+#include <__bsd_locale_fallbacks.h>
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(__APPLE__) || defined(__FreeBSD__)
 #  define _LIBCPP_GET_C_LOCALE 0
-#elif defined(__NetBSD__)
+#elif defined(__CloudABI__) || defined(__NetBSD__)
 #  define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
 #else
 #  define _LIBCPP_GET_C_LOCALE __cloc()
@@ -227,189 +234,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
 typedef _VSTD::unique_ptr<__locale_struct, decltype(&freelocale)> __locale_unique_ptr;
-#ifndef _LIBCPP_LOCALE__L_EXTENSIONS
-typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
-#endif
-
-// OSX has nice foo_l() functions that let you turn off use of the global
-// locale.  Linux, not so much.  The following functions avoid the locale when
-// that's possible and otherwise do the wrong thing.  FIXME.
-#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) || \
-    defined(_NEWLIB_VERSION)
-
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>()))
-inline _LIBCPP_INLINE_VISIBILITY
-__mb_cur_max_l(locale_t __l)
-{
-  return MB_CUR_MAX_L(__l);
-}
-#else  // _LIBCPP_LOCALE__L_EXTENSIONS
-inline _LIBCPP_ALWAYS_INLINE
-decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l)
-{
-  __locale_raii __current(uselocale(__l), uselocale);
-  return MB_CUR_MAX;
-}
-#endif // _LIBCPP_LOCALE__L_EXTENSIONS
-
-inline _LIBCPP_ALWAYS_INLINE
-wint_t __btowc_l(int __c, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return btowc_l(__c, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return btowc(__c);
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-int __wctob_l(wint_t __c, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return wctob_l(__c, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return wctob(__c);
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
-                      size_t __len, mbstate_t *__ps, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return wcrtomb_l(__s, __wc, __ps, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return wcrtomb(__s, __wc, __ps);
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
-                      size_t __len, mbstate_t *__ps, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
-                   mbstate_t *__ps, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return mbrtowc_l(__pwc, __s, __n, __ps, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return mbrtowc(__pwc, __s, __n, __ps);
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return mbtowc_l(__pwc, __pmb, __max, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return mbtowc(__pwc, __pmb, __max);
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return mbrlen_l(__s, __n, __ps, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return mbrlen(__s, __n, __ps);
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-lconv *__localeconv_l(locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return localeconv_l(__l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return localeconv();
-#endif
-}
-
-inline _LIBCPP_ALWAYS_INLINE
-size_t __mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
-                     mbstate_t *__ps, locale_t __l)
-{
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  return mbsrtowcs_l(__dest, __src, __len, __ps, __l);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  return mbsrtowcs(__dest, __src, __len, __ps);
-#endif
-}
-
-inline
-int __snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
-  va_list __va;
-  va_start(__va, __format);
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  int __res = vsnprintf_l(__s, __n, __l, __format, __va);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  int __res = vsnprintf(__s, __n, __format, __va);
-#endif
-  va_end(__va);
-  return __res;
-}
-
-inline
-int __asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
-  va_list __va;
-  va_start(__va, __format);
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  int __res = vasprintf_l(__s, __l, __format, __va);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  int __res = vasprintf(__s, __format, __va);
-#endif
-  va_end(__va);
-  return __res;
-}
-
-inline
-int __sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
-  va_list __va;
-  va_start(__va, __format);
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-  int __res = vsscanf_l(__s, __l, __format, __va);
-#else
-  __locale_raii __current(uselocale(__l), uselocale);
-  int __res = vsscanf(__s, __format, __va);
-#endif
-  va_end(__va);
-  return __res;
-}
-
-#endif  // __linux__
 
 // __scan_keyword
 // Scans [__b, __e) until a match is found in the basic_strings range
@@ -456,7 +280,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
     size_t __n_does_match = 0;       // but none of them definitely do
     // Initialize all statuses to __might_match, except for "" keywords are __does_match
     unsigned char* __st = __status;
-    for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st)
+    for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
     {
         if (!__ky->empty())
             *__st = __might_match;
@@ -482,7 +306,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
         // If the keyword doesn't match this character, then change the keyword
         //    to doesn't match
         __st = __status;
-        for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st)
+        for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
         {
             if (*__st == __might_match)
             {
@@ -516,7 +340,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
             if (__n_might_match + __n_does_match > 1)
             {
                 __st = __status;
-                for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st)
+                for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
                 {
                     if (*__st == __does_match && __ky->size() != __indx+1)
                     {
@@ -531,7 +355,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
     if (__b == __e)
         __err |= ios_base::eofbit;
     // Return the first matching result
-    for (__st = __status; __kb != __ke; ++__kb, ++__st)
+    for (__st = __status; __kb != __ke; ++__kb, (void) ++__st)
         if (*__st == __does_match)
             break;
     if (__kb == __ke)
@@ -1187,11 +1011,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
     }
     // Stage 3
     __buf.resize(__a_end - __a);
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    if (sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
-#else
-    if (__sscanf_l(__buf.c_str(), __cloc(), "%p", &__v) != 1)
-#endif
+    if (__libcpp_sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
         __err = ios_base::failbit;
     // EOF checked
     if (__b == __e)
@@ -1555,13 +1375,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
     this->__format_int(__fmt+1, __len, true, __iob.flags());
     const unsigned __nbuf = (numeric_limits<long>::digits / 3)
                           + ((numeric_limits<long>::digits % 3) != 0)
-                          + 1;
+                          + 2;
     char __nar[__nbuf];
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-    int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
-#endif
+    int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;
     char* __np = this->__identify_padding(__nar, __ne, __iob);
     // Stage 2 - Widen __nar while adding thousands separators
@@ -1585,13 +1401,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
     this->__format_int(__fmt+1, __len, true, __iob.flags());
     const unsigned __nbuf = (numeric_limits<long long>::digits / 3)
                           + ((numeric_limits<long long>::digits % 3) != 0)
-                          + 1;
+                          + 2;
     char __nar[__nbuf];
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-    int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
-#endif
+    int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;
     char* __np = this->__identify_padding(__nar, __ne, __iob);
     // Stage 2 - Widen __nar while adding thousands separators
@@ -1617,11 +1429,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
                           + ((numeric_limits<unsigned long>::digits % 3) != 0)
                           + 1;
     char __nar[__nbuf];
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-    int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
-#endif
+    int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;
     char* __np = this->__identify_padding(__nar, __ne, __iob);
     // Stage 2 - Widen __nar while adding thousands separators
@@ -1647,11 +1455,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
                           + ((numeric_limits<unsigned long long>::digits % 3) != 0)
                           + 1;
     char __nar[__nbuf];
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-    int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
-#endif
+    int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;
     char* __np = this->__identify_padding(__nar, __ne, __iob);
     // Stage 2 - Widen __nar while adding thousands separators
@@ -1678,35 +1482,17 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
     char* __nb = __nar;
     int __nc;
     if (__specify_precision)
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        __nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
+        __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
                                    (int)__iob.precision(), __v);
-#else
-        __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt,
-                            (int)__iob.precision(), __v);
-#endif
     else
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        __nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-        __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v);
-#endif
+        __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
     unique_ptr<char, void(*)(void*)> __nbh(0, free);
     if (__nc > static_cast<int>(__nbuf-1))
     {
         if (__specify_precision)
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-            __nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
-#else
-            __nc = __asprintf_l(&__nb, __cloc(), __fmt,
-                              (int)__iob.precision(), __v);
-#endif
+            __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
         else
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-            __nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-            __nc = __asprintf_l(&__nb, __cloc(), __fmt, (int)__iob.precision(), __v);
-#endif
+            __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
         if (__nb == 0)
             __throw_bad_alloc();
         __nbh.reset(__nb);
@@ -1747,35 +1533,17 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
     char* __nb = __nar;
     int __nc;
     if (__specify_precision)
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        __nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
+        __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
                                    (int)__iob.precision(), __v);
-#else
-        __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt,
-                            (int)__iob.precision(), __v);
-#endif
     else
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        __nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-        __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v);
-#endif
+        __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
     unique_ptr<char, void(*)(void*)> __nbh(0, free);
     if (__nc > static_cast<int>(__nbuf-1))
     {
         if (__specify_precision)
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-            __nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
-#else
-            __nc = __asprintf_l(&__nb, __cloc(), __fmt,
-                              (int)__iob.precision(), __v);
-#endif
+            __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
         else
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-            __nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-            __nc = __asprintf_l(&__nb, __cloc(), __fmt, __v);
-#endif
+            __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
         if (__nb == 0)
             __throw_bad_alloc();
         __nbh.reset(__nb);
@@ -1811,11 +1579,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
     char __fmt[6] = "%p";
     const unsigned __nbuf = 20;
     char __nar[__nbuf];
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#else
-    int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
-#endif
+    int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;
     char* __np = this->__identify_padding(__nar, __ne, __iob);
     // Stage 2 - Widen __nar
@@ -1857,7 +1621,7 @@ __get_up_to_n_digits(_InputIterator& __b, _InputIterator __e,
         return 0;
     }
     int __r = __ct.narrow(__c, 0) - '0';
-    for (++__b, --__n; __b != __e && __n > 0; ++__b, --__n)
+    for (++__b, (void) --__n; __b != __e && __n > 0; ++__b, (void) --__n)
     {
         // get next digit
         __c = *__b;
@@ -1889,6 +1653,9 @@ protected:
     virtual const string_type& __r() const;
     virtual const string_type& __x() const;
     virtual const string_type& __X() const;
+
+    _LIBCPP_ALWAYS_INLINE
+    ~__time_get_c_storage() {}
 };
 
 template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
@@ -2970,6 +2737,8 @@ __double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
     size_t __cur_cap = static_cast<size_t>(__e-__b.get()) * sizeof(_Tp);
     size_t __new_cap = __cur_cap < numeric_limits<size_t>::max() / 2 ?
                        2 * __cur_cap : numeric_limits<size_t>::max();
+    if (__new_cap == 0)
+        __new_cap = sizeof(_Tp);
     size_t __n_off = static_cast<size_t>(__n - __b.get());
     _Tp* __t = (_Tp*)realloc(__owns ? __b.get() : 0, __new_cap);
     if (__t == 0)
@@ -3522,11 +3291,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
     // secure memory for digit storage
     if (__n > __bs-1)
     {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        __n = static_cast<size_t>(asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));
-#else
-        __n = __asprintf_l(&__bb, __cloc(), "%.0Lf", __units);
-#endif
+        __n = static_cast<size_t>(__libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));
         if (__bb == 0)
             __throw_bad_alloc();
         __hn.reset(__bb);
@@ -3679,14 +3444,14 @@ template <class _CharT>
 typename messages<_CharT>::catalog
 messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
 {
-#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION)
-    return -1;
-#else // _WIN32 || __ANDROID__
+#ifdef _LIBCPP_HAS_CATOPEN
     catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
     if (__cat != -1)
         __cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1));
     return __cat;
-#endif // _WIN32 || __ANDROID__
+#else // !_LIBCPP_HAS_CATOPEN
+    return -1;
+#endif // _LIBCPP_HAS_CATOPEN
 }
 
 template <class _CharT>
@@ -3694,9 +3459,7 @@ typename messages<_CharT>::string_type
 messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
                          const string_type& __dflt) const
 {
-#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION)
-    return __dflt;
-#else // _WIN32
+#ifdef _LIBCPP_HAS_CATOPEN
     string __ndflt;
     __narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
                                                        __dflt.c_str(),
@@ -3709,19 +3472,21 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
     __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
                                                         __n, __n + strlen(__n));
     return __w;
-#endif // _WIN32
+#else // !_LIBCPP_HAS_CATOPEN
+    return __dflt;
+#endif // _LIBCPP_HAS_CATOPEN
 }
 
 template <class _CharT>
 void
 messages<_CharT>::do_close(catalog __c) const
 {
-#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
+#ifdef _LIBCPP_HAS_CATOPEN
     if (__c != -1)
         __c <<= 1;
     nl_catd __cat = (nl_catd)__c;
     catclose(__cat);
-#endif // !_WIN32
+#endif // _LIBCPP_HAS_CATOPEN
 }
 
 _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>)
@@ -3772,11 +3537,14 @@ private:
     wstring_convert(const wstring_convert& __wc);
     wstring_convert& operator=(const wstring_convert& __wc);
 public:
+    _LIBCPP_ALWAYS_INLINE
     _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
+    _LIBCPP_ALWAYS_INLINE
     wstring_convert(_Codecvt* __pcvt, state_type __state);
     _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err,
                     const wide_string& __wide_err = wide_string());
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_ALWAYS_INLINE
     wstring_convert(wstring_convert&& __wc);
 #endif
     ~wstring_convert();
@@ -3810,7 +3578,7 @@ public:
 };
 
 template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
-inline _LIBCPP_ALWAYS_INLINE
+inline
 wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
     wstring_convert(_Codecvt* __pcvt)
         : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0)
@@ -3818,7 +3586,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
 }
 
 template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
-inline _LIBCPP_ALWAYS_INLINE
+inline
 wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
     wstring_convert(_Codecvt* __pcvt, state_type __state)
         : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0)
@@ -3837,7 +3605,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
-inline _LIBCPP_ALWAYS_INLINE
+inline
 wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
     wstring_convert(wstring_convert&& __wc)
         : __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)),
@@ -4312,18 +4080,9 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir
     int __width = __cv_->encoding();
     if (__cv_ == 0 || __bufptr_ == 0 || (__width <= 0 && __off != 0) || sync())
         return pos_type(off_type(-1));
-    // __width > 0 || __off == 0
-    switch (__way)
-    {
-    case ios_base::beg:
-        break;
-    case ios_base::cur:
-        break;
-    case ios_base::end:
-        break;
-    default:
+    // __width > 0 || __off == 0, now check __way
+    if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end)
         return pos_type(off_type(-1));
-    }
     pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om);
     __r.state(__st_);
     return __r;
diff --git a/system/include/libcxx/map b/system/include/libcxx/map
index 5c3969acdd28c..8dc84e73cbf28 100644
--- a/system/include/libcxx/map
+++ b/system/include/libcxx/map
@@ -126,25 +126,43 @@ public:
     template <class... Args>
         iterator emplace_hint(const_iterator position, Args&&... args);
     pair<iterator, bool> insert(const value_type& v);
+    pair<iterator, bool> insert(      value_type&& v);                                // C++17
     template <class P>
         pair<iterator, bool> insert(P&& p);
     iterator insert(const_iterator position, const value_type& v);
+    iterator insert(const_iterator position,       value_type&& v);                   // C++17
     template <class P>
         iterator insert(const_iterator position, P&& p);
     template <class InputIterator>
         void insert(InputIterator first, InputIterator last);
     void insert(initializer_list<value_type> il);
 
+    template <class... Args>
+        pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
+    template <class... Args>
+        pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
+    template <class... Args>
+        iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
+    template <class... Args>
+        iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
+    template <class M>
+        pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
+    template <class M>
+        pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
+    template <class M>
+        iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
+    template <class M>
+        iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
+
     iterator  erase(const_iterator position);
+    iterator  erase(iterator position); // C++14
     size_type erase(const key_type& k);
     iterator  erase(const_iterator first, const_iterator last);
     void clear() noexcept;
 
     void swap(map& m)
-        noexcept(
-            __is_nothrow_swappable<key_compare>::value &&
-            (!allocator_type::propagate_on_container_swap::value ||
-             __is_nothrow_swappable<allocator_type>::value));
+        noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
+            is_nothrow_swappable<key_compare>::value); // C++17
 
     // observers:
     allocator_type get_allocator() const noexcept;
@@ -320,9 +338,11 @@ public:
     template <class... Args>
         iterator emplace_hint(const_iterator position, Args&&... args);
     iterator insert(const value_type& v);
+    iterator insert(      value_type&& v);                                            // C++17
     template <class P>
         iterator insert(P&& p);
     iterator insert(const_iterator position, const value_type& v);
+    iterator insert(const_iterator position,       value_type&& v);                   // C++17
     template <class P>
         iterator insert(const_iterator position, P&& p);
     template <class InputIterator>
@@ -330,15 +350,14 @@ public:
     void insert(initializer_list<value_type> il);
 
     iterator  erase(const_iterator position);
+    iterator  erase(iterator position); // C++14
     size_type erase(const key_type& k);
     iterator  erase(const_iterator first, const_iterator last);
     void clear() noexcept;
 
     void swap(multimap& m)
-        noexcept(
-            __is_nothrow_swappable<key_compare>::value &&
-            (!allocator_type::propagate_on_container_swap::value ||
-             __is_nothrow_swappable<allocator_type>::value));
+        noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
+            is_nothrow_swappable<key_compare>::value); // C++17
 
     // observers:
     allocator_type get_allocator() const noexcept;
@@ -426,6 +445,7 @@ swap(multimap<Key, T, Compare, Allocator>& x,
 #include <utility>
 #include <functional>
 #include <initializer_list>
+#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -433,10 +453,8 @@ swap(multimap<Key, T, Compare, Allocator>& x,
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <class _Key, class _CP, class _Compare, bool = is_empty<_Compare>::value
-#if __has_feature(is_final)
-                                                        && !__is_final(_Compare)
-#endif
+template <class _Key, class _CP, class _Compare,
+          bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value
          >
 class __map_value_compare
     : private _Compare
@@ -461,6 +479,12 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Key& __x, const _CP& __y) const
         {return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);}
+    void swap(__map_value_compare&__y)
+        _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
+    {
+        using _VSTD::swap;
+        swap(static_cast<const _Compare&>(*this), static_cast<const _Compare&>(__y));
+    }
 
 #if _LIBCPP_STD_VER > 11
     template <typename _K2>
@@ -503,7 +527,13 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Key& __x, const _CP& __y) const
         {return comp(__x, __y.__cc.first);}
-
+    void swap(__map_value_compare&__y)
+        _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
+    {
+        using _VSTD::swap;
+        swap(comp, __y.comp);
+    }
+    
 #if _LIBCPP_STD_VER > 11
     template <typename _K2>
     _LIBCPP_INLINE_VISIBILITY
@@ -519,18 +549,26 @@ public:
 #endif
 };
 
+template <class _Key, class _CP, class _Compare, bool __b>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__map_value_compare<_Key, _CP, _Compare, __b>& __x,
+     __map_value_compare<_Key, _CP, _Compare, __b>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
 template <class _Allocator>
 class __map_node_destructor
 {
     typedef _Allocator                          allocator_type;
     typedef allocator_traits<allocator_type>    __alloc_traits;
-    typedef typename __alloc_traits::value_type::value_type value_type;
+
 public:
     typedef typename __alloc_traits::pointer    pointer;
-private:
-    typedef typename value_type::value_type::first_type     first_type;
-    typedef typename value_type::value_type::second_type    second_type;
 
+private:
     allocator_type& __na_;
 
     __map_node_destructor& operator=(const __map_node_destructor&);
@@ -575,7 +613,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
     class multimap;
 template <class _TreeIterator> class __map_const_iterator;
 
-#if __cplusplus >= 201103L
+#ifndef _LIBCPP_CXX03_LANG
 
 template <class _Key, class _Tp>
 union __value_type
@@ -588,33 +626,29 @@ union __value_type
     value_type __cc;
     __nc_value_type __nc;
 
-    template <class ..._Args>
-    _LIBCPP_INLINE_VISIBILITY
-    __value_type(_Args&& ...__args)
-        : __cc(std::forward<_Args>(__args)...) {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    __value_type(const __value_type& __v)
-        : __cc(__v.__cc) {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    __value_type(__value_type& __v)
-        : __cc(__v.__cc) {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    __value_type(__value_type&& __v)
-        : __nc(std::move(__v.__nc)) {}
-
     _LIBCPP_INLINE_VISIBILITY
     __value_type& operator=(const __value_type& __v)
         {__nc = __v.__cc; return *this;}
 
     _LIBCPP_INLINE_VISIBILITY
     __value_type& operator=(__value_type&& __v)
-        {__nc = std::move(__v.__nc); return *this;}
+        {__nc = _VSTD::move(__v.__nc); return *this;}
 
+    template <class _ValueTp,
+              class = typename enable_if<
+                    __is_same_uncvref<_ValueTp, value_type>::value
+                 >::type
+             >
     _LIBCPP_INLINE_VISIBILITY
-    ~__value_type() {__cc.~value_type();}
+    __value_type& operator=(_ValueTp&& __v) {
+        __nc = _VSTD::forward<_ValueTp>(__v); return *this;
+    }
+
+private:
+    __value_type() _LIBCPP_EQUAL_DELETE;
+    ~__value_type() _LIBCPP_EQUAL_DELETE;
+    __value_type(const __value_type& __v) _LIBCPP_EQUAL_DELETE;
+    __value_type(__value_type&& __v) _LIBCPP_EQUAL_DELETE;
 };
 
 #else
@@ -628,42 +662,39 @@ struct __value_type
 
     value_type __cc;
 
-    _LIBCPP_INLINE_VISIBILITY
-    __value_type() {}
-
-    template <class _A0>
-    _LIBCPP_INLINE_VISIBILITY
-    __value_type(const _A0& __a0)
-        : __cc(__a0) {}
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    __value_type(const _A0& __a0, const _A1& __a1)
-        : __cc(__a0, __a1) {}
+private:
+   __value_type();
+   __value_type(__value_type const&);
+   __value_type& operator=(__value_type const&);
+   ~__value_type();
 };
 
 #endif
 
+template <class _Tp>
+struct __extract_key_value_types;
+
+template <class _Key, class _Tp>
+struct __extract_key_value_types<__value_type<_Key, _Tp> >
+{
+  typedef _Key const __key_type;
+  typedef _Tp        __mapped_type;
+};
+
 template <class _TreeIterator>
 class _LIBCPP_TYPE_VIS_ONLY __map_iterator
 {
+    typedef typename _TreeIterator::_NodeTypes                   _NodeTypes;
+    typedef typename _TreeIterator::__pointer_traits             __pointer_traits;
+
     _TreeIterator __i_;
 
-    typedef typename _TreeIterator::__pointer_traits             __pointer_traits;
-    typedef const typename _TreeIterator::value_type::value_type::first_type __key_type;
-    typedef typename _TreeIterator::value_type::value_type::second_type      __mapped_type;
 public:
     typedef bidirectional_iterator_tag                           iterator_category;
-    typedef pair<__key_type, __mapped_type>                      value_type;
+    typedef typename _NodeTypes::__map_value_type                value_type;
     typedef typename _TreeIterator::difference_type              difference_type;
     typedef value_type&                                          reference;
-    typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<value_type>
-#else
-            rebind<value_type>::other
-#endif
-                                                                 pointer;
+    typedef typename _NodeTypes::__map_value_type_pointer        pointer;
 
     _LIBCPP_INLINE_VISIBILITY
     __map_iterator() _NOEXCEPT {}
@@ -712,23 +743,17 @@ public:
 template <class _TreeIterator>
 class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator
 {
+    typedef typename _TreeIterator::_NodeTypes                   _NodeTypes;
+    typedef typename _TreeIterator::__pointer_traits             __pointer_traits;
+
     _TreeIterator __i_;
 
-    typedef typename _TreeIterator::__pointer_traits             __pointer_traits;
-    typedef const typename _TreeIterator::value_type::value_type::first_type __key_type;
-    typedef typename _TreeIterator::value_type::value_type::second_type      __mapped_type;
 public:
     typedef bidirectional_iterator_tag                           iterator_category;
-    typedef pair<__key_type, __mapped_type>                      value_type;
+    typedef typename _NodeTypes::__map_value_type                value_type;
     typedef typename _TreeIterator::difference_type              difference_type;
     typedef const value_type&                                    reference;
-    typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const value_type>
-#else
-            rebind<const value_type>::other
-#endif
-                                                                 pointer;
+    typedef typename _NodeTypes::__const_map_value_type_pointer  pointer;
 
     _LIBCPP_INLINE_VISIBILITY
     __map_const_iterator() _NOEXCEPT {}
@@ -736,10 +761,9 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
     _LIBCPP_INLINE_VISIBILITY
-    __map_const_iterator(
-            __map_iterator<typename _TreeIterator::__non_const_iterator> __i)
-                _NOEXCEPT
-                : __i_(__i.__i_) {}
+    __map_const_iterator(__map_iterator<
+        typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT
+        : __i_(__i.__i_) {}
 
     _LIBCPP_INLINE_VISIBILITY
     reference operator*() const {return __i_->__cc;}
@@ -793,6 +817,9 @@ public:
     typedef value_type&                              reference;
     typedef const value_type&                        const_reference;
 
+    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+                  "Allocator::value_type must be same type as value_type");
+
     class _LIBCPP_TYPE_VIS_ONLY value_compare
         : public binary_function<value_type, value_type, bool>
     {
@@ -811,13 +838,8 @@ private:
 
     typedef _VSTD::__value_type<key_type, mapped_type>             __value_type;
     typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
-    typedef typename allocator_traits<allocator_type>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__value_type>
-#else
-            rebind_alloc<__value_type>::other
-#endif
-                                                           __allocator_type;
+    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+                                                 __value_type>::type __allocator_type;
     typedef __tree<__value_type, __vc, __allocator_type>   __base;
     typedef typename __base::__node_traits                 __node_traits;
     typedef allocator_traits<allocator_type>               __alloc_traits;
@@ -829,7 +851,7 @@ public:
     typedef typename __alloc_traits::const_pointer         const_pointer;
     typedef typename __alloc_traits::size_type             size_type;
     typedef typename __alloc_traits::difference_type       difference_type;
-    typedef __map_iterator<typename __base::iterator>      iterator;
+    typedef __map_iterator<typename __base::iterator>             iterator;
     typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
     typedef _VSTD::reverse_iterator<iterator>               reverse_iterator;
     typedef _VSTD::reverse_iterator<const_iterator>         const_reverse_iterator;
@@ -1004,7 +1026,7 @@ public:
     size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
 
     mapped_type& operator[](const key_type& __k);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
     mapped_type& operator[](key_type&& __k);
 #endif
 
@@ -1018,18 +1040,18 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     value_compare  value_comp()    const {return value_compare(__tree_.value_comp().key_comp());}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
+#ifndef _LIBCPP_CXX03_LANG
     template <class ..._Args>
-        pair<iterator, bool>
-        emplace(_Args&& ...__args);
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> emplace(_Args&& ...__args) {
+        return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
+    }
 
     template <class ..._Args>
-        iterator
-        emplace_hint(const_iterator __p, _Args&& ...__args);
-
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+    _LIBCPP_INLINE_VISIBILITY
+    iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
+        return __tree_.__emplace_hint_unique(__p.__i_, _VSTD::forward<_Args>(__args)...);
+    }
 
     template <class _Pp,
               class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
@@ -1043,7 +1065,7 @@ public:
         iterator insert(const_iterator __pos, _Pp&& __p)
             {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
     _LIBCPP_INLINE_VISIBILITY
     pair<iterator, bool>
@@ -1054,6 +1076,16 @@ public:
         insert(const_iterator __p, const value_type& __v)
             {return __tree_.__insert_unique(__p.__i_, __v);}
 
+#ifndef _LIBCPP_CXX03_LANG
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+    insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p,  value_type&& __v)
+    {return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));}
+#endif
+
     template <class _InputIterator>
         _LIBCPP_INLINE_VISIBILITY
         void insert(_InputIterator __f, _InputIterator __l)
@@ -1070,9 +1102,107 @@ public:
 
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
+#if _LIBCPP_STD_VER > 14
+
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
+    {
+        return __tree_.__emplace_unique_key_args(__k,
+            _VSTD::piecewise_construct,
+            _VSTD::forward_as_tuple(__k),
+            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+    }
+
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
+    {
+        return __tree_.__emplace_unique_key_args(__k,
+            _VSTD::piecewise_construct,
+            _VSTD::forward_as_tuple(_VSTD::move(__k)),
+            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+    }
+
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
+    {
+        return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
+            _VSTD::piecewise_construct,
+            _VSTD::forward_as_tuple(__k),
+            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+    }
+
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
+    {
+        return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
+            _VSTD::piecewise_construct,
+            _VSTD::forward_as_tuple(_VSTD::move(__k)),
+            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+    }
+
+    template <class _Vp>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
+    {
+        iterator __p = lower_bound(__k);
+        if ( __p != end() && !key_comp()(__k, __p->first))
+        {
+            __p->second = _VSTD::forward<_Vp>(__v);
+            return _VSTD::make_pair(__p, false);
+        }
+        return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
+    }
+
+    template <class _Vp>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
+    {
+        iterator __p = lower_bound(__k);
+        if ( __p != end() && !key_comp()(__k, __p->first))
+        {
+            __p->second = _VSTD::forward<_Vp>(__v);
+            return _VSTD::make_pair(__p, false);
+        }
+        return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true);
+    }
+
+    template <class _Vp>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
+     {
+        iterator __p = lower_bound(__k);
+        if ( __p != end() && !key_comp()(__k, __p->first))
+        {
+            __p->second = _VSTD::forward<_Vp>(__v);
+            return __p;
+        }
+        return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));
+     }
+
+    template <class _Vp>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
+     {
+        iterator __p = lower_bound(__k);
+        if ( __p != end() && !key_comp()(__k, __p->first))
+        {
+            __p->second = _VSTD::forward<_Vp>(__v);
+            return __p;
+        }
+        return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
+     }
+
+#endif
+
     _LIBCPP_INLINE_VISIBILITY
     iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
     _LIBCPP_INLINE_VISIBILITY
+    iterator erase(iterator __p)       {return __tree_.erase(__p.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
     size_type erase(const key_type& __k)
         {return __tree_.__erase_unique(__k);}
     _LIBCPP_INLINE_VISIBILITY
@@ -1108,7 +1238,7 @@ public:
     template <typename _K2>
     _LIBCPP_INLINE_VISIBILITY
     typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
-    count(const _K2& __k)                  {return __tree_.__count_unique(__k);}
+    count(const _K2& __k) const {return __tree_.__count_unique(__k);}
 #endif
     _LIBCPP_INLINE_VISIBILITY
     iterator lower_bound(const key_type& __k)
@@ -1166,85 +1296,38 @@ private:
     typedef typename __base::__node                    __node;
     typedef typename __base::__node_allocator          __node_allocator;
     typedef typename __base::__node_pointer            __node_pointer;
-    typedef typename __base::__node_const_pointer      __node_const_pointer;
     typedef typename __base::__node_base_pointer       __node_base_pointer;
-    typedef typename __base::__node_base_const_pointer __node_base_const_pointer;
+
     typedef __map_node_destructor<__node_allocator> _Dp;
     typedef unique_ptr<__node, _Dp> __node_holder;
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    __node_holder __construct_node();
-    template <class _A0>
-        __node_holder __construct_node(_A0&& __a0);
-    __node_holder __construct_node_with_key(key_type&& __k);
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-    template <class _A0, class _A1, class ..._Args>
-        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif
+#ifdef _LIBCPP_CXX03_LANG
     __node_holder __construct_node_with_key(const key_type& __k);
+#endif
+
+    __node_base_pointer const&
+    __find_equal_key(__node_base_pointer& __parent, const key_type& __k) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     __node_base_pointer&
-        __find_equal_key(__node_base_pointer& __parent, const key_type& __k);
-    __node_base_const_pointer
-        __find_equal_key(__node_base_const_pointer& __parent, const key_type& __k) const;
+    __find_equal_key(__node_base_pointer& __parent, const key_type& __k) {
+        map const* __const_this = this;
+        return const_cast<__node_base_pointer&>(
+            __const_this->__find_equal_key(__parent, __k));
+    }
 };
 
-// Find place to insert if __k doesn't exist
-// Set __parent to parent of null leaf
-// Return reference to null leaf
-// If __k exists, set parent to node of __k and return reference to node of __k
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer&
-map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
-                                                       const key_type& __k)
-{
-    __node_pointer __nd = __tree_.__root();
-    if (__nd != nullptr)
-    {
-        while (true)
-        {
-            if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
-            {
-                if (__nd->__left_ != nullptr)
-                    __nd = static_cast<__node_pointer>(__nd->__left_);
-                else
-                {
-                    __parent = static_cast<__node_base_pointer>(__nd);
-                    return __parent->__left_;
-                }
-            }
-            else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
-            {
-                if (__nd->__right_ != nullptr)
-                    __nd = static_cast<__node_pointer>(__nd->__right_);
-                else
-                {
-                    __parent = static_cast<__node_base_pointer>(__nd);
-                    return __parent->__right_;
-                }
-            }
-            else
-            {
-                __parent = static_cast<__node_base_pointer>(__nd);
-                return __parent;
-            }
-        }
-    }
-    __parent = static_cast<__node_base_pointer>(__tree_.__end_node());
-    return __parent->__left_;
-}
 
 // Find __k
 // Set __parent to parent of null leaf and
 //    return reference to null leaf iv __k does not exist.
 // If __k exists, set parent to node of __k and return reference to node of __k
 template <class _Key, class _Tp, class _Compare, class _Allocator>
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_const_pointer
-map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer& __parent,
+typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer const&
+map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
                                                        const key_type& __k) const
 {
-    __node_const_pointer __nd = __tree_.__root();
+    __node_pointer __nd = __tree_.__root();
     if (__nd != nullptr)
     {
         while (true)
@@ -1256,7 +1339,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer
                 else
                 {
                     __parent = static_cast<__node_base_pointer>(__nd);
-                    return const_cast<const __node_base_const_pointer&>(__parent->__left_);
+                    return __parent->__left_;
                 }
             }
             else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
@@ -1266,7 +1349,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer
                 else
                 {
                     __parent = static_cast<__node_base_pointer>(__nd);
-                    return const_cast<const __node_base_const_pointer&>(__parent->__right_);
+                    return __parent->__right_;
                 }
             }
             else
@@ -1277,10 +1360,10 @@ map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer
         }
     }
     __parent = static_cast<__node_base_pointer>(__tree_.__end_node());
-    return const_cast<const __node_base_const_pointer&>(__parent->__left_);
+    return __parent->__left_;
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
@@ -1291,69 +1374,14 @@ map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
         const_iterator __e = cend();
         while (!__m.empty())
             __tree_.__insert_unique(__e.__i_,
-                    _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
+                    _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__nc));
     }
 }
 
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
-map<_Key, _Tp, _Compare, _Allocator>::__construct_node()
-{
-    __node_allocator& __na = __tree_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
-    __h.get_deleter().__first_constructed = true;
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class _A0>
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
-map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
-{
-    __node_allocator& __na = __tree_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_A0>(__a0));
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
-map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k)
-{
-    __node_allocator& __na = __tree_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
-    __h.get_deleter().__first_constructed = true;
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
+#endif  // !_LIBCPP_CXX03_LANG
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
 
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class _A0, class _A1, class ..._Args>
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
-map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args)
-{
-    __node_allocator& __na = __tree_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
-                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
-                             _VSTD::forward<_Args>(__args)...);
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifdef _LIBCPP_CXX03_LANG
 
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
@@ -1365,7 +1393,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type&
     __h.get_deleter().__first_constructed = true;
     __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
     __h.get_deleter().__second_constructed = true;
-    return _VSTD::move(__h);  // explicitly moved for C++03
+    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
 
 template <class _Key, class _Tp, class _Compare, class _Allocator>
@@ -1384,25 +1412,29 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
     return __r->__value_.__cc.second;
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+_Tp&
+map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
+{
+    return __tree_.__emplace_unique_key_args(__k,
+        _VSTD::piecewise_construct,
+        _VSTD::forward_as_tuple(__k),
+        _VSTD::forward_as_tuple()).first->__cc.second;
+}
 
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 _Tp&
 map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
 {
-    __node_base_pointer __parent;
-    __node_base_pointer& __child = __find_equal_key(__parent, __k);
-    __node_pointer __r = static_cast<__node_pointer>(__child);
-    if (__child == nullptr)
-    {
-        __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
-        __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
-        __r = __h.release();
-    }
-    return __r->__value_.__cc.second;
+    return __tree_.__emplace_unique_key_args(__k,
+        _VSTD::piecewise_construct,
+        _VSTD::forward_as_tuple(_VSTD::move(__k)),
+        _VSTD::forward_as_tuple()).first->__cc.second;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // !_LIBCPP_CXX03_LANG
 
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 _Tp&
@@ -1421,43 +1453,15 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
 const _Tp&
 map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
 {
-    __node_base_const_pointer __parent;
-    __node_base_const_pointer __child = __find_equal_key(__parent, __k);
+    __node_base_pointer __parent;
+    __node_base_pointer __child = __find_equal_key(__parent, __k);
 #ifndef _LIBCPP_NO_EXCEPTIONS
     if (__child == nullptr)
         throw out_of_range("map::at:  key not found");
 #endif  // _LIBCPP_NO_EXCEPTIONS
-    return static_cast<__node_const_pointer>(__child)->__value_.__cc.second;
-}
-
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class ..._Args>
-pair<typename map<_Key, _Tp, _Compare, _Allocator>::iterator, bool>
-map<_Key, _Tp, _Compare, _Allocator>::emplace(_Args&& ...__args)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-    pair<iterator, bool> __r = __tree_.__node_insert_unique(__h.get());
-    if (__r.second)
-        __h.release();
-    return __r;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class ..._Args>
-typename map<_Key, _Tp, _Compare, _Allocator>::iterator
-map<_Key, _Tp, _Compare, _Allocator>::emplace_hint(const_iterator __p,
-                                                   _Args&& ...__args)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-    iterator __r = __tree_.__node_insert_unique(__p.__i_, __h.get());
-    if (__r.__i_.__ptr_ == __h.get())
-        __h.release();
-    return __r;
+    return static_cast<__node_pointer>(__child)->__value_.__cc.second;
 }
 
-#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
 
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -1538,6 +1542,9 @@ public:
     typedef value_type&                              reference;
     typedef const value_type&                        const_reference;
 
+    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+                  "Allocator::value_type must be same type as value_type");
+
     class _LIBCPP_TYPE_VIS_ONLY value_compare
         : public binary_function<value_type, value_type, bool>
     {
@@ -1557,13 +1564,8 @@ private:
 
     typedef _VSTD::__value_type<key_type, mapped_type>             __value_type;
     typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
-    typedef typename allocator_traits<allocator_type>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__value_type>
-#else
-            rebind_alloc<__value_type>::other
-#endif
-                                                                    __allocator_type;
+    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+                                                 __value_type>::type __allocator_type;
     typedef __tree<__value_type, __vc, __allocator_type>            __base;
     typedef typename __base::__node_traits                          __node_traits;
     typedef allocator_traits<allocator_type>                        __alloc_traits;
@@ -1757,18 +1759,19 @@ public:
     value_compare  value_comp() const
         {return value_compare(__tree_.value_comp().key_comp());}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
     template <class ..._Args>
-        iterator
-        emplace(_Args&& ...__args);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator emplace(_Args&& ...__args) {
+        return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
+    }
 
     template <class ..._Args>
-        iterator
-        emplace_hint(const_iterator __p, _Args&& ...__args);
-
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+    _LIBCPP_INLINE_VISIBILITY
+    iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
+        return __tree_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
+    }
 
     template <class _Pp,
               class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
@@ -1782,7 +1785,15 @@ public:
         iterator insert(const_iterator __pos, _Pp&& __p)
             {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(value_type&& __v)
+        {return __tree_.__insert_multi(_VSTD::move(__v));}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, value_type&& __v)
+        {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));}
+
+#endif  // _LIBCPP_CXX03_LANG
 
     _LIBCPP_INLINE_VISIBILITY
     iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);}
@@ -1810,6 +1821,8 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
     _LIBCPP_INLINE_VISIBILITY
+    iterator erase(iterator __p)       {return __tree_.erase(__p.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
     size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
     _LIBCPP_INLINE_VISIBILITY
     iterator  erase(const_iterator __f, const_iterator __l)
@@ -1844,7 +1857,7 @@ public:
     template <typename _K2>
     _LIBCPP_INLINE_VISIBILITY
     typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
-    count(const _K2& __k)                   {return __tree_.__count_multi(__k);}
+    count(const _K2& __k) const {return __tree_.__count_multi(__k);}
 #endif
     _LIBCPP_INLINE_VISIBILITY
     iterator lower_bound(const key_type& __k)
@@ -1902,24 +1915,12 @@ private:
     typedef typename __base::__node                    __node;
     typedef typename __base::__node_allocator          __node_allocator;
     typedef typename __base::__node_pointer            __node_pointer;
-    typedef typename __base::__node_const_pointer      __node_const_pointer;
+
     typedef __map_node_destructor<__node_allocator> _Dp;
     typedef unique_ptr<__node, _Dp> __node_holder;
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    __node_holder __construct_node();
-    template <class _A0>
-        __node_holder
-         __construct_node(_A0&& __a0);
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-    template <class _A0, class _A1, class ..._Args>
-        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 };
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
+#ifndef _LIBCPP_CXX03_LANG
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
     : __tree_(_VSTD::move(__m.__tree_), __a)
@@ -1929,82 +1930,10 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca
         const_iterator __e = cend();
         while (!__m.empty())
             __tree_.__insert_multi(__e.__i_,
-                    _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
+                    _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__nc));
     }
 }
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
-multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node()
-{
-    __node_allocator& __na = __tree_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
-    __h.get_deleter().__first_constructed = true;
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class _A0>
-typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
-multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
-{
-    __node_allocator& __na = __tree_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_A0>(__a0));
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class _A0, class _A1, class ..._Args>
-typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
-multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args)
-{
-    __node_allocator& __na = __tree_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
-                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
-                             _VSTD::forward<_Args>(__args)...);
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class ..._Args>
-typename multimap<_Key, _Tp, _Compare, _Allocator>::iterator
-multimap<_Key, _Tp, _Compare, _Allocator>::emplace(_Args&& ...__args)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-    iterator __r = __tree_.__node_insert_multi(__h.get());
-    __h.release();
-    return __r;
-}
-
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class ..._Args>
-typename multimap<_Key, _Tp, _Compare, _Allocator>::iterator
-multimap<_Key, _Tp, _Compare, _Allocator>::emplace_hint(const_iterator __p,
-                                                        _Args&& ...__args)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-    iterator __r = __tree_.__node_insert_multi(__p.__i_, __h.get());
-    __h.release();
-    return __r;
-}
-
-#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+#endif
 
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
diff --git a/system/include/libcxx/math.h b/system/include/libcxx/math.h
new file mode 100644
index 0000000000000..20205544d51d3
--- /dev/null
+++ b/system/include/libcxx/math.h
@@ -0,0 +1,1419 @@
+// -*- C++ -*-
+//===---------------------------- math.h ----------------------------------===//
+//
+//                     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_MATH_H
+#define _LIBCPP_MATH_H
+
+/*
+    math.h synopsis
+
+Macros:
+
+    HUGE_VAL
+    HUGE_VALF               // C99
+    HUGE_VALL               // C99
+    INFINITY                // C99
+    NAN                     // C99
+    FP_INFINITE             // C99
+    FP_NAN                  // C99
+    FP_NORMAL               // C99
+    FP_SUBNORMAL            // C99
+    FP_ZERO                 // C99
+    FP_FAST_FMA             // C99
+    FP_FAST_FMAF            // C99
+    FP_FAST_FMAL            // C99
+    FP_ILOGB0               // C99
+    FP_ILOGBNAN             // C99
+    MATH_ERRNO              // C99
+    MATH_ERREXCEPT          // C99
+    math_errhandling        // C99
+
+Types:
+
+    float_t                 // C99
+    double_t                // C99
+
+// C90
+
+floating_point abs(floating_point x);
+
+floating_point acos (arithmetic x);
+float          acosf(float x);
+long double    acosl(long double x);
+
+floating_point asin (arithmetic x);
+float          asinf(float x);
+long double    asinl(long double x);
+
+floating_point atan (arithmetic x);
+float          atanf(float x);
+long double    atanl(long double x);
+
+floating_point atan2 (arithmetic y, arithmetic x);
+float          atan2f(float y, float x);
+long double    atan2l(long double y, long double x);
+
+floating_point ceil (arithmetic x);
+float          ceilf(float x);
+long double    ceill(long double x);
+
+floating_point cos (arithmetic x);
+float          cosf(float x);
+long double    cosl(long double x);
+
+floating_point cosh (arithmetic x);
+float          coshf(float x);
+long double    coshl(long double x);
+
+floating_point exp (arithmetic x);
+float          expf(float x);
+long double    expl(long double x);
+
+floating_point fabs (arithmetic x);
+float          fabsf(float x);
+long double    fabsl(long double x);
+
+floating_point floor (arithmetic x);
+float          floorf(float x);
+long double    floorl(long double x);
+
+floating_point fmod (arithmetic x, arithmetic y);
+float          fmodf(float x, float y);
+long double    fmodl(long double x, long double y);
+
+floating_point frexp (arithmetic value, int* exp);
+float          frexpf(float value, int* exp);
+long double    frexpl(long double value, int* exp);
+
+floating_point ldexp (arithmetic value, int exp);
+float          ldexpf(float value, int exp);
+long double    ldexpl(long double value, int exp);
+
+floating_point log (arithmetic x);
+float          logf(float x);
+long double    logl(long double x);
+
+floating_point log10 (arithmetic x);
+float          log10f(float x);
+long double    log10l(long double x);
+
+floating_point modf (floating_point value, floating_point* iptr);
+float          modff(float value, float* iptr);
+long double    modfl(long double value, long double* iptr);
+
+floating_point pow (arithmetic x, arithmetic y);
+float          powf(float x, float y);
+long double    powl(long double x, long double y);
+
+floating_point sin (arithmetic x);
+float          sinf(float x);
+long double    sinl(long double x);
+
+floating_point sinh (arithmetic x);
+float          sinhf(float x);
+long double    sinhl(long double x);
+
+floating_point sqrt (arithmetic x);
+float          sqrtf(float x);
+long double    sqrtl(long double x);
+
+floating_point tan (arithmetic x);
+float          tanf(float x);
+long double    tanl(long double x);
+
+floating_point tanh (arithmetic x);
+float          tanhf(float x);
+long double    tanhl(long double x);
+
+//  C99
+
+bool signbit(arithmetic x);
+
+int fpclassify(arithmetic x);
+
+bool isfinite(arithmetic x);
+bool isinf(arithmetic x);
+bool isnan(arithmetic x);
+bool isnormal(arithmetic x);
+
+bool isgreater(arithmetic x, arithmetic y);
+bool isgreaterequal(arithmetic x, arithmetic y);
+bool isless(arithmetic x, arithmetic y);
+bool islessequal(arithmetic x, arithmetic y);
+bool islessgreater(arithmetic x, arithmetic y);
+bool isunordered(arithmetic x, arithmetic y);
+
+floating_point acosh (arithmetic x);
+float          acoshf(float x);
+long double    acoshl(long double x);
+
+floating_point asinh (arithmetic x);
+float          asinhf(float x);
+long double    asinhl(long double x);
+
+floating_point atanh (arithmetic x);
+float          atanhf(float x);
+long double    atanhl(long double x);
+
+floating_point cbrt (arithmetic x);
+float          cbrtf(float x);
+long double    cbrtl(long double x);
+
+floating_point copysign (arithmetic x, arithmetic y);
+float          copysignf(float x, float y);
+long double    copysignl(long double x, long double y);
+
+floating_point erf (arithmetic x);
+float          erff(float x);
+long double    erfl(long double x);
+
+floating_point erfc (arithmetic x);
+float          erfcf(float x);
+long double    erfcl(long double x);
+
+floating_point exp2 (arithmetic x);
+float          exp2f(float x);
+long double    exp2l(long double x);
+
+floating_point expm1 (arithmetic x);
+float          expm1f(float x);
+long double    expm1l(long double x);
+
+floating_point fdim (arithmetic x, arithmetic y);
+float          fdimf(float x, float y);
+long double    fdiml(long double x, long double y);
+
+floating_point fma (arithmetic x, arithmetic y, arithmetic z);
+float          fmaf(float x, float y, float z);
+long double    fmal(long double x, long double y, long double z);
+
+floating_point fmax (arithmetic x, arithmetic y);
+float          fmaxf(float x, float y);
+long double    fmaxl(long double x, long double y);
+
+floating_point fmin (arithmetic x, arithmetic y);
+float          fminf(float x, float y);
+long double    fminl(long double x, long double y);
+
+floating_point hypot (arithmetic x, arithmetic y);
+float          hypotf(float x, float y);
+long double    hypotl(long double x, long double y);
+
+int ilogb (arithmetic x);
+int ilogbf(float x);
+int ilogbl(long double x);
+
+floating_point lgamma (arithmetic x);
+float          lgammaf(float x);
+long double    lgammal(long double x);
+
+long long llrint (arithmetic x);
+long long llrintf(float x);
+long long llrintl(long double x);
+
+long long llround (arithmetic x);
+long long llroundf(float x);
+long long llroundl(long double x);
+
+floating_point log1p (arithmetic x);
+float          log1pf(float x);
+long double    log1pl(long double x);
+
+floating_point log2 (arithmetic x);
+float          log2f(float x);
+long double    log2l(long double x);
+
+floating_point logb (arithmetic x);
+float          logbf(float x);
+long double    logbl(long double x);
+
+long lrint (arithmetic x);
+long lrintf(float x);
+long lrintl(long double x);
+
+long lround (arithmetic x);
+long lroundf(float x);
+long lroundl(long double x);
+
+double      nan (const char* str);
+float       nanf(const char* str);
+long double nanl(const char* str);
+
+floating_point nearbyint (arithmetic x);
+float          nearbyintf(float x);
+long double    nearbyintl(long double x);
+
+floating_point nextafter (arithmetic x, arithmetic y);
+float          nextafterf(float x, float y);
+long double    nextafterl(long double x, long double y);
+
+floating_point nexttoward (arithmetic x, long double y);
+float          nexttowardf(float x, long double y);
+long double    nexttowardl(long double x, long double y);
+
+floating_point remainder (arithmetic x, arithmetic y);
+float          remainderf(float x, float y);
+long double    remainderl(long double x, long double y);
+
+floating_point remquo (arithmetic x, arithmetic y, int* pquo);
+float          remquof(float x, float y, int* pquo);
+long double    remquol(long double x, long double y, int* pquo);
+
+floating_point rint (arithmetic x);
+float          rintf(float x);
+long double    rintl(long double x);
+
+floating_point round (arithmetic x);
+float          roundf(float x);
+long double    roundl(long double x);
+
+floating_point scalbln (arithmetic x, long ex);
+float          scalblnf(float x, long ex);
+long double    scalblnl(long double x, long ex);
+
+floating_point scalbn (arithmetic x, int ex);
+float          scalbnf(float x, int ex);
+long double    scalbnl(long double x, int ex);
+
+floating_point tgamma (arithmetic x);
+float          tgammaf(float x);
+long double    tgammal(long double x);
+
+floating_point trunc (arithmetic x);
+float          truncf(float x);
+long double    truncl(long double x);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <math.h>
+
+#ifdef __cplusplus
+
+// We support including .h headers inside 'extern "C"' contexts, so switch
+// back to C++ linkage before including these C++ headers.
+extern "C++" {
+
+#include <type_traits>
+
+#ifdef _LIBCPP_MSVCRT
+#include "support/win32/math_win32.h"
+#endif
+
+// signbit
+
+#ifdef signbit
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
+{
+    return signbit(__lcpp_x);
+}
+
+#undef signbit
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+signbit(_A1 __lcpp_x) _NOEXCEPT
+{
+    return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+#endif  // signbit
+
+// fpclassify
+
+#ifdef fpclassify
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+int
+__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
+{
+    return fpclassify(__lcpp_x);
+}
+
+#undef fpclassify
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, int>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT
+{
+    return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+#endif  // fpclassify
+
+// isfinite
+
+#ifdef isfinite
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
+{
+    return isfinite(__lcpp_x);
+}
+
+#undef isfinite
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+isfinite(_A1 __lcpp_x) _NOEXCEPT
+{
+    return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+#endif  // isfinite
+
+// isinf
+
+#ifdef isinf
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
+{
+    return isinf(__lcpp_x);
+}
+
+#undef isinf
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+isinf(_A1 __lcpp_x) _NOEXCEPT
+{
+    return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+#endif  // isinf
+
+// isnan
+
+#ifdef isnan
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
+{
+    return isnan(__lcpp_x);
+}
+
+#undef isnan
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+isnan(_A1 __lcpp_x) _NOEXCEPT
+{
+    return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+#endif  // isnan
+
+// isnormal
+
+#ifdef isnormal
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
+{
+    return isnormal(__lcpp_x);
+}
+
+#undef isnormal
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+isnormal(_A1 __lcpp_x) _NOEXCEPT
+{
+    return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
+}
+
+#endif  // isnormal
+
+// isgreater
+
+#ifdef isgreater
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    return isgreater(__lcpp_x, __lcpp_y);
+}
+
+#undef isgreater
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    bool
+>::type
+isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif  // isgreater
+
+// isgreaterequal
+
+#ifdef isgreaterequal
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    return isgreaterequal(__lcpp_x, __lcpp_y);
+}
+
+#undef isgreaterequal
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    bool
+>::type
+isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif  // isgreaterequal
+
+// isless
+
+#ifdef isless
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    return isless(__lcpp_x, __lcpp_y);
+}
+
+#undef isless
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    bool
+>::type
+isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif  // isless
+
+// islessequal
+
+#ifdef islessequal
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    return islessequal(__lcpp_x, __lcpp_y);
+}
+
+#undef islessequal
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    bool
+>::type
+islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif  // islessequal
+
+// islessgreater
+
+#ifdef islessgreater
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    return islessgreater(__lcpp_x, __lcpp_y);
+}
+
+#undef islessgreater
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    bool
+>::type
+islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif  // islessgreater
+
+// isunordered
+
+#ifdef isunordered
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    return isunordered(__lcpp_x, __lcpp_y);
+}
+
+#undef isunordered
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    bool
+>::type
+isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
+}
+
+#endif  // isunordered
+
+#ifndef __sun__
+
+// abs
+
+#if !defined(_AIX)
+inline _LIBCPP_INLINE_VISIBILITY
+float
+abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+double
+abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long double
+abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
+#endif // !defined(_AIX)
+
+// acos
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       acos(float __lcpp_x) _NOEXCEPT       {return acosf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);}
+
+// asin
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       asin(float __lcpp_x) _NOEXCEPT       {return asinf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);}
+
+// atan
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       atan(float __lcpp_x) _NOEXCEPT       {return atanf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);}
+
+// atan2
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT             {return atan2f(__lcpp_y, __lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);}
+#endif
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
+}
+
+// ceil
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       ceil(float __lcpp_x) _NOEXCEPT       {return ceilf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);}
+
+// cos
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       cos(float __lcpp_x) _NOEXCEPT       {return cosf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);}
+
+// cosh
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       cosh(float __lcpp_x) _NOEXCEPT       {return coshf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);}
+
+// exp
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       exp(float __lcpp_x) _NOEXCEPT       {return expf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);}
+
+// fabs
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       fabs(float __lcpp_x) _NOEXCEPT       {return fabsf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);}
+
+// floor
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       floor(float __lcpp_x) _NOEXCEPT       {return floorf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);}
+
+// fmod
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return fmodf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);}
+#endif
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// frexp
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT       {return frexpf(__lcpp_x, __lcpp_e);}
+inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __lcpp_e);}
+
+// ldexp
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT       {return ldexpf(__lcpp_x, __lcpp_e);}
+inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lcpp_e);}
+
+// log
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       log(float __lcpp_x) _NOEXCEPT       {return logf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);}
+
+// log10
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       log10(float __lcpp_x) _NOEXCEPT       {return log10f(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);}
+
+// modf
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT             {return modff(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);}
+#endif
+
+// pow
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return powf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);}
+#endif
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// sin
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       sin(float __lcpp_x) _NOEXCEPT       {return sinf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);}
+
+// sinh
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       sinh(float __lcpp_x) _NOEXCEPT       {return sinhf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);}
+
+// sqrt
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       sqrt(float __lcpp_x) _NOEXCEPT       {return sqrtf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);}
+#endif
+
+#endif // __sun__
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);}
+#ifndef __sun__
+
+// tan
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       tan(float __lcpp_x) _NOEXCEPT       {return tanf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);}
+
+// tanh
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       tanh(float __lcpp_x) _NOEXCEPT       {return tanhf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+tanh(_A1 __lcpp_x) _NOEXCEPT {return tanh((double)__lcpp_x);}
+
+// acosh
+
+#ifndef _LIBCPP_MSVCRT
+inline _LIBCPP_INLINE_VISIBILITY float       acosh(float __lcpp_x) _NOEXCEPT       {return acoshf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return acoshl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+acosh(_A1 __lcpp_x) _NOEXCEPT {return acosh((double)__lcpp_x);}
+#endif
+
+// asinh
+
+#ifndef _LIBCPP_MSVCRT
+inline _LIBCPP_INLINE_VISIBILITY float       asinh(float __lcpp_x) _NOEXCEPT       {return asinhf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return asinhl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+asinh(_A1 __lcpp_x) _NOEXCEPT {return asinh((double)__lcpp_x);}
+#endif
+
+// atanh
+
+#ifndef _LIBCPP_MSVCRT
+inline _LIBCPP_INLINE_VISIBILITY float       atanh(float __lcpp_x) _NOEXCEPT       {return atanhf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return atanhl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+atanh(_A1 __lcpp_x) _NOEXCEPT {return atanh((double)__lcpp_x);}
+#endif
+
+// cbrt
+
+#ifndef _LIBCPP_MSVCRT
+inline _LIBCPP_INLINE_VISIBILITY float       cbrt(float __lcpp_x) _NOEXCEPT       {return cbrtf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return cbrtl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);}
+#endif
+
+// copysign
+
+#if !defined(_VC_CRT_MAJOR_VERSION) || (_VC_CRT_MAJOR_VERSION < 12)
+inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
+                                                float __lcpp_y) _NOEXCEPT {
+  return copysignf(__lcpp_x, __lcpp_y);
+}
+inline _LIBCPP_INLINE_VISIBILITY long double
+copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
+  return copysignl(__lcpp_x, __lcpp_y);
+}
+#endif
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+#ifndef _LIBCPP_MSVCRT
+
+// erf
+
+inline _LIBCPP_INLINE_VISIBILITY float       erf(float __lcpp_x) _NOEXCEPT       {return erff(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return erfl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+erf(_A1 __lcpp_x) _NOEXCEPT {return erf((double)__lcpp_x);}
+
+// erfc
+
+inline _LIBCPP_INLINE_VISIBILITY float       erfc(float __lcpp_x) _NOEXCEPT       {return erfcf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return erfcl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+erfc(_A1 __lcpp_x) _NOEXCEPT {return erfc((double)__lcpp_x);}
+
+// exp2
+
+inline _LIBCPP_INLINE_VISIBILITY float       exp2(float __lcpp_x) _NOEXCEPT       {return exp2f(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return exp2l(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+exp2(_A1 __lcpp_x) _NOEXCEPT {return exp2((double)__lcpp_x);}
+
+// expm1
+
+inline _LIBCPP_INLINE_VISIBILITY float       expm1(float __lcpp_x) _NOEXCEPT       {return expm1f(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return expm1l(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+expm1(_A1 __lcpp_x) _NOEXCEPT {return expm1((double)__lcpp_x);}
+
+// fdim
+
+inline _LIBCPP_INLINE_VISIBILITY float       fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return fdimf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fdiml(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// fma
+
+inline _LIBCPP_INLINE_VISIBILITY float       fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT                   {return fmaf(__lcpp_x, __lcpp_y, __lcpp_z);}
+inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return fmal(__lcpp_x, __lcpp_y, __lcpp_z);}
+
+template <class _A1, class _A2, class _A3>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value &&
+    std::is_arithmetic<_A3>::value,
+    std::__promote<_A1, _A2, _A3>
+>::type
+fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value &&
+                     std::is_same<_A3, __result_type>::value)), "");
+    return fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
+}
+
+// fmax
+
+inline _LIBCPP_INLINE_VISIBILITY float       fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return fmaxf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmaxl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// fmin
+
+inline _LIBCPP_INLINE_VISIBILITY float       fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return fminf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fminl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// hypot
+
+inline _LIBCPP_INLINE_VISIBILITY float       hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return hypotf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return hypotl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// ilogb
+
+inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT       {return ilogbf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ilogbl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, int>::type
+ilogb(_A1 __lcpp_x) _NOEXCEPT {return ilogb((double)__lcpp_x);}
+
+// lgamma
+
+inline _LIBCPP_INLINE_VISIBILITY float       lgamma(float __lcpp_x) _NOEXCEPT       {return lgammaf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return lgammal(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+lgamma(_A1 __lcpp_x) _NOEXCEPT {return lgamma((double)__lcpp_x);}
+
+// llrint
+
+inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT       {return llrintf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return llrintl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, long long>::type
+llrint(_A1 __lcpp_x) _NOEXCEPT {return llrint((double)__lcpp_x);}
+
+// llround
+
+inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT       {return llroundf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return llroundl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, long long>::type
+llround(_A1 __lcpp_x) _NOEXCEPT {return llround((double)__lcpp_x);}
+
+// log1p
+
+inline _LIBCPP_INLINE_VISIBILITY float       log1p(float __lcpp_x) _NOEXCEPT       {return log1pf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return log1pl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+log1p(_A1 __lcpp_x) _NOEXCEPT {return log1p((double)__lcpp_x);}
+
+// log2
+
+inline _LIBCPP_INLINE_VISIBILITY float       log2(float __lcpp_x) _NOEXCEPT       {return log2f(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+log2(_A1 __lcpp_x) _NOEXCEPT {return log2((double)__lcpp_x);}
+
+// logb
+
+inline _LIBCPP_INLINE_VISIBILITY float       logb(float __lcpp_x) _NOEXCEPT       {return logbf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+logb(_A1 __lcpp_x) _NOEXCEPT {return logb((double)__lcpp_x);}
+
+// lrint
+
+inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT       {return lrintf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return lrintl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, long>::type
+lrint(_A1 __lcpp_x) _NOEXCEPT {return lrint((double)__lcpp_x);}
+
+// lround
+
+inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT       {return lroundf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return lroundl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, long>::type
+lround(_A1 __lcpp_x) _NOEXCEPT {return lround((double)__lcpp_x);}
+
+// nan
+
+// nearbyint
+
+inline _LIBCPP_INLINE_VISIBILITY float       nearbyint(float __lcpp_x) _NOEXCEPT       {return nearbyintf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return nearbyintl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+nearbyint(_A1 __lcpp_x) _NOEXCEPT {return nearbyint((double)__lcpp_x);}
+
+// nextafter
+
+inline _LIBCPP_INLINE_VISIBILITY float       nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return nextafterf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nextafterl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// nexttoward
+
+inline _LIBCPP_INLINE_VISIBILITY float       nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT       {return nexttowardf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardl(__lcpp_x, __lcpp_y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);}
+
+// remainder
+
+inline _LIBCPP_INLINE_VISIBILITY float       remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT             {return remainderf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return remainderl(__lcpp_x, __lcpp_y);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+}
+
+// remquo
+
+inline _LIBCPP_INLINE_VISIBILITY float       remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT             {return remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
+inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquol(__lcpp_x, __lcpp_y, __lcpp_z);}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+    std::is_arithmetic<_A1>::value &&
+    std::is_arithmetic<_A2>::value,
+    std::__promote<_A1, _A2>
+>::type
+remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type __result_type;
+    static_assert((!(std::is_same<_A1, __result_type>::value &&
+                     std::is_same<_A2, __result_type>::value)), "");
+    return remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
+}
+
+// rint
+
+inline _LIBCPP_INLINE_VISIBILITY float       rint(float __lcpp_x) _NOEXCEPT       {return rintf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return rintl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+rint(_A1 __lcpp_x) _NOEXCEPT {return rint((double)__lcpp_x);}
+
+// round
+
+inline _LIBCPP_INLINE_VISIBILITY float       round(float __lcpp_x) _NOEXCEPT       {return roundf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return roundl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+round(_A1 __lcpp_x) _NOEXCEPT {return round((double)__lcpp_x);}
+
+// scalbln
+
+inline _LIBCPP_INLINE_VISIBILITY float       scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT       {return scalblnf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnl(__lcpp_x, __lcpp_y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalbln((double)__lcpp_x, __lcpp_y);}
+
+// scalbn
+
+inline _LIBCPP_INLINE_VISIBILITY float       scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT       {return scalbnf(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnl(__lcpp_x, __lcpp_y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbn((double)__lcpp_x, __lcpp_y);}
+
+// tgamma
+
+inline _LIBCPP_INLINE_VISIBILITY float       tgamma(float __lcpp_x) _NOEXCEPT       {return tgammaf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return tgammal(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+tgamma(_A1 __lcpp_x) _NOEXCEPT {return tgamma((double)__lcpp_x);}
+
+// trunc
+
+inline _LIBCPP_INLINE_VISIBILITY float       trunc(float __lcpp_x) _NOEXCEPT       {return truncf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return truncl(__lcpp_x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, double>::type
+trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);}
+
+#endif // !_LIBCPP_MSVCRT
+#endif // __sun__
+
+} // extern "C++"
+
+#endif // __cplusplus
+
+#endif  // _LIBCPP_MATH_H
diff --git a/system/include/libcxx/memory b/system/include/libcxx/memory
index a9256da65e8a4..788830329d63a 100644
--- a/system/include/libcxx/memory
+++ b/system/include/libcxx/memory
@@ -75,6 +75,8 @@ struct allocator_traits
           | false_type                   propagate_on_container_move_assignment;
     typedef Alloc::propagate_on_container_swap
           | false_type                   propagate_on_container_swap;
+    typedef Alloc::is_always_equal
+          | is_empty                     is_always_equal;
 
     template <class T> using rebind_alloc  = Alloc::rebind<U>::other | Alloc<T, Args...>;
     template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
@@ -610,11 +612,12 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
     #include <cassert>
 #endif
 
-#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 #  include <atomic>
 #endif
 
 #include <__undef_min_max>
+#include <__undef___deallocate>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -622,6 +625,18 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+template <class _ValueType>
+inline _LIBCPP_ALWAYS_INLINE
+_ValueType __libcpp_relaxed_load(_ValueType const* __value) {
+#if !defined(_LIBCPP_HAS_NO_THREADS) && \
+    defined(__ATOMIC_RELAXED) &&        \
+    (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407)
+    return __atomic_load_n(__value, __ATOMIC_RELAXED);
+#else
+    return *__value;
+#endif
+}
+
 // addressof moved to <__functional_base>
 
 template <class _Tp> class allocator;
@@ -917,6 +932,15 @@ public:
         {return _VSTD::addressof(__r);}
 };
 
+template <class _From, class _To>
+struct __rebind_pointer {
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename pointer_traits<_From>::template rebind<_To>        type;
+#else
+    typedef typename pointer_traits<_From>::template rebind<_To>::other type;
+#endif
+};
+
 // allocator_traits
 
 namespace __has_pointer_type_imp
@@ -1143,6 +1167,29 @@ struct __propagate_on_container_swap<_Alloc, true>
     typedef typename _Alloc::propagate_on_container_swap type;
 };
 
+template <class _Tp>
+struct __has_is_always_equal
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_always_equal* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
+struct __is_always_equal
+{
+    typedef typename _VSTD::is_empty<_Alloc>::type type;
+};
+
+template <class _Alloc>
+struct __is_always_equal<_Alloc, true>
+{
+    typedef typename _Alloc::is_always_equal type;
+};
+
 template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
 struct __has_rebind_other
 {
@@ -1422,6 +1469,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
                      propagate_on_container_move_assignment;
     typedef typename __propagate_on_container_swap<allocator_type>::type
                      propagate_on_container_swap;
+    typedef typename __is_always_equal<allocator_type>::type
+                     is_always_equal;
 
 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
     template <class _Tp> using rebind_alloc =
@@ -1450,7 +1499,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
     template <class _Tp, class... _Args>
         _LIBCPP_INLINE_VISIBILITY
         static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
-            {__construct(__has_construct<allocator_type, pointer, _Args...>(),
+            {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
                          __a, __p, _VSTD::forward<_Args>(__args)...);}
 #else  // _LIBCPP_HAS_NO_VARIADICS
     template <class _Tp>
@@ -1520,8 +1569,42 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
         __construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
         {
             ptrdiff_t _Np = __end1 - __begin1;
-            _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
-            __begin2 += _Np;
+            if (_Np > 0)
+            {
+                _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
+                __begin2 += _Np;
+            }
+        }
+
+    template <class _Iter, class _Ptr>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        void
+        __construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2)
+        {
+            for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
+                construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1);
+        }
+
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        typename enable_if
+        <
+            (is_same<allocator_type, allocator<_Tp> >::value
+                || !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
+             is_trivially_move_constructible<_Tp>::value,
+            void
+        >::type
+        __construct_range_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
+        {
+            typedef typename remove_const<_Tp>::type _Vp;
+            ptrdiff_t _Np = __end1 - __begin1;
+            if (_Np > 0)
+            {
+                _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp));
+                __begin2 += _Np;
+            }
         }
 
     template <class _Ptr>
@@ -1551,7 +1634,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
         {
             ptrdiff_t _Np = __end1 - __begin1;
             __end2 -= _Np;
-            _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
+            if (_Np > 0)
+                _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
         }
 
 private:
@@ -1594,7 +1678,7 @@ private:
             {return __a.max_size();}
     _LIBCPP_INLINE_VISIBILITY
     static size_type __max_size(false_type, const allocator_type&)
-            {return numeric_limits<size_type>::max();}
+            {return numeric_limits<size_type>::max() / sizeof(value_type);}
 
     _LIBCPP_INLINE_VISIBILITY
     static allocator_type
@@ -1606,6 +1690,16 @@ private:
             {return __a;}
 };
 
+template <class _Traits, class _Tp>
+struct __rebind_alloc_helper
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename _Traits::template rebind_alloc<_Tp>        type;
+#else
+    typedef typename _Traits::template rebind_alloc<_Tp>::other type;
+#endif
+};
+
 // allocator
 
 template <class _Tp>
@@ -1621,6 +1715,7 @@ public:
     typedef _Tp               value_type;
 
     typedef true_type propagate_on_container_move_assignment;
+    typedef true_type is_always_equal;
 
     template <class _Up> struct rebind {typedef allocator<_Up> other;};
 
@@ -1631,7 +1726,15 @@ public:
     _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
         {return _VSTD::addressof(__x);}
     _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
-        {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));}
+        {
+        if (__n > max_size())
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw bad_alloc();
+#else
+            assert(!"allocator<T>::allocate::bad_alloc");
+#endif
+        return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
+        }
     _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
         {_VSTD::__deallocate((void*)__p);}
     _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
@@ -1713,6 +1816,7 @@ public:
     typedef const _Tp         value_type;
 
     typedef true_type propagate_on_container_move_assignment;
+    typedef true_type is_always_equal;
 
     template <class _Up> struct rebind {typedef allocator<_Up> other;};
 
@@ -1721,7 +1825,15 @@ public:
     _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
         {return _VSTD::addressof(__x);}
     _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
-        {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));}
+    {
+        if (__n > max_size())
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw bad_alloc();
+#else
+            assert(!"allocator<const T>::allocate::bad_alloc");
+#endif
+        return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
+        }
     _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
         {_VSTD::__deallocate((void*)__p);}
     _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
@@ -1813,9 +1925,16 @@ public:
     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}
     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)
         {::new(&*__x_) _Tp(__element); return *this;}
+#if _LIBCPP_STD_VER >= 14
+    _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element)
+        {::new(&*__x_) _Tp(_VSTD::move(__element)); return *this;}
+#endif
     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator  operator++(int)
         {raw_storage_iterator __t(*this); ++__x_; return __t;}
+#if _LIBCPP_STD_VER >= 14
+    _LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; } 
+#endif
 };
 
 template <class _Tp>
@@ -1905,14 +2024,9 @@ public:
 template <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type,
                                                      typename remove_cv<_T2>::type>::value,
                                 bool = is_empty<_T1>::value
-#if __has_feature(is_final)
-                                       && !__is_final(_T1)
-#endif
-                                ,
+                                       && !__libcpp_is_final<_T1>::value,
                                 bool = is_empty<_T2>::value
-#if __has_feature(is_final)
-                                       && !__is_final(_T2)
-#endif
+                                       && !__libcpp_is_final<_T2>::value
          >
 struct __libcpp_compressed_pair_switch;
 
@@ -1950,11 +2064,11 @@ public:
     typedef const typename remove_reference<_T1>::type& _T1_const_reference;
     typedef const typename remove_reference<_T2>::type& _T2_const_reference;
 
-    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
+    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_(), __second_() {}
     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
-        : __first_(_VSTD::forward<_T1_param>(__t1)) {}
+        : __first_(_VSTD::forward<_T1_param>(__t1)), __second_() {}
     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
-        : __second_(_VSTD::forward<_T2_param>(__t2)) {}
+        : __first_(), __second_(_VSTD::forward<_T2_param>(__t2)) {}
     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
         : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
 
@@ -2043,9 +2157,9 @@ public:
     typedef const _T1&                                        _T1_const_reference;
     typedef const typename remove_reference<_T2>::type& _T2_const_reference;
 
-    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
+    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __second_() {}
     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
-        : _T1(_VSTD::forward<_T1_param>(__t1)) {}
+        : _T1(_VSTD::forward<_T1_param>(__t1)), __second_() {}
     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
         : __second_(_VSTD::forward<_T2_param>(__t2)) {}
     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
@@ -2133,11 +2247,11 @@ public:
     typedef const typename remove_reference<_T1>::type& _T1_const_reference;
     typedef const _T2&                                        _T2_const_reference;
 
-    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
+    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_() {}
     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
         : __first_(_VSTD::forward<_T1_param>(__t1)) {}
     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
-        : _T2(_VSTD::forward<_T2_param>(__t2)) {}
+        : _T2(_VSTD::forward<_T2_param>(__t2)), __first_() {}
     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
                    is_nothrow_move_constructible<_T2>::value)
@@ -2450,7 +2564,7 @@ public:
                          typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT
         {
             static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type");
-            static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type");
+            static_assert(!is_void<_Tp>::value, "default_delete can not delete void type");
             delete [] __ptr;
         }
 };
@@ -2574,10 +2688,17 @@ public:
         : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {}
 
     template <class _Up, class _Ep>
-    _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u)
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<
+        !is_array<_Up>::value &&
+        is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value &&
+        is_assignable<deleter_type&, _Ep&>::value,
+        unique_ptr&
+    >::type
+    operator=(unique_ptr<_Up, _Ep> __u)
     {
         reset(__u.release());
-        __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
+        __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
         return *this;
     }
 
@@ -2813,7 +2934,6 @@ public:
         return __t;
     }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template <class _Pp>
     _LIBCPP_INLINE_VISIBILITY
     typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type
@@ -2824,29 +2944,13 @@ public:
         if (__tmp)
             __ptr_.second()(__tmp);
     }
-    _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT
-    {
-        pointer __tmp = __ptr_.first();
-        __ptr_.first() = nullptr;
-        if (__tmp)
-            __ptr_.second()(__tmp);
-    }
-    _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT
+    _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t = nullptr) _NOEXCEPT
     {
         pointer __tmp = __ptr_.first();
         __ptr_.first() = nullptr;
         if (__tmp)
             __ptr_.second()(__tmp);
     }
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer())
-    {
-        pointer __tmp = __ptr_.first();
-        __ptr_.first() = __p;
-        if (__tmp)
-            __ptr_.second()(__tmp);
-    }
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
     _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);}
 private:
@@ -2870,7 +2974,10 @@ private:
 
 template <class _Tp, class _Dp>
 inline _LIBCPP_INLINE_VISIBILITY
-void
+typename enable_if<
+    __is_swappable<_Dp>::value,
+    void
+>::type
 swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
 
 template <class _T1, class _D1, class _T2, class _D2>
@@ -2890,8 +2997,8 @@ operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y)
 {
     typedef typename unique_ptr<_T1, _D1>::pointer _P1;
     typedef typename unique_ptr<_T2, _D2>::pointer _P2;
-    typedef typename common_type<_P1, _P2>::type _V;
-    return less<_V>()(__x.get(), __y.get());
+    typedef typename common_type<_P1, _P2>::type _Vp;
+    return less<_Vp>()(__x.get(), __y.get());
 }
 
 template <class _T1, class _D1, class _T2, class _D2>
@@ -3062,8 +3169,6 @@ template<class _Tp, class... _Args>
 
 #endif  // _LIBCPP_STD_VER > 11
 
-template <class _Tp> struct hash;
-
 template <class _Size>
 inline _LIBCPP_INLINE_VISIBILITY
 _Size
@@ -3089,7 +3194,7 @@ struct __murmur2_or_cityhash<_Size, 32>
 // murmur2
 template <class _Size>
 _Size
-__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
+__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
 {
     const _Size __m = 0x5bd1e995;
     const _Size __r = 24;
@@ -3239,7 +3344,7 @@ struct __murmur2_or_cityhash<_Size, 64>
 // cityhash64
 template <class _Size>
 _Size
-__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
+__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
 {
   const char* __s = static_cast<const char*>(__key);
   if (__len <= 32) {
@@ -3335,7 +3440,7 @@ struct __scalar_hash<_Tp, 2>
             {
                 size_t __a;
                 size_t __b;
-            };
+            } __s;
         } __u;
         __u.__t = __v;
         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
@@ -3357,7 +3462,7 @@ struct __scalar_hash<_Tp, 3>
                 size_t __a;
                 size_t __b;
                 size_t __c;
-            };
+            } __s;
         } __u;
         __u.__t = __v;
         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
@@ -3380,7 +3485,7 @@ struct __scalar_hash<_Tp, 4>
                 size_t __b;
                 size_t __c;
                 size_t __d;
-            };
+            } __s;
         } __u;
         __u.__t = __v;
         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
@@ -3485,8 +3590,8 @@ uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
     try
     {
 #endif
-        for (; __f != __l; ++__f, ++__r)
-            ::new(&*__r) value_type(*__f);
+        for (; __f != __l; ++__f, (void) ++__r)
+            ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
 #ifndef _LIBCPP_NO_EXCEPTIONS
     }
     catch (...)
@@ -3509,8 +3614,8 @@ uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
     try
     {
 #endif
-        for (; __n > 0; ++__f, ++__r, --__n)
-            ::new(&*__r) value_type(*__f);
+        for (; __n > 0; ++__f, (void) ++__r, (void) --__n)
+            ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
 #ifndef _LIBCPP_NO_EXCEPTIONS
     }
     catch (...)
@@ -3534,7 +3639,7 @@ uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
     {
 #endif
         for (; __f != __l; ++__f)
-            ::new(&*__f) value_type(__x);
+            ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);
 #ifndef _LIBCPP_NO_EXCEPTIONS
     }
     catch (...)
@@ -3556,8 +3661,8 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
     try
     {
 #endif
-        for (; __n > 0; ++__f, --__n)
-            ::new(&*__f) value_type(__x);
+        for (; __n > 0; ++__f, (void) --__n)
+            ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);
 #ifndef _LIBCPP_NO_EXCEPTIONS
     }
     catch (...)
@@ -3599,7 +3704,9 @@ public:
     void __add_shared() _NOEXCEPT;
     bool __release_shared() _NOEXCEPT;
     _LIBCPP_INLINE_VISIBILITY
-    long use_count() const _NOEXCEPT {return __shared_owners_ + 1;}
+    long use_count() const _NOEXCEPT {
+        return __libcpp_relaxed_load(&__shared_owners_) + 1;
+    }
 };
 
 class _LIBCPP_TYPE_VIS __shared_weak_count
@@ -3660,7 +3767,7 @@ template <class _Tp, class _Dp, class _Alloc>
 const void*
 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT
 {
-    return __t == typeid(_Dp) ? &__data_.first().second() : 0;
+    return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : 0;
 }
 
 #endif  // _LIBCPP_NO_RTTI
@@ -3677,9 +3784,13 @@ template <class _Tp, class _Dp, class _Alloc>
 void
 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
 {
-    typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second());
+    typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _Al;
+    typedef allocator_traits<_Al> _ATraits;
+    typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+
+    _Al __a(__data_.second());
     __data_.second().~_Alloc();
-    __a.deallocate(this, 1);
+    __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
 template <class _Tp, class _Alloc>
@@ -3742,9 +3853,12 @@ template <class _Tp, class _Alloc>
 void
 __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
 {
-    typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first());
+    typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _Al;
+    typedef allocator_traits<_Al> _ATraits;
+    typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+    _Al __a(__data_.first());
     __data_.first().~_Alloc();
-    __a.deallocate(this, 1);
+    __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
 template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this;
@@ -3760,7 +3874,9 @@ private:
 
     struct __nat {int __for_bool_;};
 public:
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
     template<class _Yp>
         explicit shared_ptr(_Yp* __p,
@@ -3773,15 +3889,18 @@ public:
                    typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
     template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d);
     template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a);
-    template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT;
+    template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     shared_ptr(const shared_ptr& __r) _NOEXCEPT;
     template<class _Yp>
+        _LIBCPP_INLINE_VISIBILITY
         shared_ptr(const shared_ptr<_Yp>& __r,
                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat())
                        _NOEXCEPT;
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     shared_ptr(shared_ptr&& __r) _NOEXCEPT;
-    template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r,
+    template<class _Yp> _LIBCPP_INLINE_VISIBILITY  shared_ptr(shared_ptr<_Yp>&& __r,
                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat())
                        _NOEXCEPT;
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -3838,6 +3957,7 @@ public:
 
     ~shared_ptr();
 
+    _LIBCPP_INLINE_VISIBILITY
     shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT;
     template<class _Yp>
         typename enable_if
@@ -3845,8 +3965,10 @@ public:
             is_convertible<_Yp*, element_type*>::value,
             shared_ptr&
         >::type
+        _LIBCPP_INLINE_VISIBILITY
         operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
     template<class _Yp>
         typename enable_if
@@ -3854,8 +3976,10 @@ public:
             is_convertible<_Yp*, element_type*>::value,
             shared_ptr<_Tp>&
         >::type
+        _LIBCPP_INLINE_VISIBILITY
         operator=(shared_ptr<_Yp>&& __r);
     template<class _Yp>
+        _LIBCPP_INLINE_VISIBILITY
         typename enable_if
         <
             !is_array<_Yp>::value &&
@@ -3865,6 +3989,7 @@ public:
         operator=(auto_ptr<_Yp>&& __r);
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template<class _Yp>
+        _LIBCPP_INLINE_VISIBILITY
         typename enable_if
         <
             !is_array<_Yp>::value &&
@@ -3881,12 +4006,16 @@ public:
             shared_ptr&
         >::type
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        _LIBCPP_INLINE_VISIBILITY
         operator=(unique_ptr<_Yp, _Dp>&& __r);
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        _LIBCPP_INLINE_VISIBILITY
         operator=(unique_ptr<_Yp, _Dp> __r);
 #endif
 
+    _LIBCPP_INLINE_VISIBILITY
     void swap(shared_ptr& __r) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     void reset() _NOEXCEPT;
     template<class _Yp>
         typename enable_if
@@ -3894,6 +4023,7 @@ public:
             is_convertible<_Yp*, element_type*>::value,
             void
         >::type
+        _LIBCPP_INLINE_VISIBILITY
         reset(_Yp* __p);
     template<class _Yp, class _Dp>
         typename enable_if
@@ -3901,6 +4031,7 @@ public:
             is_convertible<_Yp*, element_type*>::value,
             void
         >::type
+        _LIBCPP_INLINE_VISIBILITY
         reset(_Yp* __p, _Dp __d);
     template<class _Yp, class _Dp, class _Alloc>
         typename enable_if
@@ -3908,6 +4039,7 @@ public:
             is_convertible<_Yp*, element_type*>::value,
             void
         >::type
+        _LIBCPP_INLINE_VISIBILITY
         reset(_Yp* __p, _Dp __d, _Alloc __a);
 
     _LIBCPP_INLINE_VISIBILITY
@@ -3994,18 +4126,22 @@ private:
         __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT
         {
             if (__e)
-                __e->__weak_this_ = *this;
+            {
+                __e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast<const _Yp*>(__e));
+                __e->__weak_this_.__cntrl_ = __cntrl_;
+                __cntrl_->__add_weak();
+            }
         }
 
     _LIBCPP_INLINE_VISIBILITY
-    void __enable_weak_this(const void*) _NOEXCEPT {}
+    void __enable_weak_this(const volatile void*) _NOEXCEPT {}
 
     template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr;
     template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
 };
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
     : __ptr_(0),
@@ -4014,7 +4150,7 @@ shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
 }
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
     : __ptr_(0),
@@ -4090,12 +4226,13 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
     {
 #endif  // _LIBCPP_NO_EXCEPTIONS
         typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;
-        typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2;
+        typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
         typedef __allocator_destructor<_A2> _D2;
         _A2 __a2(__a);
         unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
-        ::new(__hold2.get()) _CntrlBlk(__p, __d, __a);
-        __cntrl_ = __hold2.release();
+        ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
+            _CntrlBlk(__p, __d, __a);
+        __cntrl_ = _VSTD::addressof(*__hold2.release());
         __enable_weak_this(__p);
 #ifndef _LIBCPP_NO_EXCEPTIONS
     }
@@ -4117,12 +4254,13 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
     {
 #endif  // _LIBCPP_NO_EXCEPTIONS
         typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;
-        typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2;
+        typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
         typedef __allocator_destructor<_A2> _D2;
         _A2 __a2(__a);
         unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
-        ::new(__hold2.get()) _CntrlBlk(__p, __d, __a);
-        __cntrl_ = __hold2.release();
+        ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
+            _CntrlBlk(__p, __d, __a);
+        __cntrl_ = _VSTD::addressof(*__hold2.release());
 #ifndef _LIBCPP_NO_EXCEPTIONS
     }
     catch (...)
@@ -4135,7 +4273,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT
     : __ptr_(__p),
       __cntrl_(__r.__cntrl_)
@@ -4145,7 +4283,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEX
 }
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT
     : __ptr_(__r.__ptr_),
       __cntrl_(__r.__cntrl_)
@@ -4156,7 +4294,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,
                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type)
          _NOEXCEPT
@@ -4170,7 +4308,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT
     : __ptr_(__r.__ptr_),
       __cntrl_(__r.__cntrl_)
@@ -4181,7 +4319,7 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type)
          _NOEXCEPT
@@ -4226,9 +4364,16 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
                             >::type)
     : __ptr_(__r.get())
 {
-    typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
-    __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
-    __enable_weak_this(__r.get());
+#if _LIBCPP_STD_VER > 11
+    if (__ptr_ == nullptr)
+        __cntrl_ = nullptr;
+    else
+#endif
+    {
+        typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
+        __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
+        __enable_weak_this(__r.get());
+    }
     __r.release();
 }
 
@@ -4248,11 +4393,18 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
                             >::type)
     : __ptr_(__r.get())
 {
-    typedef __shared_ptr_pointer<_Yp*,
-                                 reference_wrapper<typename remove_reference<_Dp>::type>,
-                                 allocator<_Yp> > _CntrlBlk;
-    __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>());
-    __enable_weak_this(__r.get());
+#if _LIBCPP_STD_VER > 11
+    if (__ptr_ == nullptr)
+        __cntrl_ = nullptr;
+    else
+#endif
+    {
+        typedef __shared_ptr_pointer<_Yp*,
+                                     reference_wrapper<typename remove_reference<_Dp>::type>,
+                                     allocator<_Yp> > _CntrlBlk;
+        __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>());
+        __enable_weak_this(__r.get());
+    }
     __r.release();
 }
 
@@ -4282,14 +4434,15 @@ shared_ptr<_Tp>
 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
 {
     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-    typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2;
+    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
     typedef __allocator_destructor<_A2> _D2;
     _A2 __a2(__a);
     unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
-    ::new(__hold2.get()) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
+    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
+        _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
     shared_ptr<_Tp> __r;
     __r.__ptr_ = __hold2.get()->get();
-    __r.__cntrl_ = __hold2.release();
+    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
     __r.__enable_weak_this(__r.__ptr_);
     return __r;
 }
@@ -4373,14 +4526,15 @@ shared_ptr<_Tp>
 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a)
 {
     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-    typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2;
+    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
     typedef __allocator_destructor<_Alloc2> _D2;
     _Alloc2 __alloc2(__a);
     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
-    ::new(__hold2.get()) _CntrlBlk(__a);
+    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
+        _CntrlBlk(__a);
     shared_ptr<_Tp> __r;
     __r.__ptr_ = __hold2.get()->get();
-    __r.__cntrl_ = __hold2.release();
+    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
     __r.__enable_weak_this(__r.__ptr_);
     return __r;
 }
@@ -4391,14 +4545,15 @@ shared_ptr<_Tp>
 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0)
 {
     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-    typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2;
+    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
     typedef __allocator_destructor<_Alloc2> _D2;
     _Alloc2 __alloc2(__a);
     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
-    ::new(__hold2.get()) _CntrlBlk(__a, __a0);
+    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
+        _CntrlBlk(__a, __a0);
     shared_ptr<_Tp> __r;
     __r.__ptr_ = __hold2.get()->get();
-    __r.__cntrl_ = __hold2.release();
+    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
     __r.__enable_weak_this(__r.__ptr_);
     return __r;
 }
@@ -4409,14 +4564,15 @@ shared_ptr<_Tp>
 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
 {
     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-    typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2;
+    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
     typedef __allocator_destructor<_Alloc2> _D2;
     _Alloc2 __alloc2(__a);
     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
-    ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1);
+    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
+        _CntrlBlk(__a, __a0, __a1);
     shared_ptr<_Tp> __r;
     __r.__ptr_ = __hold2.get()->get();
-    __r.__cntrl_ = __hold2.release();
+    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
     __r.__enable_weak_this(__r.__ptr_);
     return __r;
 }
@@ -4427,14 +4583,15 @@ shared_ptr<_Tp>
 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2)
 {
     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-    typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2;
+    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
     typedef __allocator_destructor<_Alloc2> _D2;
     _Alloc2 __alloc2(__a);
     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
-    ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2);
+    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
+        _CntrlBlk(__a, __a0, __a1, __a2);
     shared_ptr<_Tp> __r;
     __r.__ptr_ = __hold2.get()->get();
-    __r.__cntrl_ = __hold2.release();
+    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
     __r.__enable_weak_this(__r.__ptr_);
     return __r;
 }
@@ -4449,7 +4606,7 @@ shared_ptr<_Tp>::~shared_ptr()
 }
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_ptr<_Tp>&
 shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT
 {
@@ -4459,7 +4616,7 @@ shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     is_convertible<_Yp*, _Tp*>::value,
@@ -4474,7 +4631,7 @@ shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 shared_ptr<_Tp>&
 shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT
 {
@@ -4484,7 +4641,7 @@ shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     is_convertible<_Yp*, _Tp*>::value,
@@ -4498,7 +4655,7 @@ shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r)
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     !is_array<_Yp>::value &&
@@ -4513,7 +4670,7 @@ shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r)
 
 template<class _Tp>
 template <class _Yp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     !is_array<_Yp>::value &&
@@ -4561,7 +4718,7 @@ shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r)
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT
 {
@@ -4570,7 +4727,7 @@ shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT
 }
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 shared_ptr<_Tp>::reset() _NOEXCEPT
 {
@@ -4579,7 +4736,7 @@ shared_ptr<_Tp>::reset() _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     is_convertible<_Yp*, _Tp*>::value,
@@ -4592,7 +4749,7 @@ shared_ptr<_Tp>::reset(_Yp* __p)
 
 template<class _Tp>
 template<class _Yp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     is_convertible<_Yp*, _Tp*>::value,
@@ -4605,7 +4762,7 @@ shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d)
 
 template<class _Tp>
 template<class _Yp, class _Dp, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     is_convertible<_Yp*, _Tp*>::value,
@@ -4731,8 +4888,8 @@ inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
 {
-    typedef typename common_type<_Tp*, _Up*>::type _V;
-    return less<_V>()(__x.get(), __y.get());
+    typedef typename common_type<_Tp*, _Up*>::type _Vp;
+    return less<_Vp>()(__x.get(), __y.get());
 }
 
 template<class _Tp, class _Up>
@@ -4922,23 +5079,27 @@ private:
     __shared_weak_count* __cntrl_;
 
 public:
+    _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT;
-    template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r,
+    template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r,
                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
                         _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     weak_ptr(weak_ptr const& __r) _NOEXCEPT;
-    template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r,
+    template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r,
                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
                          _NOEXCEPT;
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     weak_ptr(weak_ptr&& __r) _NOEXCEPT;
-    template<class _Yp> weak_ptr(weak_ptr<_Yp>&& __r,
+    template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r,
                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
                          _NOEXCEPT;
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     ~weak_ptr();
 
+    _LIBCPP_INLINE_VISIBILITY
     weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT;
     template<class _Yp>
         typename enable_if
@@ -4946,10 +5107,12 @@ public:
             is_convertible<_Yp*, element_type*>::value,
             weak_ptr&
         >::type
+        _LIBCPP_INLINE_VISIBILITY
         operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
+    _LIBCPP_INLINE_VISIBILITY
     weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;
     template<class _Yp>
         typename enable_if
@@ -4957,6 +5120,7 @@ public:
             is_convertible<_Yp*, element_type*>::value,
             weak_ptr&
         >::type
+        _LIBCPP_INLINE_VISIBILITY
         operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
 
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -4967,9 +5131,12 @@ public:
             is_convertible<_Yp*, element_type*>::value,
             weak_ptr&
         >::type
+        _LIBCPP_INLINE_VISIBILITY
         operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT;
 
+    _LIBCPP_INLINE_VISIBILITY
     void swap(weak_ptr& __r) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
     void reset() _NOEXCEPT;
 
     _LIBCPP_INLINE_VISIBILITY
@@ -4993,7 +5160,7 @@ public:
 };
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _LIBCPP_CONSTEXPR
 weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
     : __ptr_(0),
@@ -5002,7 +5169,7 @@ weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
 }
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT
     : __ptr_(__r.__ptr_),
       __cntrl_(__r.__cntrl_)
@@ -5013,7 +5180,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r,
                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
                          _NOEXCEPT
@@ -5026,7 +5193,7 @@ weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r,
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
          _NOEXCEPT
@@ -5040,7 +5207,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
     : __ptr_(__r.__ptr_),
       __cntrl_(__r.__cntrl_)
@@ -5051,7 +5218,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,
                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
          _NOEXCEPT
@@ -5072,7 +5239,7 @@ weak_ptr<_Tp>::~weak_ptr()
 }
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 weak_ptr<_Tp>&
 weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT
 {
@@ -5082,7 +5249,7 @@ weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     is_convertible<_Yp*, _Tp*>::value,
@@ -5097,7 +5264,7 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 weak_ptr<_Tp>&
 weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT
 {
@@ -5107,7 +5274,7 @@ weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     is_convertible<_Yp*, _Tp*>::value,
@@ -5123,7 +5290,7 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT
 
 template<class _Tp>
 template<class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     is_convertible<_Yp*, _Tp*>::value,
@@ -5136,7 +5303,7 @@ weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT
 }
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT
 {
@@ -5153,7 +5320,7 @@ swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT
 }
 
 template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 weak_ptr<_Tp>::reset() _NOEXCEPT
 {
@@ -5186,7 +5353,11 @@ weak_ptr<_Tp>::lock() const _NOEXCEPT
     return __r;
 }
 
+#if _LIBCPP_STD_VER > 14
+template <class _Tp = void> struct owner_less;
+#else
 template <class _Tp> struct owner_less;
+#endif
 
 template <class _Tp>
 struct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> >
@@ -5220,6 +5391,30 @@ struct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> >
         {return __x.owner_before(__y);}
 };
 
+#if _LIBCPP_STD_VER > 14
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY owner_less<void>
+{
+    template <class _Tp, class _Up>
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const
+        {return __x.owner_before(__y);}
+    template <class _Tp, class _Up>
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()( shared_ptr<_Tp> const& __x,  weak_ptr<_Up> const& __y) const
+        {return __x.owner_before(__y);}
+    template <class _Tp, class _Up>
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(   weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const
+        {return __x.owner_before(__y);}
+    template <class _Tp, class _Up>
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(   weak_ptr<_Tp> const& __x,   weak_ptr<_Up> const& __y) const
+        {return __x.owner_before(__y);}
+    typedef void is_transparent;
+};
+#endif
+
 template<class _Tp>
 class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this
 {
@@ -5262,7 +5457,9 @@ inline _LIBCPP_INLINE_VISIBILITY
 basic_ostream<_CharT, _Traits>&
 operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
 
-#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
+// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
+// enabled with clang.
+#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
 
 class _LIBCPP_TYPE_VIS __sp_mut
 {
@@ -5388,7 +5585,7 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v
     return atomic_compare_exchange_weak(__p, __v, __w);
 }
 
-#endif  // __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
+#endif  // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
 
 //enum class
 struct _LIBCPP_TYPE_VIS pointer_safety
@@ -5424,6 +5621,47 @@ undeclare_reachable(_Tp* __p)
 
 _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
 
+// --- Helper for container swap --
+template <typename _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
+#if _LIBCPP_STD_VER >= 14
+    _NOEXCEPT
+#else
+    _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
+#endif
+{
+    __swap_allocator(__a1, __a2, 
+      integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>());
+}
+
+template <typename _Alloc>
+_LIBCPP_INLINE_VISIBILITY
+void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
+#if _LIBCPP_STD_VER >= 14
+    _NOEXCEPT
+#else
+    _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
+#endif
+{
+    using _VSTD::swap;
+    swap(__a1, __a2);
+}
+
+template <typename _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
+
+template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
+struct __noexcept_move_assign_container : public integral_constant<bool, 
+    _Traits::propagate_on_container_move_assignment::value
+#if _LIBCPP_STD_VER > 14
+        || _Traits::is_always_equal::value
+#else
+        && is_nothrow_move_assignable<_Alloc>::value
+#endif
+    > {};
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_MEMORY
diff --git a/system/include/libcxx/module.modulemap b/system/include/libcxx/module.modulemap
index 6aeb23f028bf2..3fb7428411df9 100644
--- a/system/include/libcxx/module.modulemap
+++ b/system/include/libcxx/module.modulemap
@@ -455,9 +455,13 @@ module std [system] {
     export *
   }
 
+  // FIXME: We don't have modules for the <foo.h> headers, because they might
+  // be included from the C library's headers, and that would create a #include
+  // cycle. For the same reason, we don't have a module for __config.
+  //module __config { header "__config" export * }
+
   // FIXME: These should be private.
   module __bit_reference { header "__bit_reference" export * }
-  module __config { header "__config" export * }
   module __debug { header "__debug" export * }
   module __functional_base { header "__functional_base" export * }
   module __hash_table { header "__hash_table" export * }
@@ -469,4 +473,5 @@ module std [system] {
   module __tree { header "__tree" export * }
   module __tuple { header "__tuple" export * }
   module __undef_min_max { header "__undef_min_max" export * }
+  module __undef___deallocate { header "__undef___deallocate" export * }
 }
diff --git a/system/include/libcxx/mutex b/system/include/libcxx/mutex
index 9c26356590d36..a0875a568ec67 100644
--- a/system/include/libcxx/mutex
+++ b/system/include/libcxx/mutex
@@ -175,9 +175,13 @@ template<class Callable, class ...Args>
 #include <__config>
 #include <__mutex_base>
 #include <functional>
+#include <memory>
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 #include <tuple>
 #endif
+#ifndef _LIBCPP_HAS_NO_THREADS
+#include <sched.h>
+#endif
 
 #include <__undef_min_max>
 
@@ -441,7 +445,11 @@ void call_once(once_flag&, _Callable&&, _Args&&...);
 
 template<class _Callable>
 _LIBCPP_INLINE_VISIBILITY
-void call_once(once_flag&, _Callable);
+void call_once(once_flag&, _Callable&);
+
+template<class _Callable>
+_LIBCPP_INLINE_VISIBILITY
+void call_once(once_flag&, const _Callable&);
 
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
@@ -464,7 +472,11 @@ private:
 #else  // _LIBCPP_HAS_NO_VARIADICS
     template<class _Callable>
     friend
-    void call_once(once_flag&, _Callable);
+    void call_once(once_flag&, _Callable&);
+
+    template<class _Callable>
+    friend
+    void call_once(once_flag&, const _Callable&);
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 };
 
@@ -473,15 +485,10 @@ private:
 template <class _Fp>
 class __call_once_param
 {
-    _Fp __f_;
+    _Fp& __f_;
 public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    _LIBCPP_INLINE_VISIBILITY
-    explicit __call_once_param(_Fp&& __f) : __f_(_VSTD::move(__f)) {}
-#else
     _LIBCPP_INLINE_VISIBILITY
-    explicit __call_once_param(const _Fp& __f) : __f_(__f) {}
-#endif
+    explicit __call_once_param(_Fp& __f) : __f_(__f) {}
 
     _LIBCPP_INLINE_VISIBILITY
     void operator()()
@@ -495,7 +502,7 @@ private:
     _LIBCPP_INLINE_VISIBILITY
     void __execute(__tuple_indices<_Indices...>)
     {
-        __invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...);
+        __invoke(_VSTD::get<0>(_VSTD::move(__f_)), _VSTD::get<_Indices>(_VSTD::move(__f_))...);
     }
 };
 
@@ -504,15 +511,10 @@ private:
 template <class _Fp>
 class __call_once_param
 {
-    _Fp __f_;
+    _Fp& __f_;
 public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    _LIBCPP_INLINE_VISIBILITY
-    explicit __call_once_param(_Fp&& __f) : __f_(_VSTD::move(__f)) {}
-#else
     _LIBCPP_INLINE_VISIBILITY
-    explicit __call_once_param(const _Fp& __f) : __f_(__f) {}
-#endif
+    explicit __call_once_param(_Fp& __f) : __f_(__f) {}
 
     _LIBCPP_INLINE_VISIBILITY
     void operator()()
@@ -540,11 +542,11 @@ inline _LIBCPP_INLINE_VISIBILITY
 void
 call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
 {
-    if (__flag.__state_ != ~0ul)
+    if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul)
     {
-        typedef tuple<typename decay<_Callable>::type, typename decay<_Args>::type...> _Gp;
-        __call_once_param<_Gp> __p(_Gp(__decay_copy(_VSTD::forward<_Callable>(__func)),
-                                __decay_copy(_VSTD::forward<_Args>(__args))...));
+        typedef tuple<_Callable&&, _Args&&...> _Gp;
+        _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);
+        __call_once_param<_Gp> __p(__f);
         __call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);
     }
 }
@@ -554,15 +556,27 @@ call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
 template<class _Callable>
 inline _LIBCPP_INLINE_VISIBILITY
 void
-call_once(once_flag& __flag, _Callable __func)
+call_once(once_flag& __flag, _Callable& __func)
 {
-    if (__flag.__state_ != ~0ul)
+    if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul)
     {
         __call_once_param<_Callable> __p(__func);
         __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
     }
 }
 
+template<class _Callable>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+call_once(once_flag& __flag, const _Callable& __func)
+{
+    if (__flag.__state_ != ~0ul)
+    {
+        __call_once_param<const _Callable> __p(__func);
+        __call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
+    }
+}
+
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/system/include/libcxx/new b/system/include/libcxx/new
index a710ed93fb43b..d2b2ae648b489 100644
--- a/system/include/libcxx/new
+++ b/system/include/libcxx/new
@@ -50,11 +50,13 @@ new_handler get_new_handler() noexcept;
 void* operator new(std::size_t size);                                   // replaceable
 void* operator new(std::size_t size, const std::nothrow_t&) noexcept;   // replaceable
 void  operator delete(void* ptr) noexcept;                              // replaceable
+void  operator delete(void* ptr, std::size_t size) noexcept;            // replaceable, C++14
 void  operator delete(void* ptr, const std::nothrow_t&) noexcept;       // replaceable
 
 void* operator new[](std::size_t size);                                 // replaceable
 void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable
 void  operator delete[](void* ptr) noexcept;                            // replaceable
+void  operator delete[](void* ptr, std::size_t size) noexcept;          // replaceable, C++14
 void  operator delete[](void* ptr, const std::nothrow_t&) noexcept;     // replaceable
 
 void* operator new  (std::size_t size, void* ptr) noexcept;
@@ -68,6 +70,8 @@ void  operator delete[](void* ptr, void*) noexcept;
 #include <exception>
 #include <cstddef>
 
+#include <__undef___deallocate>
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
@@ -132,6 +136,10 @@ _LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz)
 _LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p) _NOEXCEPT;
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
+#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \
+    (defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309)
+_LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
+#endif
 
 _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
 #if !__has_feature(cxx_noexcept)
@@ -141,6 +149,10 @@ _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
 _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p) _NOEXCEPT;
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
+#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \
+    (defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309)
+_LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
+#endif
 
 inline _LIBCPP_INLINE_VISIBILITY void* operator new  (std::size_t, void* __p) _NOEXCEPT {return __p;}
 inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;}
diff --git a/system/include/libcxx/numeric b/system/include/libcxx/numeric
index e520c8e0d7598..21c3781ab6a4d 100644
--- a/system/include/libcxx/numeric
+++ b/system/include/libcxx/numeric
@@ -91,7 +91,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 _Tp
 inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
 {
-    for (; __first1 != __last1; ++__first1, ++__first2)
+    for (; __first1 != __last1; ++__first1, (void) ++__first2)
         __init = __init + *__first1 * *__first2;
     return __init;
 }
@@ -102,7 +102,7 @@ _Tp
 inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
               _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
 {
-    for (; __first1 != __last1; ++__first1, ++__first2)
+    for (; __first1 != __last1; ++__first1, (void) ++__first2)
         __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
     return __init;
 }
@@ -116,7 +116,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
     {
         typename iterator_traits<_InputIterator>::value_type __t(*__first);
         *__result = __t;
-        for (++__first, ++__result; __first != __last; ++__first, ++__result)
+        for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
         {
             __t = __t + *__first;
             *__result = __t;
@@ -135,7 +135,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
     {
         typename iterator_traits<_InputIterator>::value_type __t(*__first);
         *__result = __t;
-        for (++__first, ++__result; __first != __last; ++__first, ++__result)
+        for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
         {
             __t = __binary_op(__t, *__first);
             *__result = __t;
@@ -153,7 +153,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
     {
         typename iterator_traits<_InputIterator>::value_type __t1(*__first);
         *__result = __t1;
-        for (++__first, ++__result; __first != __last; ++__first, ++__result)
+        for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
         {
             typename iterator_traits<_InputIterator>::value_type __t2(*__first);
             *__result = __t2 - __t1;
@@ -173,7 +173,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
     {
         typename iterator_traits<_InputIterator>::value_type __t1(*__first);
         *__result = __t1;
-        for (++__first, ++__result; __first != __last; ++__first, ++__result)
+        for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
         {
             typename iterator_traits<_InputIterator>::value_type __t2(*__first);
             *__result = __binary_op(__t2, __t1);
@@ -188,7 +188,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 void
 iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
 {
-    for (; __first != __last; ++__first, ++__value_)
+    for (; __first != __last; ++__first, (void) ++__value_)
         *__first = __value_;
 }
 
diff --git a/system/include/libcxx/ostream b/system/include/libcxx/ostream
index a7af2994b6b9f..f55fd40856ec4 100644
--- a/system/include/libcxx/ostream
+++ b/system/include/libcxx/ostream
@@ -1004,7 +1004,7 @@ basic_ostream<_CharT, _Traits>&
 basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
 {
     sentry __s(*this);
-    if (__s)
+    if (!this->fail())
     {
         if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
             this->setstate(ios_base::failbit);
@@ -1018,7 +1018,7 @@ basic_ostream<_CharT, _Traits>&
 basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
 {
     sentry __s(*this);
-    if (__s)
+    if (!this->fail())
     {
         if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
             this->setstate(ios_base::failbit);
diff --git a/system/include/libcxx/queue b/system/include/libcxx/queue
index bdfd70603553a..c657b52f80382 100644
--- a/system/include/libcxx/queue
+++ b/system/include/libcxx/queue
@@ -66,7 +66,7 @@ public:
     template <class... Args> void emplace(Args&&... args);
     void pop();
 
-    void swap(queue& q) noexcept(noexcept(swap(c, q.c)));
+    void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
 };
 
 template <class T, class Container>
@@ -153,7 +153,8 @@ public:
     void pop();
 
     void swap(priority_queue& q)
-        noexcept(noexcept(swap(c, q.c)) && noexcept(swap(comp.q.comp)));
+        noexcept(is_nothrow_swappable_v<Container> &&
+                 is_nothrow_swappable_v<Comp>)
 };
 
 template <class T, class Container, class Compare>
@@ -177,7 +178,7 @@ template <class T, class Container, class Compare>
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <class _Tp, class _Container> class _LIBCPP_TYPE_VIS_ONLY queue;
+template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TYPE_VIS_ONLY queue;
 
 template <class _Tp, class _Container>
 _LIBCPP_INLINE_VISIBILITY
@@ -189,7 +190,7 @@ _LIBCPP_INLINE_VISIBILITY
 bool
 operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
 
-template <class _Tp, class _Container = deque<_Tp> >
+template <class _Tp, class _Container /*= deque<_Tp>*/>
 class _LIBCPP_TYPE_VIS_ONLY queue
 {
 public:
@@ -198,6 +199,7 @@ public:
     typedef typename container_type::reference       reference;
     typedef typename container_type::const_reference const_reference;
     typedef typename container_type::size_type       size_type;
+    static_assert((is_same<_Tp, value_type>::value), "" );
 
 protected:
     container_type c;
@@ -368,7 +370,10 @@ operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
 
 template <class _Tp, class _Container>
 inline _LIBCPP_INLINE_VISIBILITY
-void
+typename enable_if<
+    __is_swappable<_Container>::value,
+    void
+>::type
 swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
     _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
 {
@@ -392,6 +397,7 @@ public:
     typedef typename container_type::reference       reference;
     typedef typename container_type::const_reference const_reference;
     typedef typename container_type::size_type       size_type;
+    static_assert((is_same<_Tp, value_type>::value), "" );
 
 protected:
     container_type c;
@@ -430,45 +436,56 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     explicit priority_queue(const value_compare& __comp)
         : c(), comp(__comp) {}
+    _LIBCPP_INLINE_VISIBILITY
     priority_queue(const value_compare& __comp, const container_type& __c);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     explicit priority_queue(const value_compare& __comp, container_type&& __c);
 #endif
     template <class _InputIter>
+        _LIBCPP_INLINE_VISIBILITY
         priority_queue(_InputIter __f, _InputIter __l,
                        const value_compare& __comp = value_compare());
     template <class _InputIter>
+        _LIBCPP_INLINE_VISIBILITY
         priority_queue(_InputIter __f, _InputIter __l,
                        const value_compare& __comp, const container_type& __c);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template <class _InputIter>
+        _LIBCPP_INLINE_VISIBILITY
         priority_queue(_InputIter __f, _InputIter __l,
                        const value_compare& __comp, container_type&& __c);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
         explicit priority_queue(const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
                                                          _Alloc>::value>::type* = 0);
     template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
         priority_queue(const value_compare& __comp, const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
                                                          _Alloc>::value>::type* = 0);
     template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
         priority_queue(const value_compare& __comp, const container_type& __c,
                        const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
                                                          _Alloc>::value>::type* = 0);
     template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
         priority_queue(const priority_queue& __q, const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
                                                          _Alloc>::value>::type* = 0);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
         priority_queue(const value_compare& __comp, container_type&& __c,
                        const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
                                                          _Alloc>::value>::type* = 0);
     template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
         priority_queue(priority_queue&& __q, const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
                                                          _Alloc>::value>::type* = 0);
@@ -481,22 +498,26 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     const_reference top() const   {return c.front();}
 
+    _LIBCPP_INLINE_VISIBILITY
     void push(const value_type& __v);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     void push(value_type&& __v);
 #ifndef _LIBCPP_HAS_NO_VARIADICS
-    template <class... _Args> void emplace(_Args&&... __args);
+    template <class... _Args> _LIBCPP_INLINE_VISIBILITY void emplace(_Args&&... __args);
 #endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     void pop();
 
+    _LIBCPP_INLINE_VISIBILITY
     void swap(priority_queue& __q)
         _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
                    __is_nothrow_swappable<value_compare>::value);
 };
 
 template <class _Tp, class _Container, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
                                                           const container_type& __c)
     : c(__c),
@@ -508,7 +529,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp, class _Container, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
                                                           container_type&& __c)
     : c(_VSTD::move(__c)),
@@ -521,7 +542,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
 
 template <class _Tp, class _Container, class _Compare>
 template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
                                                           const value_compare& __comp)
     : c(__f, __l),
@@ -532,7 +553,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
 
 template <class _Tp, class _Container, class _Compare>
 template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
                                                           const value_compare& __comp,
                                                           const container_type& __c)
@@ -547,7 +568,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
 
 template <class _Tp, class _Container, class _Compare>
 template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
                                                           const value_compare& __comp,
                                                           container_type&& __c)
@@ -562,7 +583,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
 
 template <class _Tp, class _Container, class _Compare>
 template <class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
                                                          _Alloc>::value>::type*)
@@ -572,7 +593,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
 
 template <class _Tp, class _Container, class _Compare>
 template <class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
                                                           const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
@@ -584,7 +605,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
 
 template <class _Tp, class _Container, class _Compare>
 template <class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
                                                           const container_type& __c,
                                                           const _Alloc& __a,
@@ -598,7 +619,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
 
 template <class _Tp, class _Container, class _Compare>
 template <class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
                                                           const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
@@ -613,7 +634,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue&
 
 template <class _Tp, class _Container, class _Compare>
 template <class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
                                                           container_type&& __c,
                                                           const _Alloc& __a,
@@ -627,7 +648,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
 
 template <class _Tp, class _Container, class _Compare>
 template <class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
                                                           const _Alloc& __a,
                        typename enable_if<uses_allocator<container_type,
@@ -641,7 +662,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp, class _Container, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
 {
@@ -652,7 +673,7 @@ priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp, class _Container, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
 {
@@ -664,7 +685,7 @@ priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
 
 template <class _Tp, class _Container, class _Compare>
 template <class... _Args>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
 {
@@ -676,7 +697,7 @@ priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp, class _Container, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 priority_queue<_Tp, _Container, _Compare>::pop()
 {
@@ -685,7 +706,7 @@ priority_queue<_Tp, _Container, _Compare>::pop()
 }
 
 template <class _Tp, class _Container, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
         _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
@@ -698,7 +719,11 @@ priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
 
 template <class _Tp, class _Container, class _Compare>
 inline _LIBCPP_INLINE_VISIBILITY
-void
+typename enable_if<
+    __is_swappable<_Container>::value
+    && __is_swappable<_Compare>::value,
+    void
+>::type
 swap(priority_queue<_Tp, _Container, _Compare>& __x,
      priority_queue<_Tp, _Container, _Compare>& __y)
     _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
diff --git a/system/include/libcxx/random b/system/include/libcxx/random
index e7053ce4ecfff..794bf7b3fd157 100644
--- a/system/include/libcxx/random
+++ b/system/include/libcxx/random
@@ -1634,9 +1634,10 @@ class piecewise_linear_distribution
 
 #include <__config>
 #include <cstddef>
+#include <cstdint>
+#include <cmath>
 #include <type_traits>
 #include <initializer_list>
-#include <cstdint>
 #include <limits>
 #include <algorithm>
 #include <numeric>
@@ -1644,7 +1645,6 @@ class piecewise_linear_distribution
 #include <string>
 #include <istream>
 #include <ostream>
-#include <cmath>
 
 #include <__undef_min_max>
 
@@ -3119,6 +3119,7 @@ public:
                independent_bits_engine<_Eng, _Wp, _UI>& __x);
 
 private:
+    _LIBCPP_INLINE_VISIBILITY
     result_type __eval(false_type);
     result_type __eval(true_type);
 
@@ -3144,7 +3145,7 @@ private:
 };
 
 template<class _Engine, size_t __w, class _UIntType>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _UIntType
 independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type)
 {
@@ -3475,9 +3476,9 @@ typedef shuffle_order_engine<minstd_rand0, 256>                         knuth_b;
 
 class _LIBCPP_TYPE_VIS random_device
 {
-#if !defined(_WIN32)
+#ifdef _LIBCPP_USING_DEV_RANDOM
     int __f_;
-#endif // defined(_WIN32)
+#endif // defined(_LIBCPP_USING_DEV_RANDOM)
 public:
     // types
     typedef unsigned result_type;
@@ -3735,7 +3736,7 @@ public:
         _LIBCPP_INLINE_VISIBILITY
         result_type operator()(_URNG& __g)
         {return (*this)(__g, __p_);}
-    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+    template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p);
 
     // property functions
     _LIBCPP_INLINE_VISIBILITY
@@ -3765,7 +3766,7 @@ public:
 
 template<class _RealType>
 template<class _URNG>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename uniform_real_distribution<_RealType>::result_type
 uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
 {
@@ -3851,7 +3852,7 @@ public:
         _LIBCPP_INLINE_VISIBILITY
         result_type operator()(_URNG& __g)
         {return (*this)(__g, __p_);}
-    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+    template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p);
 
     // property functions
     _LIBCPP_INLINE_VISIBILITY
@@ -3878,7 +3879,7 @@ public:
 };
 
 template<class _URNG>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 bernoulli_distribution::result_type
 bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
 {
@@ -5522,7 +5523,7 @@ public:
         _LIBCPP_INLINE_VISIBILITY
         result_type operator()(_URNG& __g)
         {return (*this)(__g, __p_);}
-    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+    template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p);
 
     // property functions
     _LIBCPP_INLINE_VISIBILITY
@@ -5552,7 +5553,7 @@ public:
 
 template <class _RealType>
 template<class _URNG>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _RealType
 cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
 {
@@ -6044,9 +6045,6 @@ basic_istream<_CharT, _Traits>&
 operator>>(basic_istream<_CharT, _Traits>& __is,
            discrete_distribution<_IT>& __x)
 {
-    typedef discrete_distribution<_IT> _Eng;
-    typedef typename _Eng::result_type result_type;
-    typedef typename _Eng::param_type param_type;
     __save_flags<_CharT, _Traits> __lx(__is);
     __is.flags(ios_base::dec | ios_base::skipws);
     size_t __n;
@@ -6358,7 +6356,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
 {
     typedef piecewise_constant_distribution<_RT> _Eng;
     typedef typename _Eng::result_type result_type;
-    typedef typename _Eng::param_type param_type;
     __save_flags<_CharT, _Traits> __lx(__is);
     __is.flags(ios_base::dec | ios_base::skipws);
     size_t __n;
@@ -6698,7 +6695,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
 {
     typedef piecewise_linear_distribution<_RT> _Eng;
     typedef typename _Eng::result_type result_type;
-    typedef typename _Eng::param_type param_type;
     __save_flags<_CharT, _Traits> __lx(__is);
     __is.flags(ios_base::dec | ios_base::skipws);
     size_t __n;
diff --git a/system/include/libcxx/ratio b/system/include/libcxx/ratio
index 48dcd81c1a72a..8f708ce478d3c 100644
--- a/system/include/libcxx/ratio
+++ b/system/include/libcxx/ratio
@@ -21,8 +21,8 @@ template <intmax_t N, intmax_t D = 1>
 class ratio
 {
 public:
-    static const intmax_t num;
-    static const intmax_t den;
+    static constexpr intmax_t num;
+    static constexpr intmax_t den;
     typedef ratio<num, den> type;
 };
 
@@ -62,6 +62,19 @@ typedef ratio<      1000000000000000000, 1> exa;
 typedef ratio<   1000000000000000000000, 1> zetta;  // not supported
 typedef ratio<1000000000000000000000000, 1> yotta;  // not supported
 
+  // 20.11.5, ratio comparison
+  template <class R1, class R2> constexpr bool ratio_equal_v
+    = ratio_equal<R1, R2>::value;                                       // C++17
+  template <class R1, class R2> constexpr bool ratio_not_equal_v
+    = ratio_not_equal<R1, R2>::value;                                   // C++17
+  template <class R1, class R2> constexpr bool ratio_less_v
+    = ratio_less<R1, R2>::value;                                        // C++17
+  template <class R1, class R2> constexpr bool ratio_less_equal_v
+    = ratio_less_equal<R1, R2>::value;                                  // C++17
+  template <class R1, class R2> constexpr bool ratio_greater_v
+    = ratio_greater<R1, R2>::value;                                     // C++17
+  template <class R1, class R2> constexpr bool ratio_greater_equal_v
+    = ratio_greater_equal<R1, R2>::value;                               // C++17
 }
 */
 
@@ -236,19 +249,22 @@ class _LIBCPP_TYPE_VIS_ONLY ratio
     static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range");
     static_assert(_Den != 0, "ratio divide by 0");
     static_assert(__static_abs<_Den>::value >  0, "ratio denominator is out of range");
-    static const intmax_t __na = __static_abs<_Num>::value;
-    static const intmax_t __da = __static_abs<_Den>::value;
-    static const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
-    static const intmax_t __gcd = __static_gcd<__na, __da>::value;
+    static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value;
+    static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value;
+    static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
+    static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value;
 public:
-    static const intmax_t num = __s * __na / __gcd;
-    static const intmax_t den = __da / __gcd;
+    static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
+    static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
 
     typedef ratio<num, den> type;
 };
 
-template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::num;
-template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::den;
+template <intmax_t _Num, intmax_t _Den>
+_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num;
+
+template <intmax_t _Num, intmax_t _Den>
+_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den;
 
 template <class _Tp>                    struct __is_ratio                     : false_type {};
 template <intmax_t _Num, intmax_t _Den> struct __is_ratio<ratio<_Num, _Den> > : true_type  {};
@@ -398,11 +414,11 @@ struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract
 
 template <class _R1, class _R2>
 struct _LIBCPP_TYPE_VIS_ONLY ratio_equal
-    : public integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> {};
+    : public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {};
 
 template <class _R1, class _R2>
 struct _LIBCPP_TYPE_VIS_ONLY ratio_not_equal
-    : public integral_constant<bool, !ratio_equal<_R1, _R2>::value> {};
+    : public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {};
 
 // ratio_less
 
@@ -461,19 +477,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL>
 
 template <class _R1, class _R2>
 struct _LIBCPP_TYPE_VIS_ONLY ratio_less
-    : public integral_constant<bool, __ratio_less<_R1, _R2>::value> {};
+    : public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {};
 
 template <class _R1, class _R2>
 struct _LIBCPP_TYPE_VIS_ONLY ratio_less_equal
-    : public integral_constant<bool, !ratio_less<_R2, _R1>::value> {};
+    : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {};
 
 template <class _R1, class _R2>
 struct _LIBCPP_TYPE_VIS_ONLY ratio_greater
-    : public integral_constant<bool, ratio_less<_R2, _R1>::value> {};
+    : public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {};
 
 template <class _R1, class _R2>
 struct _LIBCPP_TYPE_VIS_ONLY ratio_greater_equal
-    : public integral_constant<bool, !ratio_less<_R1, _R2>::value> {};
+    : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {};
 
 template <class _R1, class _R2>
 struct __ratio_gcd
@@ -482,6 +498,26 @@ struct __ratio_gcd
                   __static_lcm<_R1::den, _R2::den>::value> type;
 };
 
+#if _LIBCPP_STD_VER > 14 && !defined(_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_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_RATIO
diff --git a/system/include/libcxx/readme.txt b/system/include/libcxx/readme.txt
index 44d9fb7efa3be..811cf9aec605a 100644
--- a/system/include/libcxx/readme.txt
+++ b/system/include/libcxx/readme.txt
@@ -1 +1 @@
-These files are from libc++, svn revision 218372, 2014-09-24.
+These files are from libc++, svn revision 268153, 2016-04-29.
diff --git a/system/include/libcxx/regex b/system/include/libcxx/regex
index 5e1c37c64e836..1139d8fb2a90e 100644
--- a/system/include/libcxx/regex
+++ b/system/include/libcxx/regex
@@ -762,6 +762,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
 #include <memory>
 #include <vector>
 #include <deque>
+#include <cassert>
 
 #include <__undef_min_max>
 
@@ -955,6 +956,17 @@ public:
     regex_constants::error_type code() const {return __code_;}
 };
 
+template <regex_constants::error_type _Ev>
+_LIBCPP_ALWAYS_INLINE
+void __throw_regex_error()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw regex_error(_Ev);
+#else
+    assert(!"regex_error");
+#endif
+}
+
 template <class _CharT>
 struct _LIBCPP_TYPE_VIS_ONLY regex_traits
 {
@@ -964,7 +976,12 @@ public:
     typedef locale                  locale_type;
     typedef ctype_base::mask        char_class_type;
 
+#if defined(__mips__) && defined(__GLIBC__)
+    static const char_class_type __regex_word = static_cast<char_class_type>(_ISbit(15));
+#else
     static const char_class_type __regex_word = 0x80;
+#endif
+
 private:
     locale __loc_;
     const ctype<char_type>* __ct_;
@@ -1036,6 +1053,7 @@ private:
     _LIBCPP_INLINE_VISIBILITY
     int __regex_traits_value(char __ch, int __radix) const
         {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);}
+    _LIBCPP_INLINE_VISIBILITY
     int __regex_traits_value(wchar_t __ch, int __radix) const;
 };
 
@@ -1258,7 +1276,7 @@ regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
 }
 
 template <class _CharT>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 int
 regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const
 {
@@ -1721,6 +1739,8 @@ template <class _CharT>
 void
 __back_ref<_CharT>::__exec(__state& __s) const
 {
+    if (__mexp_ > __s.__sub_matches_.size())
+        __throw_regex_error<regex_constants::error_backref>();
     sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
     if (__sm.matched)
     {
@@ -1947,7 +1967,8 @@ template <class _CharT>
 void
 __l_anchor<_CharT>::__exec(__state& __s) const
 {
-    if (__s.__at_first_ && __s.__current_ == __s.__first_)
+    if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
+        !(__s.__flags_ & regex_constants::match_not_bol))
     {
         __s.__do_ = __state::__accept_but_not_consume;
         __s.__node_ = this->first();
@@ -1981,7 +2002,8 @@ template <class _CharT>
 void
 __r_anchor<_CharT>::__exec(__state& __s) const
 {
-    if (__s.__current_ == __s.__last_)
+    if (__s.__current_ == __s.__last_ &&
+        !(__s.__flags_ & regex_constants::match_not_eol))
     {
         __s.__do_ = __state::__accept_but_not_consume;
         __s.__node_ = this->first();
@@ -2254,10 +2276,8 @@ public:
             }
             else
             {
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 if (__b.size() != 1 || __e.size() != 1)
-                    throw regex_error(regex_constants::error_collate);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                    __throw_regex_error<regex_constants::error_collate>();
                 if (__icase_)
                 {
                     __b[0] = __traits_.translate_nocase(__b[0]);
@@ -2599,9 +2619,7 @@ public:
         assign(_ForwardIterator __first, _ForwardIterator __last,
                             flag_type __f = regex_constants::ECMAScript)
         {
-            __member_init(__f);
-            __parse(__first, __last);
-            return *this;
+            return assign(basic_regex(__first, __last, __f));
         }
 
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -2952,7 +2970,7 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
-        : base(__s), __exp_(__exp), __invert_(__invert), __mexp_(__mexp) {}
+        : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {}
 
     virtual void __exec(__state&) const;
 };
@@ -3012,10 +3030,8 @@ basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
     case egrep:
         __first = __parse_egrep(__first, __last);
         break;
-#ifndef _LIBCPP_NO_EXCEPTIONS
     default:
-        throw regex_error(regex_constants::__re_err_grammar);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::__re_err_grammar>();
     }
     return __first;
 }
@@ -3046,10 +3062,8 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
                 }
             }
         }
-#ifndef _LIBCPP_NO_EXCEPTIONS
         if (__first != __last)
-            throw regex_error(regex_constants::__re_err_empty);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+            __throw_regex_error<regex_constants::__re_err_empty>();
     }
     return __first;
 }
@@ -3062,19 +3076,15 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
 {
     __owns_one_state<_CharT>* __sa = __end_;
     _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__temp == __first)
-        throw regex_error(regex_constants::__re_err_empty);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::__re_err_empty>();
     __first = __temp;
     while (__first != __last && *__first == '|')
     {
         __owns_one_state<_CharT>* __sb = __end_;
         __temp = __parse_ERE_branch(++__first, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
         if (__temp == __first)
-            throw regex_error(regex_constants::__re_err_empty);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+            __throw_regex_error<regex_constants::__re_err_empty>();
         __push_alternation(__sa, __sb);
         __first = __temp;
     }
@@ -3088,10 +3098,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
                                                  _ForwardIterator __last)
 {
     _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__temp == __first)
-        throw regex_error(regex_constants::__re_err_empty);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::__re_err_empty>();
     do
     {
         __first = __temp;
@@ -3126,10 +3134,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
             unsigned __temp_count = __marked_count_;
             ++__open_count_;
             __temp = __parse_extended_reg_exp(++__temp, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__temp == __last || *__temp != ')')
-                throw regex_error(regex_constants::error_paren);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_paren>();
             __push_end_marked_subexpression(__temp_count);
             --__open_count_;
             ++__temp;
@@ -3194,10 +3200,8 @@ basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
             unsigned __temp_count = __marked_count_;
             __first = __parse_RE_expression(__temp, __last);
             __temp = __parse_Back_close_paren(__first, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__temp == __first)
-                throw regex_error(regex_constants::error_paren);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_paren>();
             __push_end_marked_subexpression(__temp_count);
             __first = __temp;
         }
@@ -3511,22 +3515,16 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
                 int __min = 0;
                 __first = __temp;
                 __temp = __parse_DUP_COUNT(__first, __last, __min);
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 if (__temp == __first)
-                    throw regex_error(regex_constants::error_badbrace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                    __throw_regex_error<regex_constants::error_badbrace>();
                 __first = __temp;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 if (__first == __last)
-                    throw regex_error(regex_constants::error_brace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                    __throw_regex_error<regex_constants::error_brace>();
                 if (*__first != ',')
                 {
                     __temp = __parse_Back_close_brace(__first, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
                     if (__temp == __first)
-                        throw regex_error(regex_constants::error_brace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                        __throw_regex_error<regex_constants::error_brace>();
                     __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
                                     true);
                     __first = __temp;
@@ -3537,18 +3535,14 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
                     int __max = -1;
                     __first = __parse_DUP_COUNT(__first, __last, __max);
                     __temp = __parse_Back_close_brace(__first, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
                     if (__temp == __first)
-                        throw regex_error(regex_constants::error_brace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                        __throw_regex_error<regex_constants::error_brace>();
                     if (__max == -1)
                         __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
                     else
                     {
-#ifndef _LIBCPP_NO_EXCEPTIONS
                         if (__max < __min)
-                            throw regex_error(regex_constants::error_badbrace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                            __throw_regex_error<regex_constants::error_badbrace>();
                         __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
                                     true);
                     }
@@ -3608,15 +3602,11 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
             {
                 int __min;
                 _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 if (__temp == __first)
-                    throw regex_error(regex_constants::error_badbrace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                    __throw_regex_error<regex_constants::error_badbrace>();
                 __first = __temp;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 if (__first == __last)
-                    throw regex_error(regex_constants::error_brace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                    __throw_regex_error<regex_constants::error_brace>();
                 switch (*__first)
                 {
                 case '}':
@@ -3631,10 +3621,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
                     break;
                 case ',':
                     ++__first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                     if (__first == __last)
-                        throw regex_error(regex_constants::error_badbrace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                        __throw_regex_error<regex_constants::error_badbrace>();
                     if (*__first == '}')
                     {
                         ++__first;
@@ -3650,20 +3638,14 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
                     {
                         int __max = -1;
                         __temp = __parse_DUP_COUNT(__first, __last, __max);
-#ifndef _LIBCPP_NO_EXCEPTIONS
                         if (__temp == __first)
-                            throw regex_error(regex_constants::error_brace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                            __throw_regex_error<regex_constants::error_brace>();
                         __first = __temp;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                         if (__first == __last || *__first != '}')
-                            throw regex_error(regex_constants::error_brace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                            __throw_regex_error<regex_constants::error_brace>();
                         ++__first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                         if (__max < __min)
-                            throw regex_error(regex_constants::error_badbrace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                            __throw_regex_error<regex_constants::error_badbrace>();
                         if (__grammar == ECMAScript && __first != __last && *__first == '?')
                         {
                             ++__first;
@@ -3673,10 +3655,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
                             __push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
                     }
                     break;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 default:
-                    throw regex_error(regex_constants::error_badbrace);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                    __throw_regex_error<regex_constants::error_badbrace>();
                 }
             }
             break;
@@ -3694,10 +3674,8 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
     if (__first != __last && *__first == '[')
     {
         ++__first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
         if (__first == __last)
-            throw regex_error(regex_constants::error_brack);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+            __throw_regex_error<regex_constants::error_brack>();
         bool __negate = false;
         if (*__first == '^')
         {
@@ -3706,29 +3684,23 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
         }
         __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
         // __ml owned by *this
-#ifndef _LIBCPP_NO_EXCEPTIONS
         if (__first == __last)
-            throw regex_error(regex_constants::error_brack);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+            __throw_regex_error<regex_constants::error_brack>();
         if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
         {
             __ml->__add_char(']');
             ++__first;
         }
         __first = __parse_follow_list(__first, __last, __ml);
-#ifndef _LIBCPP_NO_EXCEPTIONS
         if (__first == __last)
-            throw regex_error(regex_constants::error_brack);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+            __throw_regex_error<regex_constants::error_brack>();
         if (*__first == '-')
         {
             __ml->__add_char('-');
             ++__first;
         }
-#ifndef _LIBCPP_NO_EXCEPTIONS
         if (__first == __last || *__first != ']')
-            throw regex_error(regex_constants::error_brack);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+            __throw_regex_error<regex_constants::error_brack>();
         ++__first;
     }
     return __first;
@@ -3848,10 +3820,8 @@ basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
                           basic_string<_CharT>& __str,
                           __bracket_expression<_CharT, _Traits>* __ml)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__first == __last)
-        throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_escape>();
     switch (*__first)
     {
     case 0:
@@ -3892,10 +3862,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
                           _ForwardIterator __last,
                           basic_string<_CharT>* __str)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__first == __last)
-        throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_escape>();
     switch (*__first)
     {
     case '\\':
@@ -3963,10 +3931,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
         else
             __push_char(_CharT(__val));
     }
-#ifndef _LIBCPP_NO_EXCEPTIONS
     else
-        throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_escape>();
     return __first;
 }
 
@@ -3982,18 +3948,14 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first
     value_type _Equal_close[2] = {'=', ']'};
     _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
                                                             _Equal_close+2);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__temp == __last)
-        throw regex_error(regex_constants::error_brack);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_brack>();
     // [__first, __temp) contains all text in [= ... =]
     typedef typename _Traits::string_type string_type;
     string_type __collate_name =
         __traits_.lookup_collatename(__first, __temp);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__collate_name.empty())
-        throw regex_error(regex_constants::error_collate);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_collate>();
     string_type __equiv_name =
         __traits_.transform_primary(__collate_name.begin(),
                                     __collate_name.end());
@@ -4009,10 +3971,8 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first
         case 2:
             __ml->__add_digraph(__collate_name[0], __collate_name[1]);
             break;
-#ifndef _LIBCPP_NO_EXCEPTIONS
         default:
-            throw regex_error(regex_constants::error_collate);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+            __throw_regex_error<regex_constants::error_collate>();
         }
     }
     __first = _VSTD::next(__temp, 2);
@@ -4031,18 +3991,14 @@ basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
     value_type _Colon_close[2] = {':', ']'};
     _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
                                                             _Colon_close+2);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__temp == __last)
-        throw regex_error(regex_constants::error_brack);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_brack>();
     // [__first, __temp) contains all text in [: ... :]
     typedef typename _Traits::char_class_type char_class_type;
     char_class_type __class_type =
         __traits_.lookup_classname(__first, __temp, __flags_ & icase);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__class_type == 0)
-        throw regex_error(regex_constants::error_brack);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_brack>();
     __ml->__add_class(__class_type);
     __first = _VSTD::next(__temp, 2);
     return __first;
@@ -4060,22 +4016,17 @@ basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
     value_type _Dot_close[2] = {'.', ']'};
     _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
                                                             _Dot_close+2);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__temp == __last)
-        throw regex_error(regex_constants::error_brack);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_brack>();
     // [__first, __temp) contains all text in [. ... .]
-    typedef typename _Traits::string_type string_type;
     __col_sym = __traits_.lookup_collatename(__first, __temp);
     switch (__col_sym.size())
     {
     case 1:
     case 2:
         break;
-#ifndef _LIBCPP_NO_EXCEPTIONS
     default:
-        throw regex_error(regex_constants::error_collate);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_regex_error<regex_constants::error_collate>();
     }
     __first = _VSTD::next(__temp, 2);
     return __first;
@@ -4219,10 +4170,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
                                 unsigned __mexp = __exp.__marked_count_;
                                 __push_lookahead(_VSTD::move(__exp), false, __marked_count_);
                                 __marked_count_ += __mexp;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                                 if (__temp == __last || *__temp != ')')
-                                    throw regex_error(regex_constants::error_paren);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                                    __throw_regex_error<regex_constants::error_paren>();
                                 __first = ++__temp;
                             }
                             break;
@@ -4234,10 +4183,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
                                 unsigned __mexp = __exp.__marked_count_;
                                 __push_lookahead(_VSTD::move(__exp), true, __marked_count_);
                                 __marked_count_ += __mexp;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                                 if (__temp == __last || *__temp != ')')
-                                    throw regex_error(regex_constants::error_paren);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                                    __throw_regex_error<regex_constants::error_paren>();
                                 __first = ++__temp;
                             }
                             break;
@@ -4274,19 +4221,15 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
         case '(':
             {
                 ++__first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 if (__first == __last)
-                    throw regex_error(regex_constants::error_paren);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                    __throw_regex_error<regex_constants::error_paren>();
                 _ForwardIterator __temp = _VSTD::next(__first);
                 if (__temp != __last && *__first == '?' && *__temp == ':')
                 {
                     ++__open_count_;
                     __first = __parse_ecma_exp(++__temp, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
                     if (__first == __last || *__first != ')')
-                        throw regex_error(regex_constants::error_paren);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                        __throw_regex_error<regex_constants::error_paren>();
                     --__open_count_;
                     ++__first;
                 }
@@ -4296,16 +4239,20 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
                     unsigned __temp_count = __marked_count_;
                     ++__open_count_;
                     __first = __parse_ecma_exp(__first, __last);
-#ifndef _LIBCPP_NO_EXCEPTIONS
                     if (__first == __last || *__first != ')')
-                        throw regex_error(regex_constants::error_paren);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                        __throw_regex_error<regex_constants::error_paren>();
                     __push_end_marked_subexpression(__temp_count);
                     --__open_count_;
                     ++__first;
                 }
             }
             break;
+        case '*':
+        case '+':
+        case '?':
+        case '{':
+            __throw_regex_error<regex_constants::error_badrepeat>();
+            break;
         default:
             __first = __parse_pattern_character(__first, __last);
             break;
@@ -4323,6 +4270,9 @@ basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
     if (__first != __last && *__first == '\\')
     {
         _ForwardIterator __t1 = _VSTD::next(__first);
+        if (__t1 == __last)
+            __throw_regex_error<regex_constants::error_escape>();
+
         _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
         if (__t2 != __t1)
             __first = __t2;
@@ -4360,10 +4310,8 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
             unsigned __v = *__first - '0';
             for (++__first; '0' <= *__first && *__first <= '9'; ++__first)
                 __v = 10 * __v + *__first - '0';
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__v > mark_count())
-                throw regex_error(regex_constants::error_backref);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_backref>();
             __push_back_ref(__v);
         }
     }
@@ -4479,62 +4427,42 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
                         __push_char(_CharT(*__t % 32));
                     __first = ++__t;
                 }
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 else 
-                    throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                    __throw_regex_error<regex_constants::error_escape>();
             }
-#ifndef _LIBCPP_NO_EXCEPTIONS
             else
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             break;
         case 'u':
             ++__first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__first == __last)
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             __hd = __traits_.value(*__first, 16);
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__hd == -1)
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             __sum = 16 * __sum + static_cast<unsigned>(__hd);
             ++__first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__first == __last)
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             __hd = __traits_.value(*__first, 16);
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__hd == -1)
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             __sum = 16 * __sum + static_cast<unsigned>(__hd);
             // drop through
         case 'x':
             ++__first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__first == __last)
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             __hd = __traits_.value(*__first, 16);
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__hd == -1)
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             __sum = 16 * __sum + static_cast<unsigned>(__hd);
             ++__first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__first == __last)
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             __hd = __traits_.value(*__first, 16);
-#ifndef _LIBCPP_NO_EXCEPTIONS
             if (__hd == -1)
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             __sum = 16 * __sum + static_cast<unsigned>(__hd);
             if (__str)
                 *__str = _CharT(__sum);
@@ -4558,10 +4486,8 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
                     __push_char(*__first);
                 ++__first;
             }
-#ifndef _LIBCPP_NO_EXCEPTIONS
             else
-                throw regex_error(regex_constants::error_escape);
-#endif  // _LIBCPP_NO_EXCEPTIONS
+                __throw_regex_error<regex_constants::error_escape>();
             break;
         }
     }
@@ -4926,7 +4852,7 @@ bool
 operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
            const sub_match<_BiIter>& __y)
 {
-    return __y.compare(__x.c_str()) == 0;
+    return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
 }
 
 template <class _BiIter, class _ST, class _SA>
@@ -4944,7 +4870,7 @@ bool
 operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
           const sub_match<_BiIter>& __y)
 {
-    return __y.compare(__x.c_str()) > 0;
+    return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
 }
 
 template <class _BiIter, class _ST, class _SA>
@@ -4979,7 +4905,7 @@ bool
 operator==(const sub_match<_BiIter>& __x,
            const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
 {
-    return __x.compare(__y.c_str()) == 0;
+    return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
 }
 
 template <class _BiIter, class _ST, class _SA>
@@ -4997,7 +4923,7 @@ bool
 operator<(const sub_match<_BiIter>& __x,
           const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
 {
-    return __x.compare(__y.c_str()) < 0;
+    return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
 }
 
 template <class _BiIter, class _ST, class _SA>
@@ -5422,8 +5348,8 @@ match_results<_BidirectionalIterator, _Allocator>::match_results(
       __unmatched_(),
       __prefix_(),
       __suffix_(),
-      __position_start_(),
-      __ready_(false)
+      __ready_(false),
+      __position_start_()
 {
 }
 
@@ -5466,8 +5392,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out,
                 if ('0' <= *__fmt_first && *__fmt_first <= '9')
                 {
                     size_t __i = *__fmt_first - '0';
-                    __out = _VSTD::copy(__matches_[__i].first,
-                                       __matches_[__i].second, __out);
+                    __out = _VSTD::copy((*this)[__i].first,
+                                        (*this)[__i].second, __out);
                 }
                 else
                 {
@@ -5518,8 +5444,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out,
                             ++__fmt_first;
                             __i = 10 * __i + *__fmt_first - '0';
                         }
-                        __out = _VSTD::copy(__matches_[__i].first,
-                                           __matches_[__i].second, __out);
+                        __out = _VSTD::copy((*this)[__i].first,
+                                            (*this)[__i].second, __out);
                     }
                     else
                     {
@@ -5603,12 +5529,17 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma(
     __node* __st = __start_.get();
     if (__st)
     {
+        sub_match<const _CharT*> __unmatched;
+        __unmatched.first   = __last;
+        __unmatched.second  = __last;
+        __unmatched.matched = false;
+
         __states.push_back(__state());
         __states.back().__do_ = 0;
         __states.back().__first_ = __first;
         __states.back().__current_ = __first;
         __states.back().__last_ = __last;
-        __states.back().__sub_matches_.resize(mark_count());
+        __states.back().__sub_matches_.resize(mark_count(), __unmatched);
         __states.back().__loop_data_.resize(__loop_count());
         __states.back().__node_ = __st;
         __states.back().__flags_ = __flags;
@@ -5643,9 +5574,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma(
                 __states.pop_back();
                 break;
             default:
-#ifndef _LIBCPP_NO_EXCEPTIONS
-                throw regex_error(regex_constants::__re_err_unknown);
-#endif
+                __throw_regex_error<regex_constants::__re_err_unknown>();
                 break;
 
             }
@@ -5715,9 +5644,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
                 __states.pop_back();
                 break;
             default:
-#ifndef _LIBCPP_NO_EXCEPTIONS
-                throw regex_error(regex_constants::__re_err_unknown);
-#endif
+                __throw_regex_error<regex_constants::__re_err_unknown>();
                 break;
             }
         } while (!__states.empty());
@@ -5748,12 +5675,17 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
     __node* __st = __start_.get();
     if (__st)
     {
+        sub_match<const _CharT*> __unmatched;
+        __unmatched.first   = __last;
+        __unmatched.second  = __last;
+        __unmatched.matched = false;
+
         __states.push_back(__state());
         __states.back().__do_ = 0;
         __states.back().__first_ = __first;
         __states.back().__current_ = __first;
         __states.back().__last_ = __last;
-        __states.back().__sub_matches_.resize(mark_count());
+        __states.back().__sub_matches_.resize(mark_count(), __unmatched);
         __states.back().__loop_data_.resize(__loop_count());
         __states.back().__node_ = __st;
         __states.back().__flags_ = __flags;
@@ -5798,9 +5730,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
                 __states.pop_back();
                 break;
             default:
-#ifndef _LIBCPP_NO_EXCEPTIONS
-                throw regex_error(regex_constants::__re_err_unknown);
-#endif
+                __throw_regex_error<regex_constants::__re_err_unknown>();
                 break;
             }
         } while (!__states.empty());
diff --git a/system/include/libcxx/scoped_allocator b/system/include/libcxx/scoped_allocator
index aa8bece6d3313..9436dac9c1990 100644
--- a/system/include/libcxx/scoped_allocator
+++ b/system/include/libcxx/scoped_allocator
@@ -38,6 +38,7 @@ public:
     typedef see below propagate_on_container_copy_assignment;
     typedef see below propagate_on_container_move_assignment;
     typedef see below propagate_on_container_swap;
+    typedef see below is_always_equal;
 
     template <class Tp>
         struct rebind
@@ -57,6 +58,8 @@ public:
     template <class OuterA2>
         scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
 
+    scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
+    scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
     ~scoped_allocator_adaptor();
 
     inner_allocator_type& inner_allocator() noexcept;
@@ -170,6 +173,22 @@ struct __get_poc_swap<_A0, _Allocs...>
         __get_poc_swap<_Allocs...>::value;
 };
 
+template <class ..._Allocs> struct __get_is_always_equal;
+
+template <class _A0>
+struct __get_is_always_equal<_A0>
+{
+    static const bool value = allocator_traits<_A0>::is_always_equal::value;
+};
+
+template <class _A0, class ..._Allocs>
+struct __get_is_always_equal<_A0, _Allocs...>
+{
+    static const bool value =
+        allocator_traits<_A0>::is_always_equal::value &&
+        __get_is_always_equal<_Allocs...>::value;
+};
+
 template <class ..._Allocs>
 class __scoped_allocator_storage;
 
@@ -397,6 +416,11 @@ public:
                 bool,
                 __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value
             > propagate_on_container_swap;
+    typedef integral_constant
+            <
+                bool,
+                __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value
+            > is_always_equal;
 
     template <class _Tp>
     struct rebind
@@ -435,6 +459,8 @@ public:
             scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
                 : base(_VSTD::move(__other)) {}
 
+    // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
+    // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
     // ~scoped_allocator_adaptor() = default;
 
     _LIBCPP_INLINE_VISIBILITY
diff --git a/system/include/libcxx/set b/system/include/libcxx/set
index 22d794da547af..ac69e085241f7 100644
--- a/system/include/libcxx/set
+++ b/system/include/libcxx/set
@@ -116,6 +116,7 @@ public:
     void insert(initializer_list<value_type> il);
 
     iterator  erase(const_iterator position);
+    iterator  erase(iterator position);  // C++14
     size_type erase(const key_type& k);
     iterator  erase(const_iterator first, const_iterator last);
     void clear() noexcept;
@@ -297,6 +298,7 @@ public:
     void insert(initializer_list<value_type> il);
 
     iterator  erase(const_iterator position);
+    iterator  erase(iterator position);  // C++14
     size_type erase(const key_type& k);
     iterator  erase(const_iterator first, const_iterator last);
     void clear() noexcept;
@@ -407,6 +409,9 @@ public:
     typedef value_type&                              reference;
     typedef const value_type&                        const_reference;
 
+    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+                  "Allocator::value_type must be same type as value_type");
+
 private:
     typedef __tree<value_type, value_compare, allocator_type> __base;
     typedef allocator_traits<allocator_type>                  __alloc_traits;
@@ -817,6 +822,9 @@ public:
     typedef value_type&                              reference;
     typedef const value_type&                        const_reference;
 
+    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+                  "Allocator::value_type must be same type as value_type");
+
 private:
     typedef __tree<value_type, value_compare, allocator_type> __base;
     typedef allocator_traits<allocator_type>                  __alloc_traits;
diff --git a/system/include/libcxx/__tuple_03 b/system/include/libcxx/setjmp.h
similarity index 52%
rename from system/include/libcxx/__tuple_03
rename to system/include/libcxx/setjmp.h
index b91c2cd48a63c..464b4a5408972 100644
--- a/system/include/libcxx/__tuple_03
+++ b/system/include/libcxx/setjmp.h
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===----------------------------------------------------------------------===//
+//===--------------------------- setjmp.h ---------------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,8 +8,23 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP___TUPLE_03
-#define _LIBCPP___TUPLE_03
+#ifndef _LIBCPP_SETJMP_H
+#define _LIBCPP_SETJMP_H
+
+/*
+    setjmp.h synopsis
+
+Macros:
+
+    setjmp
+
+Types:
+
+    jmp_buf
+
+void longjmp(jmp_buf env, int val);
+
+*/
 
 #include <__config>
 
@@ -17,11 +32,14 @@
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#include_next <setjmp.h>
 
-template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
-template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element;
+#ifdef __cplusplus
+
+#ifndef setjmp
+#define setjmp(env) setjmp(env)
+#endif
 
-_LIBCPP_END_NAMESPACE_STD
+#endif // __cplusplus
 
-#endif  // _LIBCPP___TUPLE_03
+#endif  // _LIBCPP_SETJMP_H
diff --git a/system/include/libcxx/shared_mutex b/system/include/libcxx/shared_mutex
index 9b7f0bf773546..923fe07ab38b4 100644
--- a/system/include/libcxx/shared_mutex
+++ b/system/include/libcxx/shared_mutex
@@ -19,6 +19,29 @@
 namespace std
 {
 
+class shared_mutex      // C++17
+{
+public:
+    shared_mutex();
+    ~shared_mutex();
+
+    shared_mutex(const shared_mutex&) = delete;
+    shared_mutex& operator=(const shared_mutex&) = delete;
+
+    // Exclusive ownership
+    void lock(); // blocking
+    bool try_lock();
+    void unlock();
+
+    // Shared ownership
+    void lock_shared(); // blocking
+    bool try_lock_shared();
+    void unlock_shared();
+
+    typedef implementation-defined native_handle_type; // See 30.2.3
+    native_handle_type native_handle(); // See 30.2.3
+};
+
 class shared_timed_mutex
 {
 public:
@@ -118,7 +141,7 @@ template <class Mutex>
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-class _LIBCPP_TYPE_VIS shared_timed_mutex
+struct _LIBCPP_TYPE_VIS __shared_mutex_base
 {
     mutex               __mut_;
     condition_variable  __gate1_;
@@ -127,6 +150,58 @@ class _LIBCPP_TYPE_VIS shared_timed_mutex
 
     static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
     static const unsigned __n_readers_ = ~__write_entered_;
+
+    __shared_mutex_base();
+    _LIBCPP_INLINE_VISIBILITY ~__shared_mutex_base() = default;
+
+    __shared_mutex_base(const __shared_mutex_base&) = delete;
+    __shared_mutex_base& operator=(const __shared_mutex_base&) = delete;
+
+    // Exclusive ownership
+    void lock(); // blocking
+    bool try_lock();
+    void unlock();
+
+    // Shared ownership
+    void lock_shared(); // blocking
+    bool try_lock_shared();
+    void unlock_shared();
+
+//     typedef implementation-defined native_handle_type; // See 30.2.3
+//     native_handle_type native_handle(); // See 30.2.3
+};
+
+
+#if _LIBCPP_STD_VER > 14
+class _LIBCPP_TYPE_VIS shared_mutex
+{
+	__shared_mutex_base __base;
+public:
+    shared_mutex() : __base() {}
+    _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;
+
+    shared_mutex(const shared_mutex&) = delete;
+    shared_mutex& operator=(const shared_mutex&) = delete;
+
+    // Exclusive ownership
+    _LIBCPP_INLINE_VISIBILITY void lock()     { return __base.lock(); }
+    _LIBCPP_INLINE_VISIBILITY bool try_lock() { return __base.try_lock(); }
+    _LIBCPP_INLINE_VISIBILITY void unlock()   { return __base.unlock(); }
+
+    // Shared ownership
+    _LIBCPP_INLINE_VISIBILITY void lock_shared()     { return __base.lock_shared(); }
+    _LIBCPP_INLINE_VISIBILITY bool try_lock_shared() { return __base.try_lock_shared(); }
+    _LIBCPP_INLINE_VISIBILITY void unlock_shared()   { return __base.unlock_shared(); }
+
+//     typedef __shared_mutex_base::native_handle_type native_handle_type;
+//     _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() { return __base::unlock_shared(); }
+};
+#endif
+
+
+class _LIBCPP_TYPE_VIS shared_timed_mutex
+{
+	__shared_mutex_base __base;
 public:
     shared_timed_mutex();
     _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
@@ -170,29 +245,30 @@ bool
 shared_timed_mutex::try_lock_until(
                         const chrono::time_point<_Clock, _Duration>& __abs_time)
 {
-    unique_lock<mutex> __lk(__mut_);
-    if (__state_ & __write_entered_)
+    unique_lock<mutex> __lk(__base.__mut_);
+    if (__base.__state_ & __base.__write_entered_)
     {
         while (true)
         {
-            cv_status __status = __gate1_.wait_until(__lk, __abs_time);
-            if ((__state_ & __write_entered_) == 0)
+            cv_status __status = __base.__gate1_.wait_until(__lk, __abs_time);
+            if ((__base.__state_ & __base.__write_entered_) == 0)
                 break;
             if (__status == cv_status::timeout)
                 return false;
         }
     }
-    __state_ |= __write_entered_;
-    if (__state_ & __n_readers_)
+    __base.__state_ |= __base.__write_entered_;
+    if (__base.__state_ & __base.__n_readers_)
     {
         while (true)
         {
-            cv_status __status = __gate2_.wait_until(__lk, __abs_time);
-            if ((__state_ & __n_readers_) == 0)
+            cv_status __status = __base.__gate2_.wait_until(__lk, __abs_time);
+            if ((__base.__state_ & __base.__n_readers_) == 0)
                 break;
             if (__status == cv_status::timeout)
             {
-                __state_ &= ~__write_entered_;
+                __base.__state_ &= ~__base.__write_entered_;
+                __base.__gate1_.notify_all();
                 return false;
             }
         }
@@ -205,22 +281,22 @@ bool
 shared_timed_mutex::try_lock_shared_until(
                         const chrono::time_point<_Clock, _Duration>& __abs_time)
 {
-    unique_lock<mutex> __lk(__mut_);
-    if ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
+    unique_lock<mutex> __lk(__base.__mut_);
+    if ((__base.__state_ & __base.__write_entered_) || (__base.__state_ & __base.__n_readers_) == __base.__n_readers_)
     {
         while (true)
         {
-            cv_status status = __gate1_.wait_until(__lk, __abs_time);
-            if ((__state_ & __write_entered_) == 0 &&
-                                       (__state_ & __n_readers_) < __n_readers_)
+            cv_status status = __base.__gate1_.wait_until(__lk, __abs_time);
+            if ((__base.__state_ & __base.__write_entered_) == 0 &&
+                                       (__base.__state_ & __base.__n_readers_) < __base.__n_readers_)
                 break;
             if (status == cv_status::timeout)
                 return false;
         }
     }
-    unsigned __num_readers = (__state_ & __n_readers_) + 1;
-    __state_ &= ~__n_readers_;
-    __state_ |= __num_readers;
+    unsigned __num_readers = (__base.__state_ & __base.__n_readers_) + 1;
+    __base.__state_ &= ~__base.__n_readers_;
+    __base.__state_ |= __num_readers;
     return true;
 }
 
@@ -243,25 +319,25 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     explicit shared_lock(mutex_type& __m)
-        : __m_(&__m),
+        : __m_(_VSTD::addressof(__m)),
           __owns_(true)
         {__m_->lock_shared();}
 
     _LIBCPP_INLINE_VISIBILITY
     shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
-        : __m_(&__m),
+        : __m_(_VSTD::addressof(__m)),
           __owns_(false)
         {}
 
     _LIBCPP_INLINE_VISIBILITY
     shared_lock(mutex_type& __m, try_to_lock_t)
-        : __m_(&__m),
+        : __m_(_VSTD::addressof(__m)),
           __owns_(__m.try_lock_shared())
         {}
 
     _LIBCPP_INLINE_VISIBILITY
     shared_lock(mutex_type& __m, adopt_lock_t)
-        : __m_(&__m),
+        : __m_(_VSTD::addressof(__m)),
           __owns_(true)
         {}
 
@@ -269,7 +345,7 @@ public:
         _LIBCPP_INLINE_VISIBILITY
         shared_lock(mutex_type& __m,
                     const chrono::time_point<_Clock, _Duration>& __abs_time)
-            : __m_(&__m),
+            : __m_(_VSTD::addressof(__m)),
               __owns_(__m.try_lock_shared_until(__abs_time))
             {}
 
@@ -277,7 +353,7 @@ public:
         _LIBCPP_INLINE_VISIBILITY
         shared_lock(mutex_type& __m,
                     const chrono::duration<_Rep, _Period>& __rel_time)
-            : __m_(&__m),
+            : __m_(_VSTD::addressof(__m)),
               __owns_(__m.try_lock_shared_for(__rel_time))
             {}
 
diff --git a/system/include/libcxx/stack b/system/include/libcxx/stack
index 30909c1ee3bd1..48b3b0d16ec2f 100644
--- a/system/include/libcxx/stack
+++ b/system/include/libcxx/stack
@@ -58,7 +58,7 @@ public:
     template <class... Args> void emplace(Args&&... args);
     void pop();
 
-    void swap(stack& c) noexcept(noexcept(swap(c, q.c)));
+    void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>)
 };
 
 template <class T, class Container>
@@ -91,7 +91,7 @@ template <class T, class Container>
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <class _Tp, class _Container> class _LIBCPP_TYPE_VIS_ONLY stack;
+template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TYPE_VIS_ONLY stack;
 
 template <class _Tp, class _Container>
 _LIBCPP_INLINE_VISIBILITY
@@ -103,7 +103,7 @@ _LIBCPP_INLINE_VISIBILITY
 bool
 operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
 
-template <class _Tp, class _Container = deque<_Tp> >
+template <class _Tp, class _Container /*= deque<_Tp>*/>
 class _LIBCPP_TYPE_VIS_ONLY stack
 {
 public:
@@ -112,7 +112,8 @@ public:
     typedef typename container_type::reference       reference;
     typedef typename container_type::const_reference const_reference;
     typedef typename container_type::size_type       size_type;
-
+    static_assert((is_same<_Tp, value_type>::value), "" );
+    
 protected:
     container_type c;
 
@@ -274,7 +275,10 @@ operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
 
 template <class _Tp, class _Container>
 inline _LIBCPP_INLINE_VISIBILITY
-void
+typename enable_if<
+    __is_swappable<_Container>::value,
+    void
+>::type
 swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
     _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
 {
diff --git a/system/include/libcxx/stdbool.h b/system/include/libcxx/stdbool.h
new file mode 100644
index 0000000000000..86a127f0fd620
--- /dev/null
+++ b/system/include/libcxx/stdbool.h
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+//===--------------------------- stdbool.h --------------------------------===//
+//
+//                     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_STDBOOL_H
+#define _LIBCPP_STDBOOL_H
+
+
+/*
+    stdbool.h synopsis
+
+Macros:
+
+    __bool_true_false_are_defined
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <stdbool.h>
+
+#ifdef __cplusplus
+#undef bool
+#undef true
+#undef false
+#undef __bool_true_false_are_defined
+#define __bool_true_false_are_defined 1
+#endif
+
+#endif  // _LIBCPP_STDBOOL_H
diff --git a/system/include/libcxx/stddef.h b/system/include/libcxx/stddef.h
new file mode 100644
index 0000000000000..8841bbea29786
--- /dev/null
+++ b/system/include/libcxx/stddef.h
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+//===--------------------------- stddef.h ---------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__need_ptrdiff_t) || defined(__need_size_t) || \
+    defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <stddef.h>
+
+#elif !defined(_LIBCPP_STDDEF_H)
+#define _LIBCPP_STDDEF_H
+
+/*
+    stddef.h synopsis
+
+Macros:
+
+    offsetof(type,member-designator)
+    NULL
+
+Types:
+
+    ptrdiff_t
+    size_t
+    max_align_t
+    nullptr_t
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <stddef.h>
+
+#ifdef __cplusplus
+
+extern "C++" {
+#include <__nullptr>
+using std::nullptr_t;
+}
+
+// Re-use the compiler's <stddef.h> max_align_t where possible.
+#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T)
+typedef long double max_align_t;
+#endif
+
+#endif
+
+#endif  // _LIBCPP_STDDEF_H
diff --git a/system/include/libcxx/stdexcept b/system/include/libcxx/stdexcept
index 5fc912a644be8..4218b1398d85b 100644
--- a/system/include/libcxx/stdexcept
+++ b/system/include/libcxx/stdexcept
@@ -53,7 +53,11 @@ public:
 #ifndef _LIBCPP___REFSTRING
 _LIBCPP_BEGIN_NAMESPACE_STD
 class _LIBCPP_HIDDEN __libcpp_refstring {
+#ifdef __clang__
+    const char *__imp_ __attribute__((__unused__)); // only clang emits a warning
+#else
     const char *__imp_;
+#endif
 };
 _LIBCPP_END_NAMESPACE_STD
 #endif
diff --git a/system/include/libcxx/stdio.h b/system/include/libcxx/stdio.h
new file mode 100644
index 0000000000000..56fb2d83bb287
--- /dev/null
+++ b/system/include/libcxx/stdio.h
@@ -0,0 +1,127 @@
+// -*- C++ -*-
+//===---------------------------- stdio.h ---------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__need_FILE) || defined(__need___FILE)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <stdio.h>
+
+#elif !defined(_LIBCPP_STDIO_H)
+#define _LIBCPP_STDIO_H
+
+/*
+    stdio.h synopsis
+
+Macros:
+
+    BUFSIZ
+    EOF
+    FILENAME_MAX
+    FOPEN_MAX
+    L_tmpnam
+    NULL
+    SEEK_CUR
+    SEEK_END
+    SEEK_SET
+    TMP_MAX
+    _IOFBF
+    _IOLBF
+    _IONBF
+    stderr
+    stdin
+    stdout
+
+Types:
+
+FILE
+fpos_t
+size_t
+
+int remove(const char* filename);
+int rename(const char* old, const char* new);
+FILE* tmpfile(void);
+char* tmpnam(char* s);
+int fclose(FILE* stream);
+int fflush(FILE* stream);
+FILE* fopen(const char* restrict filename, const char* restrict mode);
+FILE* freopen(const char* restrict filename, const char * restrict mode,
+              FILE * restrict stream);
+void setbuf(FILE* restrict stream, char* restrict buf);
+int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
+int fprintf(FILE* restrict stream, const char* restrict format, ...);
+int fscanf(FILE* restrict stream, const char * restrict format, ...);
+int printf(const char* restrict format, ...);
+int scanf(const char* restrict format, ...);
+int snprintf(char* restrict s, size_t n, const char* restrict format, ...);    // C99
+int sprintf(char* restrict s, const char* restrict format, ...);
+int sscanf(const char* restrict s, const char* restrict format, ...);
+int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
+int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg);  // C99
+int vprintf(const char* restrict format, va_list arg);
+int vscanf(const char* restrict format, va_list arg);                          // C99
+int vsnprintf(char* restrict s, size_t n, const char* restrict format,         // C99
+              va_list arg);
+int vsprintf(char* restrict s, const char* restrict format, va_list arg);
+int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
+int fgetc(FILE* stream);
+char* fgets(char* restrict s, int n, FILE* restrict stream);
+int fputc(int c, FILE* stream);
+int fputs(const char* restrict s, FILE* restrict stream);
+int getc(FILE* stream);
+int getchar(void);
+char* gets(char* s);  // removed in C++14
+int putc(int c, FILE* stream);
+int putchar(int c);
+int puts(const char* s);
+int ungetc(int c, FILE* stream);
+size_t fread(void* restrict ptr, size_t size, size_t nmemb,
+             FILE* restrict stream);
+size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
+              FILE* restrict stream);
+int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
+int fseek(FILE* stream, long offset, int whence);
+int fsetpos(FILE*stream, const fpos_t* pos);
+long ftell(FILE* stream);
+void rewind(FILE* stream);
+void clearerr(FILE* stream);
+int feof(FILE* stream);
+int ferror(FILE* stream);
+void perror(const char* s);
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <stdio.h>
+
+#ifdef __cplusplus
+
+// snprintf
+#if defined(_LIBCPP_MSVCRT)
+extern "C++" {
+#include "support/win32/support.h"
+}
+#endif
+
+#undef getc
+#undef putc
+#undef clearerr
+#undef feof
+#undef ferror
+
+#endif
+
+#endif  // _LIBCPP_STDIO_H
diff --git a/system/include/libcxx/stdlib.h b/system/include/libcxx/stdlib.h
new file mode 100644
index 0000000000000..12fd676a15f55
--- /dev/null
+++ b/system/include/libcxx/stdlib.h
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+//===--------------------------- stdlib.h ---------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__need_malloc_and_calloc)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <stdlib.h>
+
+#elif !defined(_LIBCPP_STDLIB_H)
+#define _LIBCPP_STDLIB_H
+
+/*
+    stdlib.h synopsis
+
+Macros:
+
+    EXIT_FAILURE
+    EXIT_SUCCESS
+    MB_CUR_MAX
+    NULL
+    RAND_MAX
+
+Types:
+
+    size_t
+    div_t
+    ldiv_t
+    lldiv_t                                                               // C99
+
+double    atof (const char* nptr);
+int       atoi (const char* nptr);
+long      atol (const char* nptr);
+long long atoll(const char* nptr);                                        // C99
+double             strtod  (const char* restrict nptr, char** restrict endptr);
+float              strtof  (const char* restrict nptr, char** restrict endptr); // C99
+long double        strtold (const char* restrict nptr, char** restrict endptr); // C99
+long               strtol  (const char* restrict nptr, char** restrict endptr, int base);
+long long          strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
+unsigned long      strtoul (const char* restrict nptr, char** restrict endptr, int base);
+unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
+int rand(void);
+void srand(unsigned int seed);
+void* calloc(size_t nmemb, size_t size);
+void free(void* ptr);
+void* malloc(size_t size);
+void* realloc(void* ptr, size_t size);
+void abort(void);
+int atexit(void (*func)(void));
+void exit(int status);
+void _Exit(int status);
+char* getenv(const char* name);
+int system(const char* string);
+void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
+              int (*compar)(const void *, const void *));
+void qsort(void* base, size_t nmemb, size_t size,
+           int (*compar)(const void *, const void *));
+int         abs(      int j);
+long        abs(     long j);
+long long   abs(long long j);                                             // C++0X
+long       labs(     long j);
+long long llabs(long long j);                                             // C99
+div_t     div(      int numer,       int denom);
+ldiv_t    div(     long numer,      long denom);
+lldiv_t   div(long long numer, long long denom);                          // C++0X
+ldiv_t   ldiv(     long numer,      long denom);
+lldiv_t lldiv(long long numer, long long denom);                          // C99
+int mblen(const char* s, size_t n);
+int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
+int wctomb(char* s, wchar_t wchar);
+size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
+size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
+int at_quick_exit(void (*func)(void))                                     // C++11
+void quick_exit(int status);                                              // C++11
+void *aligned_alloc(size_t alignment, size_t size);                       // C11
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <stdlib.h>
+
+#ifdef __cplusplus
+
+extern "C++" {
+
+#ifdef _LIBCPP_MSVCRT
+#include "support/win32/locale_win32.h"
+#endif // _LIBCPP_MSVCRT
+
+#undef abs
+#undef div
+#undef labs
+#undef ldiv
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+#undef llabs
+#undef lldiv
+#endif
+
+// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+
+inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
+
+}  // extern "C++"
+
+#endif  // __cplusplus
+
+#endif  // _LIBCPP_STDLIB_H
diff --git a/system/include/libcxx/streambuf b/system/include/libcxx/streambuf
index 6adfc9237c7d9..603c680387963 100644
--- a/system/include/libcxx/streambuf
+++ b/system/include/libcxx/streambuf
@@ -536,12 +536,23 @@ basic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n)
 {
     streamsize __i = 0;
     int_type __eof = traits_type::eof();
-    for (; __i < __n; ++__s, ++__i)
+    while( __i < __n)
     {
-        if (__nout_ < __eout_)
-            *__nout_++ = *__s;
-        else if (overflow(traits_type::to_int_type(*__s)) == __eof)
-            break;
+        if (__nout_ >= __eout_)
+        {
+            if (overflow(traits_type::to_int_type(*__s)) == __eof)
+                break;
+            ++__s;
+            ++__i;
+        }
+        else
+        {
+            streamsize __chunk_size = _VSTD::min(__eout_ - __nout_, __n - __i);
+            traits_type::copy(__nout_, __s, __chunk_size);
+            __nout_ += __chunk_size;
+            __s     += __chunk_size;
+            __i     += __chunk_size;
+        }
     }
     return __i;
 }
diff --git a/system/include/libcxx/string b/system/include/libcxx/string
index 12f541e263794..786735f970f8e 100644
--- a/system/include/libcxx/string
+++ b/system/include/libcxx/string
@@ -98,8 +98,10 @@ public:
     basic_string(const basic_string& str);
     basic_string(basic_string&& str)
         noexcept(is_nothrow_move_constructible<allocator_type>::value);
-    basic_string(const basic_string& str, size_type pos, size_type n = npos,
+    basic_string(const basic_string& str, size_type pos,
                  const allocator_type& a = allocator_type());
+    basic_string(const basic_string& str, size_type pos, size_type n,
+                 const Allocator& a = Allocator());             
     basic_string(const value_type* s, const allocator_type& a = allocator_type());
     basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type());
     basic_string(size_type n, value_type c, const allocator_type& a = allocator_type());
@@ -115,8 +117,8 @@ public:
     basic_string& operator=(const basic_string& str);
     basic_string& operator=(basic_string&& str)
         noexcept(
-             allocator_type::propagate_on_container_move_assignment::value &&
-             is_nothrow_move_assignable<allocator_type>::value);
+             allocator_type::propagate_on_container_move_assignment::value ||
+             allocator_type::is_always_equal::value ); // C++17
     basic_string& operator=(const value_type* s);
     basic_string& operator=(value_type c);
     basic_string& operator=(initializer_list<value_type>);
@@ -220,11 +222,12 @@ public:
     basic_string substr(size_type pos = 0, size_type n = npos) const;
 
     void swap(basic_string& str)
-        noexcept(!allocator_type::propagate_on_container_swap::value ||
-                 __is_nothrow_swappable<allocator_type>::value)
+        noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
+                 allocator_traits<allocator_type>::is_always_equal::value);  // C++17
 
     const value_type* c_str() const noexcept;
     const value_type* data() const noexcept;
+          value_type* data()       noexcept;   // C++17
 
     allocator_type get_allocator() const noexcept;
 
@@ -517,10 +520,14 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
         {return __c1 < __c2;}
 
     static int              compare(const char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static size_t           length(const char_type* __s);
+    _LIBCPP_INLINE_VISIBILITY
     static const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
     static char_type*       move(char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static char_type*       copy(char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static char_type*       assign(char_type* __s, size_t __n, char_type __a);
 
     static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
@@ -550,7 +557,7 @@ char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_
 }
 
 template <class _CharT>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 size_t
 char_traits<_CharT>::length(const char_type* __s)
 {
@@ -561,7 +568,7 @@ char_traits<_CharT>::length(const char_type* __s)
 }
 
 template <class _CharT>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 const _CharT*
 char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
 {
@@ -595,7 +602,7 @@ char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
 }
 
 template <class _CharT>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _CharT*
 char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
 {
@@ -607,7 +614,7 @@ char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
 }
 
 template <class _CharT>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _CharT*
 char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
 {
@@ -636,19 +643,19 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char>
         {return (unsigned char)__c1 < (unsigned char)__c2;}
 
     static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
-        {return memcmp(__s1, __s2, __n);}
+        {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);}
     static inline size_t length(const char_type* __s) {return strlen(__s);}
     static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
-        {return (const char_type*)memchr(__s, to_int_type(__a), __n);}
+        {return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_type(__a), __n);}
     static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
-        {return (char_type*)memmove(__s1, __s2, __n);}
+        {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
     static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
         {
             _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
-            return (char_type*)memcpy(__s1, __s2, __n);
+            return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
         }
     static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
-        {return (char_type*)memset(__s, to_int_type(__a), __n);}
+        {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
 
     static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
         {return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -681,20 +688,20 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t>
         {return __c1 < __c2;}
 
     static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
-        {return wmemcmp(__s1, __s2, __n);}
+        {return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);}
     static inline size_t length(const char_type* __s)
         {return wcslen(__s);}
     static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
-        {return (const char_type*)wmemchr(__s, __a, __n);}
+        {return __n == 0 ? NULL : (const char_type*)wmemchr(__s, __a, __n);}
     static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
-        {return (char_type*)wmemmove(__s1, __s2, __n);}
+        {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);}
     static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
         {
             _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
-            return (char_type*)wmemcpy(__s1, __s2, __n);
+            return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n);
         }
     static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
-        {return (char_type*)wmemset(__s, __a, __n);}
+        {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);}
 
     static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
         {return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -726,11 +733,17 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
     static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
         {return __c1 < __c2;}
 
+    _LIBCPP_INLINE_VISIBILITY
     static int              compare(const char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static size_t           length(const char_type* __s);
+    _LIBCPP_INLINE_VISIBILITY
     static const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
     static char_type*       move(char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static char_type*       copy(char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static char_type*       assign(char_type* __s, size_t __n, char_type __a);
 
     static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
@@ -742,10 +755,10 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
     static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
         {return __c1 == __c2;}
     static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
-        {return int_type(0xDFFF);}
+        {return int_type(0xFFFF);}
 };
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 int
 char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
 {
@@ -759,7 +772,7 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz
     return 0;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 size_t
 char_traits<char16_t>::length(const char_type* __s)
 {
@@ -769,7 +782,7 @@ char_traits<char16_t>::length(const char_type* __s)
     return __len;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 const char16_t*
 char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a)
 {
@@ -782,7 +795,7 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
     return 0;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 char16_t*
 char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
 {
@@ -802,7 +815,7 @@ char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
     return __r;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 char16_t*
 char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
 {
@@ -813,7 +826,7 @@ char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
     return __r;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 char16_t*
 char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a)
 {
@@ -839,11 +852,17 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
     static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
         {return __c1 < __c2;}
 
+    _LIBCPP_INLINE_VISIBILITY
     static int              compare(const char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static size_t           length(const char_type* __s);
+    _LIBCPP_INLINE_VISIBILITY
     static const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
     static char_type*       move(char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static char_type*       copy(char_type* __s1, const char_type* __s2, size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     static char_type*       assign(char_type* __s, size_t __n, char_type __a);
 
     static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
@@ -858,7 +877,7 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
         {return int_type(0xFFFFFFFF);}
 };
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 int
 char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
 {
@@ -872,7 +891,7 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz
     return 0;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 size_t
 char_traits<char32_t>::length(const char_type* __s)
 {
@@ -882,7 +901,7 @@ char_traits<char32_t>::length(const char_type* __s)
     return __len;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 const char32_t*
 char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a)
 {
@@ -895,7 +914,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
     return 0;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 char32_t*
 char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
 {
@@ -915,7 +934,7 @@ char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
     return __r;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 char32_t*
 char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
 {
@@ -926,7 +945,7 @@ char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
     return __r;
 }
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 char32_t*
 char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a)
 {
@@ -942,7 +961,7 @@ char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a)
 
 // __str_find
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find(const _CharT *__p, _SizeT __sz, 
              _CharT __c, _SizeT __pos) _NOEXCEPT
 {
@@ -955,7 +974,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
 }
 
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find(const _CharT *__p, _SizeT __sz, 
        const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
 {
@@ -966,7 +985,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
     const _CharT* __r = 
         _VSTD::__search(__p + __pos, __p + __sz,
                         __s, __s + __n, _Traits::eq,
-                        random_access_iterator_tag(), random_access_iterator_tag());
+                        random_access_iterator_tag(), random_access_iterator_tag()).first;
     if (__r == __p + __sz)
         return __npos;
     return static_cast<_SizeT>(__r - __p);
@@ -976,7 +995,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
 // __str_rfind
 
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_rfind(const _CharT *__p, _SizeT __sz, 
               _CharT __c, _SizeT __pos) _NOEXCEPT
 {
@@ -995,7 +1014,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
 }
 
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_rfind(const _CharT *__p, _SizeT __sz, 
         const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
 {
@@ -1014,7 +1033,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
 
 // __str_find_first_of
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find_first_of(const _CharT *__p, _SizeT __sz,
                 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
 {
@@ -1030,7 +1049,7 @@ __str_find_first_of(const _CharT *__p, _SizeT __sz,
 
 // __str_find_last_of
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find_last_of(const _CharT *__p, _SizeT __sz,
                const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
     {
@@ -1053,7 +1072,7 @@ __str_find_last_of(const _CharT *__p, _SizeT __sz,
 
 // __str_find_first_not_of
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
                     const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
 {
@@ -1069,7 +1088,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
 
 
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
                           _CharT __c, _SizeT __pos) _NOEXCEPT
 {
@@ -1086,7 +1105,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
 
 // __str_find_last_not_of
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
                    const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
 {
@@ -1102,7 +1121,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
 
 
 template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
                          _CharT __c, _SizeT __pos) _NOEXCEPT
 {
@@ -1185,7 +1204,31 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common<true>)
 #pragma warning( pop )
 #endif // _LIBCPP_MSVC
 
-#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+#ifdef _LIBCPP_NO_EXCEPTIONS
+template <class _Iter>
+struct __libcpp_string_gets_noexcept_iterator_impl : public true_type {};
+#elif defined(_LIBCPP_HAS_NO_NOEXCEPT)
+template <class _Iter>
+struct __libcpp_string_gets_noexcept_iterator_impl : public false_type {};
+#else
+template <class _Iter, bool = __is_forward_iterator<_Iter>::value>
+struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT((
+    noexcept(++(declval<_Iter&>())) && 
+    is_nothrow_assignable<_Iter&, _Iter>::value && 
+    noexcept(declval<_Iter>() == declval<_Iter>()) && 
+    noexcept(*declval<_Iter>())
+)) {};
+
+template <class _Iter> 
+struct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {};
+#endif
+
+
+template <class _Iter>
+struct __libcpp_string_gets_noexcept_iterator
+    : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {};
+
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
 template <class _CharT, size_t = sizeof(_CharT)>
 struct __padding
@@ -1198,7 +1241,7 @@ struct __padding<_CharT, 1>
 {
 };
 
-#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
 template<class _CharT, class _Traits, class _Allocator>
 class _LIBCPP_TYPE_VIS_ONLY basic_string
@@ -1234,7 +1277,7 @@ public:
 
 private:
 
-#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     struct __long
     {
@@ -1294,7 +1337,7 @@ private:
         value_type __data_[__min_cap];
     };
 
-#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     union __ulx{__long __lx; __short __lxx;};
 
@@ -1322,13 +1365,26 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY basic_string()
         _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
-    _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a);
+
+    _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
+#else
+        _NOEXCEPT;
+#endif
+
     basic_string(const basic_string& __str);
     basic_string(const basic_string& __str, const allocator_type& __a);
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     basic_string(basic_string&& __str)
+#if _LIBCPP_STD_VER <= 14
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#else
+        _NOEXCEPT;
+#endif
+
     _LIBCPP_INLINE_VISIBILITY
     basic_string(basic_string&& __str, const allocator_type& __a);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1343,7 +1399,10 @@ public:
     basic_string(size_type __n, value_type __c);
     _LIBCPP_INLINE_VISIBILITY
     basic_string(size_type __n, value_type __c, const allocator_type& __a);
-    basic_string(const basic_string& __str, size_type __pos, size_type __n = npos,
+    basic_string(const basic_string& __str, size_type __pos, size_type __n,
+                 const allocator_type& __a = allocator_type());
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string(const basic_string& __str, size_type __pos,
                  const allocator_type& __a = allocator_type());
     template<class _InputIterator>
         _LIBCPP_INLINE_VISIBILITY
@@ -1364,8 +1423,7 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     basic_string& operator=(basic_string&& __str)
-        _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
-                   is_nothrow_move_assignable<allocator_type>::value);
+        _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
 #endif
     _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}
     basic_string& operator=(value_type __c);
@@ -1432,7 +1490,8 @@ public:
     _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();}
     _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT;
     _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT
-        {return (__is_long() ? __get_long_cap() : __min_cap) - 1;}
+        {return (__is_long() ? __get_long_cap()
+                             : static_cast<size_type>(__min_cap)) - 1;}
 
     void resize(size_type __n, value_type __c);
     _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}
@@ -1466,15 +1525,16 @@ public:
     template<class _InputIterator>
         typename enable_if
         <
-             __is_input_iterator  <_InputIterator>::value &&
-            !__is_forward_iterator<_InputIterator>::value,
+            __is_exactly_input_iterator<_InputIterator>::value
+                || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
             basic_string&
         >::type
         append(_InputIterator __first, _InputIterator __last);
     template<class _ForwardIterator>
         typename enable_if
         <
-            __is_forward_iterator<_ForwardIterator>::value,
+            __is_forward_iterator<_ForwardIterator>::value
+                && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
             basic_string&
         >::type
         append(_ForwardIterator __first, _ForwardIterator __last);
@@ -1492,10 +1552,11 @@ public:
     _LIBCPP_INLINE_VISIBILITY const_reference back() const;
 
     _LIBCPP_INLINE_VISIBILITY
-    basic_string& assign(const basic_string& __str);
+    basic_string& assign(const basic_string& __str) { return *this = __str; }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     basic_string& assign(basic_string&& str)
+        _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
         {*this = _VSTD::move(str); return *this;}
 #endif
     basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
@@ -1505,15 +1566,16 @@ public:
     template<class _InputIterator>
         typename enable_if
         <
-             __is_input_iterator  <_InputIterator>::value &&
-            !__is_forward_iterator<_InputIterator>::value,
+           __is_exactly_input_iterator<_InputIterator>::value
+                || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
             basic_string&
         >::type
         assign(_InputIterator __first, _InputIterator __last);
     template<class _ForwardIterator>
         typename enable_if
         <
-            __is_forward_iterator<_ForwardIterator>::value,
+            __is_forward_iterator<_ForwardIterator>::value
+                 && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
             basic_string&
         >::type
         assign(_ForwardIterator __first, _ForwardIterator __last);
@@ -1534,15 +1596,16 @@ public:
     template<class _InputIterator>
         typename enable_if
         <
-             __is_input_iterator  <_InputIterator>::value &&
-            !__is_forward_iterator<_InputIterator>::value,
+           __is_exactly_input_iterator<_InputIterator>::value
+                || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
             iterator
         >::type
         insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
     template<class _ForwardIterator>
         typename enable_if
         <
-            __is_forward_iterator<_ForwardIterator>::value,
+            __is_forward_iterator<_ForwardIterator>::value
+                 && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
             iterator
         >::type
         insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
@@ -1591,13 +1654,21 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     void swap(basic_string& __str)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value);
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT;
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value);
+#endif
 
     _LIBCPP_INLINE_VISIBILITY
     const value_type* c_str() const _NOEXCEPT {return data();}
     _LIBCPP_INLINE_VISIBILITY
     const value_type* data() const _NOEXCEPT  {return _VSTD::__to_raw_pointer(__get_pointer());}
+#if _LIBCPP_STD_VER > 14
+    _LIBCPP_INLINE_VISIBILITY
+    value_type* data()             _NOEXCEPT  {return _VSTD::__to_raw_pointer(__get_pointer());}
+#endif
 
     _LIBCPP_INLINE_VISIBILITY
     allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
@@ -1680,7 +1751,7 @@ private:
     const allocator_type& __alloc() const _NOEXCEPT
         {return __r_.second();}
 
-#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     _LIBCPP_INLINE_VISIBILITY
     void __set_short_size(size_type __s) _NOEXCEPT
@@ -1698,7 +1769,7 @@ private:
         {return __r_.first().__s.__size_;}
 #   endif
 
-#else  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#else  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     _LIBCPP_INLINE_VISIBILITY
     void __set_short_size(size_type __s) _NOEXCEPT
@@ -1716,7 +1787,7 @@ private:
         {return __r_.first().__s.__size_ >> 1;}
 #   endif
 
-#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     _LIBCPP_INLINE_VISIBILITY
     void __set_long_size(size_type __s) _NOEXCEPT
@@ -1768,11 +1839,11 @@ private:
     template <size_type __a> static
         _LIBCPP_INLINE_VISIBILITY
         size_type __align_it(size_type __s) _NOEXCEPT
-            {return __s + (__a-1) & ~(__a-1);}
+            {return (__s + (__a-1)) & ~(__a-1);}
     enum {__alignment = 16};
     static _LIBCPP_INLINE_VISIBILITY
     size_type __recommend(size_type __s) _NOEXCEPT
-        {return (__s < __min_cap ? __min_cap :
+        {return (__s < __min_cap ? static_cast<size_type>(__min_cap) :
                  __align_it<sizeof(value_type) < __alignment ?
                             __alignment/sizeof(value_type) : 1 > (__s+1)) - 1;}
 
@@ -1783,8 +1854,7 @@ private:
     template <class _InputIterator>
     typename enable_if
     <
-         __is_input_iterator  <_InputIterator>::value &&
-        !__is_forward_iterator<_InputIterator>::value,
+        __is_exactly_input_iterator<_InputIterator>::value,
         void
     >::type
     __init(_InputIterator __first, _InputIterator __last);
@@ -1828,10 +1898,15 @@ private:
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
-    void __move_assign(basic_string& __str, false_type);
+    void __move_assign(basic_string& __str, false_type)
+        _NOEXCEPT_(__alloc_traits::is_always_equal::value);
     _LIBCPP_INLINE_VISIBILITY
     void __move_assign(basic_string& __str, true_type)
+#if _LIBCPP_STD_VER > 14
+        _NOEXCEPT;
+#else
         _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+#endif
 #endif
 
     _LIBCPP_INLINE_VISIBILITY
@@ -1855,24 +1930,6 @@ private:
         _NOEXCEPT
         {}
 
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type& __x, allocator_type& __y)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value)
-        {__swap_alloc(__x, __y, integral_constant<bool,
-                      __alloc_traits::propagate_on_container_swap::value>());}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type)
-        _NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value)
-        {
-            using _VSTD::swap;
-            swap(__x, __y);
-        }
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type&, allocator_type&, false_type) _NOEXCEPT
-        {}
-
     _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
     _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type);
 
@@ -1937,7 +1994,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string()
 template <class _CharT, class _Traits, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
-    : __r_(__a)
+#if _LIBCPP_STD_VER <= 14
+        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+        _NOEXCEPT
+#endif
+: __r_(__a)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
     __get_db()->__insert_c(this);
@@ -2070,7 +2132,11 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
 template <class _CharT, class _Traits, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
+#if _LIBCPP_STD_VER <= 14
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#else
+        _NOEXCEPT
+#endif
     : __r_(_VSTD::move(__str.__r_))
 {
     __str.__zero();
@@ -2161,12 +2227,26 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
 #endif
 }
 
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
+                                                        const allocator_type& __a)
+    : __r_(__a)
+{
+    size_type __str_sz = __str.size();
+    if (__pos > __str_sz)
+        this->__throw_out_of_range();
+    __init(__str.data() + __pos, __str_sz - __pos);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
 template <class _CharT, class _Traits, class _Allocator>
 template <class _InputIterator>
 typename enable_if
 <
-     __is_input_iterator  <_InputIterator>::value &&
-    !__is_forward_iterator<_InputIterator>::value,
+    __is_exactly_input_iterator<_InputIterator>::value,
     void
 >::type
 basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)
@@ -2215,7 +2295,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
         __set_long_cap(__cap+1);
         __set_long_size(__sz);
     }
-    for (; __first != __last; ++__first, ++__p)
+    for (; __first != __last; ++__first, (void) ++__p)
         traits_type::assign(*__p, *__first);
     traits_type::assign(*__p, value_type());
 }
@@ -2411,7 +2491,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
     if (this != &__str)
     {
         __copy_assign_alloc(__str);
-        assign(__str);
+        assign(__str.data(), __str.size());
     }
     return *this;
 }
@@ -2422,6 +2502,7 @@ template <class _CharT, class _Traits, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 void
 basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
+    _NOEXCEPT_(__alloc_traits::is_always_equal::value)
 {
     if (__alloc() != __str.__alloc())
         assign(__str);
@@ -2433,7 +2514,11 @@ template <class _CharT, class _Traits, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 void
 basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
+#if _LIBCPP_STD_VER > 14
+    _NOEXCEPT
+#else
     _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+#endif
 {
     clear();
     shrink_to_fit();
@@ -2446,8 +2531,7 @@ template <class _CharT, class _Traits, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>&
 basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)
-    _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
-               is_nothrow_move_assignable<allocator_type>::value)
+    _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
 {
     __move_assign(__str, integral_constant<bool,
           __alloc_traits::propagate_on_container_move_assignment::value>());
@@ -2460,15 +2544,14 @@ template <class _CharT, class _Traits, class _Allocator>
 template<class _InputIterator>
 typename enable_if
 <
-     __is_input_iterator  <_InputIterator>::value &&
-    !__is_forward_iterator<_InputIterator>::value,
+     __is_exactly_input_iterator <_InputIterator>::value
+          || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
     basic_string<_CharT, _Traits, _Allocator>&
 >::type
 basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
 {
-    clear();
-    for (; __first != __last; ++__first)
-        push_back(*__first);
+    basic_string __temp(__first, __last, __alloc());
+    assign(__temp.data(), __temp.size());
     return *this;
 }
 
@@ -2476,7 +2559,8 @@ template <class _CharT, class _Traits, class _Allocator>
 template<class _ForwardIterator>
 typename enable_if
 <
-    __is_forward_iterator<_ForwardIterator>::value,
+    __is_forward_iterator<_ForwardIterator>::value
+         && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
     basic_string<_CharT, _Traits, _Allocator>&
 >::type
 basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
@@ -2498,14 +2582,6 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
     return *this;
 }
 
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-basic_string<_CharT, _Traits, _Allocator>&
-basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str)
-{
-    return assign(__str.data(), __str.size());
-}
-
 template <class _CharT, class _Traits, class _Allocator>
 basic_string<_CharT, _Traits, _Allocator>&
 basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
@@ -2609,14 +2685,14 @@ template <class _CharT, class _Traits, class _Allocator>
 template<class _InputIterator>
 typename enable_if
 <
-     __is_input_iterator  <_InputIterator>::value &&
-    !__is_forward_iterator<_InputIterator>::value,
+    __is_exactly_input_iterator<_InputIterator>::value
+             || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
     basic_string<_CharT, _Traits, _Allocator>&
 >::type
 basic_string<_CharT, _Traits, _Allocator>::append(_InputIterator __first, _InputIterator __last)
 {
-    for (; __first != __last; ++__first)
-        push_back(*__first);
+	basic_string __temp (__first, __last, __alloc());
+	append(__temp.data(), __temp.size());
     return *this;
 }
 
@@ -2624,7 +2700,8 @@ template <class _CharT, class _Traits, class _Allocator>
 template<class _ForwardIterator>
 typename enable_if
 <
-    __is_forward_iterator<_ForwardIterator>::value,
+    __is_forward_iterator<_ForwardIterator>::value
+          && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
     basic_string<_CharT, _Traits, _Allocator>&
 >::type
 basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last)
@@ -2740,9 +2817,9 @@ template <class _CharT, class _Traits, class _Allocator>
 template<class _InputIterator>
 typename enable_if
 <
-     __is_input_iterator  <_InputIterator>::value &&
-    !__is_forward_iterator<_InputIterator>::value,
-    typename basic_string<_CharT, _Traits, _Allocator>::iterator
+   __is_exactly_input_iterator<_InputIterator>::value
+        || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
+   typename basic_string<_CharT, _Traits, _Allocator>::iterator
 >::type
 basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)
 {
@@ -2751,24 +2828,16 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt
         "string::insert(iterator, range) called with an iterator not"
         " referring to this string");
 #endif
-    size_type __old_sz = size();
-    difference_type __ip = __pos - begin();
-    for (; __first != __last; ++__first)
-        push_back(*__first);
-    pointer __p = __get_pointer();
-    _VSTD::rotate(__p + __ip, __p + __old_sz, __p + size());
-#if _LIBCPP_DEBUG_LEVEL >= 2
-    return iterator(this, __p + __ip);
-#else
-    return iterator(__p + __ip);
-#endif
+    basic_string __temp(__first, __last, __alloc());
+    return insert(__pos, __temp.data(), __temp.data() + __temp.size());
 }
 
 template <class _CharT, class _Traits, class _Allocator>
 template<class _ForwardIterator>
 typename enable_if
 <
-    __is_forward_iterator<_ForwardIterator>::value,
+    __is_forward_iterator<_ForwardIterator>::value
+        && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
     typename basic_string<_CharT, _Traits, _Allocator>::iterator
 >::type
 basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
@@ -2971,22 +3040,8 @@ typename enable_if
 basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2,
                                                    _InputIterator __j1, _InputIterator __j2)
 {
-    for (; true; ++__i1, ++__j1)
-    {
-        if (__i1 == __i2)
-        {
-            if (__j1 != __j2)
-                insert(__i1, __j1, __j2);
-            break;
-        }
-        if (__j1 == __j2)
-        {
-            erase(__i1, __i2);
-            break;
-        }
-        traits_type::assign(const_cast<value_type&>(*__i1), *__j1);
-    }
-    return *this;
+    basic_string __temp(__j1, __j2, __alloc());
+    return this->replace(__i1, __i2, __temp);
 }
 
 template <class _CharT, class _Traits, class _Allocator>
@@ -3349,8 +3404,12 @@ template <class _CharT, class _Traits, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 void
 basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value)
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value)
+#endif
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
     if (!__is_long())
@@ -3360,7 +3419,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
     __get_db()->swap(this, &__str);
 #endif
     _VSTD::swap(__r_.first(), __str.__r_.first());
-    __swap_alloc(__alloc(), __str.__alloc());
+    __swap_allocator(__alloc(), __str.__alloc());
 }
 
 // find
@@ -3775,7 +3834,11 @@ bool
 operator==(const _CharT* __lhs,
            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
 {
-    return __rhs.compare(__lhs) == 0;
+    typedef basic_string<_CharT, _Traits, _Allocator> _String;
+    _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr");
+    size_t __lhs_len = _Traits::length(__lhs);
+    if (__lhs_len != __rhs.size()) return false;
+    return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;
 }
 
 template<class _CharT, class _Traits, class _Allocator>
@@ -3784,7 +3847,11 @@ bool
 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
            const _CharT* __rhs) _NOEXCEPT
 {
-    return __lhs.compare(__rhs) == 0;
+    typedef basic_string<_CharT, _Traits, _Allocator> _String;
+    _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr");
+    size_t __rhs_len = _Traits::length(__rhs);
+    if (__rhs_len != __lhs.size()) return false;
+    return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;
 }
 
 // operator!=
diff --git a/system/include/libcxx/string.h b/system/include/libcxx/string.h
new file mode 100644
index 0000000000000..a1ce56cbcd6d6
--- /dev/null
+++ b/system/include/libcxx/string.h
@@ -0,0 +1,110 @@
+// -*- C++ -*-
+//===--------------------------- string.h ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_STRING_H
+#define _LIBCPP_STRING_H
+
+/*
+    string.h synopsis
+
+Macros:
+
+    NULL
+
+Types:
+
+    size_t
+
+void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
+void* memmove(void* s1, const void* s2, size_t n);
+char* strcpy (char* restrict s1, const char* restrict s2);
+char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
+char* strcat (char* restrict s1, const char* restrict s2);
+char* strncat(char* restrict s1, const char* restrict s2, size_t n);
+int memcmp(const void* s1, const void* s2, size_t n);
+int strcmp (const char* s1, const char* s2);
+int strncmp(const char* s1, const char* s2, size_t n);
+int strcoll(const char* s1, const char* s2);
+size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
+const void* memchr(const void* s, int c, size_t n);
+      void* memchr(      void* s, int c, size_t n);
+const char* strchr(const char* s, int c);
+      char* strchr(      char* s, int c);
+size_t strcspn(const char* s1, const char* s2);
+const char* strpbrk(const char* s1, const char* s2);
+      char* strpbrk(      char* s1, const char* s2);
+const char* strrchr(const char* s, int c);
+      char* strrchr(      char* s, int c);
+size_t strspn(const char* s1, const char* s2);
+const char* strstr(const char* s1, const char* s2);
+      char* strstr(      char* s1, const char* s2);
+char* strtok(char* restrict s1, const char* restrict s2);
+void* memset(void* s, int c, size_t n);
+char* strerror(int errnum);
+size_t strlen(const char* s);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <string.h>
+
+// MSVCRT, GNU libc and its derivates may already have the correct prototype in
+// <string.h>. This macro can be defined by users if their C library provides
+// the right signature.
+#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \
+    defined(__sun__) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
+#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
+#endif
+
+#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
+extern "C++" {
+inline _LIBCPP_INLINE_VISIBILITY
+char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      char* strchr(      char* __s, int __c) {return __libcpp_strchr(__s, __c);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const char* strpbrk(const char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      char* strpbrk(      char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const char* strrchr(const char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      char* strrchr(      char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      void* memchr(      void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const char* strstr(const char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      char* strstr(      char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
+}
+#endif
+
+#endif  // _LIBCPP_STRING_H
diff --git a/system/include/libcxx/support/ibm/locale_mgmt_aix.h b/system/include/libcxx/support/ibm/locale_mgmt_aix.h
new file mode 100644
index 0000000000000..e3b7a78c45a0f
--- /dev/null
+++ b/system/include/libcxx/support/ibm/locale_mgmt_aix.h
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+//===------------------- support/ibm/locale_mgmt_aix.h --------------------===//
+//
+//                     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_SUPPORT_IBM_LOCALE_MGMT_AIX_H
+#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H
+
+#if defined(_AIX)
+#include "cstdlib"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_AIX71)
+// AIX 7.1 and higher has these definitions.  Definitions and stubs
+// are provied here as a temporary workaround on AIX 6.1.
+
+#define LC_COLLATE_MASK         1
+#define LC_CTYPE_MASK           2
+#define LC_MESSAGES_MASK        4
+#define LC_MONETARY_MASK        8
+#define LC_NUMERIC_MASK         16
+#define LC_TIME_MASK            32
+#define LC_ALL_MASK             (LC_COLLATE_MASK | LC_CTYPE_MASK | \
+                                 LC_MESSAGES_MASK | LC_MONETARY_MASK |\
+                                 LC_NUMERIC_MASK | LC_TIME_MASK)
+
+typedef void* locale_t;
+
+// The following are stubs.  They are not supported on AIX 6.1.
+static inline
+locale_t newlocale(int category_mask, const char *locale, locale_t base)
+{
+  _LC_locale_t *newloc, *loc;
+  if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL)
+  {
+    errno = EINVAL;
+    return (locale_t)0;
+  }
+  if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL)
+  {
+    errno = ENOMEM;
+    return (locale_t)0;
+  }
+  if (!base)
+    base = (_LC_locale_t *)__xopen_locale("C");
+  memcpy(newloc, base, sizeof (_LC_locale_t));
+  if (category_mask & LC_COLLATE_MASK)
+    newloc->lc_collate = loc->lc_collate;
+  if (category_mask & LC_CTYPE_MASK)
+    newloc->lc_ctype = loc->lc_ctype;
+  //if (category_mask & LC_MESSAGES_MASK)
+  //  newloc->lc_messages = loc->lc_messages;
+  if (category_mask & LC_MONETARY_MASK)
+    newloc->lc_monetary = loc->lc_monetary;
+  if (category_mask & LC_TIME_MASK)
+    newloc->lc_time = loc->lc_time;
+  if (category_mask & LC_NUMERIC_MASK)
+    newloc->lc_numeric = loc->lc_numeric;
+  return (locale_t)newloc;
+}
+static inline
+void freelocale(locale_t locobj)
+{
+  free(locobj);
+}
+static inline
+locale_t uselocale(locale_t newloc)
+{
+  return (locale_t)0;
+}
+#endif // !defined(_AIX71)
+
+#ifdef __cplusplus
+}
+#endif
+#endif // defined(_AIX)
+#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H
diff --git a/system/include/libcxx/support/ibm/xlocale.h b/system/include/libcxx/support/ibm/xlocale.h
index 8d99a5c7d34d5..f39c0ba95d901 100644
--- a/system/include/libcxx/support/ibm/xlocale.h
+++ b/system/include/libcxx/support/ibm/xlocale.h
@@ -10,6 +10,7 @@
 
 #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
 #define _LIBCPP_SUPPORT_IBM_XLOCALE_H
+#include <support/ibm/locale_mgmt_aix.h>
 
 #if defined(_AIX)
 #include "cstdlib"
@@ -21,62 +22,6 @@ extern "C" {
 #if !defined(_AIX71)
 // AIX 7.1 and higher has these definitions.  Definitions and stubs
 // are provied here as a temporary workaround on AIX 6.1.
-
-#define LC_COLLATE_MASK         1
-#define LC_CTYPE_MASK           2
-#define LC_MESSAGES_MASK        4
-#define LC_MONETARY_MASK        8
-#define LC_NUMERIC_MASK         16
-#define LC_TIME_MASK            32
-#define LC_ALL_MASK             (LC_COLLATE_MASK | LC_CTYPE_MASK | \
-                                 LC_MESSAGES_MASK | LC_MONETARY_MASK |\
-                                 LC_NUMERIC_MASK | LC_TIME_MASK)
-
-typedef void* locale_t;
-
-// The following are stubs.  They are not supported on AIX 6.1.
-static inline
-locale_t newlocale(int category_mask, const char *locale, locale_t base)
-{
-  _LC_locale_t *newloc, *loc;
-  if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL)
-  {
-    errno = EINVAL;
-    return (locale_t)0;
-  }
-  if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL)
-  {
-    errno = ENOMEM;
-    return (locale_t)0;
-  }
-  if (!base)
-    base = (_LC_locale_t *)__xopen_locale("C");
-  memcpy(newloc, base, sizeof (_LC_locale_t));
-  if (category_mask & LC_COLLATE_MASK) 
-    newloc->lc_collate = loc->lc_collate;
-  if (category_mask & LC_CTYPE_MASK)
-    newloc->lc_ctype = loc->lc_ctype;
-  //if (category_mask & LC_MESSAGES_MASK)
-  //  newloc->lc_messages = loc->lc_messages;
-  if (category_mask & LC_MONETARY_MASK)
-    newloc->lc_monetary = loc->lc_monetary;
-  if (category_mask & LC_TIME_MASK)
-    newloc->lc_time = loc->lc_time;
-  if (category_mask & LC_NUMERIC_MASK)
-    newloc->lc_numeric = loc->lc_numeric;
-  return (locale_t)newloc; 
-}
-static inline
-void freelocale(locale_t locobj)
-{
-  free(locobj);
-}
-static inline
-locale_t uselocale(locale_t newloc)
-{
-  return (locale_t)0;
-}
-
 static inline
 int isalnum_l(int c, locale_t locale)
 {
diff --git a/system/include/libcxx/support/musl/xlocale.h b/system/include/libcxx/support/musl/xlocale.h
new file mode 100644
index 0000000000000..3e31c99596ce9
--- /dev/null
+++ b/system/include/libcxx/support/musl/xlocale.h
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+//===------------------- support/musl/xlocale.h ------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+// This adds support for the extended locale functions that are currently
+// missing from the Musl C library.
+//
+// This only works when the specified locale is "C" or "POSIX", but that's
+// about as good as we can do without implementing full xlocale support
+// in Musl.
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_MUSL_XLOCALE_H
+#define _LIBCPP_SUPPORT_MUSL_XLOCALE_H
+
+#include <cstdlib>
+#include <cwchar>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline long long strtoll_l(const char *nptr, char **endptr, int base,
+                                  locale_t) {
+  return strtoll(nptr, endptr, base);
+}
+
+static inline unsigned long long strtoull_l(const char *nptr, char **endptr,
+                                            int base, locale_t) {
+  return strtoull(nptr, endptr, base);
+}
+
+static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr,
+                                  int base, locale_t) {
+  return wcstoll(nptr, endptr, base);
+}
+
+static inline unsigned long long wcstoull_l(const wchar_t *nptr,
+                                            wchar_t **endptr, int base,
+                                            locale_t) {
+  return wcstoull(nptr, endptr, base);
+}
+
+static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr,
+                                    locale_t) {
+  return wcstold(nptr, endptr);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LIBCPP_SUPPORT_MUSL_XLOCALE_H
diff --git a/system/include/libcxx/support/newlib/xlocale.h b/system/include/libcxx/support/newlib/xlocale.h
index d067cf85a3bcb..f729ee5f071b3 100644
--- a/system/include/libcxx/support/newlib/xlocale.h
+++ b/system/include/libcxx/support/newlib/xlocale.h
@@ -16,41 +16,12 @@
 #include <clocale>
 #include <cwctype>
 #include <ctype.h>
+#include <support/xlocale/__nop_locale_mgmt.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// Patch over newlib's lack of extended locale support
-typedef void *locale_t;
-static inline locale_t duplocale(locale_t) {
-  return NULL;
-}
-
-static inline void freelocale(locale_t) {
-}
-
-static inline locale_t newlocale(int, const char *, locale_t) {
-  return NULL;
-}
-
-static inline locale_t uselocale(locale_t) {
-  return NULL;
-}
-
-#define LC_COLLATE_MASK  (1 << LC_COLLATE)
-#define LC_CTYPE_MASK    (1 << LC_CTYPE)
-#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
-#define LC_MONETARY_MASK (1 << LC_MONETARY)
-#define LC_NUMERIC_MASK  (1 << LC_NUMERIC)
-#define LC_TIME_MASK     (1 << LC_TIME)
-#define LC_ALL_MASK (LC_COLLATE_MASK|\
-                     LC_CTYPE_MASK|\
-                     LC_MONETARY_MASK|\
-                     LC_NUMERIC_MASK|\
-                     LC_TIME_MASK|\
-                     LC_MESSAGES_MASK)
-
 // Share implementation with Android's Bionic
 #include <support/xlocale/xlocale.h>
 
diff --git a/system/include/libcxx/support/solaris/xlocale.h b/system/include/libcxx/support/solaris/xlocale.h
index 875a39add760f..62b0d74a6d23f 100644
--- a/system/include/libcxx/support/solaris/xlocale.h
+++ b/system/include/libcxx/support/solaris/xlocale.h
@@ -14,112 +14,23 @@
 #ifndef __XLOCALE_H_INCLUDED
 #define __XLOCALE_H_INCLUDED
 
+#include <stdlib.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
-typedef struct _LC_locale_t* locale_t;
-
-#define LC_COLLATE_MASK  (1<<0)
-#define LC_CTYPE_MASK    (1<<1)
-#define LC_MESSAGES_MASK (1<<2)
-#define LC_MONETARY_MASK (1<<3)
-#define LC_NUMERIC_MASK  (1<<4)
-#define LC_TIME_MASK     (1<<5)
-#define LC_ALL_MASK      (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | \
-                LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
-
-#define LC_GLOBAL_LOCALE ((locale_t)-1)
-
-size_t __mb_cur_max(locale_t l);
-#define MB_CUR_MAX_L(l) __mb_cur_max(l) 
-
-locale_t newlocale(int mask, const char * locale, locale_t base);
-void freelocale(locale_t loc);
-
-wint_t btowc_l(int __c, locale_t __l);
-
-int wctob_l(wint_t __c, locale_t __l);
-
-size_t wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l);
-
-size_t mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
-                 mbstate_t *__ps, locale_t __l);
-
-int mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l);
-
-size_t mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l);
-
-struct lconv *localeconv_l(locale_t __l);
-
-size_t mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
-                   mbstate_t *__ps, locale_t __l);
-
-int sprintf_l(char *__s, locale_t __l, const char *__format, ...);
-
 int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...);
-
 int asprintf_l(char **__s, locale_t __l, const char *__format, ...);
 
 int sscanf_l(const char *__s, locale_t __l, const char *__format, ...);
 
-int isalnum_l(int,locale_t);
-int isalpha_l(int,locale_t);
-int isblank_l(int,locale_t);
-int iscntrl_l(int,locale_t);
-int isdigit_l(int,locale_t);
-int isgraph_l(int,locale_t);
-int islower_l(int,locale_t);
-int isprint_l(int,locale_t);
-int ispunct_l(int,locale_t);
-int isspace_l(int,locale_t);
-int isupper_l(int,locale_t);
-int isxdigit_l(int,locale_t);
-
-int iswalnum_l(wchar_t,locale_t);
-int iswalpha_l(wchar_t,locale_t);
-int iswblank_l(wchar_t,locale_t);
-int iswcntrl_l(wchar_t,locale_t);
-int iswdigit_l(wchar_t,locale_t);
-int iswgraph_l(wchar_t,locale_t);
-int iswlower_l(wchar_t,locale_t);
-int iswprint_l(wchar_t,locale_t);
-int iswpunct_l(wchar_t,locale_t);
-int iswspace_l(wchar_t,locale_t);
-int iswupper_l(wchar_t,locale_t);
-int iswxdigit_l(wchar_t,locale_t);
-
-int iswctype_l(wint_t, wctype_t, locale_t);
-
 int toupper_l(int __c, locale_t __l);
 int tolower_l(int __c, locale_t __l);
-wint_t towupper_l(wint_t __c, locale_t __l);
-wint_t towlower_l(wint_t __c, locale_t __l);
-
-
-int strcoll_l(const char *__s1, const char *__s2, locale_t __l);
-int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t __l);
-size_t strftime_l(char *__s, size_t __size, const char *__fmt, const struct tm
-    *__tm, locale_t __l);
-
-size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t __l);
-
-size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n,
-    locale_t __l);
 
-
-
-size_t
-mbsnrtowcs_l(wchar_t * __restrict dst, const char ** __restrict src,
-    size_t nms, size_t len, mbstate_t * __restrict ps, locale_t loc);
-
-
-size_t
-wcsnrtombs_l(char * __restrict dst, const wchar_t ** __restrict src,
-    size_t nwc, size_t len, mbstate_t * __restrict ps, locale_t loc);
-
-locale_t __cloc(void);
+struct lconv *localeconv(void);
+struct lconv *localeconv_l(locale_t __l);
 
 // FIXME: These are quick-and-dirty hacks to make things pretend to work
 static inline
@@ -148,6 +59,7 @@ unsigned long strtoul_l(const char *__nptr, char **__endptr,
   return strtoul(__nptr, __endptr, __base);
 }
 
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/system/include/libcxx/support/win32/locale_mgmt_win32.h b/system/include/libcxx/support/win32/locale_mgmt_win32.h
new file mode 100644
index 0000000000000..b3316d62596f4
--- /dev/null
+++ b/system/include/libcxx/support/win32/locale_mgmt_win32.h
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//===----------------- support/win32/locale_mgmt_win32.h ------------------===//
+//
+//                     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_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
+
+#include <xlocinfo.h> // _locale_t
+#define locale_t _locale_t
+#define LC_COLLATE_MASK _M_COLLATE
+#define LC_CTYPE_MASK _M_CTYPE
+#define LC_MONETARY_MASK _M_MONETARY
+#define LC_NUMERIC_MASK _M_NUMERIC
+#define LC_TIME_MASK _M_TIME
+#define LC_MESSAGES_MASK _M_MESSAGES
+#define LC_ALL_MASK (  LC_COLLATE_MASK \
+                     | LC_CTYPE_MASK \
+                     | LC_MESSAGES_MASK \
+                     | LC_MONETARY_MASK \
+                     | LC_NUMERIC_MASK \
+                     | LC_TIME_MASK )
+#define freelocale _free_locale
+// FIXME: base currently unused. Needs manual work to construct the new locale
+locale_t newlocale( int mask, const char * locale, locale_t base );
+locale_t uselocale( locale_t newloc );
+
+#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
diff --git a/system/include/libcxx/support/win32/locale_win32.h b/system/include/libcxx/support/win32/locale_win32.h
index f728d234472f9..7f3710ecc1881 100644
--- a/system/include/libcxx/support/win32/locale_win32.h
+++ b/system/include/libcxx/support/win32/locale_win32.h
@@ -15,26 +15,10 @@
 extern "C" unsigned short  __declspec(dllimport) _ctype[];
 
 #include "support/win32/support.h"
+#include "support/win32/locale_mgmt_win32.h"
 #include <stdio.h>
 #include <memory>
-#include <xlocinfo.h> // _locale_t
-#define locale_t _locale_t
-#define LC_COLLATE_MASK _M_COLLATE
-#define LC_CTYPE_MASK _M_CTYPE
-#define LC_MONETARY_MASK _M_MONETARY
-#define LC_NUMERIC_MASK _M_NUMERIC
-#define LC_TIME_MASK _M_TIME
-#define LC_MESSAGES_MASK _M_MESSAGES
-#define LC_ALL_MASK (  LC_COLLATE_MASK \
-                     | LC_CTYPE_MASK \
-                     | LC_MESSAGES_MASK \
-                     | LC_MONETARY_MASK \
-                     | LC_NUMERIC_MASK \
-                     | LC_TIME_MASK )
-#define freelocale _free_locale
-// FIXME: base currently unused. Needs manual work to construct the new locale
-locale_t newlocale( int mask, const char * locale, locale_t base );
-locale_t uselocale( locale_t newloc );
+
 lconv *localeconv_l( locale_t loc );
 size_t mbrlen_l( const char *__restrict s, size_t n,
                  mbstate_t *__restrict ps, locale_t loc);
diff --git a/system/include/libcxx/support/win32/math_win32.h b/system/include/libcxx/support/win32/math_win32.h
index c62c54e3cd850..0d6b422a165cf 100644
--- a/system/include/libcxx/support/win32/math_win32.h
+++ b/system/include/libcxx/support/win32/math_win32.h
@@ -17,7 +17,9 @@
 
 #include <math.h>
 #include <float.h> // _FPCLASS_PN etc.
+#include <crtversion.h>
 
+#if ((_VC_CRT_MAJOR_VERSION-0) < 12)
 // Necessary?
 typedef float float_t;
 typedef double double_t;
@@ -109,7 +111,7 @@ _LIBCPP_ALWAYS_INLINE int fpclassify( double num )
 {
     return _fpclass(num);
 }
-
+#endif
 #endif // _LIBCPP_MSVCRT
 
 #endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
diff --git a/system/include/libcxx/support/win32/support.h b/system/include/libcxx/support/win32/support.h
index bc96587f58c41..5765babcd13b5 100644
--- a/system/include/libcxx/support/win32/support.h
+++ b/system/include/libcxx/support/win32/support.h
@@ -31,6 +31,8 @@
 #define NOMINMAX
 #endif
 
+// The mingw headers already define these as static.
+#ifndef __MINGW32__
 extern "C" {
 
 int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
@@ -40,6 +42,7 @@ size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
 size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
                   size_t nwc, size_t len, mbstate_t *__restrict ps);
 }
+#endif // __MINGW32__
 
 #if defined(_LIBCPP_MSVCRT)
 #define snprintf _snprintf
diff --git a/system/include/libcxx/support/xlocale/__nop_locale_mgmt.h b/system/include/libcxx/support/xlocale/__nop_locale_mgmt.h
new file mode 100644
index 0000000000000..0d3f23a2c9698
--- /dev/null
+++ b/system/include/libcxx/support/xlocale/__nop_locale_mgmt.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===------------  support/xlocale/__nop_locale_mgmt.h -----------------===//
+//
+//                     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_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
+#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Patch over lack of extended locale support
+typedef void *locale_t;
+static inline locale_t duplocale(locale_t) {
+  return NULL;
+}
+
+static inline void freelocale(locale_t) {
+}
+
+static inline locale_t newlocale(int, const char *, locale_t) {
+  return NULL;
+}
+
+static inline locale_t uselocale(locale_t) {
+  return NULL;
+}
+
+#define LC_COLLATE_MASK  (1 << LC_COLLATE)
+#define LC_CTYPE_MASK    (1 << LC_CTYPE)
+#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
+#define LC_MONETARY_MASK (1 << LC_MONETARY)
+#define LC_NUMERIC_MASK  (1 << LC_NUMERIC)
+#define LC_TIME_MASK     (1 << LC_TIME)
+#define LC_ALL_MASK (LC_COLLATE_MASK|\
+                     LC_CTYPE_MASK|\
+                     LC_MONETARY_MASK|\
+                     LC_NUMERIC_MASK|\
+                     LC_TIME_MASK|\
+                     LC_MESSAGES_MASK)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
diff --git a/system/include/libcxx/system_error b/system/include/libcxx/system_error
index 66bf6d6c42495..134bb32740317 100644
--- a/system/include/libcxx/system_error
+++ b/system/include/libcxx/system_error
@@ -371,7 +371,7 @@ public:
     error_category() _NOEXCEPT;
 #else
     _LIBCPP_ALWAYS_INLINE
-    _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT
 #endif
 private:
     error_category(const error_category&);// = delete;
diff --git a/system/include/libcxx/thread b/system/include/libcxx/thread
index 808d76b82a093..bf5b8e84d3524 100644
--- a/system/include/libcxx/thread
+++ b/system/include/libcxx/thread
@@ -99,6 +99,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
 #include <tuple>
 #endif
 #include <pthread.h>
+#include <sched.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -112,11 +113,38 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+template <class _Tp> class __thread_specific_ptr;
+class _LIBCPP_TYPE_VIS __thread_struct;
+class _LIBCPP_HIDDEN __thread_struct_imp;
+class __assoc_sub_state;
+
+_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data();
+
+class _LIBCPP_TYPE_VIS __thread_struct
+{
+    __thread_struct_imp* __p_;
+
+    __thread_struct(const __thread_struct&);
+    __thread_struct& operator=(const __thread_struct&);
+public:
+    __thread_struct();
+    ~__thread_struct();
+
+    void notify_all_at_thread_exit(condition_variable*, mutex*);
+    void __make_ready_at_thread_exit(__assoc_sub_state*);
+};
+
 template <class _Tp>
 class __thread_specific_ptr
 {
     pthread_key_t __key_;
 
+     // Only __thread_local_data() may construct a __thread_specific_ptr
+     // and only with _Tp == __thread_struct.
+    static_assert((is_same<_Tp, __thread_struct>::value), "");
+    __thread_specific_ptr();
+    friend _LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data();
+
     __thread_specific_ptr(const __thread_specific_ptr&);
     __thread_specific_ptr& operator=(const __thread_specific_ptr&);
 
@@ -124,7 +152,6 @@ class __thread_specific_ptr
 public:
     typedef _Tp* pointer;
 
-    __thread_specific_ptr();
     ~__thread_specific_ptr();
 
     _LIBCPP_INLINE_VISIBILITY
@@ -158,7 +185,10 @@ __thread_specific_ptr<_Tp>::__thread_specific_ptr()
 template <class _Tp>
 __thread_specific_ptr<_Tp>::~__thread_specific_ptr()
 {
-    pthread_key_delete(__key_);
+    // __thread_specific_ptr is only created with a static storage duration
+    // so this destructor is only invoked during program termination. Invoking
+    // pthread_key_delete(__key_) may prevent other threads from deleting their
+    // thread local data. For this reason we leak the key.
 }
 
 template <class _Tp>
@@ -189,7 +219,7 @@ _LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT;
 
 }  // this_thread
 
-template<> struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>;
+template<> struct hash<__thread_id>;
 
 class _LIBCPP_TYPE_VIS_ONLY __thread_id
 {
@@ -288,6 +318,7 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {__t.__t_ = 0;}
+    _LIBCPP_INLINE_VISIBILITY
     thread& operator=(thread&& __t) _NOEXCEPT;
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
@@ -306,43 +337,23 @@ public:
     static unsigned hardware_concurrency() _NOEXCEPT;
 };
 
-class __assoc_sub_state;
-
-class _LIBCPP_HIDDEN __thread_struct_imp;
-
-class _LIBCPP_TYPE_VIS __thread_struct
-{
-    __thread_struct_imp* __p_;
-
-    __thread_struct(const __thread_struct&);
-    __thread_struct& operator=(const __thread_struct&);
-public:
-    __thread_struct();
-    ~__thread_struct();
-
-    void notify_all_at_thread_exit(condition_variable*, mutex*);
-    void __make_ready_at_thread_exit(__assoc_sub_state*);
-};
-
-_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data();
-
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
-template <class _Fp, class ..._Args, size_t ..._Indices>
+template <class _TSp, class _Fp, class ..._Args, size_t ..._Indices>
 inline _LIBCPP_INLINE_VISIBILITY
 void
-__thread_execute(tuple<_Fp, _Args...>& __t, __tuple_indices<_Indices...>)
+__thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
 {
-    __invoke(_VSTD::move(_VSTD::get<0>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
+    __invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
 }
 
 template <class _Fp>
-void*
-__thread_proxy(void* __vp)
+void* __thread_proxy(void* __vp)
 {
-    __thread_local_data().reset(new __thread_struct);
+    // _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>
     std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
-    typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index;
+    __thread_local_data().reset(_VSTD::get<0>(*__p).release());
+    typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index;
     __thread_execute(*__p, _Index());
     return nullptr;
 }
@@ -352,9 +363,13 @@ template <class _Fp, class ..._Args,
          >
 thread::thread(_Fp&& __f, _Args&&... __args)
 {
-    typedef tuple<typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;
-    _VSTD::unique_ptr<_Gp> __p(new _Gp(__decay_copy(_VSTD::forward<_Fp>(__f)),
-                                __decay_copy(_VSTD::forward<_Args>(__args))...));
+    typedef unique_ptr<__thread_struct> _TSPtr;
+    _TSPtr __tsp(new __thread_struct);
+    typedef tuple<_TSPtr, typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;
+    _VSTD::unique_ptr<_Gp> __p(
+            new _Gp(std::move(__tsp),
+                    __decay_copy(_VSTD::forward<_Fp>(__f)),
+                    __decay_copy(_VSTD::forward<_Args>(__args))...));
     int __ec = pthread_create(&__t_, 0, &__thread_proxy<_Gp>, __p.get());
     if (__ec == 0)
         __p.release();
@@ -365,22 +380,34 @@ thread::thread(_Fp&& __f, _Args&&... __args)
 #else  // _LIBCPP_HAS_NO_VARIADICS
 
 template <class _Fp>
-void*
-__thread_proxy(void* __vp)
+struct __thread_invoke_pair {
+    // This type is used to pass memory for thread local storage and a functor
+    // to a newly created thread because std::pair doesn't work with
+    // std::unique_ptr in C++03.
+    __thread_invoke_pair(_Fp& __f) : __tsp_(new __thread_struct), __fn_(__f) {}
+    unique_ptr<__thread_struct> __tsp_;
+    _Fp __fn_;
+};
+
+template <class _Fp>
+void* __thread_proxy_cxx03(void* __vp)
 {
-    __thread_local_data().reset(new __thread_struct);
     std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
-    (*__p)();
+    __thread_local_data().reset(__p->__tsp_.release());
+    (__p->__fn_)();
     return nullptr;
 }
 
 template <class _Fp>
 thread::thread(_Fp __f)
 {
-    std::unique_ptr<_Fp> __p(new _Fp(__f));
-    int __ec = pthread_create(&__t_, 0, &__thread_proxy<_Fp>, __p.get());
+
+    typedef __thread_invoke_pair<_Fp> _InvokePair;
+    typedef std::unique_ptr<_InvokePair> _PairPtr;
+    _PairPtr __pp(new _InvokePair(__f));
+    int __ec = pthread_create(&__t_, 0, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
     if (__ec == 0)
-        __p.release();
+        __pp.release();
     else
         __throw_system_error(__ec, "thread constructor failed");
 }
@@ -389,7 +416,7 @@ thread::thread(_Fp __f)
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 thread&
 thread::operator=(thread&& __t) _NOEXCEPT
 {
diff --git a/system/include/libcxx/tuple b/system/include/libcxx/tuple
index 1463170fe1c70..73f42a0403ca0 100644
--- a/system/include/libcxx/tuple
+++ b/system/include/libcxx/tuple
@@ -80,28 +80,33 @@ template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // cons
 // 20.4.1.4, tuple helper classes:
 template <class T> class tuple_size; // undefined
 template <class... T> class tuple_size<tuple<T...>>;
-template <intsize_t I, class T> class tuple_element; // undefined
-template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
-template <size_t _Ip, class ..._Tp>
-  using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14
+template <size_t I, class T> class tuple_element; // undefined
+template <size_t I, class... T> class tuple_element<I, tuple<T...>>;
+template <size_t I, class T>
+  using tuple_element_t = typename tuple_element <I, T>::type; // C++14
 
 // 20.4.1.5, element access:
-template <intsize_t I, class... T>
+template <size_t I, class... T>
     typename tuple_element<I, tuple<T...>>::type&
     get(tuple<T...>&) noexcept; // constexpr in C++14
-template <intsize_t I, class... T>
-    typename const tuple_element<I, tuple<T...>>::type &
+template <size_t I, class... T>
+    const typename tuple_element<I, tuple<T...>>::type&
     get(const tuple<T...>&) noexcept; // constexpr in C++14
-template <intsize_t I, class... T>
+template <size_t I, class... T>
     typename tuple_element<I, tuple<T...>>::type&&
     get(tuple<T...>&&) noexcept; // constexpr in C++14
+template <size_t I, class... T>
+    const typename tuple_element<I, tuple<T...>>::type&&
+    get(const tuple<T...>&&) noexcept; // constexpr in C++14
 
 template <class T1, class... T>
     constexpr T1& get(tuple<T...>&) noexcept;  // C++14
 template <class T1, class... T>
-    constexpr T1 const& get(const tuple<T...>&) noexcept;   // C++14
+    constexpr const T1& get(const tuple<T...>&) noexcept;   // C++14
 template <class T1, class... T>
     constexpr T1&& get(tuple<T...>&&) noexcept;   // C++14
+template <class T1, class... T>
+    constexpr const T1&& get(const tuple<T...>&&) noexcept;   // C++14
 
 // 20.4.1.6, relational operators:
 template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
@@ -161,10 +166,8 @@ using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
 
 // __tuple_leaf
 
-template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
-#if __has_feature(is_final)
-                                 && !__is_final(_Hp)
-#endif
+template <size_t _Ip, class _Hp,
+          bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
          >
 class __tuple_leaf;
 
@@ -376,19 +379,21 @@ template <class ..._Tp>
 _LIBCPP_INLINE_VISIBILITY
 void __swallow(_Tp&&...) _NOEXCEPT {}
 
-template <bool ...> struct __all;
+template <bool ..._Pred>
+struct __all
+    : is_same<__all<_Pred...>, __all<(_Pred, true)...>>
+{ };
 
-template <>
-struct __all<>
-{
-    static const bool value = true;
-};
+template <class ..._Tp>
+struct __lazy_all : __all<_Tp::value...> {};
 
-template <bool _B0, bool ... _Bp>
-struct __all<_B0, _Bp...>
-{
-    static const bool value = _B0 && __all<_Bp...>::value;
-};
+template <class _Tp>
+struct __all_default_constructible;
+
+template <class ..._Tp>
+struct __all_default_constructible<__tuple_types<_Tp...>>
+    : __all<is_default_constructible<_Tp>::value...>
+{ };
 
 // __tuple_impl
 
@@ -444,7 +449,7 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
     template <class _Alloc, class _Tuple,
               class = typename enable_if
                       <
-                         __tuple_convertible<_Tuple, tuple<_Tp...> >::value
+                         __tuple_constructible<_Tuple, tuple<_Tp...> >::value
                       >::type
              >
         _LIBCPP_INLINE_VISIBILITY
@@ -497,6 +502,28 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
     }
 };
 
+template <bool _IsTuple, class _SizeTrait, size_t _Expected>
+struct __tuple_like_with_size_imp : false_type {};
+
+template <class _SizeTrait, size_t _Expected>
+struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
+    : integral_constant<bool, _SizeTrait::value == _Expected> {};
+
+template <class _Tuple, size_t _ExpectedSize,
+          class _RawTuple = typename __uncvref<_Tuple>::type>
+using __tuple_like_with_size = __tuple_like_with_size_imp<
+                                   __tuple_like<_RawTuple>::value,
+                                   tuple_size<_RawTuple>, _ExpectedSize
+                              >;
+
+
+struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
+    template <class ...>
+    static constexpr bool __enable_explicit() { return false; }
+    template <class ...>
+    static constexpr bool __enable_implicit() { return false; }
+};
+
 template <class ..._Tp>
 class _LIBCPP_TYPE_VIS_ONLY tuple
 {
@@ -504,20 +531,159 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
 
     base base_;
 
+    template <class ..._Args>
+    struct _PackExpandsToThisTuple : false_type {};
+
+    template <class _Arg>
+    struct _PackExpandsToThisTuple<_Arg>
+        : is_same<typename __uncvref<_Arg>::type, tuple> {};
+
+    template <bool _MaybeEnable, class _Dummy = void>
+    struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
+
+    template <class _Dummy>
+    struct _CheckArgsConstructor<true, _Dummy>
+    {
+        template <class ..._Args>
+        static constexpr bool __enable_explicit() {
+            return
+                __tuple_constructible<
+                    tuple<_Args...>,
+                    typename __make_tuple_types<tuple,
+                             sizeof...(_Args) < sizeof...(_Tp) ?
+                                 sizeof...(_Args) :
+                                 sizeof...(_Tp)>::type
+                >::value &&
+                !__tuple_convertible<
+                    tuple<_Args...>,
+                    typename __make_tuple_types<tuple,
+                             sizeof...(_Args) < sizeof...(_Tp) ?
+                                 sizeof...(_Args) :
+                                 sizeof...(_Tp)>::type
+                >::value &&
+                __all_default_constructible<
+                    typename __make_tuple_types<tuple, sizeof...(_Tp),
+                             sizeof...(_Args) < sizeof...(_Tp) ?
+                                 sizeof...(_Args) :
+                                 sizeof...(_Tp)>::type
+                >::value;
+        }
+
+        template <class ..._Args>
+        static constexpr bool __enable_implicit() {
+            return
+                __tuple_convertible<
+                    tuple<_Args...>,
+                    typename __make_tuple_types<tuple,
+                             sizeof...(_Args) < sizeof...(_Tp) ?
+                                 sizeof...(_Args) :
+                                 sizeof...(_Tp)>::type
+                >::value &&
+                __all_default_constructible<
+                    typename __make_tuple_types<tuple, sizeof...(_Tp),
+                             sizeof...(_Args) < sizeof...(_Tp) ?
+                                 sizeof...(_Args) :
+                                 sizeof...(_Tp)>::type
+                >::value;
+        }
+    };
+
+    template <bool _MaybeEnable,
+              bool = sizeof...(_Tp) == 1,
+              class _Dummy = void>
+    struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
+
+    template <class _Dummy>
+    struct _CheckTupleLikeConstructor<true, false, _Dummy>
+    {
+        template <class _Tuple>
+        static constexpr bool __enable_implicit() {
+            return __tuple_convertible<_Tuple, tuple>::value;
+        }
+
+        template <class _Tuple>
+        static constexpr bool __enable_explicit() {
+            return __tuple_constructible<_Tuple, tuple>::value
+               && !__tuple_convertible<_Tuple, tuple>::value;
+        }
+    };
+
+    template <class _Dummy>
+    struct _CheckTupleLikeConstructor<true, true, _Dummy>
+    {
+        // This trait is used to disable the tuple-like constructor when
+        // the UTypes... constructor should be selected instead.
+        // See LWG issue #2549.
+        template <class _Tuple>
+        using _PreferTupleLikeConstructor = __lazy_or<
+            // Don't attempt the two checks below if the tuple we are given
+            // has the same type as this tuple.
+            is_same<typename __uncvref<_Tuple>::type, tuple>,
+            __lazy_and<
+                __lazy_not<is_constructible<_Tp..., _Tuple>>,
+                __lazy_not<is_convertible<_Tuple, _Tp...>>
+            >
+        >;
+
+        template <class _Tuple>
+        static constexpr bool __enable_implicit() {
+            return __lazy_and<
+                __tuple_convertible<_Tuple, tuple>,
+                _PreferTupleLikeConstructor<_Tuple>
+            >::value;
+        }
+
+        template <class _Tuple>
+        static constexpr bool __enable_explicit() {
+            return __lazy_and<
+                __tuple_constructible<_Tuple, tuple>,
+                _PreferTupleLikeConstructor<_Tuple>,
+                __lazy_not<__tuple_convertible<_Tuple, tuple>>
+            >::value;
+        }
+    };
+
     template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
         typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
     template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
         const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
     template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
         typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
+    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
+        const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
 public:
 
+    template <bool _Dummy = true, class = typename enable_if<
+        __all<__dependent_type<is_default_constructible<_Tp>, _Dummy>::value...>::value
+    >::type>
     _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR tuple()
         _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
 
+    template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
+        __lazy_and<
+            is_base_of<allocator_arg_t, _AllocArgT>,
+            __lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
+       >::value
+    >::type>
+    _LIBCPP_INLINE_VISIBILITY
+    tuple(_AllocArgT, _Alloc const& __a)
+      : base_(allocator_arg_t(), __a,
+                    __tuple_indices<>(), __tuple_types<>(),
+                    typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
+                    __tuple_types<_Tp...>()) {}
+
+    template <bool _Dummy = true,
+              typename enable_if
+                      <
+                         _CheckArgsConstructor<
+                            _Dummy
+                         >::template __enable_implicit<_Tp...>(),
+                         bool
+                      >::type = false
+        >
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-    explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value)) 
+    tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
         : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
                 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
                 typename __make_tuple_indices<0>::type(),
@@ -525,7 +691,33 @@ public:
                 __t...
                ) {}
 
-    template <class _Alloc>
+    template <bool _Dummy = true,
+              typename enable_if
+                      <
+                         _CheckArgsConstructor<
+                            _Dummy
+                         >::template __enable_explicit<_Tp...>(),
+                         bool
+                      >::type = false
+        >
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
+        : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
+                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
+                typename __make_tuple_indices<0>::type(),
+                typename __make_tuple_types<tuple, 0>::type(),
+                __t...
+               ) {}
+
+    template <class _Alloc, bool _Dummy = true,
+              typename enable_if
+                      <
+                         _CheckArgsConstructor<
+                            _Dummy
+                         >::template __enable_implicit<_Tp...>(),
+                         bool
+                      >::type = false
+        >
       _LIBCPP_INLINE_VISIBILITY
       tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
         : base_(allocator_arg_t(), __a,
@@ -536,18 +728,33 @@ public:
                 __t...
                ) {}
 
+    template <class _Alloc, bool _Dummy = true,
+              typename enable_if
+                      <
+                         _CheckArgsConstructor<
+                            _Dummy
+                         >::template __enable_explicit<_Tp...>(),
+                         bool
+                      >::type = false
+        >
+      _LIBCPP_INLINE_VISIBILITY
+      explicit
+      tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
+        : base_(allocator_arg_t(), __a,
+                typename __make_tuple_indices<sizeof...(_Tp)>::type(),
+                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
+                typename __make_tuple_indices<0>::type(),
+                typename __make_tuple_types<tuple, 0>::type(),
+                __t...
+               ) {}
+
     template <class ..._Up,
               typename enable_if
                       <
-                         sizeof...(_Up) <= sizeof...(_Tp) &&
-                         __tuple_convertible
-                         <
-                            tuple<_Up...>,
-                            typename __make_tuple_types<tuple,
-                                     sizeof...(_Up) < sizeof...(_Tp) ?
-                                        sizeof...(_Up) :
-                                        sizeof...(_Tp)>::type
-                         >::value,
+                         _CheckArgsConstructor<
+                             sizeof...(_Up) <= sizeof...(_Tp)
+                             && !_PackExpandsToThisTuple<_Up...>::value
+                         >::template __enable_implicit<_Up...>(),
                          bool
                       >::type = false
              >
@@ -571,25 +778,12 @@ public:
     template <class ..._Up,
               typename enable_if
                       <
-                         sizeof...(_Up) <= sizeof...(_Tp) &&
-                         __tuple_constructible
-                         <
-                            tuple<_Up...>,
-                            typename __make_tuple_types<tuple,
-                                     sizeof...(_Up) < sizeof...(_Tp) ?
-                                        sizeof...(_Up) :
-                                        sizeof...(_Tp)>::type
-                         >::value &&
-                         !__tuple_convertible
-                         <
-                            tuple<_Up...>,
-                            typename __make_tuple_types<tuple,
-                                     sizeof...(_Up) < sizeof...(_Tp) ?
-                                        sizeof...(_Up) :
-                                        sizeof...(_Tp)>::type
-                         >::value,
+                         _CheckArgsConstructor<
+                             sizeof...(_Up) <= sizeof...(_Tp)
+                             && !_PackExpandsToThisTuple<_Up...>::value
+                         >::template __enable_explicit<_Up...>(),
                          bool
-                      >::type =false
+                      >::type = false
              >
         _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
         explicit
@@ -610,18 +804,14 @@ public:
                     _VSTD::forward<_Up>(__u)...) {}
 
     template <class _Alloc, class ..._Up,
-              class = typename enable_if
+              typename enable_if
                       <
-                         sizeof...(_Up) <= sizeof...(_Tp) &&
-                         __tuple_convertible
-                         <
-                            tuple<_Up...>,
-                            typename __make_tuple_types<tuple,
-                                     sizeof...(_Up) < sizeof...(_Tp) ?
-                                        sizeof...(_Up) :
-                                        sizeof...(_Tp)>::type
-                         >::value
-                      >::type
+                         _CheckArgsConstructor<
+                             sizeof...(_Up) == sizeof...(_Tp) &&
+                             !_PackExpandsToThisTuple<_Up...>::value
+                         >::template __enable_implicit<_Up...>(),
+                         bool
+                      >::type = false
              >
         _LIBCPP_INLINE_VISIBILITY
         tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
@@ -632,10 +822,33 @@ public:
                     typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
                     _VSTD::forward<_Up>(__u)...) {}
 
+    template <class _Alloc, class ..._Up,
+              typename enable_if
+                      <
+                         _CheckArgsConstructor<
+                             sizeof...(_Up) == sizeof...(_Tp) &&
+                             !_PackExpandsToThisTuple<_Up...>::value
+                         >::template __enable_explicit<_Up...>(),
+                         bool
+                      >::type = false
+             >
+        _LIBCPP_INLINE_VISIBILITY
+        explicit
+        tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
+            : base_(allocator_arg_t(), __a,
+                    typename __make_tuple_indices<sizeof...(_Up)>::type(),
+                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
+                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
+                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
+                    _VSTD::forward<_Up>(__u)...) {}
+
     template <class _Tuple,
               typename enable_if
                       <
-                         __tuple_convertible<_Tuple, tuple>::value,
+                         _CheckTupleLikeConstructor<
+                             __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
+                             && !_PackExpandsToThisTuple<_Tuple>::value
+                         >::template __enable_implicit<_Tuple>(),
                          bool
                       >::type = false
              >
@@ -646,8 +859,10 @@ public:
     template <class _Tuple,
               typename enable_if
                       <
-                         __tuple_constructible<_Tuple, tuple>::value &&
-                         !__tuple_convertible<_Tuple, tuple>::value,
+                         _CheckTupleLikeConstructor<
+                             __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
+                             && !_PackExpandsToThisTuple<_Tuple>::value
+                         >::template __enable_explicit<_Tuple>(),
                          bool
                       >::type = false
              >
@@ -657,12 +872,29 @@ public:
             : base_(_VSTD::forward<_Tuple>(__t)) {}
 
     template <class _Alloc, class _Tuple,
-              class = typename enable_if
+              typename enable_if
                       <
-                         __tuple_convertible<_Tuple, tuple>::value
-                      >::type
+                         _CheckTupleLikeConstructor<
+                             __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
+                         >::template __enable_implicit<_Tuple>(),
+                         bool
+                      >::type = false
+             >
+        _LIBCPP_INLINE_VISIBILITY
+        tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
+            : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
+
+    template <class _Alloc, class _Tuple,
+              typename enable_if
+                      <
+                         _CheckTupleLikeConstructor<
+                             __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
+                         >::template __enable_explicit<_Tuple>(),
+                         bool
+                      >::type = false
              >
         _LIBCPP_INLINE_VISIBILITY
+        explicit
         tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
             : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
 
@@ -748,6 +980,16 @@ get(tuple<_Tp...>&& __t) _NOEXCEPT
              static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
 }
 
+template <size_t _Ip, class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(const tuple<_Tp...>&& __t) _NOEXCEPT
+{
+    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
+    return static_cast<const type&&>(
+             static_cast<const __tuple_leaf<_Ip, type>&&>(__t.base_).get());
+}
+
 #if _LIBCPP_STD_VER > 11
 // get by type
 template <typename _T1, size_t _Idx, typename... _Args>
@@ -804,6 +1046,13 @@ constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
     return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
 }
 
+template <class _T1, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
+{
+    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
+}
+
 #endif
 
 // tie
@@ -826,8 +1075,6 @@ struct __ignore_t
 
 namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
 
-template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
-
 template <class _Tp>
 struct __make_tuple_return_impl
 {
@@ -907,8 +1154,12 @@ struct __tuple_less
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     bool operator()(const _Tp& __x, const _Up& __y)
     {
-        return __tuple_less<_Ip-1>()(__x, __y) ||
-             (!__tuple_less<_Ip-1>()(__y, __x) && _VSTD::get<_Ip-1>(__x) < _VSTD::get<_Ip-1>(__y));
+        const size_t __idx = tuple_size<_Tp>::value - _Ip;
+        if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
+            return true;
+        if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
+            return false;
+        return __tuple_less<_Ip-1>()(__x, __y);
     }
 };
 
diff --git a/system/include/libcxx/type_traits b/system/include/libcxx/type_traits
index 4beaf74970343..99dd679b2829b 100644
--- a/system/include/libcxx/type_traits
+++ b/system/include/libcxx/type_traits
@@ -19,8 +19,13 @@ namespace std
 
     // helper class:
     template <class T, T v> struct integral_constant;
-    typedef integral_constant<bool, true>  true_type;
-    typedef integral_constant<bool, false> false_type;
+    typedef integral_constant<bool, true>  true_type;   // C++11
+    typedef integral_constant<bool, false> false_type;  // C++11
+    
+    template <bool B>                                   // C++14
+    using bool_constant = integral_constant<bool, B>;   // C++14
+    typedef bool_constant<true> true_type;              // C++14
+    typedef bool_constant<false> false_type;            // C++14
 
     // helper traits
     template <bool, class T = void> struct enable_if;
@@ -100,6 +105,8 @@ namespace std
     template <class T, class U>       struct is_assignable;
     template <class T>                struct is_copy_assignable;
     template <class T>                struct is_move_assignable;
+    template <class T, class U>       struct is_swappable_with;       // C++17
+    template <class T>                struct is_swappable;            // C++17
     template <class T>                struct is_destructible;
 
     template <class T, class... Args> struct is_trivially_constructible;
@@ -118,6 +125,8 @@ namespace std
     template <class T, class U>       struct is_nothrow_assignable;
     template <class T>                struct is_nothrow_copy_assignable;
     template <class T>                struct is_nothrow_move_assignable;
+    template <class T, class U>       struct is_nothrow_swappable_with; // C++17
+    template <class T>                struct is_nothrow_swappable;      // C++17
     template <class T>                struct is_nothrow_destructible;
 
     template <class T> struct has_virtual_destructor;
@@ -127,6 +136,14 @@ namespace std
     template <class Base, class Derived> struct is_base_of;
     template <class From, class To> struct is_convertible;
 
+    template <class, class R = void> struct is_callable; // not defined
+    template <class Fn, class... ArgTypes, class R>
+      struct is_callable<Fn(ArgTypes...), R>;
+
+    template <class, class R = void> struct is_nothrow_callable; // not defined
+    template <class Fn, class... ArgTypes, class R>
+      struct is_nothrow_callable<Fn(ArgTypes...), R>;
+
     // Alignment properties and transformations:
     template <class T> struct alignment_of;
     template <size_t Len, size_t Align = most_stringent_alignment_requirement>
@@ -197,7 +214,173 @@ namespace std
     template <class F, class... ArgTypes>
       using result_of_t       = typename result_of<F(ArgTypes...)>::type;  // C++14
 
-}  // std
+    template <class...>
+      using void_t = void;   // C++17
+      
+      // See C++14 20.10.4.1, primary type categories
+      template <class T> constexpr bool is_void_v
+        = is_void<T>::value;                                             // C++17
+      template <class T> constexpr bool is_null_pointer_v
+        = is_null_pointer<T>::value;                                     // C++17
+      template <class T> constexpr bool is_integral_v
+        = is_integral<T>::value;                                         // C++17
+      template <class T> constexpr bool is_floating_point_v
+        = is_floating_point<T>::value;                                   // C++17
+      template <class T> constexpr bool is_array_v
+        = is_array<T>::value;                                            // C++17
+      template <class T> constexpr bool is_pointer_v
+        = is_pointer<T>::value;                                          // C++17
+      template <class T> constexpr bool is_lvalue_reference_v
+        = is_lvalue_reference<T>::value;                                 // C++17
+      template <class T> constexpr bool is_rvalue_reference_v
+        = is_rvalue_reference<T>::value;                                 // C++17
+      template <class T> constexpr bool is_member_object_pointer_v
+        = is_member_object_pointer<T>::value;                            // C++17
+      template <class T> constexpr bool is_member_function_pointer_v
+        = is_member_function_pointer<T>::value;                          // C++17
+      template <class T> constexpr bool is_enum_v
+        = is_enum<T>::value;                                             // C++17
+      template <class T> constexpr bool is_union_v
+        = is_union<T>::value;                                            // C++17
+      template <class T> constexpr bool is_class_v
+        = is_class<T>::value;                                            // C++17
+      template <class T> constexpr bool is_function_v
+        = is_function<T>::value;                                         // C++17
+
+      // See C++14 20.10.4.2, composite type categories
+      template <class T> constexpr bool is_reference_v
+        = is_reference<T>::value;                                        // C++17
+      template <class T> constexpr bool is_arithmetic_v
+        = is_arithmetic<T>::value;                                       // C++17
+      template <class T> constexpr bool is_fundamental_v
+        = is_fundamental<T>::value;                                      // C++17
+      template <class T> constexpr bool is_object_v
+        = is_object<T>::value;                                           // C++17
+      template <class T> constexpr bool is_scalar_v
+        = is_scalar<T>::value;                                           // C++17
+      template <class T> constexpr bool is_compound_v
+        = is_compound<T>::value;                                         // C++17
+      template <class T> constexpr bool is_member_pointer_v
+        = is_member_pointer<T>::value;                                   // C++17
+
+      // See C++14 20.10.4.3, type properties
+      template <class T> constexpr bool is_const_v
+        = is_const<T>::value;                                            // C++17
+      template <class T> constexpr bool is_volatile_v
+        = is_volatile<T>::value;                                         // C++17
+      template <class T> constexpr bool is_trivial_v
+        = is_trivial<T>::value;                                          // C++17
+      template <class T> constexpr bool is_trivially_copyable_v
+        = is_trivially_copyable<T>::value;                               // C++17
+      template <class T> constexpr bool is_standard_layout_v
+        = is_standard_layout<T>::value;                                  // C++17
+      template <class T> constexpr bool is_pod_v
+        = is_pod<T>::value;                                              // C++17
+      template <class T> constexpr bool is_literal_type_v
+        = is_literal_type<T>::value;                                     // C++17
+      template <class T> constexpr bool is_empty_v
+        = is_empty<T>::value;                                            // C++17
+      template <class T> constexpr bool is_polymorphic_v
+        = is_polymorphic<T>::value;                                      // C++17
+      template <class T> constexpr bool is_abstract_v
+        = is_abstract<T>::value;                                         // C++17
+      template <class T> constexpr bool is_final_v
+        = is_final<T>::value;                                            // C++17
+      template <class T> constexpr bool is_signed_v
+        = is_signed<T>::value;                                           // C++17
+      template <class T> constexpr bool is_unsigned_v
+        = is_unsigned<T>::value;                                         // C++17
+      template <class T, class... Args> constexpr bool is_constructible_v
+        = is_constructible<T, Args...>::value;                           // C++17
+      template <class T> constexpr bool is_default_constructible_v
+        = is_default_constructible<T>::value;                            // C++17
+      template <class T> constexpr bool is_copy_constructible_v
+        = is_copy_constructible<T>::value;                               // C++17
+      template <class T> constexpr bool is_move_constructible_v
+        = is_move_constructible<T>::value;                               // C++17
+      template <class T, class U> constexpr bool is_assignable_v
+        = is_assignable<T, U>::value;                                    // C++17
+      template <class T> constexpr bool is_copy_assignable_v
+        = is_copy_assignable<T>::value;                                  // C++17
+      template <class T> constexpr bool is_move_assignable_v
+        = is_move_assignable<T>::value;                                  // C++17
+      template <class T, class U> constexpr bool is_swappable_with_v
+        = is_swappable_with<T, U>::value;                                // C++17
+      template <class T> constexpr bool is_swappable_v
+        = is_swappable<T>::value;                                        // C++17
+      template <class T> constexpr bool is_destructible_v
+        = is_destructible<T>::value;                                     // C++17
+      template <class T, class... Args> constexpr bool is_trivially_constructible_v
+        = is_trivially_constructible<T, Args...>::value;                 // C++17
+      template <class T> constexpr bool is_trivially_default_constructible_v
+        = is_trivially_default_constructible<T>::value;                  // C++17
+      template <class T> constexpr bool is_trivially_copy_constructible_v
+        = is_trivially_copy_constructible<T>::value;                     // C++17
+      template <class T> constexpr bool is_trivially_move_constructible_v
+        = is_trivially_move_constructible<T>::value;                     // C++17
+      template <class T, class U> constexpr bool is_trivially_assignable_v
+        = is_trivially_assignable<T, U>::value;                          // C++17
+      template <class T> constexpr bool is_trivially_copy_assignable_v
+        = is_trivially_copy_assignable<T>::value;                        // C++17
+      template <class T> constexpr bool is_trivially_move_assignable_v
+        = is_trivially_move_assignable<T>::value;                        // C++17
+      template <class T> constexpr bool is_trivially_destructible_v
+        = is_trivially_destructible<T>::value;                           // C++17
+      template <class T, class... Args> constexpr bool is_nothrow_constructible_v
+        = is_nothrow_constructible<T, Args...>::value;                   // C++17
+      template <class T> constexpr bool is_nothrow_default_constructible_v
+        = is_nothrow_default_constructible<T>::value;                    // C++17
+      template <class T> constexpr bool is_nothrow_copy_constructible_v
+        = is_nothrow_copy_constructible<T>::value;                       // C++17
+      template <class T> constexpr bool is_nothrow_move_constructible_v
+        = is_nothrow_move_constructible<T>::value;                       // C++17
+      template <class T, class U> constexpr bool is_nothrow_assignable_v
+        = is_nothrow_assignable<T, U>::value;                            // C++17
+      template <class T> constexpr bool is_nothrow_copy_assignable_v
+        = is_nothrow_copy_assignable<T>::value;                          // C++17
+      template <class T> constexpr bool is_nothrow_move_assignable_v
+        = is_nothrow_move_assignable<T>::value;                          // C++17
+      template <class T, class U> constexpr bool is_nothrow_swappable_with_v
+        = is_nothrow_swappable_with<T, U>::value;                       // C++17
+      template <class T> constexpr bool is_nothrow_swappable_v
+        = is_nothrow_swappable<T>::value;                               // C++17
+      template <class T> constexpr bool is_nothrow_destructible_v
+        = is_nothrow_destructible<T>::value;                             // C++17
+      template <class T> constexpr bool has_virtual_destructor_v
+        = has_virtual_destructor<T>::value;                              // C++17
+
+      // See C++14 20.10.5, type property queries
+      template <class T> constexpr size_t alignment_of_v
+        = alignment_of<T>::value;                                        // C++17
+      template <class T> constexpr size_t rank_v
+        = rank<T>::value;                                                // C++17
+      template <class T, unsigned I = 0> constexpr size_t extent_v
+        = extent<T, I>::value;                                           // C++17
+
+      // See C++14 20.10.6, type relations
+      template <class T, class U> constexpr bool is_same_v
+        = is_same<T, U>::value;                                          // C++17
+      template <class Base, class Derived> constexpr bool is_base_of_v
+        = is_base_of<Base, Derived>::value;                              // C++17
+      template <class From, class To> constexpr bool is_convertible_v
+        = is_convertible<From, To>::value;                               // C++17
+      template <class T, class R = void> constexpr bool is_callable_v
+        = is_callable<T, R>::value;                                      // C++17
+      template <class T, class R = void> constexpr bool is_nothrow_callable_v
+        = is_nothrow_callable<T, R>::value;                              // C++17
+
+      // [meta.logical], logical operator traits:
+      template<class... B> struct conjunction;                           // C++17
+      template<class... B> 
+        constexpr bool conjunction_v = conjunction<B...>::value;         // C++17
+      template<class... B> struct disjunction;                           // C++17
+      template<class... B>
+        constexpr bool disjunction_v = disjunction<B...>::value;         // C++17
+      template<class B> struct negation;                                 // C++17
+      template<class B> 
+        constexpr bool negation_v = negation<B>::value;                  // C++17
+
+}
 
 */
 #include <__config>
@@ -209,6 +392,19 @@ namespace std
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
+
+template <class>
+struct __void_t { typedef void type; };
+
+template <class _Tp>
+struct __identity { typedef _Tp type; };
+
+template <class _Tp, bool>
+struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {};
+
 template <bool _Bp, class _If, class _Then>
     struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
 template <class _If, class _Then>
@@ -218,6 +414,9 @@ template <class _If, class _Then>
 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
 #endif
 
+template <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
+
 template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
 
@@ -225,6 +424,69 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef
 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
 #endif
 
+// addressof
+#if __has_builtin(__builtin_addressof)
+
+template <class _Tp>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
+_Tp*
+addressof(_Tp& __x) _NOEXCEPT
+{
+    return __builtin_addressof(__x);
+}
+
+#else
+
+template <class _Tp>
+inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
+_Tp*
+addressof(_Tp& __x) _NOEXCEPT
+{
+    return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
+}
+
+#endif // __has_builtin(__builtin_addressof)
+
+#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
+// Objective-C++ Automatic Reference Counting uses qualified pointers
+// that require special addressof() signatures. When
+// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
+// itself is providing these definitions. Otherwise, we provide them.
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__strong _Tp*
+addressof(__strong _Tp& __x) _NOEXCEPT
+{
+  return &__x;
+}
+
+#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__weak _Tp*
+addressof(__weak _Tp& __x) _NOEXCEPT
+{
+  return &__x;
+}
+#endif
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__autoreleasing _Tp*
+addressof(__autoreleasing _Tp& __x) _NOEXCEPT
+{
+  return &__x;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__unsafe_unretained _Tp*
+addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
+{
+  return &__x;
+}
+#endif
 
 struct __two {char __lx[2];};
 
@@ -247,19 +509,114 @@ struct _LIBCPP_TYPE_VIS_ONLY integral_constant
 template <class _Tp, _Tp __v>
 _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
 
-typedef integral_constant<bool, true>  true_type;
-typedef integral_constant<bool, false> false_type;
+#if _LIBCPP_STD_VER > 14
+template <bool __b>
+using bool_constant = integral_constant<bool, __b>;
+#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
+#else
+#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
+#endif
+
+typedef _LIBCPP_BOOL_CONSTANT(true)  true_type;
+typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
+
+#if !defined(_LIBCPP_HAS_NO_VARIADICS)
+
+// __lazy_and
+
+template <bool _Last, class ..._Preds>
+struct __lazy_and_impl;
+
+template <class ..._Preds>
+struct __lazy_and_impl<false, _Preds...> : false_type {};
+
+template <>
+struct __lazy_and_impl<true> : true_type {};
+
+template <class _Pred>
+struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
+
+template <class _Hp, class ..._Tp>
+struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
+
+template <class _P1, class ..._Pr>
+struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
+
+// __lazy_or
+
+template <bool _List, class ..._Preds>
+struct __lazy_or_impl;
+
+template <class ..._Preds>
+struct __lazy_or_impl<true, _Preds...> : true_type {};
+
+template <>
+struct __lazy_or_impl<false> : false_type {};
+
+template <class _Hp, class ..._Tp>
+struct __lazy_or_impl<false, _Hp, _Tp...>
+        : __lazy_or_impl<_Hp::type::value, _Tp...> {};
+
+template <class _P1, class ..._Pr>
+struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
+
+// __lazy_not
+
+template <class _Pred>
+struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
+
+// __and_
+template<class...> struct __and_;
+template<> struct __and_<> : true_type {};
+
+template<class _B0> struct __and_<_B0> : _B0 {};
+
+template<class _B0, class _B1>
+struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
+
+template<class _B0, class _B1, class _B2, class... _Bn>
+struct __and_<_B0, _B1, _B2, _Bn...> 
+        : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
+
+// __or_
+template<class...> struct __or_;
+template<> struct __or_<> : false_type {};
+
+template<class _B0> struct __or_<_B0> : _B0 {};
+
+template<class _B0, class _B1>
+struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
+
+template<class _B0, class _B1, class _B2, class... _Bn>
+struct __or_<_B0, _B1, _B2, _Bn...> 
+        : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
+
+// __not_
+template<class _Tp> 
+struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
+
+#endif // !defined(_LIBCPP_HAS_NO_VARIADICS)
 
 // is_const
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const            : public false_type {};
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
+    = is_const<_Tp>::value;
+#endif
+
 // is_volatile
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile               : public false_type {};
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
+    = is_volatile<_Tp>::value;
+#endif
+
 // remove_const
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const            {typedef _Tp type;};
@@ -292,6 +649,11 @@ template <>          struct __libcpp_is_void<void> : public true_type {};
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
     : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
+    = is_void<_Tp>::value;
+#endif
+
 // __is_nullptr_t
 
 template <class _Tp> struct __is_nullptr_t_impl       : public false_type {};
@@ -303,6 +665,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
 #if _LIBCPP_STD_VER > 11
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
     : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
+    = is_null_pointer<_Tp>::value;
+#endif
 #endif
 
 // is_integral
@@ -333,6 +700,11 @@ template <>          struct __libcpp_is_integral<__uint128_t>        : public tr
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
     : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
+    = is_integral<_Tp>::value;
+#endif
+
 // is_floating_point
 
 template <class _Tp> struct __libcpp_is_floating_point              : public false_type {};
@@ -343,6 +715,11 @@ template <>          struct __libcpp_is_floating_point<long double> : public tru
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
     : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
+    = is_floating_point<_Tp>::value;
+#endif
+
 // is_array
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
@@ -352,6 +729,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
     : public true_type {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
+    = is_array<_Tp>::value;
+#endif
+
 // is_pointer
 
 template <class _Tp> struct __libcpp_is_pointer       : public false_type {};
@@ -360,6 +742,11 @@ template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
     : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
+    = is_pointer<_Tp>::value;
+#endif
+
 // is_reference
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference       : public false_type {};
@@ -376,6 +763,16 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&>  : public t
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
+    = is_reference<_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;
+#endif
 // is_union
 
 #if __has_feature(is_union) || (_GNUC_VER >= 403)
@@ -391,6 +788,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
 
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
+    = is_union<_Tp>::value;
+#endif
+
 // is_class
 
 #if __has_feature(is_class) || (_GNUC_VER >= 403)
@@ -411,11 +813,21 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
 
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
+    = is_class<_Tp>::value;
+#endif
+
 // is_same
 
 template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same           : public false_type {};
 template <class _Tp>            struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
+    = is_same<_Tp, _Up>::value;
+#endif
+
 // is_function
 
 namespace __libcpp_is_function_imp
@@ -425,7 +837,7 @@ template <class _Tp> char  __test(_Tp*);
 template <class _Tp> char __test(__dummy_type);
 template <class _Tp> __two __test(...);
 template <class _Tp> _Tp&  __source(int);
-template <class _Tp> __dummy_type __source(long);
+template <class _Tp> __dummy_type __source(...);
 }
 
 template <class _Tp, bool = is_class<_Tp>::value ||
@@ -441,31 +853,37 @@ template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
     : public __libcpp_is_function<_Tp> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
+    = is_function<_Tp>::value;
+#endif
+
 // is_member_function_pointer
 
 // template <class _Tp> struct            __libcpp_is_member_function_pointer             : public false_type {};
 // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
 // 
 
-template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
+template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
 struct __member_pointer_traits_imp
 {  // forward declaration; specializations later
 };
 
 
-namespace __libcpp_is_member_function_pointer_imp {
-    template <typename _Tp>
-    char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *);
-
-    template <typename>
-    std::__two __test(...);
-};
-    
 template <class _Tp> struct __libcpp_is_member_function_pointer
-    : public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {};
+    : public false_type {};
+
+template <class _Ret, class _Class>
+struct __libcpp_is_member_function_pointer<_Ret _Class::*>
+    : public is_function<_Ret> {};
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
-    : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {};
+    : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
+
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
+    = is_member_function_pointer<_Tp>::value;
+#endif
 
 // is_member_pointer
 
@@ -475,12 +893,22 @@ template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> :
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
     : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
+    = is_member_pointer<_Tp>::value;
+#endif
+
 // is_member_object_pointer
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
     : public integral_constant<bool, is_member_pointer<_Tp>::value &&
                                     !is_member_function_pointer<_Tp>::value> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
+    = is_member_object_pointer<_Tp>::value;
+#endif
+
 // is_enum
 
 #if __has_feature(is_enum) || (_GNUC_VER >= 403)
@@ -504,12 +932,22 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
 
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
+    = is_enum<_Tp>::value;
+#endif
+
 // is_arithmetic
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
     : public integral_constant<bool, is_integral<_Tp>::value      ||
                                      is_floating_point<_Tp>::value> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
+    = is_arithmetic<_Tp>::value;
+#endif
+
 // is_fundamental
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
@@ -517,6 +955,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
                                      __is_nullptr_t<_Tp>::value ||
                                      is_arithmetic<_Tp>::value> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
+    = is_fundamental<_Tp>::value;
+#endif
+
 // is_scalar
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
@@ -528,6 +971,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
 
 template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
+    = is_scalar<_Tp>::value;
+#endif
+
 // is_object
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
@@ -536,11 +984,34 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
                                      is_union<_Tp>::value  ||
                                      is_class<_Tp>::value  > {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
+    = is_object<_Tp>::value;
+#endif
+
 // is_compound
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
     : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
+    = is_compound<_Tp>::value;
+#endif
+
+
+// __is_referenceable  [defns.referenceable]
+
+struct __is_referenceable_impl {
+    template <class _Tp> static _Tp& __test(int);
+    template <class _Tp> static __two __test(...);
+};
+
+template <class _Tp>
+struct __is_referenceable : std::integral_constant<bool,
+    !std::is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
+
+
 // add_const
 
 template <class _Tp, bool = is_reference<_Tp>::value ||
@@ -598,12 +1069,11 @@ template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::
 
 // add_lvalue_reference
 
-template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference                      {typedef _Tp& type;};
-template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&>                {typedef _Tp& type;};  // for older compiler
-template <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void>                {typedef void type;};
-template <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void>          {typedef const void type;};
-template <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void>       {typedef volatile void type;};
-template <>          struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
+template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl            { typedef _Tp  type; };
+template <class _Tp                                       > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference
+{typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
 
 #if _LIBCPP_STD_VER > 11
 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
@@ -611,11 +1081,11 @@ template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_referenc
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
-template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY  add_rvalue_reference                     {typedef _Tp&& type;};
-template <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void>                {typedef void type;};
-template <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void>          {typedef const void type;};
-template <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void>       {typedef volatile void type;};
-template <>          struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
+template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl            { typedef _Tp   type; };
+template <class _Tp                                       > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference
+{typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
 
 #if _LIBCPP_STD_VER > 11
 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
@@ -637,6 +1107,24 @@ declval();
 
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
+// __uncvref
+
+template <class _Tp>
+struct __uncvref  {
+    typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
+};
+
+template <class _Tp>
+struct __unconstref {
+    typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
+};
+
+// __is_same_uncvref
+
+template <class _Tp, class _Up>
+struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
+                                   typename __uncvref<_Up>::type> {};
+
 struct __any
 {
     __any(...);
@@ -656,8 +1144,16 @@ template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type
 
 // add_pointer
 
-template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
+template <class _Tp, 
+        bool = __is_referenceable<_Tp>::value || 
+                is_same<typename remove_cv<_Tp>::type, void>::value>
+struct __add_pointer_impl
     {typedef typename remove_reference<_Tp>::type* type;};
+template <class _Tp> struct __add_pointer_impl<_Tp, false> 
+    {typedef _Tp type;};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
+    {typedef typename __add_pointer_impl<_Tp>::type type;};
 
 #if _LIBCPP_STD_VER > 11
 template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
@@ -666,7 +1162,7 @@ template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
 // is_signed
 
 template <class _Tp, bool = is_integral<_Tp>::value>
-struct __libcpp_is_signed_impl : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
+struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
 
 template <class _Tp>
 struct __libcpp_is_signed_impl<_Tp, false> : public true_type {};  // floating point
@@ -678,10 +1174,15 @@ template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
+    = is_signed<_Tp>::value;
+#endif
+
 // is_unsigned
 
 template <class _Tp, bool = is_integral<_Tp>::value>
-struct __libcpp_is_unsigned_impl : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
+struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
 
 template <class _Tp>
 struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {};  // floating point
@@ -693,6 +1194,11 @@ template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
+    = is_unsigned<_Tp>::value;
+#endif
+
 // rank
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
@@ -702,6 +1208,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
 template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
     : public integral_constant<size_t, rank<_Tp>::value + 1> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
+    = rank<_Tp>::value;
+#endif
+
 // extent
 
 template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
@@ -715,6 +1226,11 @@ template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0
 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
     : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v
+    = extent<_Tp, _Ip>::value;
+#endif
+
 // remove_extent
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
@@ -781,13 +1297,31 @@ template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
+    = is_abstract<_Tp>::value;
+#endif
+
 // is_final
 
-#if _LIBCPP_STD_VER > 11 && __has_feature(is_final)
-template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY 
+#if defined(_LIBCPP_HAS_IS_FINAL)
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
+__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
+#else
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
+__libcpp_is_final : public false_type {};
+#endif
+
+#if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
 is_final : public integral_constant<bool, __is_final(_Tp)> {};
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
+    = is_final<_Tp>::value;
+#endif
+
 // is_base_of
 
 #ifdef _LIBCPP_HAS_IS_BASE_OF
@@ -823,9 +1357,14 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of
 
 #endif  // _LIBCPP_HAS_IS_BASE_OF
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
+    = is_base_of<_Bp, _Dp>::value;
+#endif
+
 // is_convertible
 
-#if __has_feature(is_convertible_to)
+#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
 
 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
     : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
@@ -835,13 +1374,15 @@ template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
 
 namespace __is_convertible_imp
 {
-template <class _Tp> char  __test(_Tp);
-template <class _Tp> __two __test(...);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-template <class _Tp> _Tp&& __source();
-#else
-template <class _Tp> typename remove_reference<_Tp>::type& __source();
-#endif
+template <class _Tp> void  __test_convert(_Tp);
+
+template <class _From, class _To, class = void>
+struct __is_convertible_test : public false_type {};
+
+template <class _From, class _To>
+struct __is_convertible_test<_From, _To,
+    decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
+{};
 
 template <class _Tp, bool _IsArray =    is_array<_Tp>::value,
                      bool _IsFunction = is_function<_Tp>::value,
@@ -870,10 +1411,8 @@ template <class _T1, class _T2,
     unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
 struct __is_convertible
     : public integral_constant<bool,
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
-#else
-        sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
+        __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
+#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
          && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
               && (!is_const<typename remove_reference<_T2>::type>::value
                   || is_volatile<typename remove_reference<_T2>::type>::value)
@@ -887,6 +1426,7 @@ struct __is_convertible
 template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
 
 template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
+template <class _T1> struct __is_convertible<const _T1, const _T1&, 1, 0> : true_type {};
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
 template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
@@ -942,6 +1482,11 @@ template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
 
 #endif  // __has_feature(is_convertible_to)
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
+    = is_convertible<_From, _To>::value;
+#endif
+
 // is_empty
 
 #if __has_feature(is_empty) || (_GNUC_VER >= 407)
@@ -973,6 +1518,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_emp
 
 #endif  // __has_feature(is_empty)
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
+    = is_empty<_Tp>::value;
+#endif
+
 // is_polymorphic
 
 #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
@@ -993,6 +1543,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
 
 #endif // __has_feature(is_polymorphic)
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
+    = is_polymorphic<_Tp>::value;
+#endif
+
 // has_virtual_destructor
 
 #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
@@ -1007,11 +1562,21 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
 
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
+    = has_virtual_destructor<_Tp>::value;
+#endif
+
 // alignment_of
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
     : public integral_constant<size_t, __alignof__(_Tp)> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
+    = alignment_of<_Tp>::value;
+#endif
+
 // aligned_storage
 
 template <class _Hp, class _Tp>
@@ -1104,7 +1669,7 @@ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
     union type
     {
         _Aligner __align;
-        unsigned char __data[_Len];
+        unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
     };
 };
 
@@ -1119,7 +1684,7 @@ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
 {\
     struct _ALIGNAS(n) type\
     {\
-        unsigned char __lx[_Len];\
+        unsigned char __lx[(_Len + n - 1)/n * n];\
     };\
 }
 
@@ -1211,54 +1776,45 @@ template <class _A1, class _A2 = void, class _A3 = void,
           bool = __numeric_type<_A1>::value &&
                  __numeric_type<_A2>::value &&
                  __numeric_type<_A3>::value>
-class __promote
+class __promote_imp
 {
+public:
     static const bool value = false;
 };
 
 template <class _A1, class _A2, class _A3>
-class __promote<_A1, _A2, _A3, true>
+class __promote_imp<_A1, _A2, _A3, true>
 {
 private:
-    typedef typename __promote<_A1>::type __type1;
-    typedef typename __promote<_A2>::type __type2;
-    typedef typename __promote<_A3>::type __type3;
+    typedef typename __promote_imp<_A1>::type __type1;
+    typedef typename __promote_imp<_A2>::type __type2;
+    typedef typename __promote_imp<_A3>::type __type3;
 public:
     typedef decltype(__type1() + __type2() + __type3()) type;
     static const bool value = true;
 };
 
 template <class _A1, class _A2>
-class __promote<_A1, _A2, void, true>
+class __promote_imp<_A1, _A2, void, true>
 {
 private:
-    typedef typename __promote<_A1>::type __type1;
-    typedef typename __promote<_A2>::type __type2;
+    typedef typename __promote_imp<_A1>::type __type1;
+    typedef typename __promote_imp<_A2>::type __type2;
 public:
     typedef decltype(__type1() + __type2()) type;
     static const bool value = true;
 };
 
 template <class _A1>
-class __promote<_A1, void, void, true>
+class __promote_imp<_A1, void, void, true>
 {
 public:
     typedef typename __numeric_type<_A1>::type type;
     static const bool value = true;
-    static const bool __does_not_throw = _NOEXCEPT_OR_FALSE(static_cast<type>(declval<_A1>()));
 };
 
-#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
-
-// __transform
-
-template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;};
-template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char      type;};
-template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short     type;};
-template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int       type;};
-template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;};
-
-#endif  // _LIBCPP_STORE_AS_OPTIMIZATION
+template <class _A1, class _A2 = void, class _A3 = void>
+class __promote : public __promote_imp<_A1, _A2, _A3> {};
 
 // make_signed / make_unsigned
 
@@ -1423,11 +1979,11 @@ template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
 
 #ifdef _LIBCPP_HAS_NO_VARIADICS
 
-template <class _Tp, class _Up = void, class V = void>
+template <class _Tp, class _Up = void, class _Vp = void>
 struct _LIBCPP_TYPE_VIS_ONLY common_type
 {
 public:
-    typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
+    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
 };
 
 template <class _Tp>
@@ -1440,21 +1996,19 @@ public:
 template <class _Tp, class _Up>
 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
 {
-private:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    static _Tp&& __t();
-    static _Up&& __u();
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    static _Tp __t();
-    static _Up __u();
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-public:
-    typedef typename remove_reference<decltype(true ? __t() : __u())>::type type;
+    typedef typename decay<decltype(
+        true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
+      )>::type type;
 };
 
 #else  // _LIBCPP_HAS_NO_VARIADICS
 
-template <class ..._Tp> struct common_type;
+// bullet 1 - sizeof...(Tp) == 0
+
+template <class ..._Tp>
+struct _LIBCPP_TYPE_VIS_ONLY common_type {};
+
+// bullet 2 - sizeof...(Tp) == 1
 
 template <class _Tp>
 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
@@ -1462,23 +2016,46 @@ struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
     typedef typename decay<_Tp>::type type;
 };
 
+// bullet 3 - sizeof...(Tp) == 2
+
+template <class _Tp, class _Up, class = void>
+struct __common_type2 {};
+
 template <class _Tp, class _Up>
-struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
+struct __common_type2<_Tp, _Up,
+    typename __void_t<decltype(
+        true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
+    )>::type>
 {
-private:
-    static _Tp&& __t();
-    static _Up&& __u();
-    static bool __f();
-public:
-    typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
+    typedef typename decay<decltype(
+        true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
+    )>::type type;
 };
 
+template <class _Tp, class _Up>
+struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
+    : __common_type2<_Tp, _Up> {};
+
+// bullet 4 - sizeof...(Tp) > 2
+
+template <class ...Tp> struct __common_types;
+
+template <class, class = void>
+struct __common_type_impl {};
+
 template <class _Tp, class _Up, class ..._Vp>
-struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
+struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
+    typename __void_t<typename common_type<_Tp, _Up>::type>::type>
 {
-    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
+    typedef typename common_type<
+        typename common_type<_Tp, _Up>::type, _Vp...
+    >::type type;
 };
 
+template <class _Tp, class _Up, class ..._Vp>
+struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
+    : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
+
 #if _LIBCPP_STD_VER > 11
 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
 #endif
@@ -1509,7 +2086,7 @@ template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::va
 struct __is_assignable_imp
     : public common_type
         <
-            decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
+            decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
         >::type {};
 
 template <class _Tp, class _Arg>
@@ -1522,12 +2099,22 @@ template <class _Tp, class _Arg>
 struct is_assignable
     : public __is_assignable_imp<_Tp, _Arg> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v
+    = is_assignable<_Tp, _Arg>::value;
+#endif
+
 // is_copy_assignable
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
     : public is_assignable<typename add_lvalue_reference<_Tp>::type,
                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
+    = is_copy_assignable<_Tp>::value;
+#endif
+
 // is_move_assignable
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
@@ -1538,13 +2125,18 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
     : public is_copy_assignable<_Tp> {};
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
+    = is_move_assignable<_Tp>::value;
+#endif
+
 // is_destructible
 
-//	if it's a reference, return true
-//	if it's a function, return false
-//	if it's   void,     return false
-//	if it's an array of unknown bound, return false
-//	Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
+//  if it's a reference, return true
+//  if it's a function, return false
+//  if it's   void,     return false
+//  if it's an array of unknown bound, return false
+//  Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
 //    where _Up is remove_all_extents<_Tp>::type
 
 template <class>
@@ -1552,15 +2144,15 @@ struct __is_destructible_apply { typedef int type; };
 
 template <typename _Tp>
 struct __is_destructor_wellformed {
-	template <typename _Tp1>
-	static char  __test (
+    template <typename _Tp1>
+    static char  __test (
         typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
     );
 
-	template <typename _Tp1>
-	static __two __test (...);
-	
-	static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
+    template <typename _Tp1>
+    static __two __test (...);
+    
+    static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
 };
 
 template <class _Tp, bool>
@@ -1596,6 +2188,11 @@ template <>
 struct is_destructible<void>
     : public _VSTD::false_type {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
+    = is_destructible<_Tp>::value;
+#endif
+
 // move
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1756,7 +2353,8 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil
     typedef _Rp (_FnType) (_Param..., ...);
 };
 
-#if __has_feature(cxx_reference_qualified_functions)
+#if __has_feature(cxx_reference_qualified_functions) || \
+    (defined(_GNUC_VER) && _GNUC_VER >= 409)
 
 template <class _Rp, class _Class, class ..._Param>
 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
@@ -1886,7 +2484,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil
     typedef _Rp (_FnType) (_Param..., ...);
 };
 
-#endif  // __has_feature(cxx_reference_qualified_functions)
+#endif  // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
 
 #else  // _LIBCPP_HAS_NO_VARIADICS
 
@@ -2166,6 +2764,15 @@ struct __member_pointer_traits
 //     typedef ... _FnType;
 };
 
+
+template <class _DecayedFp>
+struct __member_pointer_class_type {};
+
+template <class _Ret, class _ClassType>
+struct __member_pointer_class_type<_Ret _ClassType::*> {
+  typedef _ClassType type;
+};
+
 // result_of
 
 template <class _Callable> class result_of;
@@ -2212,7 +2819,7 @@ struct __result_of_mp;
 
 template <class _MP, class _Tp>
 struct __result_of_mp<_MP, _Tp, true>
-    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
+    : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
 {
 };
 
@@ -2280,7 +2887,7 @@ template <class _Fn>
 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
     : public __result_of<_Fn(),
                          is_class<typename remove_reference<_Fn>::type>::value ||
-                         is_function<typename remove_reference<_Fn>::type>::value,
+                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
                          is_member_pointer<typename remove_reference<_Fn>::type>::value
                         >
 {
@@ -2290,7 +2897,7 @@ template <class _Fn, class _A0>
 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
     : public __result_of<_Fn(_A0),
                          is_class<typename remove_reference<_Fn>::type>::value ||
-                         is_function<typename remove_reference<_Fn>::type>::value,
+                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
                          is_member_pointer<typename remove_reference<_Fn>::type>::value
                         >
 {
@@ -2300,7 +2907,7 @@ template <class _Fn, class _A0, class _A1>
 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
     : public __result_of<_Fn(_A0, _A1),
                          is_class<typename remove_reference<_Fn>::type>::value ||
-                         is_function<typename remove_reference<_Fn>::type>::value,
+                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
                          is_member_pointer<typename remove_reference<_Fn>::type>::value
                         >
 {
@@ -2310,7 +2917,7 @@ template <class _Fn, class _A0, class _A1, class _A2>
 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
     : public __result_of<_Fn(_A0, _A1, _A2),
                          is_class<typename remove_reference<_Fn>::type>::value ||
-                         is_function<typename remove_reference<_Fn>::type>::value,
+                         is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
                          is_member_pointer<typename remove_reference<_Fn>::type>::value
                         >
 {
@@ -2629,6 +3236,11 @@ struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 #endif  // __has_feature(is_constructible)
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v
+    = is_constructible<_Tp, _Args...>::value;
+#endif
+
 // is_default_constructible
 
 template <class _Tp>
@@ -2636,6 +3248,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
     : public is_constructible<_Tp>
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
+    = is_default_constructible<_Tp>::value;
+#endif
+
 // is_copy_constructible
 
 template <class _Tp>
@@ -2643,6 +3260,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
     : public is_constructible<_Tp, 
                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
+    = is_copy_constructible<_Tp>::value;
+#endif
+
 // is_move_constructible
 
 template <class _Tp>
@@ -2654,11 +3276,16 @@ struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
 #endif
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
+    = is_move_constructible<_Tp>::value;
+#endif
+
 // is_trivially_constructible
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
-#if __has_feature(is_trivially_constructible)
+#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
 
 template <class _Tp, class... _Args>
 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
@@ -2717,7 +3344,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
 {
 };
 
-#if __has_feature(is_trivially_constructible)
+#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
 
 template <class _Tp>
 struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
@@ -2781,18 +3408,33 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
 
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+template <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
+    = is_trivially_constructible<_Tp, _Args...>::value;
+#endif
+
 // is_trivially_default_constructible
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
     : public is_trivially_constructible<_Tp>
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
+    = is_trivially_default_constructible<_Tp>::value;
+#endif
+
 // is_trivially_copy_constructible
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
     : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
+    = is_trivially_copy_constructible<_Tp>::value;
+#endif
+
 // is_trivially_move_constructible
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
@@ -2803,9 +3445,14 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructibl
 #endif
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
+    = is_trivially_move_constructible<_Tp>::value;
+#endif
+
 // is_trivially_assignable
 
-#if __has_feature(is_trivially_assignable)
+#if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
 
 template <class _Tp, class _Arg>
 struct is_trivially_assignable
@@ -2841,12 +3488,22 @@ struct is_trivially_assignable<_Tp&, _Tp&&>
 
 #endif  // !__has_feature(is_trivially_assignable)
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
+    = is_trivially_assignable<_Tp, _Arg>::value;
+#endif
+
 // is_trivially_copy_assignable
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
     : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
+    = is_trivially_copy_assignable<_Tp>::value;
+#endif
+
 // is_trivially_move_assignable
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
@@ -2858,6 +3515,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
 #endif
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
+    = is_trivially_move_assignable<_Tp>::value;
+#endif
+
 // is_trivially_destructible
 
 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
@@ -2874,6 +3536,14 @@ template <class _Tp> struct __libcpp_trivial_destructor
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
     : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
 
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]>
+    : public false_type {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
+    = is_trivially_destructible<_Tp>::value;
 #endif
 
 // is_nothrow_constructible
@@ -2891,29 +3561,38 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
 
 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
 
-template <bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
+template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
 
 template <class _Tp, class... _Args>
-struct __libcpp_is_nothrow_constructible<true, _Tp, _Args...>
+struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
     : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
 {
 };
 
-template <class _Tp, class... _Args>
-struct __libcpp_is_nothrow_constructible<false, _Tp, _Args...>
+template <class _Tp>
+void __implicit_conversion_to(_Tp) noexcept { }
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
+    : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
+{
+};
+
+template <class _Tp, bool _IsReference, class... _Args>
+struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
     : public false_type
 {
 };
 
 template <class _Tp, class... _Args>
 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
-    : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
+    : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
 {
 };
 
 template <class _Tp, size_t _Ns>
 struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
-    : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, _Tp>
+    : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
 {
 };
 
@@ -3027,18 +3706,33 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 #endif  // __has_feature(is_nothrow_constructible)
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
+    = is_nothrow_constructible<_Tp, _Args...>::value;
+#endif
+
 // is_nothrow_default_constructible
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
     : public is_nothrow_constructible<_Tp>
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
+    = is_nothrow_default_constructible<_Tp>::value;
+#endif
+
 // is_nothrow_copy_constructible
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
     : public is_nothrow_constructible<_Tp,
                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
+    = is_nothrow_copy_constructible<_Tp>::value;
+#endif
+
 // is_nothrow_move_constructible
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
@@ -3049,6 +3743,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
 #endif
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
+    = is_nothrow_move_constructible<_Tp>::value;
+#endif
+
 // is_nothrow_assignable
 
 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
@@ -3117,12 +3816,22 @@ struct is_nothrow_assignable<_Tp&, _Tp&&>
 
 #endif  // __has_feature(cxx_noexcept)
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
+    = is_nothrow_assignable<_Tp, _Arg>::value;
+#endif
+
 // is_nothrow_copy_assignable
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
     : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
                   typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
+    = is_nothrow_copy_assignable<_Tp>::value;
+#endif
+
 // is_nothrow_move_assignable
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
@@ -3134,6 +3843,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
 #endif
     {};
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
+    = is_nothrow_move_assignable<_Tp>::value;
+#endif
+
 // is_nothrow_destructible
 
 #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
@@ -3189,6 +3903,15 @@ template <class _Tp> struct __libcpp_nothrow_destructor
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
     : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
 
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]>
+    : public false_type {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
+    = is_nothrow_destructible<_Tp>::value;
 #endif
 
 // is_pod
@@ -3208,6 +3931,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
 
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
+    = is_pod<_Tp>::value;
+#endif
+
 // is_literal_type;
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
@@ -3219,6 +3947,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
 #endif
     {};
     
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
+    = is_literal_type<_Tp>::value;
+#endif
+
 // is_standard_layout;
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
@@ -3229,20 +3962,32 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
 #endif
     {};
     
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
+    = is_standard_layout<_Tp>::value;
+#endif
+
 // is_trivially_copyable;
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
 #if __has_feature(is_trivially_copyable)
     : public integral_constant<bool, __is_trivially_copyable(_Tp)>
+#elif _GNUC_VER >= 501
+    : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
 #else
     : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
 #endif
     {};
     
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
+    = is_trivially_copyable<_Tp>::value;
+#endif
+
 // is_trivial;
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
-#if __has_feature(is_trivial) || (_GNUC_VER >= 407)
+#if __has_feature(is_trivial) || _GNUC_VER >= 407
     : public integral_constant<bool, __is_trivial(_Tp)>
 #else
     : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
@@ -3250,7 +3995,17 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
 #endif
     {};
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
+    = is_trivial<_Tp>::value;
+#endif
+
+template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
+template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
+template <class _Tp> struct __is_reference_wrapper
+    : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
+
+#ifndef _LIBCPP_CXX03_LANG
 
 // Check for complete types
 
@@ -3338,8 +4093,6 @@ struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
 {
 };
 
-#if __has_feature(cxx_reference_qualified_functions)
-
 template <class _Rp, class _Class, class ..._Param>
 struct __check_complete<_Rp (_Class::*)(_Param...) &>
     : private __check_complete<_Class>
@@ -3388,125 +4141,257 @@ struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
 {
 };
 
-#endif
-
 template <class _Rp, class _Class>
 struct __check_complete<_Rp _Class::*>
     : private __check_complete<_Class>
 {
 };
 
+
+template <class _Fp, class _A0,
+         class _DecayFp = typename decay<_Fp>::type,
+         class _DecayA0 = typename decay<_A0>::type,
+         class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet1 = typename enable_if
+    <
+        is_member_function_pointer<_DecayFp>::value
+        && is_base_of<_ClassT, _DecayA0>::value
+    >::type;
+
+template <class _Fp, class _A0,
+         class _DecayFp = typename decay<_Fp>::type,
+         class _DecayA0 = typename decay<_A0>::type>
+using __enable_if_bullet2 = typename enable_if
+    <
+        is_member_function_pointer<_DecayFp>::value
+        && __is_reference_wrapper<_DecayA0>::value
+    >::type;
+
+template <class _Fp, class _A0,
+         class _DecayFp = typename decay<_Fp>::type,
+         class _DecayA0 = typename decay<_A0>::type,
+         class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet3 = typename enable_if
+    <
+        is_member_function_pointer<_DecayFp>::value
+        && !is_base_of<_ClassT, _DecayA0>::value
+        && !__is_reference_wrapper<_DecayA0>::value
+    >::type;
+
+template <class _Fp, class _A0,
+         class _DecayFp = typename decay<_Fp>::type,
+         class _DecayA0 = typename decay<_A0>::type,
+         class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet4 = typename enable_if
+    <
+        is_member_object_pointer<_DecayFp>::value
+        && is_base_of<_ClassT, _DecayA0>::value
+    >::type;
+
+template <class _Fp, class _A0,
+         class _DecayFp = typename decay<_Fp>::type,
+         class _DecayA0 = typename decay<_A0>::type>
+using __enable_if_bullet5 = typename enable_if
+    <
+        is_member_object_pointer<_DecayFp>::value
+        && __is_reference_wrapper<_DecayA0>::value
+    >::type;
+
+template <class _Fp, class _A0,
+         class _DecayFp = typename decay<_Fp>::type,
+         class _DecayA0 = typename decay<_A0>::type,
+         class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet6 = typename enable_if
+    <
+        is_member_object_pointer<_DecayFp>::value
+        && !is_base_of<_ClassT, _DecayA0>::value
+        && !__is_reference_wrapper<_DecayA0>::value
+    >::type;
+
 // __invoke forward declarations
 
 // fall back - none of the bullets
 
+#define _LIBCPP_INVOKE_RETURN(...) \
+    noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
+    { return __VA_ARGS__; }
+
+template <class ..._Args>
+auto __invoke(__any, _Args&& ...__args) -> __nat;
+
 template <class ..._Args>
+auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
+
+// bullets 1, 2 and 3
+
+template <class _Fp, class _A0, class ..._Args,
+          class = __enable_if_bullet1<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
 auto
-__invoke(__any, _Args&& ...__args)
-    -> __nat;
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
 
-// bullets 1 and 2
+template <class _Fp, class _A0, class ..._Args,
+          class = __enable_if_bullet1<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR auto
+__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
 
 template <class _Fp, class _A0, class ..._Args,
-            class = typename enable_if
-            <
-                is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
-                is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
-                           typename remove_reference<_A0>::type>::value
-            >::type
-         >
-_LIBCPP_INLINE_VISIBILITY
+          class = __enable_if_bullet2<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-    -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
+_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
+
+template <class _Fp, class _A0, class ..._Args,
+          class = __enable_if_bullet2<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR auto
+__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
 
 template <class _Fp, class _A0, class ..._Args,
-            class = typename enable_if
-            <
-                is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
-                !is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
-                           typename remove_reference<_A0>::type>::value
-            >::type
-         >
-_LIBCPP_INLINE_VISIBILITY
+          class = __enable_if_bullet3<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
+_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
+
+template <class _Fp, class _A0, class ..._Args,
+          class = __enable_if_bullet3<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR auto
+__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
+
+// bullets 4, 5 and 6
+
+template <class _Fp, class _A0,
+          class = __enable_if_bullet4<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _A0&& __a0)
+_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
 
-// bullets 3 and 4
+template <class _Fp, class _A0,
+          class = __enable_if_bullet4<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR auto
+__invoke_constexpr(_Fp&& __f, _A0&& __a0)
+_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
 
 template <class _Fp, class _A0,
-            class = typename enable_if
-            <
-                is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
-                is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
-                           typename remove_reference<_A0>::type>::value
-            >::type
-         >
-_LIBCPP_INLINE_VISIBILITY
+          class = __enable_if_bullet5<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _A0&& __a0)
-    -> decltype(_VSTD::forward<_A0>(__a0).*__f);
+_LIBCPP_INVOKE_RETURN(__a0.get().*__f)
 
 template <class _Fp, class _A0,
-            class = typename enable_if
-            <
-                is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
-                !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
-                           typename remove_reference<_A0>::type>::value
-            >::type
-         >
-_LIBCPP_INLINE_VISIBILITY
+          class = __enable_if_bullet5<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR auto
+__invoke_constexpr(_Fp&& __f, _A0&& __a0)
+_LIBCPP_INVOKE_RETURN(__a0.get().*__f)
+
+template <class _Fp, class _A0,
+          class = __enable_if_bullet6<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _A0&& __a0)
-    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
+_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
 
-// bullet 5
+template <class _Fp, class _A0,
+          class = __enable_if_bullet6<_Fp, _A0>>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR auto
+__invoke_constexpr(_Fp&& __f, _A0&& __a0)
+_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
+
+// bullet 7
 
 template <class _Fp, class ..._Args>
-_LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _Args&& ...__args)
-    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
+_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
+
+template <class _Fp, class ..._Args>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR auto
+__invoke_constexpr(_Fp&& __f, _Args&& ...__args)
+_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
+
+#undef _LIBCPP_INVOKE_RETURN
 
 // __invokable
 
-template <class _Fp, class ..._Args>
-struct __invokable_imp
+template <class _Ret, class _Fp, class ..._Args>
+struct __invokable_r
     : private __check_complete<_Fp>
 {
-    typedef decltype(
-            __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
-                    ) type;
-    static const bool value = !is_same<type, __nat>::value;
+    using _Result = decltype(
+        _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
+
+    static const bool value =
+        conditional<
+            !is_same<_Result, __nat>::value,
+            typename conditional<
+                is_void<_Ret>::value,
+                true_type,
+                is_convertible<_Result, _Ret>
+            >::type,
+            false_type
+        >::type::value;
 };
 
 template <class _Fp, class ..._Args>
-struct __invokable
-    : public integral_constant<bool,
-          __invokable_imp<_Fp, _Args...>::value>
-{
-};
+using __invokable = __invokable_r<void, _Fp, _Args...>;
 
-// __invoke_of
+template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
+struct __nothrow_invokable_r_imp {
+  static const bool value = false;
+};
 
-template <bool _Invokable, class _Fp, class ..._Args>
-struct __invoke_of_imp  // false
+template <class _Ret, class _Fp, class ..._Args>
+struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
 {
+    typedef __nothrow_invokable_r_imp _ThisT;
+
+    template <class _Tp>
+    static void __test_noexcept(_Tp) noexcept;
+
+    static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
+        _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
 };
 
-template <class _Fp, class ..._Args>
-struct __invoke_of_imp<true, _Fp, _Args...>
+template <class _Ret, class _Fp, class ..._Args>
+struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
 {
-    typedef typename __invokable_imp<_Fp, _Args...>::type type;
+    static const bool value = noexcept(
+        _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
 };
 
+template <class _Ret, class _Fp, class ..._Args>
+using __nothrow_invokable_r =
+    __nothrow_invokable_r_imp<
+            __invokable_r<_Ret, _Fp, _Args...>::value,
+            is_void<_Ret>::value,
+            _Ret, _Fp, _Args...
+    >;
+
 template <class _Fp, class ..._Args>
 struct __invoke_of
-    : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
+    : public enable_if<
+        __invokable<_Fp, _Args...>::value,
+        typename __invokable_r<void, _Fp, _Args...>::_Result>
 {
 };
 
+// result_of
+
 template <class _Fp, class ..._Args>
 class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
     : public __invoke_of<_Fp, _Args...>
@@ -3517,7 +4402,39 @@ class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
 template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
 #endif
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+#if _LIBCPP_STD_VER > 14
+
+// is_callable
+
+template <class _Fn, class _Ret = void>
+struct _LIBCPP_TYPE_VIS_ONLY is_callable;
+
+template <class _Fn, class ..._Args, class _Ret>
+struct _LIBCPP_TYPE_VIS_ONLY is_callable<_Fn(_Args...), _Ret>
+    : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
+
+template <class _Fn, class _Ret = void>
+constexpr bool is_callable_v = is_callable<_Fn, _Ret>::value;
+
+// is_nothrow_callable
+
+template <class _Fn, class _Ret = void>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable;
+
+template <class _Fn, class ..._Args, class _Ret>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable<_Fn(_Args...), _Ret>
+    : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value>
+{};
+
+template <class _Fn, class _Ret = void>
+constexpr bool is_nothrow_callable_v = is_nothrow_callable<_Fn, _Ret>::value;
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif  // !defined(_LIBCPP_CXX03_LANG)
+
+template <class _Tp> struct __is_swappable;
+template <class _Tp> struct __is_nothrow_swappable;
 
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -3538,6 +4455,13 @@ swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
     __y = _VSTD::move(__t);
 }
 
+template<class _Tp, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<
+    __is_swappable<_Tp>::value
+>::type
+swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
+
 template <class _ForwardIterator1, class _ForwardIterator2>
 inline _LIBCPP_INLINE_VISIBILITY
 void
@@ -3553,55 +4477,103 @@ iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
 
 namespace __detail
 {
-
+// ALL generic swap overloads MUST already have a declaration available at this point.
 using _VSTD::swap;
 __nat swap(__any, __any);
 
-template <class _Tp>
-struct __swappable
+template <class _Tp, class _Up = _Tp,
+          bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
+struct __swappable_with
 {
-    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
-    static const bool value = !is_same<type, __nat>::value;
+    typedef decltype(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>())) __swap1;
+    typedef decltype(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>())) __swap2;
+
+    static const bool value = !is_same<__swap1, __nat>::value
+                           && !is_same<__swap2, __nat>::value;
+};
+
+template <class _Tp, class _Up>
+struct __swappable_with<_Tp, _Up,  false> : false_type {};
+
+template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
+struct __nothrow_swappable_with {
+  static const bool value =
+#ifndef _LIBCPP_HAS_NO_NOEXCEPT
+      noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
+  &&  noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
+#else
+      false;
+#endif
 };
 
+template <class _Tp, class _Up>
+struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
+
 }  // __detail
 
 template <class _Tp>
 struct __is_swappable
-    : public integral_constant<bool, __detail::__swappable<_Tp>::value>
+    : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
 {
 };
 
-#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
-
-template <bool, class _Tp>
-struct __is_nothrow_swappable_imp
-    : public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
-                                                   _VSTD::declval<_Tp&>()))>
+template <class _Tp>
+struct __is_nothrow_swappable
+    : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
 {
 };
 
-template <class _Tp>
-struct __is_nothrow_swappable_imp<false, _Tp>
-    : public false_type
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp, class _Up>
+struct _LIBCPP_TYPE_VIS_ONLY is_swappable_with
+    : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
 {
 };
 
 template <class _Tp>
-struct __is_nothrow_swappable
-    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_swappable
+    : public conditional<
+        __is_referenceable<_Tp>::value,
+        is_swappable_with<
+            typename add_lvalue_reference<_Tp>::type,
+            typename add_lvalue_reference<_Tp>::type>,
+        false_type
+    >::type
 {
 };
 
-#else  // __has_feature(cxx_noexcept)
+template <class _Tp, class _Up>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable_with
+    : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
+{
+};
 
 template <class _Tp>
-struct __is_nothrow_swappable
-    : public false_type
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable
+    : public conditional<
+        __is_referenceable<_Tp>::value,
+        is_nothrow_swappable_with<
+            typename add_lvalue_reference<_Tp>::type,
+            typename add_lvalue_reference<_Tp>::type>,
+        false_type
+    >::type
 {
 };
 
-#endif  // __has_feature(cxx_noexcept)
+template <class _Tp, class _Up>
+constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
+
+template <class _Tp>
+constexpr bool is_swappable_v = is_swappable<_Tp>::value;
+
+template <class _Tp, class _Up>
+constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
+
+template <class _Tp>
+constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
+
+#endif // _LIBCPP_STD_VER > 14
 
 #ifdef _LIBCPP_UNDERLYING_TYPE
 
@@ -3627,27 +4599,133 @@ struct underlying_type
 
 #endif // _LIBCPP_UNDERLYING_TYPE
 
+
+template <class _Tp, bool = std::is_enum<_Tp>::value>
+struct __sfinae_underlying_type
+{
+    typedef typename underlying_type<_Tp>::type type;
+    typedef decltype(((type)1) + 0) __promoted_type;
+};
+
+template <class _Tp>
+struct __sfinae_underlying_type<_Tp, false> {};
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __convert_to_integral(int __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned __convert_to_integral(unsigned __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+long __convert_to_integral(long __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long __convert_to_integral(unsigned long __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long __convert_to_integral(long long __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
+
+#ifndef _LIBCPP_HAS_NO_INT128
+inline _LIBCPP_INLINE_VISIBILITY
+__int128_t __convert_to_integral(__int128_t __val) { return __val; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
+#endif
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __sfinae_underlying_type<_Tp>::__promoted_type
+__convert_to_integral(_Tp __val) { return __val; }
+
 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
 
 template <class _Tp>
-struct __has_operator_addressof_imp
+struct __has_operator_addressof_member_imp
 {
+    template <class _Up>
+        static auto __test(int)
+            -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
     template <class>
-        static auto __test(__any) -> false_type;
+        static auto __test(long) -> false_type;
+
+    static const bool value = decltype(__test<_Tp>(0))::value;
+};
+
+template <class _Tp>
+struct __has_operator_addressof_free_imp
+{
     template <class _Up>
-        static auto __test(_Up* __u)
-            -> typename __select_2nd<decltype(__u->operator&()), true_type>::type;
+        static auto __test(int)
+            -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
+    template <class>
+        static auto __test(long) -> false_type;
 
-    static const bool value = decltype(__test<_Tp>(nullptr))::value;
+    static const bool value = decltype(__test<_Tp>(0))::value;
 };
 
 template <class _Tp>
 struct __has_operator_addressof
-    : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value>
+    : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
+                                  || __has_operator_addressof_free_imp<_Tp>::value>
 {};
 
 #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
 
+#if _LIBCPP_STD_VER > 14
+template <class...> using void_t = void;
+
+# ifndef _LIBCPP_HAS_NO_VARIADICS
+template <class... _Args>
+struct conjunction : __and_<_Args...> {};
+template<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value;
+
+template <class... _Args>
+struct disjunction : __or_<_Args...> {};
+template<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value;
+
+template <class _Tp>
+struct negation : __not_<_Tp> {};
+template<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
+# endif // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_STD_VER > 14
+
+// These traits are used in __tree and __hash_table
+#ifndef _LIBCPP_CXX03_LANG
+struct __extract_key_fail_tag {};
+struct __extract_key_self_tag {};
+struct __extract_key_first_tag {};
+
+template <class _ValTy, class _Key,
+          class _RawValTy = typename __unconstref<_ValTy>::type>
+struct __can_extract_key
+    : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
+                  __extract_key_fail_tag>::type {};
+
+template <class _Pair, class _Key, class _First, class _Second>
+struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
+    : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
+                  __extract_key_first_tag, __extract_key_fail_tag>::type {};
+
+// __can_extract_map_key uses true_type/false_type instead of the tags.
+// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
+// and _ValTy == _Key.
+template <class _ValTy, class _Key, class _ContainerValueTy,
+          class _RawValTy = typename __unconstref<_ValTy>::type>
+struct __can_extract_map_key
+    : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
+
+// This specialization returns __extract_key_fail_tag for non-map containers
+// because _Key == _ContainerValueTy
+template <class _ValTy, class _Key, class _RawValTy>
+struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
+    : false_type {};
+
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_TYPE_TRAITS
diff --git a/system/include/libcxx/unordered_map b/system/include/libcxx/unordered_map
index 0fa87d19ad035..319c71e11fbd0 100644
--- a/system/include/libcxx/unordered_map
+++ b/system/include/libcxx/unordered_map
@@ -122,7 +122,25 @@ public:
         void insert(InputIterator first, InputIterator last);
     void insert(initializer_list<value_type>);
 
+    template <class... Args>
+        pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
+    template <class... Args>
+        pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
+    template <class... Args>
+        iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
+    template <class... Args>
+        iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
+    template <class M>
+        pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
+    template <class M>
+        pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
+    template <class M>
+        iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
+    template <class M>
+        iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
+
     iterator erase(const_iterator position);
+    iterator erase(iterator position);  // C++14
     size_type erase(const key_type& k);
     iterator erase(const_iterator first, const_iterator last);
     void clear() noexcept;
@@ -287,6 +305,7 @@ public:
     void insert(initializer_list<value_type>);
 
     iterator erase(const_iterator position);
+    iterator erase(iterator position);  // C++14
     size_type erase(const key_type& k);
     iterator erase(const_iterator first, const_iterator last);
     void clear() noexcept;
@@ -350,6 +369,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
 #include <__hash_table>
 #include <functional>
 #include <stdexcept>
+#include <tuple>
 
 #include <__debug>
 
@@ -359,10 +379,8 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <class _Key, class _Cp, class _Hash, bool = is_empty<_Hash>::value
-#if __has_feature(is_final)
-                                         && !__is_final(_Hash)
-#endif
+template <class _Key, class _Cp, class _Hash,
+          bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value
          >
 class __unordered_map_hasher
     : private _Hash
@@ -384,13 +402,18 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(const _Key& __x) const
         {return static_cast<const _Hash&>(*this)(__x);}
+    void swap(__unordered_map_hasher&__y)
+        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
+    {
+        using _VSTD::swap;
+        swap(static_cast<const _Hash&>(*this), static_cast<const _Hash&>(__y));
+    }
 };
 
 template <class _Key, class _Cp, class _Hash>
 class __unordered_map_hasher<_Key, _Cp, _Hash, false>
 {
     _Hash __hash_;
-
 public:
     _LIBCPP_INLINE_VISIBILITY
     __unordered_map_hasher()
@@ -408,12 +431,26 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(const _Key& __x) const
         {return __hash_(__x);}
+    void swap(__unordered_map_hasher&__y)
+        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
+    {
+        using _VSTD::swap;
+        swap(__hash_, __y.__hash_);
+    }
 };
 
-template <class _Key, class _Cp, class _Pred, bool = is_empty<_Pred>::value
-#if __has_feature(is_final)
-                                         && !__is_final(_Pred)
-#endif
+template <class _Key, class _Cp, class _Hash, bool __b>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,
+     __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Key, class _Cp, class _Pred,
+          bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
          >
 class __unordered_map_equal
     : private _Pred
@@ -438,13 +475,18 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Key& __x, const _Cp& __y) const
         {return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
+    void swap(__unordered_map_equal&__y)
+        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
+    {
+        using _VSTD::swap;
+        swap(static_cast<const _Pred&>(*this), static_cast<const _Pred&>(__y));
+    }
 };
 
 template <class _Key, class _Cp, class _Pred>
 class __unordered_map_equal<_Key, _Cp, _Pred, false>
 {
     _Pred __pred_;
-
 public:
     _LIBCPP_INLINE_VISIBILITY
     __unordered_map_equal()
@@ -465,19 +507,34 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Key& __x, const _Cp& __y) const
         {return __pred_(__x, __y.__cc.first);}
+    void swap(__unordered_map_equal&__y)
+        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
+    {
+        using _VSTD::swap;
+        swap(__pred_, __y.__pred_);
+    }
 };
 
+template <class _Key, class _Cp, class _Pred, bool __b>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x,
+     __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
 template <class _Alloc>
 class __hash_map_node_destructor
 {
     typedef _Alloc                              allocator_type;
     typedef allocator_traits<allocator_type>    __alloc_traits;
-    typedef typename __alloc_traits::value_type::value_type value_type;
+
 public:
-    typedef typename __alloc_traits::pointer    pointer;
+
+    typedef typename __alloc_traits::pointer       pointer;
 private:
-    typedef typename value_type::value_type::first_type     first_type;
-    typedef typename value_type::value_type::second_type    second_type;
 
     allocator_type& __na_;
 
@@ -527,8 +584,7 @@ public:
     }
 };
 
-#if __cplusplus >= 201103L
-
+#ifndef _LIBCPP_CXX03_LANG
 template <class _Key, class _Tp>
 union __hash_value_type
 {
@@ -540,29 +596,31 @@ union __hash_value_type
     value_type __cc;
     __nc_value_type __nc;
 
-    template <class ..._Args>
-    _LIBCPP_INLINE_VISIBILITY
-    __hash_value_type(_Args&& ...__args)
-        : __cc(std::forward<_Args>(__args)...) {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    __hash_value_type(const __hash_value_type& __v)
-        : __cc(__v.__cc) {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    __hash_value_type(__hash_value_type&& __v)
-        : __nc(std::move(__v.__nc)) {}
-
     _LIBCPP_INLINE_VISIBILITY
     __hash_value_type& operator=(const __hash_value_type& __v)
         {__nc = __v.__cc; return *this;}
 
     _LIBCPP_INLINE_VISIBILITY
     __hash_value_type& operator=(__hash_value_type&& __v)
-        {__nc = std::move(__v.__nc); return *this;}
+        {__nc = _VSTD::move(__v.__nc); return *this;}
 
+    template <class _ValueTp,
+              class = typename enable_if<
+                    __is_same_uncvref<_ValueTp, value_type>::value
+                 >::type
+             >
     _LIBCPP_INLINE_VISIBILITY
-    ~__hash_value_type() {__cc.~value_type();}
+    __hash_value_type& operator=(_ValueTp&& __v) {
+        __nc = _VSTD::forward<_ValueTp>(__v); return *this;
+    }
+
+private:
+    __hash_value_type(const __hash_value_type& __v) = delete;
+    __hash_value_type(__hash_value_type&& __v) = delete;
+    template <class ..._Args>
+    explicit __hash_value_type(_Args&& ...__args) = delete;
+
+    ~__hash_value_type() = delete;
 };
 
 #else
@@ -576,18 +634,8 @@ struct __hash_value_type
 
     value_type __cc;
 
-    _LIBCPP_INLINE_VISIBILITY
-    __hash_value_type() {}
-
-    template <class _A0>
-    _LIBCPP_INLINE_VISIBILITY
-    __hash_value_type(const _A0& __a0)
-        : __cc(__a0) {}
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    __hash_value_type(const _A0& __a0, const _A1& __a1)
-        : __cc(__a0, __a1) {}
+private:
+   ~__hash_value_type();
 };
 
 #endif
@@ -597,21 +645,14 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator
 {
     _HashIterator __i_;
 
-    typedef pointer_traits<typename _HashIterator::pointer>      __pointer_traits;
-    typedef const typename _HashIterator::value_type::value_type::first_type key_type;
-    typedef typename _HashIterator::value_type::value_type::second_type      mapped_type;
+    typedef  __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
+
 public:
     typedef forward_iterator_tag                                 iterator_category;
-    typedef pair<key_type, mapped_type>                          value_type;
-    typedef typename _HashIterator::difference_type              difference_type;
+    typedef typename _NodeTypes::__map_value_type                value_type;
+    typedef typename _NodeTypes::difference_type                 difference_type;
     typedef value_type&                                          reference;
-    typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<value_type>
-#else
-            rebind<value_type>::other
-#endif
-                                                                 pointer;
+    typedef typename _NodeTypes::__map_value_type_pointer       pointer;
 
     _LIBCPP_INLINE_VISIBILITY
     __hash_map_iterator() _NOEXCEPT {}
@@ -653,21 +694,14 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator
 {
     _HashIterator __i_;
 
-    typedef pointer_traits<typename _HashIterator::pointer>      __pointer_traits;
-    typedef const typename _HashIterator::value_type::value_type::first_type key_type;
-    typedef typename _HashIterator::value_type::value_type::second_type      mapped_type;
+    typedef  __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
+
 public:
     typedef forward_iterator_tag                                 iterator_category;
-    typedef pair<key_type, mapped_type>                          value_type;
-    typedef typename _HashIterator::difference_type              difference_type;
+    typedef typename _NodeTypes::__map_value_type                value_type;
+    typedef typename _NodeTypes::difference_type                 difference_type;
     typedef const value_type&                                    reference;
-    typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind<const value_type>
-#else
-            rebind<const value_type>::other
-#endif
-                                                                 pointer;
+    typedef typename _NodeTypes::__const_map_value_type_pointer  pointer;
 
     _LIBCPP_INLINE_VISIBILITY
     __hash_map_const_iterator() _NOEXCEPT {}
@@ -730,19 +764,15 @@ private:
     typedef __hash_value_type<key_type, mapped_type>                 __value_type;
     typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
     typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
-    typedef typename allocator_traits<allocator_type>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__value_type>
-#else
-            rebind_alloc<__value_type>::other
-#endif
-                                                           __allocator_type;
+    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+                                                 __value_type>::type __allocator_type;
 
     typedef __hash_table<__value_type, __hasher,
                          __key_equal,  __allocator_type>   __table;
 
     __table __table_;
 
+    typedef typename __table::_NodeTypes                   _NodeTypes;
     typedef typename __table::__node_pointer               __node_pointer;
     typedef typename __table::__node_const_pointer         __node_const_pointer;
     typedef typename __table::__node_traits                __node_traits;
@@ -751,11 +781,14 @@ private:
     typedef __hash_map_node_destructor<__node_allocator>   _Dp;
     typedef unique_ptr<__node, _Dp>                         __node_holder;
     typedef allocator_traits<allocator_type>               __alloc_traits;
+
+    static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
+    static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
 public:
     typedef typename __alloc_traits::pointer         pointer;
     typedef typename __alloc_traits::const_pointer   const_pointer;
-    typedef typename __alloc_traits::size_type       size_type;
-    typedef typename __alloc_traits::difference_type difference_type;
+    typedef typename __table::size_type              size_type;
+    typedef typename __table::difference_type        difference_type;
 
     typedef __hash_map_iterator<typename __table::iterator>       iterator;
     typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
@@ -786,10 +819,12 @@ public:
                       size_type __n, const hasher& __hf,
                       const key_equal& __eql,
                       const allocator_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
     explicit unordered_map(const allocator_type& __a);
     unordered_map(const unordered_map& __u);
     unordered_map(const unordered_map& __u, const allocator_type& __a);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     unordered_map(unordered_map&& __u)
         _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
     unordered_map(unordered_map&& __u, const allocator_type& __a);
@@ -845,10 +880,12 @@ public:
         return *this;
     }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     unordered_map& operator=(unordered_map&& __u)
         _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
 #endif
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
     unordered_map& operator=(initializer_list<value_type> __il);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
@@ -876,79 +913,168 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     const_iterator cend()   const _NOEXCEPT {return __table_.end();}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> insert(const value_type& __x)
+        {return __table_.__insert_unique(__x);}
 
-    template <class... _Args>
-        pair<iterator, bool> emplace(_Args&&... __args);
+    iterator insert(const_iterator __p, const value_type& __x) {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+            "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
+            " referring to this unordered_map");
+#endif
+        return insert(__x).first;
+    }
 
-    template <class... _Args>
+    template <class _InputIterator>
         _LIBCPP_INLINE_VISIBILITY
+        void insert(_InputIterator __first, _InputIterator __last);
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    void insert(initializer_list<value_type> __il)
+        {insert(__il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_CXX03_LANG
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> insert(value_type&& __x)
+        {return __table_.__insert_unique(_VSTD::move(__x));}
+
+    iterator insert(const_iterator __p, value_type&& __x) {
 #if _LIBCPP_DEBUG_LEVEL >= 2
-        iterator emplace_hint(const_iterator __p, _Args&&... __args)
-        {
-            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
-                "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
-                " referring to this unordered_map");
-            return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
-        }
-#else
-        iterator emplace_hint(const_iterator, _Args&&... __args)
-            {return emplace(_VSTD::forward<_Args>(__args)...).first;}
+        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+            "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
+            " referring to this unordered_map");
 #endif
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    _LIBCPP_INLINE_VISIBILITY
-    pair<iterator, bool> insert(const value_type& __x)
-        {return __table_.__insert_unique(__x);}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        return __table_.__insert_unique(_VSTD::move(__x)).first;
+    }
+
     template <class _Pp,
               class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
         _LIBCPP_INLINE_VISIBILITY
         pair<iterator, bool> insert(_Pp&& __x)
             {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    _LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL >= 2
-    iterator insert(const_iterator __p, const value_type& __x)
-        {
-            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
-                "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
-                " referring to this unordered_map");
-            return insert(__x).first;
-        }
-#else
-    iterator insert(const_iterator, const value_type& __x)
-        {return insert(__x).first;}
-#endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
     template <class _Pp,
               class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
         _LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL >= 2
         iterator insert(const_iterator __p, _Pp&& __x)
         {
+#if _LIBCPP_DEBUG_LEVEL >= 2
             _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
                 "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
                 " referring to this unordered_map");
+#endif
             return insert(_VSTD::forward<_Pp>(__x)).first;
         }
-#else
-        iterator insert(const_iterator, _Pp&& __x)
-            {return insert(_VSTD::forward<_Pp>(__x)).first;}
-#endif
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    template <class _InputIterator>
-        void insert(_InputIterator __first, _InputIterator __last);
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    template <class... _Args>
     _LIBCPP_INLINE_VISIBILITY
-    void insert(initializer_list<value_type> __il)
-        {insert(__il.begin(), __il.end());}
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    pair<iterator, bool> emplace(_Args&&... __args) {
+        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
+    }
+
+    template <class... _Args>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator emplace_hint(const_iterator __p, _Args&&... __args) {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+            "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
+            " referring to this unordered_map");
+#endif
+        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
+    }
+
+#endif  // _LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER > 14
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
+    {
+        return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
+            _VSTD::forward_as_tuple(__k),
+            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+    }
+
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
+    {
+        return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
+            _VSTD::forward_as_tuple(_VSTD::move(__k)),
+            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+    }
+
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+            "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
+            " referring to this unordered_map");
+#endif
+            return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
+    }
+
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+            "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
+            " referring to this unordered_map");
+#endif
+        return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
+    }
+
+    template <class _Vp>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
+    {
+        pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
+            __k, _VSTD::forward<_Vp>(__v));
+        if (!__res.second) {
+            __res.first->second = _VSTD::forward<_Vp>(__v);
+        }
+        return __res;
+    }
+
+    template <class _Vp>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
+    {
+        pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
+            _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
+        if (!__res.second) {
+            __res.first->second = _VSTD::forward<_Vp>(__v);
+        }
+        return __res;
+    }
+
+    template <class _Vp>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
+     {
+          return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first;
+     }
+
+    template <class _Vp>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
+     {
+        return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first;
+     }
+#endif
 
     _LIBCPP_INLINE_VISIBILITY
     iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
     _LIBCPP_INLINE_VISIBILITY
+    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
     size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
     _LIBCPP_INLINE_VISIBILITY
     iterator erase(const_iterator __first, const_iterator __last)
@@ -982,7 +1108,7 @@ public:
         {return __table_.__equal_range_unique(__k);}
 
     mapped_type& operator[](const key_type& __k);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
     mapped_type& operator[](key_type&& __k);
 #endif
 
@@ -1038,18 +1164,10 @@ public:
 #endif  // _LIBCPP_DEBUG_LEVEL >= 2
 
 private:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    __node_holder __construct_node();
-    template <class _A0>
-        __node_holder
-         __construct_node(_A0&& __a0);
-    __node_holder __construct_node_with_key(key_type&& __k);
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-    template <class _A0, class _A1, class ..._Args>
-        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifdef _LIBCPP_CXX03_LANG
     __node_holder __construct_node_with_key(const key_type& __k);
+#endif
 };
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1076,7 +1194,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
 }
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
         const allocator_type& __a)
     : __table_(__a)
@@ -1152,7 +1270,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
         unordered_map&& __u)
     _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
@@ -1175,10 +1293,10 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
     if (__a != __u.get_allocator())
     {
         iterator __i = __u.begin();
-        while (__u.size() != 0)
-            __table_.__insert_unique(
-                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
-                                    );
+        while (__u.size() != 0) {
+            __table_.__emplace_unique(_VSTD::move(
+                __u.__table_.remove((__i++).__i_)->__value_.__nc));
+        }
     }
 #if _LIBCPP_DEBUG_LEVEL >= 2
     else
@@ -1231,7 +1349,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
     _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
@@ -1245,7 +1363,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
         initializer_list<value_type> __il)
@@ -1256,81 +1374,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
 
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
-{
-    __node_allocator& __na = __table_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_));
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class _A0>
-typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
-{
-    __node_allocator& __na = __table_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
-                             _VSTD::forward<_A0>(__a0));
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_type&& __k)
-{
-    __node_allocator& __na = __table_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
-    __h.get_deleter().__first_constructed = true;
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class _A0, class _A1, class ..._Args>
-typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0,
-                                                                 _A1&& __a1,
-                                                                 _Args&&... __args)
-{
-    __node_allocator& __na = __table_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
-                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
-                             _VSTD::forward<_Args>(__args)...);
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class... _Args>
-pair<typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator, bool>
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
-    if (__r.second)
-        __h.release();
-    return __r;
-}
-
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
+#ifdef _LIBCPP_CXX03_LANG
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
@@ -1341,12 +1385,13 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const
     __h.get_deleter().__first_constructed = true;
     __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
     __h.get_deleter().__second_constructed = true;
-    return _VSTD::move(__h);  // explicitly moved for C++03
+    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
+#endif
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
                                                        _InputIterator __last)
@@ -1355,6 +1400,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
         __table_.__insert_unique(*__first);
 }
 
+#ifdef _LIBCPP_CXX03_LANG
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
 _Tp&
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
@@ -1367,23 +1413,27 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
     __h.release();
     return __r.first->second;
 }
+#else
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+_Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
+{
+    return __table_.__emplace_unique_key_args(__k,
+        std::piecewise_construct, std::forward_as_tuple(__k),
+                                  std::forward_as_tuple()).first->__cc.second;
+}
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
 _Tp&
 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
 {
-    iterator __i = find(__k);
-    if (__i != end())
-        return __i->second;
-    __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
-    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
-    __h.release();
-    return __r.first->second;
+    return __table_.__emplace_unique_key_args(__k,
+        std::piecewise_construct, std::forward_as_tuple(std::move(__k)),
+                                  std::forward_as_tuple()).first->__cc.second;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // !_LIBCPP_CXX03_MODE
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
 _Tp&
@@ -1469,30 +1519,29 @@ private:
     typedef __hash_value_type<key_type, mapped_type>                 __value_type;
     typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
     typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
-    typedef typename allocator_traits<allocator_type>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind_alloc<__value_type>
-#else
-            rebind_alloc<__value_type>::other
-#endif
-                                                           __allocator_type;
+    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+                                                 __value_type>::type __allocator_type;
 
     typedef __hash_table<__value_type, __hasher,
                          __key_equal,  __allocator_type>   __table;
 
     __table __table_;
 
+    typedef typename __table::_NodeTypes                   _NodeTypes;
     typedef typename __table::__node_traits                __node_traits;
     typedef typename __table::__node_allocator             __node_allocator;
     typedef typename __table::__node                       __node;
     typedef __hash_map_node_destructor<__node_allocator>   _Dp;
     typedef unique_ptr<__node, _Dp>                         __node_holder;
     typedef allocator_traits<allocator_type>               __alloc_traits;
+    static_assert((is_same<typename __node_traits::size_type,
+                          typename __alloc_traits::size_type>::value),
+                 "Allocator uses different size_type for different types");
 public:
     typedef typename __alloc_traits::pointer         pointer;
     typedef typename __alloc_traits::const_pointer   const_pointer;
-    typedef typename __alloc_traits::size_type       size_type;
-    typedef typename __alloc_traits::difference_type difference_type;
+    typedef typename __table::size_type              size_type;
+    typedef typename __table::difference_type        difference_type;
 
     typedef __hash_map_iterator<typename __table::iterator>       iterator;
     typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
@@ -1523,10 +1572,12 @@ public:
                       size_type __n, const hasher& __hf,
                       const key_equal& __eql,
                       const allocator_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
     explicit unordered_multimap(const allocator_type& __a);
     unordered_multimap(const unordered_multimap& __u);
     unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     unordered_multimap(unordered_multimap&& __u)
         _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
     unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
@@ -1583,10 +1634,12 @@ public:
         return *this;
     }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     unordered_multimap& operator=(unordered_multimap&& __u)
         _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
 #endif
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
     unordered_multimap& operator=(initializer_list<value_type> __il);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
@@ -1614,46 +1667,60 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     const_iterator cend()   const _NOEXCEPT {return __table_.end();}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
-    template <class... _Args>
-        iterator emplace(_Args&&... __args);
-
-    template <class... _Args>
-        iterator emplace_hint(const_iterator __p, _Args&&... __args);
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    template <class _Pp,
-              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
-        _LIBCPP_INLINE_VISIBILITY
-        iterator insert(_Pp&& __x)
-            {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
     _LIBCPP_INLINE_VISIBILITY
     iterator insert(const_iterator __p, const value_type& __x)
         {return __table_.__insert_multi(__p.__i_, __x);}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    template <class _Pp,
-              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
-        _LIBCPP_INLINE_VISIBILITY
-        iterator insert(const_iterator __p, _Pp&& __x)
-            {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
     template <class _InputIterator>
-        void insert(_InputIterator __first, _InputIterator __last);
+    _LIBCPP_INLINE_VISIBILITY
+    void insert(_InputIterator __first, _InputIterator __last);
+
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     _LIBCPP_INLINE_VISIBILITY
     void insert(initializer_list<value_type> __il)
         {insert(__il.begin(), __il.end());}
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
+#ifndef _LIBCPP_CXX03_LANG
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, value_type&& __x)
+        {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));}
+
+    template <class _Pp,
+              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(_Pp&& __x)
+        {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
+
+    template <class _Pp,
+              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, _Pp&& __x)
+        {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
+
+    template <class... _Args>
+    iterator emplace(_Args&&... __args) {
+        return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
+    }
+
+    template <class... _Args>
+    iterator emplace_hint(const_iterator __p, _Args&&... __args) {
+        return __table_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
+    }
+#endif  // _LIBCPP_CXX03_LANG
+
+
     _LIBCPP_INLINE_VISIBILITY
     iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
     _LIBCPP_INLINE_VISIBILITY
+    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
     size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
     _LIBCPP_INLINE_VISIBILITY
     iterator erase(const_iterator __first, const_iterator __last)
@@ -1735,17 +1802,7 @@ public:
 
 #endif  // _LIBCPP_DEBUG_LEVEL >= 2
 
-private:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    __node_holder __construct_node();
-    template <class _A0>
-        __node_holder
-         __construct_node(_A0&& __a0);
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-    template <class _A0, class _A1, class ..._Args>
-        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
 };
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1811,7 +1868,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
 }
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
         const allocator_type& __a)
     : __table_(__a)
@@ -1848,7 +1905,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
         unordered_multimap&& __u)
     _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
@@ -1874,7 +1931,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
         while (__u.size() != 0)
         {
             __table_.__insert_multi(
-                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
+                      _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_.__nc)
                                    );
         }
     }
@@ -1929,7 +1986,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
     _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
@@ -1943,7 +2000,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multima
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
         initializer_list<value_type> __il)
@@ -1954,81 +2011,11 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
 
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
-unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
-{
-    __node_allocator& __na = __table_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_));
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class _A0>
-typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
-unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
-{
-    __node_allocator& __na = __table_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
-                             _VSTD::forward<_A0>(__a0));
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-#ifndef _LIBCPP_HAS_NO_VARIADICS
 
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class _A0, class _A1, class ..._Args>
-typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
-unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(
-        _A0&& __a0, _A1&& __a1, _Args&&... __args)
-{
-    __node_allocator& __na = __table_.__node_alloc();
-    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
-                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
-                             _VSTD::forward<_Args>(__args)...);
-    __h.get_deleter().__first_constructed = true;
-    __h.get_deleter().__second_constructed = true;
-    return __h;
-}
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class... _Args>
-typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator
-unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-    iterator __r = __table_.__node_insert_multi(__h.get());
-    __h.release();
-    return __r;
-}
-
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class... _Args>
-typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator
-unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace_hint(
-        const_iterator __p, _Args&&... __args)
-{
-    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-    iterator __r = __table_.__node_insert_multi(__p.__i_, __h.get());
-    __h.release();
-    return __r;
-}
-
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
                                                             _InputIterator __last)
diff --git a/system/include/libcxx/unordered_set b/system/include/libcxx/unordered_set
index d06629fdcd47f..fb38b648a86a6 100644
--- a/system/include/libcxx/unordered_set
+++ b/system/include/libcxx/unordered_set
@@ -114,16 +114,15 @@ public:
     void insert(initializer_list<value_type>);
 
     iterator erase(const_iterator position);
+    iterator erase(iterator position);  // C++14
     size_type erase(const key_type& k);
     iterator erase(const_iterator first, const_iterator last);
     void clear() noexcept;
 
     void swap(unordered_set&)
-        noexcept(
-            (!allocator_type::propagate_on_container_swap::value ||
-             __is_nothrow_swappable<allocator_type>::value) &&
-            __is_nothrow_swappable<hasher>::value &&
-            __is_nothrow_swappable<key_equal>::value);
+       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
+                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
 
     hasher hash_function() const;
     key_equal key_eq() const;
@@ -263,16 +262,15 @@ public:
     void insert(initializer_list<value_type>);
 
     iterator erase(const_iterator position);
+    iterator erase(iterator position);  // C++14
     size_type erase(const key_type& k);
     iterator erase(const_iterator first, const_iterator last);
     void clear() noexcept;
 
     void swap(unordered_multiset&)
-        noexcept(
-            (!allocator_type::propagate_on_container_swap::value ||
-             __is_nothrow_swappable<allocator_type>::value) &&
-            __is_nothrow_swappable<hasher>::value &&
-            __is_nothrow_swappable<key_equal>::value);
+       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
+                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
 
     hasher hash_function() const;
     key_equal key_eq() const;
@@ -406,10 +404,12 @@ public:
                       size_type __n, const hasher& __hf, const allocator_type& __a)
             : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
 #endif
+    _LIBCPP_INLINE_VISIBILITY
     explicit unordered_set(const allocator_type& __a);
     unordered_set(const unordered_set& __u);
     unordered_set(const unordered_set& __u, const allocator_type& __a);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     unordered_set(unordered_set&& __u)
         _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
     unordered_set(unordered_set&& __u, const allocator_type& __a);
@@ -441,10 +441,12 @@ public:
         return *this;
     }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     unordered_set& operator=(unordered_set&& __u)
         _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
 #endif
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
     unordered_set& operator=(initializer_list<value_type> __il);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
@@ -529,6 +531,7 @@ public:
 #endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
         void insert(_InputIterator __first, _InputIterator __last);
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     _LIBCPP_INLINE_VISIBILITY
@@ -680,7 +683,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
 }
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
         const allocator_type& __a)
     : __table_(__a)
@@ -717,7 +720,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
         unordered_set&& __u)
     _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
@@ -794,7 +797,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_set<_Value, _Hash, _Pred, _Alloc>&
 unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
     _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
@@ -808,7 +811,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_set<_Value, _Hash, _Pred, _Alloc>&
 unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
         initializer_list<value_type> __il)
@@ -821,7 +824,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
                                                     _InputIterator __last)
@@ -942,10 +945,12 @@ public:
                        size_type __n, const hasher& __hf, const allocator_type& __a)
         : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
 #endif
+    _LIBCPP_INLINE_VISIBILITY
     explicit unordered_multiset(const allocator_type& __a);
     unordered_multiset(const unordered_multiset& __u);
     unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     unordered_multiset(unordered_multiset&& __u)
         _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
     unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
@@ -975,6 +980,7 @@ public:
         return *this;
     }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     unordered_multiset& operator=(unordered_multiset&& __u)
         _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
 #endif
@@ -1031,6 +1037,7 @@ public:
         {return __table_.__insert_multi(__p, _VSTD::move(__x));}
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
         void insert(_InputIterator __first, _InputIterator __last);
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     _LIBCPP_INLINE_VISIBILITY
@@ -1183,7 +1190,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
 }
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
         const allocator_type& __a)
     : __table_(__a)
@@ -1220,7 +1227,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
         unordered_multiset&& __u)
     _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
@@ -1297,7 +1304,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
 unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
         unordered_multiset&& __u)
@@ -1325,7 +1332,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
                                                          _InputIterator __last)
diff --git a/system/include/libcxx/utility b/system/include/libcxx/utility
index 4eafda41696b9..27b81a0305e58 100644
--- a/system/include/libcxx/utility
+++ b/system/include/libcxx/utility
@@ -52,6 +52,9 @@ template <class T>
     >::type
     move_if_noexcept(T& x) noexcept; // constexpr in C++14
 
+template <class T> constexpr add_const<T>_t& as_const(T& t) noexcept;      // C++17
+template <class T>                      void as_const(const T&&) = delete; // C++17
+
 template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
 
 template <class T1, class T2>
@@ -79,8 +82,8 @@ struct pair
                                        is_nothrow_move_assignable<T2>::value);
     template <class U, class V> pair& operator=(pair<U, V>&& p);
 
-    void swap(pair& p) noexcept(noexcept(swap(first, p.first)) &&
-                                noexcept(swap(second, p.second)));
+    void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> &&
+                                is_nothrow_swappable_v<T2>);
 };
 
 template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
@@ -110,22 +113,41 @@ template<size_t I, class T1, class T2>
     get(pair<T1, T2>&) noexcept; // constexpr in C++14
 
 template<size_t I, class T1, class T2>
-    const typename const tuple_element<I, pair<T1, T2> >::type&
+    const typename tuple_element<I, pair<T1, T2> >::type&
     get(const pair<T1, T2>&) noexcept; // constexpr in C++14
 
 template<size_t I, class T1, class T2>
     typename tuple_element<I, pair<T1, T2> >::type&&
     get(pair<T1, T2>&&) noexcept; // constexpr in C++14
 
+template<size_t I, class T1, class T2>
+    const typename tuple_element<I, pair<T1, T2> >::type&&
+    get(const pair<T1, T2>&&) noexcept; // constexpr in C++14
+
 template<class T1, class T2>
     constexpr T1& get(pair<T1, T2>&) noexcept; // C++14
 
-template<size_t I, class T1, class T2>
-    constexpr T1 const& get(pair<T1, T2> const &) noexcept; // C++14
+template<class T1, class T2>
+    constexpr const T1& get(const pair<T1, T2>&) noexcept; // C++14
 
-template<size_t I, class T1, class T2>
+template<class T1, class T2>
     constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14
 
+template<class T1, class T2>
+    constexpr const T1&& get(const pair<T1, T2>&&) noexcept; // C++14
+
+template<class T1, class T2>
+    constexpr T1& get(pair<T2, T1>&) noexcept; // C++14
+
+template<class T1, class T2>
+    constexpr const T1& get(const pair<T2, T1>&) noexcept; // C++14
+
+template<class T1, class T2>
+    constexpr T1&& get(pair<T2, T1>&&) noexcept; // C++14
+
+template<class T1, class T2>
+    constexpr const T1&& get(const pair<T2, T1>&&) noexcept; // C++14
+
 // C++14
 
 template<class T, T... I>
@@ -156,6 +178,7 @@ template<class T, class U=T>
 #include <__config>
 #include <__tuple>
 #include <type_traits>
+#include <initializer_list>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -202,19 +225,23 @@ operator>=(const _Tp& __x, const _Tp& __y)
 
 // swap_ranges
 
+
 template <class _ForwardIterator1, class _ForwardIterator2>
 inline _LIBCPP_INLINE_VISIBILITY
 _ForwardIterator2
 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
 {
-    for(; __first1 != __last1; ++__first1, ++__first2)
+    for(; __first1 != __last1; ++__first1, (void) ++__first2)
         swap(*__first1, *__first2);
     return __first2;
 }
 
+// forward declared in <type_traits>
 template<class _Tp, size_t _Np>
 inline _LIBCPP_INLINE_VISIBILITY
-void
+typename enable_if<
+    __is_swappable<_Tp>::value
+>::type
 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
 {
     _VSTD::swap_ranges(__a, __a + _Np, __b);
@@ -237,6 +264,11 @@ move_if_noexcept(_Tp& __x) _NOEXCEPT
     return _VSTD::move(__x);
 }
 
+#if _LIBCPP_STD_VER > 14
+template <class _Tp> constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; }
+template <class _Tp>                        void as_const(const _Tp&&) = delete;
+#endif
+
 struct _LIBCPP_TYPE_VIS_ONLY piecewise_construct_t { };
 #if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY)
 extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
@@ -256,6 +288,12 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
     // pair(const pair&) = default;
     // pair(pair&&) = default;
 
+#ifndef _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
+    template <bool _Dummy = true, class = typename enable_if<
+        __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
+        __dependent_type<is_default_constructible<_T2>, _Dummy>::value
+      >::type>
+#endif
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -383,8 +421,9 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
     swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
                                __is_nothrow_swappable<second_type>::value)
     {
-        _VSTD::iter_swap(&first, &__p.first);
-        _VSTD::iter_swap(&second, &__p.second);
+        using _VSTD::swap;
+        swap(first,  __p.first);
+        swap(second, __p.second);
     }
 private:
 
@@ -462,7 +501,6 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
-template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
 
 template <class _Tp>
 struct __make_pair_return_impl
@@ -507,10 +545,6 @@ template <class _T1, class _T2>
   class _LIBCPP_TYPE_VIS_ONLY tuple_size<pair<_T1, _T2> >
     : public integral_constant<size_t, 2> {};
 
-template <class _T1, class _T2>
-  class _LIBCPP_TYPE_VIS_ONLY tuple_size<const pair<_T1, _T2> >
-    : public integral_constant<size_t, 2> {};
-
 template <class _T1, class _T2>
 class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> >
 {
@@ -525,20 +559,6 @@ public:
     typedef _T2 type;
 };
 
-template <class _T1, class _T2>
-class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, const pair<_T1, _T2> >
-{
-public:
-    typedef const _T1 type;
-};
-
-template <class _T1, class _T2>
-class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, const pair<_T1, _T2> >
-{
-public:
-    typedef const _T2 type;
-};
-
 template <size_t _Ip> struct __get_pair;
 
 template <>
@@ -564,6 +584,12 @@ struct __get_pair<0>
     _T1&&
     get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
 
+    template <class _T1, class _T2>
+    static
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    const _T1&&
+    get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);}
+
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 };
 
@@ -590,6 +616,12 @@ struct __get_pair<1>
     _T2&&
     get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
 
+    template <class _T1, class _T2>
+    static
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    const _T2&&
+    get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T2>(__p.second);}
+
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 };
 
@@ -619,6 +651,14 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT
     return __get_pair<_Ip>::get(_VSTD::move(__p));
 }
 
+template <size_t _Ip, class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(const pair<_T1, _T2>&& __p) _NOEXCEPT
+{
+    return __get_pair<_Ip>::get(_VSTD::move(__p));
+}
+
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 #if _LIBCPP_STD_VER > 11
@@ -643,6 +683,13 @@ constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT
     return __get_pair<0>::get(_VSTD::move(__p));
 }
 
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const && get(pair<_T1, _T2> const&& __p) _NOEXCEPT
+{
+    return __get_pair<0>::get(_VSTD::move(__p));
+}
+
 template <class _T1, class _T2>
 inline _LIBCPP_INLINE_VISIBILITY
 constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT
@@ -664,6 +711,13 @@ constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT
     return __get_pair<1>::get(_VSTD::move(__p));
 }
 
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT
+{
+    return __get_pair<1>::get(_VSTD::move(__p));
+}
+
 #endif
 
 #if _LIBCPP_STD_VER > 11
@@ -684,6 +738,16 @@ struct _LIBCPP_TYPE_VIS_ONLY integer_sequence
 template<size_t... _Ip>
     using index_sequence = integer_sequence<size_t, _Ip...>;
 
+#if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
+
+template <class _Tp, _Tp _Ep>
+struct __make_integer_sequence
+{
+    typedef __make_integer_seq<integer_sequence, _Tp, _Ep> type;
+};
+
+#else
+
 namespace __detail {
 
 template<typename _Tp, size_t ..._Extra> struct __repeat;
@@ -737,10 +801,14 @@ struct __make_integer_sequence
 {
     static_assert(is_integral<_Tp>::value,
                   "std::make_integer_sequence can only be instantiated with an integral type" );
-    static_assert(0 <= _Ep, "std::make_integer_sequence input shall not be negative");
-    typedef __make_integer_sequence_unchecked<_Tp, _Ep> type;
+    static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length");
+    // Workaround GCC bug by preventing bad installations when 0 <= _Ep
+    // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929
+    typedef __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type;
 };
 
+#endif
+
 template<class _Tp, _Tp _Np>
     using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type;
 
diff --git a/system/include/libcxx/valarray b/system/include/libcxx/valarray
index 2b942046db9df..bde644e8719b6 100644
--- a/system/include/libcxx/valarray
+++ b/system/include/libcxx/valarray
@@ -348,6 +348,7 @@ template <class T> unspecified2 end(const valarray<T>& v);
 #include <new>
 
 #include <__undef_min_max>
+#include <__undef___deallocate>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -801,11 +802,14 @@ public:
     // construct/destroy:
     _LIBCPP_INLINE_VISIBILITY
     valarray() : __begin_(0), __end_(0) {}
-    explicit valarray(size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
+    inline explicit valarray(size_t __n);
+    _LIBCPP_INLINE_VISIBILITY
     valarray(const value_type& __x, size_t __n);
     valarray(const value_type* __p, size_t __n);
     valarray(const valarray& __v);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     valarray(valarray&& __v) _NOEXCEPT;
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -815,22 +819,31 @@ public:
     valarray(const gslice_array<value_type>& __ga);
     valarray(const mask_array<value_type>& __ma);
     valarray(const indirect_array<value_type>& __ia);
+    inline _LIBCPP_INLINE_VISIBILITY
     ~valarray();
 
     // assignment:
     valarray& operator=(const valarray& __v);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator=(valarray&& __v) _NOEXCEPT;
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator=(initializer_list<value_type>);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator=(const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator=(const slice_array<value_type>& __sa);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator=(const gslice_array<value_type>& __ga);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator=(const mask_array<value_type>& __ma);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator=(const indirect_array<value_type>& __ia);
     template <class _ValExpr>
+        _LIBCPP_INLINE_VISIBILITY
         valarray& operator=(const __val_expr<_ValExpr>& __v);
 
     // element access:
@@ -841,24 +854,38 @@ public:
     value_type&       operator[](size_t __i)       {return __begin_[__i];}
 
     // subset operations:
+    _LIBCPP_INLINE_VISIBILITY
     __val_expr<__slice_expr<const valarray&> >    operator[](slice __s) const;
+    _LIBCPP_INLINE_VISIBILITY
     slice_array<value_type>                       operator[](slice __s);
+    _LIBCPP_INLINE_VISIBILITY
     __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
+    _LIBCPP_INLINE_VISIBILITY
     gslice_array<value_type>   operator[](const gslice& __gs);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
+    _LIBCPP_INLINE_VISIBILITY
     gslice_array<value_type>                      operator[](gslice&& __gs);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     __val_expr<__mask_expr<const valarray&> >     operator[](const valarray<bool>& __vb) const;
+    _LIBCPP_INLINE_VISIBILITY
     mask_array<value_type>                        operator[](const valarray<bool>& __vb);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     __val_expr<__mask_expr<const valarray&> >     operator[](valarray<bool>&& __vb) const;
+    _LIBCPP_INLINE_VISIBILITY
     mask_array<value_type>                        operator[](valarray<bool>&& __vb);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
+    _LIBCPP_INLINE_VISIBILITY
     indirect_array<value_type>                    operator[](const valarray<size_t>& __vs);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
+    _LIBCPP_INLINE_VISIBILITY
     indirect_array<value_type>                    operator[](valarray<size_t>&& __vs);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
@@ -869,15 +896,25 @@ public:
     valarray<bool> operator!() const;
 
     // computed assignment:
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator*= (const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator/= (const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator%= (const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator+= (const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator-= (const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator^= (const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator&= (const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator|= (const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator<<=(const value_type& __x);
+    _LIBCPP_INLINE_VISIBILITY
     valarray& operator>>=(const value_type& __x);
 
     template <class _Expr>
@@ -886,6 +923,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator*= (const _Expr& __v);
 
     template <class _Expr>
@@ -894,6 +932,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator/= (const _Expr& __v);
 
     template <class _Expr>
@@ -902,6 +941,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator%= (const _Expr& __v);
 
     template <class _Expr>
@@ -910,6 +950,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator+= (const _Expr& __v);
 
     template <class _Expr>
@@ -918,6 +959,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator-= (const _Expr& __v);
 
     template <class _Expr>
@@ -926,6 +968,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator^= (const _Expr& __v);
 
     template <class _Expr>
@@ -934,6 +977,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator|= (const _Expr& __v);
 
     template <class _Expr>
@@ -942,6 +986,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator&= (const _Expr& __v);
 
     template <class _Expr>
@@ -950,6 +995,7 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator<<= (const _Expr& __v);
 
     template <class _Expr>
@@ -958,16 +1004,21 @@ public:
         __is_val_expr<_Expr>::value,
         valarray&
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator>>= (const _Expr& __v);
 
     // member functions:
+    _LIBCPP_INLINE_VISIBILITY
     void swap(valarray& __v) _NOEXCEPT;
 
     _LIBCPP_INLINE_VISIBILITY
     size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
 
+    _LIBCPP_INLINE_VISIBILITY
     value_type sum() const;
+    _LIBCPP_INLINE_VISIBILITY
     value_type min() const;
+    _LIBCPP_INLINE_VISIBILITY
     value_type max() const;
 
     valarray shift (int __i) const;
@@ -1113,6 +1164,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1121,6 +1173,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator*=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1129,6 +1182,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator/=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1137,6 +1191,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator%=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1145,6 +1200,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator+=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1153,6 +1209,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator-=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1161,6 +1218,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator^=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1169,6 +1227,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator&=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1177,6 +1236,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator|=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1185,6 +1245,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator<<=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1193,10 +1254,13 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator>>=(const _Expr& __v) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     const slice_array& operator=(const slice_array& __sa) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     void operator=(const value_type& __x) const;
 
 private:
@@ -1212,7 +1276,7 @@ private:
 };
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 const slice_array<_Tp>&
 slice_array<_Tp>::operator=(const slice_array& __sa) const
 {
@@ -1225,7 +1289,7 @@ slice_array<_Tp>::operator=(const slice_array& __sa) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1240,7 +1304,7 @@ slice_array<_Tp>::operator=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1255,7 +1319,7 @@ slice_array<_Tp>::operator*=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1270,7 +1334,7 @@ slice_array<_Tp>::operator/=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1285,7 +1349,7 @@ slice_array<_Tp>::operator%=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1300,7 +1364,7 @@ slice_array<_Tp>::operator+=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1315,7 +1379,7 @@ slice_array<_Tp>::operator-=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1330,7 +1394,7 @@ slice_array<_Tp>::operator^=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1345,7 +1409,7 @@ slice_array<_Tp>::operator&=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1360,7 +1424,7 @@ slice_array<_Tp>::operator|=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1375,7 +1439,7 @@ slice_array<_Tp>::operator<<=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1389,7 +1453,7 @@ slice_array<_Tp>::operator>>=(const _Expr& __v) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 slice_array<_Tp>::operator=(const value_type& __x) const
 {
@@ -1483,6 +1547,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1491,6 +1556,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator*=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1499,6 +1565,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator/=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1507,6 +1574,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator%=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1515,6 +1583,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator+=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1523,6 +1592,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator-=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1531,6 +1601,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator^=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1539,6 +1610,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator&=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1547,6 +1619,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator|=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1555,6 +1628,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator<<=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1563,10 +1637,13 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator>>=(const _Expr& __v) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     const gslice_array& operator=(const gslice_array& __ga) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     void operator=(const value_type& __x) const;
 
 //  gslice_array(const gslice_array&)            = default;
@@ -1575,20 +1652,16 @@ public:
 //  gslice_array& operator=(gslice_array&&)      = default;
 
 private:
-    _LIBCPP_INLINE_VISIBILITY
     gslice_array(const gslice& __gs, const valarray<value_type>& __v)
         : __vp_(const_cast<value_type*>(__v.__begin_)),
           __1d_(__gs.__1d_)
         {}
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-    _LIBCPP_INLINE_VISIBILITY
     gslice_array(gslice&& __gs, const valarray<value_type>& __v)
         : __vp_(const_cast<value_type*>(__v.__begin_)),
           __1d_(move(__gs.__1d_))
         {}
-
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
     template <class> friend class valarray;
@@ -1596,7 +1669,7 @@ private:
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1612,7 +1685,7 @@ gslice_array<_Tp>::operator=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1628,7 +1701,7 @@ gslice_array<_Tp>::operator*=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1644,7 +1717,7 @@ gslice_array<_Tp>::operator/=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1660,7 +1733,7 @@ gslice_array<_Tp>::operator%=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1676,7 +1749,7 @@ gslice_array<_Tp>::operator+=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1692,7 +1765,7 @@ gslice_array<_Tp>::operator-=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1708,7 +1781,7 @@ gslice_array<_Tp>::operator^=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1724,7 +1797,7 @@ gslice_array<_Tp>::operator&=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1740,7 +1813,7 @@ gslice_array<_Tp>::operator|=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1756,7 +1829,7 @@ gslice_array<_Tp>::operator<<=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1771,7 +1844,7 @@ gslice_array<_Tp>::operator>>=(const _Expr& __v) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 const gslice_array<_Tp>&
 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
 {
@@ -1784,7 +1857,7 @@ gslice_array<_Tp>::operator=(const gslice_array& __ga) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 gslice_array<_Tp>::operator=(const value_type& __x) const
 {
@@ -1812,6 +1885,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1820,6 +1894,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator*=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1828,6 +1903,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator/=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1836,6 +1912,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator%=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1844,6 +1921,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator+=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1852,6 +1930,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator-=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1860,6 +1939,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator^=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1868,6 +1948,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator&=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1876,6 +1957,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator|=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1884,6 +1966,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator<<=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -1892,10 +1975,13 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator>>=(const _Expr& __v) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     const mask_array& operator=(const mask_array& __ma) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     void operator=(const value_type& __x) const;
 
 //  mask_array(const mask_array&)            = default;
@@ -1920,7 +2006,7 @@ private:
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1935,7 +2021,7 @@ mask_array<_Tp>::operator=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1950,7 +2036,7 @@ mask_array<_Tp>::operator*=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1965,7 +2051,7 @@ mask_array<_Tp>::operator/=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1980,7 +2066,7 @@ mask_array<_Tp>::operator%=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -1995,7 +2081,7 @@ mask_array<_Tp>::operator+=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2010,7 +2096,7 @@ mask_array<_Tp>::operator-=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2025,7 +2111,7 @@ mask_array<_Tp>::operator^=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2040,7 +2126,7 @@ mask_array<_Tp>::operator&=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2055,7 +2141,7 @@ mask_array<_Tp>::operator|=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2070,7 +2156,7 @@ mask_array<_Tp>::operator<<=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2084,7 +2170,7 @@ mask_array<_Tp>::operator>>=(const _Expr& __v) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 const mask_array<_Tp>&
 mask_array<_Tp>::operator=(const mask_array& __ma) const
 {
@@ -2095,7 +2181,7 @@ mask_array<_Tp>::operator=(const mask_array& __ma) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 mask_array<_Tp>::operator=(const value_type& __x) const
 {
@@ -2157,6 +2243,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2165,6 +2252,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator*=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2173,6 +2261,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator/=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2181,6 +2270,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator%=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2189,6 +2279,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator+=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2197,6 +2288,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator-=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2205,6 +2297,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator^=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2213,6 +2306,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator&=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2221,6 +2315,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator|=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2229,6 +2324,7 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator<<=(const _Expr& __v) const;
 
     template <class _Expr>
@@ -2237,10 +2333,13 @@ public:
         __is_val_expr<_Expr>::value,
         void
     >::type
+    _LIBCPP_INLINE_VISIBILITY
     operator>>=(const _Expr& __v) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     const indirect_array& operator=(const indirect_array& __ia) const;
 
+    _LIBCPP_INLINE_VISIBILITY
     void operator=(const value_type& __x) const;
 
 //  indirect_array(const indirect_array&)            = default;
@@ -2270,7 +2369,7 @@ private:
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2285,7 +2384,7 @@ indirect_array<_Tp>::operator=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2300,7 +2399,7 @@ indirect_array<_Tp>::operator*=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2315,7 +2414,7 @@ indirect_array<_Tp>::operator/=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2330,7 +2429,7 @@ indirect_array<_Tp>::operator%=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2345,7 +2444,7 @@ indirect_array<_Tp>::operator+=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2360,7 +2459,7 @@ indirect_array<_Tp>::operator-=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2375,7 +2474,7 @@ indirect_array<_Tp>::operator^=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2390,7 +2489,7 @@ indirect_array<_Tp>::operator&=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2405,7 +2504,7 @@ indirect_array<_Tp>::operator|=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2420,7 +2519,7 @@ indirect_array<_Tp>::operator<<=(const _Expr& __v) const
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -2434,7 +2533,7 @@ indirect_array<_Tp>::operator>>=(const _Expr& __v) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 const indirect_array<_Tp>&
 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
 {
@@ -2447,7 +2546,7 @@ indirect_array<_Tp>::operator=(const indirect_array& __ia) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 indirect_array<_Tp>::operator=(const value_type& __x) const
 {
@@ -2649,7 +2748,7 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
 // valarray
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>::valarray(size_t __n)
     : __begin_(0),
       __end_(0)
@@ -2658,7 +2757,7 @@ valarray<_Tp>::valarray(size_t __n)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
     : __begin_(0),
       __end_(0)
@@ -2719,7 +2818,7 @@ valarray<_Tp>::valarray(const valarray& __v)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
     : __begin_(__v.__begin_),
       __end_(__v.__end_)
@@ -2873,7 +2972,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>::~valarray()
 {
     resize(0);
@@ -2895,7 +2994,7 @@ valarray<_Tp>::operator=(const valarray& __v)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
 {
@@ -2912,7 +3011,7 @@ valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator=(initializer_list<value_type> __il)
 {
@@ -2925,7 +3024,7 @@ valarray<_Tp>::operator=(initializer_list<value_type> __il)
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator=(const value_type& __x)
 {
@@ -2934,7 +3033,7 @@ valarray<_Tp>::operator=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
 {
@@ -2946,7 +3045,7 @@ valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
 {
@@ -2960,7 +3059,7 @@ valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
 {
@@ -2974,7 +3073,7 @@ valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
 {
@@ -2989,7 +3088,7 @@ valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
 
 template <class _Tp>
 template <class _ValExpr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
 {
@@ -3003,7 +3102,7 @@ valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __val_expr<__slice_expr<const valarray<_Tp>&> >
 valarray<_Tp>::operator[](slice __s) const
 {
@@ -3011,7 +3110,7 @@ valarray<_Tp>::operator[](slice __s) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 slice_array<_Tp>
 valarray<_Tp>::operator[](slice __s)
 {
@@ -3019,7 +3118,7 @@ valarray<_Tp>::operator[](slice __s)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __val_expr<__indirect_expr<const valarray<_Tp>&> >
 valarray<_Tp>::operator[](const gslice& __gs) const
 {
@@ -3027,7 +3126,7 @@ valarray<_Tp>::operator[](const gslice& __gs) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 gslice_array<_Tp>
 valarray<_Tp>::operator[](const gslice& __gs)
 {
@@ -3037,7 +3136,7 @@ valarray<_Tp>::operator[](const gslice& __gs)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __val_expr<__indirect_expr<const valarray<_Tp>&> >
 valarray<_Tp>::operator[](gslice&& __gs) const
 {
@@ -3045,7 +3144,7 @@ valarray<_Tp>::operator[](gslice&& __gs) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 gslice_array<_Tp>
 valarray<_Tp>::operator[](gslice&& __gs)
 {
@@ -3055,7 +3154,7 @@ valarray<_Tp>::operator[](gslice&& __gs)
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __val_expr<__mask_expr<const valarray<_Tp>&> >
 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
 {
@@ -3063,7 +3162,7 @@ valarray<_Tp>::operator[](const valarray<bool>& __vb) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 mask_array<_Tp>
 valarray<_Tp>::operator[](const valarray<bool>& __vb)
 {
@@ -3073,7 +3172,7 @@ valarray<_Tp>::operator[](const valarray<bool>& __vb)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __val_expr<__mask_expr<const valarray<_Tp>&> >
 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
 {
@@ -3081,7 +3180,7 @@ valarray<_Tp>::operator[](valarray<bool>&& __vb) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 mask_array<_Tp>
 valarray<_Tp>::operator[](valarray<bool>&& __vb)
 {
@@ -3091,7 +3190,7 @@ valarray<_Tp>::operator[](valarray<bool>&& __vb)
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __val_expr<__indirect_expr<const valarray<_Tp>&> >
 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
 {
@@ -3099,7 +3198,7 @@ valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 indirect_array<_Tp>
 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
 {
@@ -3109,7 +3208,7 @@ valarray<_Tp>::operator[](const valarray<size_t>& __vs)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __val_expr<__indirect_expr<const valarray<_Tp>&> >
 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
 {
@@ -3117,7 +3216,7 @@ valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 indirect_array<_Tp>
 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
 {
@@ -3195,7 +3294,7 @@ valarray<_Tp>::operator!() const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator*=(const value_type& __x)
 {
@@ -3205,7 +3304,7 @@ valarray<_Tp>::operator*=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator/=(const value_type& __x)
 {
@@ -3215,7 +3314,7 @@ valarray<_Tp>::operator/=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator%=(const value_type& __x)
 {
@@ -3225,7 +3324,7 @@ valarray<_Tp>::operator%=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator+=(const value_type& __x)
 {
@@ -3235,7 +3334,7 @@ valarray<_Tp>::operator+=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator-=(const value_type& __x)
 {
@@ -3245,7 +3344,7 @@ valarray<_Tp>::operator-=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator^=(const value_type& __x)
 {
@@ -3255,7 +3354,7 @@ valarray<_Tp>::operator^=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator&=(const value_type& __x)
 {
@@ -3265,7 +3364,7 @@ valarray<_Tp>::operator&=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator|=(const value_type& __x)
 {
@@ -3275,7 +3374,7 @@ valarray<_Tp>::operator|=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator<<=(const value_type& __x)
 {
@@ -3285,7 +3384,7 @@ valarray<_Tp>::operator<<=(const value_type& __x)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 valarray<_Tp>&
 valarray<_Tp>::operator>>=(const value_type& __x)
 {
@@ -3296,7 +3395,7 @@ valarray<_Tp>::operator>>=(const value_type& __x)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3312,7 +3411,7 @@ valarray<_Tp>::operator*=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3328,7 +3427,7 @@ valarray<_Tp>::operator/=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3344,7 +3443,7 @@ valarray<_Tp>::operator%=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3360,7 +3459,7 @@ valarray<_Tp>::operator+=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3376,7 +3475,7 @@ valarray<_Tp>::operator-=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3392,7 +3491,7 @@ valarray<_Tp>::operator^=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3408,7 +3507,7 @@ valarray<_Tp>::operator|=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3424,7 +3523,7 @@ valarray<_Tp>::operator&=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3440,7 +3539,7 @@ valarray<_Tp>::operator<<=(const _Expr& __v)
 
 template <class _Tp>
 template <class _Expr>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename enable_if
 <
     __is_val_expr<_Expr>::value,
@@ -3455,7 +3554,7 @@ valarray<_Tp>::operator>>=(const _Expr& __v)
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
 {
@@ -3464,7 +3563,7 @@ valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _Tp
 valarray<_Tp>::sum() const
 {
@@ -3478,7 +3577,7 @@ valarray<_Tp>::sum() const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _Tp
 valarray<_Tp>::min() const
 {
@@ -3488,7 +3587,7 @@ valarray<_Tp>::min() const
 }
 
 template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 _Tp
 valarray<_Tp>::max() const
 {
diff --git a/system/include/libcxx/vector b/system/include/libcxx/vector
index cd9aab3246536..81c514ee6b78b 100644
--- a/system/include/libcxx/vector
+++ b/system/include/libcxx/vector
@@ -51,8 +51,8 @@ public:
     vector& operator=(const vector& x);
     vector& operator=(vector&& x)
         noexcept(
-             allocator_type::propagate_on_container_move_assignment::value &&
-             is_nothrow_move_assignable<allocator_type>::value);
+             allocator_type::propagate_on_container_move_assignment::value ||
+             allocator_type::is_always_equal::value); // C++17
     vector& operator=(initializer_list<value_type> il);
     template <class InputIterator>
         void assign(InputIterator first, InputIterator last);
@@ -119,8 +119,8 @@ public:
     void resize(size_type sz, const value_type& c);
 
     void swap(vector&)
-        noexcept(!allocator_type::propagate_on_container_swap::value ||
-                 __is_nothrow_swappable<allocator_type>::value);
+        noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
+                 allocator_traits<allocator_type>::is_always_equal::value);  // C++17
 
     bool __invariants() const;
 };
@@ -175,8 +175,8 @@ public:
     vector& operator=(const vector& x);
     vector& operator=(vector&& x)
         noexcept(
-             allocator_type::propagate_on_container_move_assignment::value &&
-             is_nothrow_move_assignable<allocator_type>::value);
+             allocator_type::propagate_on_container_move_assignment::value ||
+             allocator_type::is_always_equal::value); // C++17
     vector& operator=(initializer_list<value_type> il);
     template <class InputIterator>
         void assign(InputIterator first, InputIterator last);
@@ -237,8 +237,8 @@ public:
     void resize(size_type sz, value_type x);
 
     void swap(vector&)
-        noexcept(!allocator_type::propagate_on_container_swap::value ||
-                 __is_nothrow_swappable<allocator_type>::value);
+        noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
+                 allocator_traits<allocator_type>::is_always_equal::value);  // C++17
     void flip() noexcept;
 
     bool __invariants() const;
@@ -262,6 +262,7 @@ void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
 */
 
 #include <__config>
+#include <iosfwd> // for forward declaration of vector
 #include <__bit_reference>
 #include <type_traits>
 #include <climits>
@@ -385,14 +386,6 @@ protected:
             is_nothrow_move_assignable<allocator_type>::value)
         {__move_assign_alloc(__c, integral_constant<bool,
                       __alloc_traits::propagate_on_container_move_assignment::value>());}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type& __x, allocator_type& __y)
-        _NOEXCEPT_(
-            !__alloc_traits::propagate_on_container_swap::value ||
-            __is_nothrow_swappable<allocator_type>::value)
-        {__swap_alloc(__x, __y, integral_constant<bool,
-                      __alloc_traits::propagate_on_container_swap::value>());}
 private:
     _LIBCPP_INLINE_VISIBILITY
     void __copy_assign_alloc(const __vector_base& __c, true_type)
@@ -421,18 +414,6 @@ private:
     void __move_assign_alloc(__vector_base&, false_type)
         _NOEXCEPT
         {}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type)
-        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
-        {
-            using _VSTD::swap;
-            swap(__x, __y);
-        }
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(allocator_type&, allocator_type&, false_type)
-        _NOEXCEPT
-        {}
 };
 
 template <class _Tp, class _Allocator>
@@ -473,7 +454,7 @@ __vector_base<_Tp, _Allocator>::~__vector_base()
     }
 }
 
-template <class _Tp, class _Allocator = allocator<_Tp> >
+template <class _Tp, class _Allocator /* = allocator<_Tp> */>
 class _LIBCPP_TYPE_VIS_ONLY vector
     : private __vector_base<_Tp, _Allocator>
 {
@@ -500,14 +481,18 @@ public:
                   "Allocator::value_type must be same type as value_type");
 
     _LIBCPP_INLINE_VISIBILITY
-    vector()
-        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+    vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
         {
 #if _LIBCPP_DEBUG_LEVEL >= 2
             __get_db()->__insert_c(this);
 #endif
         }
     _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+        _NOEXCEPT
+#endif
         : __base(__a)
     {
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -569,14 +554,16 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     vector(vector&& __x)
+#if _LIBCPP_STD_VER > 14
+        _NOEXCEPT;
+#else
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#endif
     _LIBCPP_INLINE_VISIBILITY
     vector(vector&& __x, const allocator_type& __a);
     _LIBCPP_INLINE_VISIBILITY
     vector& operator=(vector&& __x)
-        _NOEXCEPT_(
-             __alloc_traits::propagate_on_container_move_assignment::value &&
-             is_nothrow_move_assignable<allocator_type>::value);
+        _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     _LIBCPP_INLINE_VISIBILITY
@@ -699,9 +686,11 @@ public:
     _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
 #ifndef _LIBCPP_HAS_NO_VARIADICS
     template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
         void emplace_back(_Args&&... __args);
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     void pop_back();
 
     iterator insert(const_iterator __position, const_reference __x);
@@ -756,8 +745,12 @@ public:
     void resize(size_type __sz, const_reference __x);
 
     void swap(vector&)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value);
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT;
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value);
+#endif
 
     bool __invariants() const;
 
@@ -776,6 +769,7 @@ private:
     void deallocate() _NOEXCEPT;
     _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
     void __construct_at_end(size_type __n);
+    _LIBCPP_INLINE_VISIBILITY
     void __construct_at_end(size_type __n, const_reference __x);
     template <class _ForwardIterator>
         typename enable_if
@@ -783,7 +777,7 @@ private:
             __is_forward_iterator<_ForwardIterator>::value,
             void
         >::type
-        __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+        __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
     void __append(size_type __n);
     void __append(size_type __n, const_reference __x);
     _LIBCPP_INLINE_VISIBILITY
@@ -795,7 +789,8 @@ private:
     void __move_range(pointer __from_s, pointer __from_e, pointer __to);
     void __move_assign(vector& __c, true_type)
         _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
-    void __move_assign(vector& __c, false_type);
+    void __move_assign(vector& __c, false_type)
+        _NOEXCEPT_(__alloc_traits::is_always_equal::value);
     _LIBCPP_INLINE_VISIBILITY
     void __destruct_at_end(pointer __new_last) _NOEXCEPT
     {
@@ -868,17 +863,17 @@ private:
     // but if an exception is thrown after that the annotation has to be undone.
     struct __RAII_IncreaseAnnotator {
       __RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1)
-        : __commit(false), __v(__v), __n(__n) {
+        : __commit(false), __v(__v), __old_size(__v.size() + __n) {
         __v.__annotate_increase(__n);
       }
       void __done() { __commit = true; }
       ~__RAII_IncreaseAnnotator() {
         if (__commit) return;
-        __v.__annotate_shrink(__v.size() + __n);
+        __v.__annotate_shrink(__old_size);
       }
       bool __commit;
-      size_type __n;
       const vector &__v;
+      size_type __old_size;
     };
 #else
     struct __RAII_IncreaseAnnotator {
@@ -999,7 +994,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
 //  Postcondition:  size() == old size() + __n
 //  Postcondition:  [i] == __x for all i in [size() - __n, __n)
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
 {
@@ -1021,16 +1016,12 @@ typename enable_if
     __is_forward_iterator<_ForwardIterator>::value,
     void
 >::type
-vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
+vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
 {
     allocator_type& __a = this->__alloc();
-    for (; __first != __last; ++__first)
-    {
-        __RAII_IncreaseAnnotator __annotator(*this);
-        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
-        __annotator.__done();
-        ++this->__end_;
-    }
+    __RAII_IncreaseAnnotator __annotator(*this, __n);
+    __alloc_traits::__construct_range_forward(__a, __first, __last, this->__end_);
+    __annotator.__done();
 }
 
 //  Default constructs __n objects starting at __end_
@@ -1177,7 +1168,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
     if (__n > 0)
     {
         allocate(__n);
-        __construct_at_end(__first, __last);
+        __construct_at_end(__first, __last, __n);
     }
 }
 
@@ -1197,7 +1188,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
     if (__n > 0)
     {
         allocate(__n);
-        __construct_at_end(__first, __last);
+        __construct_at_end(__first, __last, __n);
     }
 }
 
@@ -1212,7 +1203,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
     if (__n > 0)
     {
         allocate(__n);
-        __construct_at_end(__x.__begin_, __x.__end_);
+        __construct_at_end(__x.__begin_, __x.__end_, __n);
     }
 }
 
@@ -1227,7 +1218,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
     if (__n > 0)
     {
         allocate(__n);
-        __construct_at_end(__x.__begin_, __x.__end_);
+        __construct_at_end(__x.__begin_, __x.__end_, __n);
     }
 }
 
@@ -1236,7 +1227,11 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
 template <class _Tp, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>::vector(vector&& __x)
+#if _LIBCPP_STD_VER > 14
+        _NOEXCEPT
+#else
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#endif
     : __base(_VSTD::move(__x.__alloc()))
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1286,7 +1281,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
     if (__il.size() > 0)
     {
         allocate(__il.size());
-        __construct_at_end(__il.begin(), __il.end());
+        __construct_at_end(__il.begin(), __il.end(), __il.size());
     }
 }
 
@@ -1301,7 +1296,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
     if (__il.size() > 0)
     {
         allocate(__il.size());
-        __construct_at_end(__il.begin(), __il.end());
+        __construct_at_end(__il.begin(), __il.end(), __il.size());
     }
 }
 
@@ -1311,9 +1306,7 @@ template <class _Tp, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>&
 vector<_Tp, _Allocator>::operator=(vector&& __x)
-        _NOEXCEPT_(
-             __alloc_traits::propagate_on_container_move_assignment::value &&
-             is_nothrow_move_assignable<allocator_type>::value)
+    _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
 {
     __move_assign(__x, integral_constant<bool,
           __alloc_traits::propagate_on_container_move_assignment::value>());
@@ -1323,6 +1316,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)
 template <class _Tp, class _Allocator>
 void
 vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
+    _NOEXCEPT_(__alloc_traits::is_always_equal::value)
 {
     if (__base::__alloc() != __c.__alloc())
     {
@@ -1394,12 +1388,12 @@ typename enable_if
 >::type
 vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
 {
-    typename iterator_traits<_ForwardIterator>::difference_type __new_size = _VSTD::distance(__first, __last);
-    if (static_cast<size_type>(__new_size) <= capacity())
+    size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last));
+    if (__new_size <= capacity())
     {
         _ForwardIterator __mid = __last;
         bool __growing = false;
-        if (static_cast<size_type>(__new_size) > size())
+        if (__new_size > size())
         {
             __growing = true;
             __mid =  __first;
@@ -1407,15 +1401,15 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
         }
         pointer __m = _VSTD::copy(__first, __mid, this->__begin_);
         if (__growing)
-            __construct_at_end(__mid, __last);
+            __construct_at_end(__mid, __last, __new_size - size());
         else
             this->__destruct_at_end(__m);
     }
     else
     {
         deallocate();
-        allocate(__recommend(static_cast<size_type>(__new_size)));
-        __construct_at_end(__first, __last);
+        allocate(__recommend(__new_size));
+        __construct_at_end(__first, __last, __new_size);
     }
 }
 
@@ -1637,7 +1631,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
 
 template <class _Tp, class _Allocator>
 template <class... _Args>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
 {
@@ -1658,7 +1652,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 vector<_Tp, _Allocator>::pop_back()
 {
@@ -1861,7 +1855,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
             }
             if (__n > 0)
             {
-                __RAII_IncreaseAnnotator __annotator(*this);
+                __RAII_IncreaseAnnotator __annotator(*this, __n);
                 __move_range(__p, __old_last, __p + __old_n);
                 __annotator.__done();
                 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
@@ -1905,9 +1899,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
     pointer __old_last = this->__end_;
     for (; this->__end_ != this->__end_cap() && __first != __last; ++__first)
     {
+        __RAII_IncreaseAnnotator __annotator(*this);
         __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_),
                                   *__first);
         ++this->__end_;
+        __annotator.__done();
     }
     __split_buffer<value_type, allocator_type&> __v(__a);
     if (__first != __last)
@@ -1967,8 +1963,9 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
             if (__n > __dx)
             {
                 __m = __first;
-                _VSTD::advance(__m, this->__end_ - __p);
-                __construct_at_end(__m, __last);
+                difference_type __diff = this->__end_ - __p;
+                _VSTD::advance(__m, __diff);
+                __construct_at_end(__m, __last, __n - __diff);
                 __n = __dx;
             }
             if (__n > 0)
@@ -2015,8 +2012,12 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
 template <class _Tp, class _Allocator>
 void
 vector<_Tp, _Allocator>::swap(vector& __x)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value)
+#if _LIBCPP_STD_VER >= 14
+    _NOEXCEPT
+#else
+    _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                __is_nothrow_swappable<allocator_type>::value)
+#endif
 {
     _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
                    this->__alloc() == __x.__alloc(),
@@ -2025,7 +2026,8 @@ vector<_Tp, _Allocator>::swap(vector& __x)
     _VSTD::swap(this->__begin_, __x.__begin_);
     _VSTD::swap(this->__end_, __x.__end_);
     _VSTD::swap(this->__end_cap(), __x.__end_cap());
-    __base::__swap_alloc(this->__alloc(), __x.__alloc());
+    __swap_allocator(this->__alloc(), __x.__alloc(), 
+        integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
 #if _LIBCPP_DEBUG_LEVEL >= 2
     __get_db()->swap(this, &__x);
 #endif  // _LIBCPP_DEBUG_LEVEL >= 2
@@ -2128,13 +2130,7 @@ public:
     typedef _VSTD::reverse_iterator<const_iterator>   const_reverse_iterator;
 
 private:
-    typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-                rebind_alloc<__storage_type>
-#else
-                rebind_alloc<__storage_type>::other
-#endif
-                                                     __storage_allocator;
+    typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;
     typedef allocator_traits<__storage_allocator>    __storage_traits;
     typedef typename __storage_traits::pointer       __storage_pointer;
     typedef typename __storage_traits::const_pointer __const_storage_pointer;
@@ -2170,9 +2166,14 @@ private:
 
 public:
     _LIBCPP_INLINE_VISIBILITY
-    vector()
-        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
-    _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a);
+    vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+
+    _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
+#else
+        _NOEXCEPT;
+#endif
     ~vector();
     explicit vector(size_type __n);
 #if _LIBCPP_STD_VER > 11
@@ -2206,13 +2207,15 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     vector(vector&& __v)
+#if _LIBCPP_STD_VER > 14
+        _NOEXCEPT;
+#else
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#endif
     vector(vector&& __v, const allocator_type& __a);
     _LIBCPP_INLINE_VISIBILITY
     vector& operator=(vector&& __v)
-        _NOEXCEPT_(
-             __alloc_traits::propagate_on_container_move_assignment::value &&
-             is_nothrow_move_assignable<allocator_type>::value);
+        _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     _LIBCPP_INLINE_VISIBILITY
@@ -2354,8 +2357,13 @@ public:
     void clear() _NOEXCEPT {__size_ = 0;}
 
     void swap(vector&)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value);
+#if _LIBCPP_STD_VER >= 14
+        _NOEXCEPT;
+#else
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                    __is_nothrow_swappable<allocator_type>::value);
+#endif
+    static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
 
     void resize(size_type __sz, value_type __x = false);
     void flip() _NOEXCEPT;
@@ -2433,26 +2441,6 @@ private:
         _NOEXCEPT
         {}
 
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__storage_allocator& __x, __storage_allocator& __y)
-        _NOEXCEPT_(
-            !__storage_traits::propagate_on_container_swap::value ||
-            __is_nothrow_swappable<allocator_type>::value)
-        {__swap_alloc(__x, __y, integral_constant<bool,
-                      __storage_traits::propagate_on_container_swap::value>());}
-
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__storage_allocator& __x, __storage_allocator& __y, true_type)
-        _NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value)
-        {
-            using _VSTD::swap;
-            swap(__x, __y);
-        }
-    _LIBCPP_INLINE_VISIBILITY
-    static void __swap_alloc(__storage_allocator&, __storage_allocator&, false_type)
-        _NOEXCEPT
-        {}
-
     size_t __hash_code() const _NOEXCEPT;
 
     friend class __bit_reference<vector>;
@@ -2559,7 +2547,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
 template <class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<bool, _Allocator>::vector()
-        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+    _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
     : __begin_(nullptr),
       __size_(0),
       __cap_alloc_(0)
@@ -2569,6 +2557,11 @@ vector<bool, _Allocator>::vector()
 template <class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<bool, _Allocator>::vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+        _NOEXCEPT
+#endif
     : __begin_(nullptr),
       __size_(0),
       __cap_alloc_(0, static_cast<__storage_allocator>(__a))
@@ -2807,7 +2800,11 @@ vector<bool, _Allocator>::operator=(const vector& __v)
 template <class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<bool, _Allocator>::vector(vector&& __v)
+#if _LIBCPP_STD_VER > 14
+        _NOEXCEPT
+#else
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#endif
     : __begin_(__v.__begin_),
       __size_(__v.__size_),
       __cap_alloc_(__v.__cap_alloc_)
@@ -2842,9 +2839,7 @@ template <class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<bool, _Allocator>&
 vector<bool, _Allocator>::operator=(vector&& __v)
-        _NOEXCEPT_(
-             __alloc_traits::propagate_on_container_move_assignment::value &&
-             is_nothrow_move_assignable<allocator_type>::value)
+    _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
 {
     __move_assign(__v, integral_constant<bool,
           __storage_traits::propagate_on_container_move_assignment::value>());
@@ -3150,13 +3145,18 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
 template <class _Allocator>
 void
 vector<bool, _Allocator>::swap(vector& __x)
-        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
-                   __is_nothrow_swappable<allocator_type>::value)
+#if _LIBCPP_STD_VER >= 14
+    _NOEXCEPT
+#else
+    _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+                __is_nothrow_swappable<allocator_type>::value)
+#endif
 {
     _VSTD::swap(this->__begin_, __x.__begin_);
     _VSTD::swap(this->__size_, __x.__size_);
     _VSTD::swap(this->__cap(), __x.__cap());
-    __swap_alloc(this->__alloc(), __x.__alloc());
+    __swap_allocator(this->__alloc(), __x.__alloc(), 
+        integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
 }
 
 template <class _Allocator>
diff --git a/system/include/libcxx/wchar.h b/system/include/libcxx/wchar.h
new file mode 100644
index 0000000000000..c0c6ef754fbeb
--- /dev/null
+++ b/system/include/libcxx/wchar.h
@@ -0,0 +1,175 @@
+// -*- C++ -*-
+//===--------------------------- wchar.h ----------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__need_wint_t) || defined(__need_mbstate_t)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <wchar.h>
+
+#elif !defined(_LIBCPP_WCHAR_H)
+#define _LIBCPP_WCHAR_H
+
+/*
+    wchar.h synopsis
+
+Macros:
+
+    NULL
+    WCHAR_MAX
+    WCHAR_MIN
+    WEOF
+
+Types:
+
+    mbstate_t
+    size_t
+    tm
+    wint_t
+
+int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
+int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
+int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
+int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
+int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
+int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);  // C99
+int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
+int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg);  // C99
+int vwprintf(const wchar_t* restrict format, va_list arg);
+int vwscanf(const wchar_t* restrict format, va_list arg);  // C99
+int wprintf(const wchar_t* restrict format, ...);
+int wscanf(const wchar_t* restrict format, ...);
+wint_t fgetwc(FILE* stream);
+wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
+wint_t fputwc(wchar_t c, FILE* stream);
+int fputws(const wchar_t* restrict s, FILE* restrict stream);
+int fwide(FILE* stream, int mode);
+wint_t getwc(FILE* stream);
+wint_t getwchar();
+wint_t putwc(wchar_t c, FILE* stream);
+wint_t putwchar(wchar_t c);
+wint_t ungetwc(wint_t c, FILE* stream);
+double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
+float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr);         // C99
+long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr);  // C99
+long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);  // C99
+unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
+unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);  // C99
+wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
+wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
+wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+int wcscmp(const wchar_t* s1, const wchar_t* s2);
+int wcscoll(const wchar_t* s1, const wchar_t* s2);
+int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
+size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+const wchar_t* wcschr(const wchar_t* s, wchar_t c);
+      wchar_t* wcschr(      wchar_t* s, wchar_t c);
+size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
+size_t wcslen(const wchar_t* s);
+const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
+      wchar_t* wcspbrk(      wchar_t* s1, const wchar_t* s2);
+const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
+      wchar_t* wcsrchr(      wchar_t* s, wchar_t c);
+size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
+const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
+      wchar_t* wcsstr(      wchar_t* s1, const wchar_t* s2);
+wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
+const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
+      wchar_t* wmemchr(      wchar_t* s, wchar_t c, size_t n);
+int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
+wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
+wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
+size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
+                const tm* restrict timeptr);
+wint_t btowc(int c);
+int wctob(wint_t c);
+int mbsinit(const mbstate_t* ps);
+size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
+size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
+size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
+size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
+                 mbstate_t* restrict ps);
+size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
+                 mbstate_t* restrict ps);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#ifdef __cplusplus
+#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
+#endif
+
+#include_next <wchar.h>
+
+// Determine whether we have const-correct overloads for wcschr and friends.
+#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
+#  define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
+#elif defined(__GLIBC_PREREQ)
+#  if __GLIBC_PREREQ(2, 10)
+#    define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
+#  endif
+#endif
+
+#if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
+extern "C++" {
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      wchar_t* wcschr(      wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      wchar_t* wcspbrk(      wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      wchar_t* wcsrchr(      wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      wchar_t* wcsstr(      wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t* __libcpp_wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return (wchar_t*)wmemchr(__s, __c, __n);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
+      wchar_t* wmemchr(      wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
+}
+#endif
+
+#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__))
+extern "C++" {
+#include <support/win32/support.h> // pull in *swprintf defines
+}  // extern "C++"
+#endif  // __cplusplus && _LIBCPP_MSVCRT
+
+#endif  // _LIBCPP_WCHAR_H
diff --git a/system/include/libcxx/wctype.h b/system/include/libcxx/wctype.h
new file mode 100644
index 0000000000000..f9c5a47754bb4
--- /dev/null
+++ b/system/include/libcxx/wctype.h
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+//===--------------------------- wctype.h ---------------------------------===//
+//
+//                     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_WCTYPE_H
+#define _LIBCPP_WCTYPE_H
+
+/*
+    wctype.h synopsis
+
+Macros:
+
+    WEOF
+
+Types:
+
+    wint_t
+    wctrans_t
+    wctype_t
+
+int iswalnum(wint_t wc);
+int iswalpha(wint_t wc);
+int iswblank(wint_t wc);  // C99
+int iswcntrl(wint_t wc);
+int iswdigit(wint_t wc);
+int iswgraph(wint_t wc);
+int iswlower(wint_t wc);
+int iswprint(wint_t wc);
+int iswpunct(wint_t wc);
+int iswspace(wint_t wc);
+int iswupper(wint_t wc);
+int iswxdigit(wint_t wc);
+int iswctype(wint_t wc, wctype_t desc);
+wctype_t wctype(const char* property);
+wint_t towlower(wint_t wc);
+wint_t towupper(wint_t wc);
+wint_t towctrans(wint_t wc, wctrans_t desc);
+wctrans_t wctrans(const char* property);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <wctype.h>
+
+#ifdef __cplusplus
+
+#undef iswalnum
+#undef iswalpha
+#undef iswblank
+#undef iswcntrl
+#undef iswdigit
+#undef iswgraph
+#undef iswlower
+#undef iswprint
+#undef iswpunct
+#undef iswspace
+#undef iswupper
+#undef iswxdigit
+#undef iswctype
+#undef wctype
+#undef towlower
+#undef towupper
+#undef towctrans
+#undef wctrans
+
+#endif  // __cplusplus
+
+#endif  // _LIBCPP_WCTYPE_H
diff --git a/system/lib/libcxx/CREDITS.TXT b/system/lib/libcxx/CREDITS.TXT
index 7a28adae09659..1cf713a688427 100644
--- a/system/lib/libcxx/CREDITS.TXT
+++ b/system/lib/libcxx/CREDITS.TXT
@@ -12,6 +12,10 @@ N: Saleem Abdulrasool
 E: compnerd@compnerd.org
 D: Minor patches and Linux fixes.
 
+N: Dan Albert
+E: danalbert@google.com
+D: Android support and test runner improvements.
+
 N: Dimitry Andric
 E: dimitry@andric.com
 D: Visibility fixes, minor FreeBSD portability patches.
@@ -84,6 +88,10 @@ N: Nico Rieck
 E: nico.rieck@gmail.com
 D: Windows fixes
 
+N: Jon Roelofs
+E: jonathan@codesourcery.com
+D: Remote testing, Newlib port, baremetal/single-threaded support.
+
 N: Jonathan Sauer
 D: Minor patches, mostly related to constexpr
 
@@ -105,6 +113,9 @@ D: Minor <atomic> fix
 N: Michael van der Westhuizen
 E: r1mikey at gmail dot com
 
+N: Larisse Voufo
+D: Minor patches.
+
 N: Klaas de Vries
 E: klaas at klaasgaaf dot nl
 D: Minor bug fix.
diff --git a/system/lib/libcxx/LICENSE.TXT b/system/lib/libcxx/LICENSE.TXT
index 41ca5d19cc658..339e232c68fd4 100644
--- a/system/lib/libcxx/LICENSE.TXT
+++ b/system/lib/libcxx/LICENSE.TXT
@@ -14,7 +14,7 @@ Full text of the relevant licenses is included below.
 University of Illinois/NCSA
 Open Source License
 
-Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
+Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT
 
 All rights reserved.
 
diff --git a/system/lib/libcxx/any.cpp b/system/lib/libcxx/any.cpp
new file mode 100644
index 0000000000000..f77684578905b
--- /dev/null
+++ b/system/lib/libcxx/any.cpp
@@ -0,0 +1,18 @@
+//===---------------------------- any.cpp ---------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#include "experimental/any"
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+const char* bad_any_cast::what() const _NOEXCEPT {
+    return "bad any cast";
+}
+
+_LIBCPP_END_NAMESPACE_LFTS
diff --git a/system/lib/libcxx/chrono.cpp b/system/lib/libcxx/chrono.cpp
index 456941144e011..62149fbf420cd 100644
--- a/system/lib/libcxx/chrono.cpp
+++ b/system/lib/libcxx/chrono.cpp
@@ -8,14 +8,21 @@
 //===----------------------------------------------------------------------===//
 
 #include "chrono"
-#include <sys/time.h>        //for gettimeofday and timeval
-#ifdef __APPLE__
+#include "cerrno"        // errno
+#include "system_error"  // __throw_system_error
+#include <time.h>        // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
+
+#if !defined(CLOCK_REALTIME)
+#include <sys/time.h>        // for gettimeofday and timeval
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(CLOCK_MONOTONIC)
+#if __APPLE__
 #include <mach/mach_time.h>  // mach_absolute_time, mach_timebase_info_data_t
-#else  /* !__APPLE__ */
-#include <cerrno>  // errno
-#include <system_error>  // __throw_system_error
-#include <time.h>  // clock_gettime, CLOCK_MONOTONIC
-#endif  // __APPLE__
+#else
+#error "Monotonic clock not implemented"
+#endif
+#endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -29,9 +36,16 @@ const bool system_clock::is_steady;
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
+#ifdef CLOCK_REALTIME
+    struct timespec tp;
+    if (0 != clock_gettime(CLOCK_REALTIME, &tp))
+        __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
+    return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#else  // !CLOCK_REALTIME
     timeval tv;
     gettimeofday(&tv, 0);
     return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
+#endif  // CLOCK_REALTIME
 }
 
 time_t
@@ -48,10 +62,26 @@ system_clock::from_time_t(time_t t) _NOEXCEPT
 
 #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
 // steady_clock
+//
+// Warning:  If this is not truly steady, then it is non-conforming.  It is
+//  better for it to not exist and have the rest of libc++ use system_clock
+//  instead.
 
 const bool steady_clock::is_steady;
 
-#ifdef __APPLE__
+#ifdef CLOCK_MONOTONIC
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+    struct timespec tp;
+    if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
+        __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
+    return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#elif defined(__APPLE__)
+
 //   mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of
 //   nanoseconds since the computer booted up.  MachInfo.numer and MachInfo.denom
 //   are run time constants supplied by the OS.  This clock has no relationship
@@ -108,23 +138,9 @@ steady_clock::now() _NOEXCEPT
     return time_point(duration(fp()));
 }
 
-#else  // __APPLE__
-// FIXME: if _LIBCPP_HAS_NO_MONOTONIC_CLOCK, then clock_gettime isn't going to
-// work. It may be possible to fall back on something else, depending on the system.
-
-// Warning:  If this is not truly steady, then it is non-conforming.  It is
-//  better for it to not exist and have the rest of libc++ use system_clock
-//  instead.
-
-steady_clock::time_point
-steady_clock::now() _NOEXCEPT
-{
-    struct timespec tp;
-    if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
-        __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
-    return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
-}
-#endif  // __APPLE__
+#else
+#error "Monotonic clock not implemented"
+#endif
 
 #endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK
 
diff --git a/system/lib/libcxx/debug.cpp b/system/lib/libcxx/debug.cpp
index 60694a3bdb0ea..b1a16e6e72d48 100644
--- a/system/lib/libcxx/debug.cpp
+++ b/system/lib/libcxx/debug.cpp
@@ -214,10 +214,10 @@ __libcpp_db::__erase_i(void* __i)
             else
                 q->__next_ = p->__next_;
             __c_node* c = p->__c_;
-            free(p);
             --__isz_;
             if (c != nullptr)
                 c->__remove(p);
+            free(p);
         }
     }
 }
diff --git a/system/lib/libcxx/exception.cpp b/system/lib/libcxx/exception.cpp
index 3ce6f2e11188d..e172f642d4830 100644
--- a/system/lib/libcxx/exception.cpp
+++ b/system/lib/libcxx/exception.cpp
@@ -12,11 +12,7 @@
 #include "exception"
 #include "new"
 
-#ifndef __has_include
-#define __has_include(inc) 0
-#endif
-
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(LIBCXXRT)
   #include <cxxabi.h>
 
   using namespace __cxxabiv1;
@@ -29,16 +25,16 @@
     #define __terminate_handler  __cxxabiapple::__cxa_terminate_handler
     #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler
   #endif  // _LIBCPPABI_VERSION
-#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
+#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
   #include <cxxabi.h>
   using namespace __cxxabiv1;
   #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION)
     #define HAVE_DEPENDENT_EH_ABI 1
   #endif
-#elif !defined(__GLIBCXX__) // __has_include(<cxxabi.h>)
+#elif !defined(__GLIBCXX__) // defined(LIBCXX_BUILDING_LIBCXXABI)
   static std::terminate_handler  __terminate_handler;
   static std::unexpected_handler __unexpected_handler;
-#endif // __has_include(<cxxabi.h>)
+#endif // defined(LIBCXX_BUILDING_LIBCXXABI)
 
 namespace std
 {
@@ -90,14 +86,14 @@ terminate() _NOEXCEPT
 #endif  // _LIBCPP_NO_EXCEPTIONS
         (*get_terminate())();
         // handler should not return
-        printf("terminate_handler unexpectedly returned\n");
+        fprintf(stderr, "terminate_handler unexpectedly returned\n");
         ::abort();
 #ifndef _LIBCPP_NO_EXCEPTIONS
     }
     catch (...)
     {
         // handler should not throw exception
-        printf("terminate_handler unexpectedly threw an exception\n");
+        fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
         ::abort();
     }
 #endif  // _LIBCPP_NO_EXCEPTIONS
@@ -106,18 +102,24 @@ terminate() _NOEXCEPT
 #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
 
 #if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__)
-bool uncaught_exception() _NOEXCEPT
+bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
+
+int uncaught_exceptions() _NOEXCEPT
 {
 #if defined(__APPLE__) || defined(_LIBCPPABI_VERSION)
-    // on Darwin, there is a helper function so __cxa_get_globals is private
-    return __cxa_uncaught_exception();
+   // on Darwin, there is a helper function so __cxa_get_globals is private
+# if _LIBCPPABI_VERSION > 1101
+    return __cxa_uncaught_exceptions();
+# else
+    return __cxa_uncaught_exception() ? 1 : 0;
+# endif
 #else  // __APPLE__
 #   if defined(_MSC_VER) && ! defined(__clang__)
-        _LIBCPP_WARNING("uncaught_exception not yet implemented")
+        _LIBCPP_WARNING("uncaught_exceptions not yet implemented")
 #   else
 #       warning uncaught_exception not yet implemented
 #   endif
-    printf("uncaught_exception not yet implemented\n");
+    fprintf(stderr, "uncaught_exceptions not yet implemented\n");
     ::abort();
 #endif  // __APPLE__
 }
@@ -190,7 +192,7 @@ exception_ptr::~exception_ptr() _NOEXCEPT
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
@@ -209,7 +211,7 @@ exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
@@ -234,7 +236,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
@@ -278,7 +280,7 @@ exception_ptr current_exception() _NOEXCEPT
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
@@ -300,7 +302,7 @@ void rethrow_exception(exception_ptr p)
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
diff --git a/system/lib/libcxx/future.cpp b/system/lib/libcxx/future.cpp
index 0c5c2c4488d2d..e1758f39df3a7 100644
--- a/system/lib/libcxx/future.cpp
+++ b/system/lib/libcxx/future.cpp
@@ -98,7 +98,6 @@ __assoc_sub_state::set_value()
 #endif
     __state_ |= __constructed | ready;
     __cv_.notify_all();
-    __lk.unlock();
 }
 
 void
@@ -111,7 +110,6 @@ __assoc_sub_state::set_value_at_thread_exit()
 #endif
     __state_ |= __constructed;
     __thread_local_data()->__make_ready_at_thread_exit(this);
-    __lk.unlock();
 }
 
 void
@@ -124,7 +122,6 @@ __assoc_sub_state::set_exception(exception_ptr __p)
 #endif
     __exception_ = __p;
     __state_ |= ready;
-    __lk.unlock();
     __cv_.notify_all();
 }
 
@@ -138,7 +135,6 @@ __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p)
 #endif
     __exception_ = __p;
     __thread_local_data()->__make_ready_at_thread_exit(this);
-    __lk.unlock();
 }
 
 void
@@ -146,7 +142,6 @@ __assoc_sub_state::__make_ready()
 {
     unique_lock<mutex> __lk(__mut_);
     __state_ |= ready;
-    __lk.unlock();
     __cv_.notify_all();
 }
 
@@ -226,10 +221,12 @@ promise<void>::~promise()
 {
     if (__state_)
     {
+#ifndef _LIBCPP_NO_EXCEPTIONS
         if (!__state_->__has_value() && __state_->use_count() > 1)
             __state_->set_exception(make_exception_ptr(
                       future_error(make_error_code(future_errc::broken_promise))
                                                       ));
+#endif // _LIBCPP_NO_EXCEPTIONS
         __state_->__release_shared();
     }
 }
diff --git a/system/lib/libcxx/include/atomic_support.h b/system/lib/libcxx/include/atomic_support.h
new file mode 100644
index 0000000000000..8b719c5f22148
--- /dev/null
+++ b/system/lib/libcxx/include/atomic_support.h
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===////
+//
+//                     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 ATOMIC_SUPPORT_H
+#define ATOMIC_SUPPORT_H
+
+#include "__config"
+#include "memory" // for __libcpp_relaxed_load
+
+#if defined(__clang__) && __has_builtin(__atomic_load_n)             \
+                       && __has_builtin(__atomic_store_n)            \
+                       && __has_builtin(__atomic_add_fetch)          \
+                       && __has_builtin(__atomic_compare_exchange_n) \
+                       && defined(__ATOMIC_RELAXED)                  \
+                       && defined(__ATOMIC_CONSUME)                  \
+                       && defined(__ATOMIC_ACQUIRE)                  \
+                       && defined(__ATOMIC_RELEASE)                  \
+                       && defined(__ATOMIC_ACQ_REL)                  \
+                       && defined(__ATOMIC_SEQ_CST)
+#   define _LIBCPP_HAS_ATOMIC_BUILTINS
+#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407
+#   define _LIBCPP_HAS_ATOMIC_BUILTINS
+#endif
+
+#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+# if defined(_MSC_VER) && !defined(__clang__)
+    _LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
+# else
+#   warning Building libc++ without __atomic builtins is unsupported
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace {
+
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+
+enum __libcpp_atomic_order {
+    _AO_Relaxed = __ATOMIC_RELAXED,
+    _AO_Consume = __ATOMIC_CONSUME,
+    _AO_Aquire  = __ATOMIC_ACQUIRE,
+    _AO_Release = __ATOMIC_RELEASE,
+    _AO_Acq_Rel = __ATOMIC_ACQ_REL,
+    _AO_Seq     = __ATOMIC_SEQ_CST
+};
+
+template <class _ValueType, class _FromType>
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
+                           int __order = _AO_Seq)
+{
+    __atomic_store_n(__dest, __val, __order);
+}
+
+template <class _ValueType, class _FromType>
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
+{
+    __atomic_store_n(__dest, __val, _AO_Relaxed);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_load(_ValueType const* __val,
+                                int __order = _AO_Seq)
+{
+    return __atomic_load_n(__val, __order);
+}
+
+template <class _ValueType, class _AddType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
+                               int __order = _AO_Seq)
+{
+    return __atomic_add_fetch(__val, __a, __order);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+bool __libcpp_atomic_compare_exchange(_ValueType* __val,
+    _ValueType* __expected, _ValueType __after,
+    int __success_order = _AO_Seq,
+    int __fail_order = _AO_Seq)
+{
+    return __atomic_compare_exchange_n(__val, __expected, __after, true,
+                                       __success_order, __fail_order);
+}
+
+#else // _LIBCPP_HAS_NO_THREADS
+
+enum __libcpp_atomic_order {
+    _AO_Relaxed,
+    _AO_Consume,
+    _AO_Acquire,
+    _AO_Release,
+    _AO_Acq_Rel,
+    _AO_Seq
+};
+
+template <class _ValueType, class _FromType>
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
+                           int = 0)
+{
+    *__dest = __val;
+}
+
+template <class _ValueType, class _FromType>
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
+{
+    *__dest = __val;
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_load(_ValueType const* __val,
+                                int = 0)
+{
+    return *__val;
+}
+
+template <class _ValueType, class _AddType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
+                               int = 0)
+{
+    return *__val += __a;
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+bool __libcpp_atomic_compare_exchange(_ValueType* __val,
+    _ValueType* __expected, _ValueType __after,
+    int = 0, int = 0)
+{
+    if (*__val == *__expected) {
+        *__val = __after;
+        return true;
+    }
+    *__expected = *__val;
+    return false;
+}
+
+#endif // _LIBCPP_HAS_NO_THREADS
+
+} // end namespace
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // ATOMIC_SUPPORT_H
diff --git a/system/lib/libcxx/include/config_elast.h b/system/lib/libcxx/include/config_elast.h
new file mode 100644
index 0000000000000..9d6a76b0c004e
--- /dev/null
+++ b/system/lib/libcxx/include/config_elast.h
@@ -0,0 +1,36 @@
+//===----------------------- config_elast.h -------------------------------===//
+//
+//                     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_CONFIG_ELAST
+#define _LIBCPP_CONFIG_ELAST
+
+#if defined(_WIN32)
+#include <stdlib.h>
+#else
+#include <errno.h>
+#endif
+
+#if defined(ELAST)
+#define _LIBCPP_ELAST ELAST
+#elif defined(_NEWLIB_VERSION)
+#define _LIBCPP_ELAST __ELASTERROR
+#elif defined(__linux__)
+#define _LIBCPP_ELAST 4095
+#elif defined(__APPLE__)
+// No _LIBCPP_ELAST needed on Apple
+#elif defined(__sun__)
+#define _LIBCPP_ELAST ESTALE
+#elif defined(_WIN32)
+#define _LIBCPP_ELAST _sys_nerr
+#else
+// Warn here so that the person doing the libcxx port has an easier time:
+#warning ELAST for this platform not yet implemented
+#endif
+
+#endif // _LIBCPP_CONFIG_ELAST
diff --git a/system/lib/libcxx/ios.cpp b/system/lib/libcxx/ios.cpp
index 06426c7b60427..23e3ee0ca044e 100644
--- a/system/lib/libcxx/ios.cpp
+++ b/system/lib/libcxx/ios.cpp
@@ -8,16 +8,20 @@
 //===----------------------------------------------------------------------===//
 
 #include "__config"
+
 #include "ios"
-#include "streambuf"
-#include "istream"
-#include "string"
+
+#include <stdlib.h>
+
 #include "__locale"
 #include "algorithm"
+#include "include/config_elast.h"
+#include "istream"
+#include "limits"
 #include "memory"
 #include "new"
-#include "limits"
-#include <stdlib.h>
+#include "streambuf"
+#include "string"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -148,12 +152,22 @@ ios_base::getloc() const
 }
 
 // xalloc
-#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
+#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
 atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0);
 #else
 int ios_base::__xindex_ = 0;
 #endif
 
+template <typename _Tp>
+static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)
+{ // Precondition: __req_size > __current_cap
+	const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
+	if (__req_size < mx/2)
+		return _VSTD::max(2 * __current_cap, __req_size);
+	else
+		return mx;
+}
+
 int
 ios_base::xalloc()
 {
@@ -166,14 +180,8 @@ ios_base::iword(int index)
     size_t req_size = static_cast<size_t>(index)+1;
     if (req_size > __iarray_cap_)
     {
-        size_t newcap;
-        const size_t mx = std::numeric_limits<size_t>::max();
-        if (req_size < mx/2)
-            newcap = _VSTD::max(2 * __iarray_cap_, req_size);
-        else
-            newcap = mx;
-        size_t newsize = newcap * sizeof(long);
-        long* iarray = static_cast<long*>(realloc(__iarray_, newsize));
+        size_t newcap = __ios_new_cap<long>(req_size, __iarray_cap_);
+        long* iarray = static_cast<long*>(realloc(__iarray_, newcap * sizeof(long)));
         if (iarray == 0)
         {
             setstate(badbit);
@@ -182,8 +190,9 @@ ios_base::iword(int index)
             return error;
         }
         __iarray_ = iarray;
-        for (long* p = __iarray_ + __iarray_size_; __iarray_cap_ < newcap; ++__iarray_cap_, ++p)
+        for (long* p = __iarray_ + __iarray_size_; p < __iarray_ + newcap; ++p)
             *p = 0;
+        __iarray_cap_ = newcap;
     }
     __iarray_size_ = max<size_t>(__iarray_size_, req_size);
     return __iarray_[index];
@@ -195,14 +204,8 @@ ios_base::pword(int index)
     size_t req_size = static_cast<size_t>(index)+1;
     if (req_size > __parray_cap_)
     {
-        size_t newcap;
-        const size_t mx = std::numeric_limits<size_t>::max();
-        if (req_size < mx/2)
-            newcap = _VSTD::max(2 * __parray_cap_, req_size);
-        else
-            newcap = mx;
-        size_t newsize = newcap * sizeof(void*);
-        void** parray = static_cast<void**>(realloc(__parray_, newsize));
+        size_t newcap = __ios_new_cap<void *>(req_size, __iarray_cap_);
+        void** parray = static_cast<void**>(realloc(__parray_, newcap * sizeof(void *)));
         if (parray == 0)
         {
             setstate(badbit);
@@ -211,8 +214,9 @@ ios_base::pword(int index)
             return error;
         }
         __parray_ = parray;
-        for (void** p = __parray_ + __parray_size_; __parray_cap_ < newcap; ++__parray_cap_, ++p)
+        for (void** p = __parray_ + __parray_size_; p < __parray_ + newcap; ++p)
             *p = 0;
+        __parray_cap_ = newcap;
     }
     __parray_size_ = max<size_t>(__parray_size_, req_size);
     return __parray_[index];
@@ -226,22 +230,16 @@ ios_base::register_callback(event_callback fn, int index)
     size_t req_size = __event_size_ + 1;
     if (req_size > __event_cap_)
     {
-        size_t newcap;
-        const size_t mx = std::numeric_limits<size_t>::max();
-        if (req_size < mx/2)
-            newcap = _VSTD::max(2 * __event_cap_, req_size);
-        else
-            newcap = mx;
-        size_t newesize = newcap * sizeof(event_callback);
-        event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newesize));
+        size_t newcap = __ios_new_cap<event_callback>(req_size, __event_cap_);
+        event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newcap * sizeof(event_callback)));
         if (fns == 0)
             setstate(badbit);
         __fn_ = fns;
-        size_t newisize = newcap * sizeof(int);
-        int* indxs = static_cast<int *>(realloc(__index_, newisize));
+        int* indxs = static_cast<int *>(realloc(__index_, newcap * sizeof(int)));
         if (indxs == 0)
             setstate(badbit);
         __index_ = indxs;
+        __event_cap_ = newcap;
     }
     __fn_[__event_size_] = fn;
     __index_[__event_size_] = index;
diff --git a/system/lib/libcxx/iostream.cpp b/system/lib/libcxx/iostream.cpp
index c407c25988948..75d0c5a532ceb 100644
--- a/system/lib/libcxx/iostream.cpp
+++ b/system/lib/libcxx/iostream.cpp
@@ -13,55 +13,75 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-static mbstate_t state_types[6] = {};
-
+#ifndef _LIBCPP_HAS_NO_STDIN
+_ALIGNAS_TYPE (istream)  _LIBCPP_FUNC_VIS char cin [sizeof(istream)];
 _ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin [sizeof(__stdinbuf <char>)];
-_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
-_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
+static mbstate_t mb_cin;
+_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)];
 _ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin [sizeof(__stdinbuf <wchar_t>)];
-_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
-_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
+static mbstate_t mb_wcin;
+#endif
 
-_ALIGNAS_TYPE (istream)  _LIBCPP_FUNC_VIS char cin [sizeof(istream)];
+#ifndef _LIBCPP_HAS_NO_STDOUT
 _ALIGNAS_TYPE (ostream)  _LIBCPP_FUNC_VIS char cout[sizeof(ostream)];
-_ALIGNAS_TYPE (ostream)  _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)];
-_ALIGNAS_TYPE (ostream)  _LIBCPP_FUNC_VIS char clog[sizeof(ostream)];
-_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)];
+_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
+static mbstate_t mb_cout;
 _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)];
+_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
+static mbstate_t mb_wcout;
+#endif
+
+_ALIGNAS_TYPE (ostream)  _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)];
+_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
+static mbstate_t mb_cerr;
 _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)];
+_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
+static mbstate_t mb_wcerr;
+
+_ALIGNAS_TYPE (ostream)  _LIBCPP_FUNC_VIS char clog[sizeof(ostream)];
 _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)];
 
 ios_base::Init __attribute__((init_priority(101))) __start_std_streams; // XXX EMSCRIPTEN: ensure a high priority for this constructor, see #3824
 
 ios_base::Init::Init()
 {
-    istream* cin_ptr  = ::new(cin)  istream(::new(__cin)  __stdinbuf <char>(stdin, state_types+0) );
-    ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, state_types+1));
-    ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, state_types+2));
+#ifndef _LIBCPP_HAS_NO_STDIN
+    istream* cin_ptr  = ::new(cin)  istream(::new(__cin)  __stdinbuf <char>(stdin, &mb_cin));
+    wistream* wcin_ptr  = ::new(wcin)  wistream(::new(__wcin)  __stdinbuf <wchar_t>(stdin, &mb_wcin));
+#endif
+#ifndef _LIBCPP_HAS_NO_STDOUT
+    ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, &mb_cout));
+    wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));
+#endif
+    ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, &mb_cerr));
                         ::new(clog) ostream(cerr_ptr->rdbuf());
-    cin_ptr->tie(cout_ptr);
-    _VSTD::unitbuf(*cerr_ptr);
-    cerr_ptr->tie(cout_ptr);
-
-    wistream* wcin_ptr  = ::new(wcin)  wistream(::new(__wcin)  __stdinbuf <wchar_t>(stdin, state_types+3) );
-    wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, state_types+4));
-    wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, state_types+5));
+    wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));
                           ::new(wclog) wostream(wcerr_ptr->rdbuf());
+
+#if !defined(_LIBCPP_HAS_NO_STDIN) && !defined(_LIBCPP_HAS_NO_STDOUT)
+    cin_ptr->tie(cout_ptr);
     wcin_ptr->tie(wcout_ptr);
+#endif
+    _VSTD::unitbuf(*cerr_ptr);
     _VSTD::unitbuf(*wcerr_ptr);
+#ifndef _LIBCPP_HAS_NO_STDOUT
+    cerr_ptr->tie(cout_ptr);
     wcerr_ptr->tie(wcout_ptr);
+#endif
 }
 
 ios_base::Init::~Init()
 {
+#ifndef _LIBCPP_HAS_NO_STDOUT
     ostream* cout_ptr = reinterpret_cast<ostream*>(cout);
-    ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
+    wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);
     cout_ptr->flush();
-    clog_ptr->flush();
+    wcout_ptr->flush();
+#endif
 
-    wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);
+    ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
     wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
-    wcout_ptr->flush();
+    clog_ptr->flush();
     wclog_ptr->flush();
 }
 
diff --git a/system/lib/libcxx/locale.cpp b/system/lib/libcxx/locale.cpp
index f21e35dd540a1..bc2427bfce918 100644
--- a/system/lib/libcxx/locale.cpp
+++ b/system/lib/libcxx/locale.cpp
@@ -27,7 +27,7 @@
 #include "cwctype"
 #include "__sso_allocator"
 #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
-#include <support/win32/locale_win32.h>
+#include "support/win32/locale_win32.h"
 #elif !defined(__ANDROID__)
 #include <langinfo.h>
 #endif
@@ -123,11 +123,6 @@ const locale::category locale::time;
 const locale::category locale::messages;
 const locale::category locale::all;
 
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
 class _LIBCPP_HIDDEN locale::__imp
     : public facet
 {
@@ -163,10 +158,6 @@ class _LIBCPP_HIDDEN locale::__imp
     template <class F> void install_from(const __imp& other);
 };
 
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
 locale::__imp::__imp(size_t refs)
     : facet(refs),
       facets_(N),
@@ -575,8 +566,10 @@ locale::global(const locale& loc)
     locale& g = __global();
     locale r = g;
     g = loc;
+#ifndef __CloudABI__
     if (g.name() != "*")
         setlocale(LC_ALL, g.name().c_str());
+#endif
     return r;
 }
 
@@ -810,10 +803,11 @@ ctype<wchar_t>::do_toupper(char_type c) const
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
     return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+      defined(__NetBSD__)
     return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
 #else
-    return (isascii(c) && iswlower_l(c, __cloc())) ? c-L'a'+L'A' : c;
+    return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
 #endif
 }
 
@@ -823,11 +817,12 @@ ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const
     for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
         *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+      defined(__NetBSD__)
         *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
                              : *low;
 #else
-        *low = (isascii(*low) && islower_l(*low, __cloc())) ? (*low-L'a'+L'A') : *low;
+        *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low-L'a'+L'A') : *low;
 #endif
     return low;
 }
@@ -837,10 +832,11 @@ ctype<wchar_t>::do_tolower(char_type c) const
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
     return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+      defined(__NetBSD__)
     return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
 #else
-    return (isascii(c) && isupper_l(c, __cloc())) ? c-L'A'+'a' : c;
+    return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
 #endif
 }
 
@@ -850,11 +846,12 @@ ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
     for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
         *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+      defined(__NetBSD__)
         *low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
                              : *low;
 #else
-        *low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-L'A'+L'a' : *low;
+        *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-L'A'+L'a' : *low;
 #endif
     return low;
 }
@@ -920,10 +917,10 @@ ctype<char>::do_toupper(char_type c) const
 #elif defined(__NetBSD__)
     return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
 #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
-    return isascii(c) ? 
+    return isascii(c) ?
       static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
 #else
-    return (isascii(c) && islower_l(c, __cloc())) ? c-'a'+'A' : c;
+    return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
 #endif
 }
 
@@ -940,7 +937,7 @@ ctype<char>::do_toupper(char_type* low, const char_type* high) const
         *low = isascii(*low) ?
           static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
 #else
-        *low = (isascii(*low) && islower_l(*low, __cloc())) ? *low-'a'+'A' : *low;
+        *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'a'+'A' : *low;
 #endif
     return low;
 }
@@ -953,11 +950,11 @@ ctype<char>::do_tolower(char_type c) const
       static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;
 #elif defined(__NetBSD__)
     return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
     return isascii(c) ?
       static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
 #else
-    return (isascii(c) && isupper_l(c, __cloc())) ? c-'A'+'a' : c;
+    return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'A'+'a' : c;
 #endif
 }
 
@@ -972,7 +969,7 @@ ctype<char>::do_tolower(char_type* low, const char_type* high) const
 #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
         *low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
 #else
-        *low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-'A'+'a' : *low;
+        *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
 #endif
     return low;
 }
@@ -1010,12 +1007,93 @@ ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault,
     return low;
 }
 
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__)
 extern "C" const unsigned short ** __ctype_b_loc();
 extern "C" const int ** __ctype_tolower_loc();
 extern "C" const int ** __ctype_toupper_loc();
 #endif
 
+#ifdef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+const ctype<char>::mask*
+ctype<char>::classic_table()  _NOEXCEPT
+{
+    static _LIBCPP_CONSTEXPR const ctype<char>::mask builtin_table[table_size] = {
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl | space | blank,
+        cntrl | space,                  cntrl | space,
+        cntrl | space,                  cntrl | space,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        cntrl,                          cntrl,
+        space | blank | print,          punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        digit | print | xdigit,         digit | print | xdigit,
+        digit | print | xdigit,         digit | print | xdigit,
+        digit | print | xdigit,         digit | print | xdigit,
+        digit | print | xdigit,         digit | print | xdigit,
+        digit | print | xdigit,         digit | print | xdigit,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  upper | xdigit | print | alpha,
+        upper | xdigit | print | alpha, upper | xdigit | print | alpha,
+        upper | xdigit | print | alpha, upper | xdigit | print | alpha,
+        upper | xdigit | print | alpha, upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          upper | print | alpha,
+        upper | print | alpha,          punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  lower | xdigit | print | alpha,
+        lower | xdigit | print | alpha, lower | xdigit | print | alpha,
+        lower | xdigit | print | alpha, lower | xdigit | print | alpha,
+        lower | xdigit | print | alpha, lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          lower | print | alpha,
+        lower | print | alpha,          punct | print,
+        punct | print,                  punct | print,
+        punct | print,                  cntrl,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+    };
+    return builtin_table;
+}
+#else
 const ctype<char>::mask*
 ctype<char>::classic_table()  _NOEXCEPT
 {
@@ -1024,7 +1102,7 @@ ctype<char>::classic_table()  _NOEXCEPT
 #elif defined(__NetBSD__)
     return _C_ctype_tab_ + 1;
 #elif defined(__GLIBC__)
-    return __cloc()->__ctype_b;
+    return _LIBCPP_GET_C_LOCALE->__ctype_b;
 #elif __sun__
     return __ctype_mask;
 #elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
@@ -1033,10 +1111,11 @@ ctype<char>::classic_table()  _NOEXCEPT
 // going to end up dereferencing it later...
 #elif defined(__EMSCRIPTEN__)
     return *__ctype_b_loc();
+#elif defined(_NEWLIB_VERSION)
+    // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1].
+    return _ctype_ + 1;
 #elif defined(_AIX)
     return (const unsigned int *)__lc_ctype_ptr->obj->mask;
-#elif defined(__ANDROID__)
-    return reinterpret_cast<const unsigned char*>(_ctype_) + 1;
 #else
     // Platform not supported: abort so the person doing the port knows what to
     // fix
@@ -1046,18 +1125,19 @@ ctype<char>::classic_table()  _NOEXCEPT
     return NULL;
 #endif
 }
+#endif
 
 #if defined(__GLIBC__)
 const int*
 ctype<char>::__classic_lower_table() _NOEXCEPT
 {
-    return __cloc()->__ctype_tolower;
+    return _LIBCPP_GET_C_LOCALE->__ctype_tolower;
 }
 
 const int*
 ctype<char>::__classic_upper_table() _NOEXCEPT
 {
-    return __cloc()->__ctype_toupper;
+    return _LIBCPP_GET_C_LOCALE->__ctype_toupper;
 }
 #elif __NetBSD__
 const short*
@@ -1084,7 +1164,7 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
 {
     return *__ctype_toupper_loc();
 }
-#endif // __GLIBC__ || __EMSCRIPTEN__ || __NETBSD__
+#endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__
 
 // template <> class ctype_byname<char>
 
@@ -1180,16 +1260,16 @@ ctype_byname<wchar_t>::do_is(mask m, char_type c) const
 #else
     bool result = false;
     wint_t ch = static_cast<wint_t>(c);
-    if (m & space) result |= (iswspace_l(ch, __l) != 0);
-    if (m & print) result |= (iswprint_l(ch, __l) != 0);
-    if (m & cntrl) result |= (iswcntrl_l(ch, __l) != 0);
-    if (m & upper) result |= (iswupper_l(ch, __l) != 0);
-    if (m & lower) result |= (iswlower_l(ch, __l) != 0);
-    if (m & alpha) result |= (iswalpha_l(ch, __l) != 0);
-    if (m & digit) result |= (iswdigit_l(ch, __l) != 0);
-    if (m & punct) result |= (iswpunct_l(ch, __l) != 0);
-    if (m & xdigit) result |= (iswxdigit_l(ch, __l) != 0);
-    if (m & blank) result |= (iswblank_l(ch, __l) != 0);
+    if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0);
+    if ((m & print) == print) result |= (iswprint_l(ch, __l) != 0);
+    if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l) != 0);
+    if ((m & upper) == upper) result |= (iswupper_l(ch, __l) != 0);
+    if ((m & lower) == lower) result |= (iswlower_l(ch, __l) != 0);
+    if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l) != 0);
+    if ((m & digit) == digit) result |= (iswdigit_l(ch, __l) != 0);
+    if ((m & punct) == punct) result |= (iswpunct_l(ch, __l) != 0);
+    if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l) != 0);
+    if ((m & blank) == blank) result |= (iswblank_l(ch, __l) != 0);
     return result;
 #endif
 }
@@ -1207,22 +1287,32 @@ ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask*
             wint_t ch = static_cast<wint_t>(*low);
             if (iswspace_l(ch, __l))
                 *vec |= space;
+#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
             if (iswprint_l(ch, __l))
                 *vec |= print;
+#endif
             if (iswcntrl_l(ch, __l))
                 *vec |= cntrl;
             if (iswupper_l(ch, __l))
                 *vec |= upper;
             if (iswlower_l(ch, __l))
                 *vec |= lower;
+#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
             if (iswalpha_l(ch, __l))
                 *vec |= alpha;
+#endif
             if (iswdigit_l(ch, __l))
                 *vec |= digit;
             if (iswpunct_l(ch, __l))
                 *vec |= punct;
+#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
             if (iswxdigit_l(ch, __l))
                 *vec |= xdigit;
+#endif
+#if !defined(__sun__)
+            if (iswblank_l(ch, __l))
+                *vec |= blank;
+#endif
         }
     }
     return low;
@@ -1238,16 +1328,16 @@ ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type*
             break;
 #else
         wint_t ch = static_cast<wint_t>(*low);
-        if (m & space && iswspace_l(ch, __l)) break;
-        if (m & print && iswprint_l(ch, __l)) break;
-        if (m & cntrl && iswcntrl_l(ch, __l)) break;
-        if (m & upper && iswupper_l(ch, __l)) break;
-        if (m & lower && iswlower_l(ch, __l)) break;
-        if (m & alpha && iswalpha_l(ch, __l)) break;
-        if (m & digit && iswdigit_l(ch, __l)) break;
-        if (m & punct && iswpunct_l(ch, __l)) break;
-        if (m & xdigit && iswxdigit_l(ch, __l)) break;
-        if (m & blank && iswblank_l(ch, __l)) break;
+        if ((m & space) == space && iswspace_l(ch, __l)) break;
+        if ((m & print) == print && iswprint_l(ch, __l)) break;
+        if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) break;
+        if ((m & upper) == upper && iswupper_l(ch, __l)) break;
+        if ((m & lower) == lower && iswlower_l(ch, __l)) break;
+        if ((m & alpha) == alpha && iswalpha_l(ch, __l)) break;
+        if ((m & digit) == digit && iswdigit_l(ch, __l)) break;
+        if ((m & punct) == punct && iswpunct_l(ch, __l)) break;
+        if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) break;
+        if ((m & blank) == blank && iswblank_l(ch, __l)) break;
 #endif
     }
     return low;
@@ -1263,16 +1353,16 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type
             break;
 #else
         wint_t ch = static_cast<wint_t>(*low);
-        if (m & space && iswspace_l(ch, __l)) continue;
-        if (m & print && iswprint_l(ch, __l)) continue;
-        if (m & cntrl && iswcntrl_l(ch, __l)) continue;
-        if (m & upper && iswupper_l(ch, __l)) continue;
-        if (m & lower && iswlower_l(ch, __l)) continue;
-        if (m & alpha && iswalpha_l(ch, __l)) continue;
-        if (m & digit && iswdigit_l(ch, __l)) continue;
-        if (m & punct && iswpunct_l(ch, __l)) continue;
-        if (m & xdigit && iswxdigit_l(ch, __l)) continue;
-        if (m & blank && iswblank_l(ch, __l)) continue;
+        if ((m & space) == space && iswspace_l(ch, __l)) continue;
+        if ((m & print) == print && iswprint_l(ch, __l)) continue;
+        if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) continue;
+        if ((m & upper) == upper && iswupper_l(ch, __l)) continue;
+        if ((m & lower) == lower && iswlower_l(ch, __l)) continue;
+        if ((m & alpha) == alpha && iswalpha_l(ch, __l)) continue;
+        if ((m & digit) == digit && iswdigit_l(ch, __l)) continue;
+        if ((m & punct) == punct && iswpunct_l(ch, __l)) continue;
+        if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) continue;
+        if ((m & blank) == blank && iswblank_l(ch, __l)) continue;
         break;
 #endif
     }
@@ -1310,33 +1400,21 @@ ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
 wchar_t
 ctype_byname<wchar_t>::do_widen(char c) const
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    return btowc_l(c, __l);
-#else
-    return __btowc_l(c, __l);
-#endif
+    return __libcpp_btowc_l(c, __l);
 }
 
 const char*
 ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
 {
     for (; low != high; ++low, ++dest)
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        *dest = btowc_l(*low, __l);
-#else
-        *dest = __btowc_l(*low, __l);
-#endif
+        *dest = __libcpp_btowc_l(*low, __l);
     return low;
 }
 
 char
 ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    int r = wctob_l(c, __l);
-#else
-    int r = __wctob_l(c, __l);
-#endif
+    int r = __libcpp_wctob_l(c, __l);
     return r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
 }
 
@@ -1345,11 +1423,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
 {
     for (; low != high; ++low, ++dest)
     {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        int r = wctob_l(*low, __l);
-#else
-        int r = __wctob_l(*low, __l);
-#endif
+        int r = __libcpp_wctob_l(*low, __l);
         *dest = r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
     }
     return low;
@@ -1459,22 +1533,14 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
     {
         // save state in case it is needed to recover to_nxt on error
         mbstate_t save_state = st;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        size_t n = wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
-                                static_cast<size_t>(to_end-to), &st, __l);
-#else
-        size_t n = __wcsnrtombs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
-#endif
+        size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
+                                     static_cast<size_t>(to_end-to), &st, __l);
         if (n == size_t(-1))
         {
             // need to recover to_nxt
             for (to_nxt = to; frm != frm_nxt; ++frm)
             {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-                n = wcrtomb_l(to_nxt, *frm, &save_state, __l);
-#else
-                n = __wcrtomb_l(to_nxt, *frm, &save_state, __l);
-#endif
+                n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l);
                 if (n == size_t(-1))
                     break;
                 to_nxt += n;
@@ -1491,11 +1557,7 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
         {
             // Try to write the terminating null
             extern_type tmp[MB_LEN_MAX];
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-            n = wcrtomb_l(tmp, intern_type(), &st, __l);
-#else
-            n = __wcrtomb_l(tmp, intern_type(), &st, __l);
-#endif
+            n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
             if (n == size_t(-1))  // on error
                 return error;
             if (n > static_cast<size_t>(to_end-to_nxt))  // is there room?
@@ -1528,23 +1590,15 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
     {
         // save state in case it is needed to recover to_nxt on error
         mbstate_t save_state = st;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        size_t n = mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
-                                static_cast<size_t>(to_end-to), &st, __l);
-#else
-        size_t n = __mbsnrtowcs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
-#endif
+        size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
+                                     static_cast<size_t>(to_end-to), &st, __l);
         if (n == size_t(-1))
         {
             // need to recover to_nxt
             for (to_nxt = to; frm != frm_nxt; ++to_nxt)
             {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-                n = mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
-                              &save_state, __l);
-#else
-                n = __mbrtowc_l(to_nxt, frm, fend-frm, &save_state, __l);
-#endif
+                n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
+                                   &save_state, __l);
                 switch (n)
                 {
                 case 0:
@@ -1564,7 +1618,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
             frm_nxt = frm;
             return frm_nxt == frm_end ? ok : partial;
         }
-        if (n == 0)
+        if (n == size_t(-1))
             return error;
         to_nxt += n;
         if (to_nxt == to_end)
@@ -1572,11 +1626,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
         if (fend != frm_end)  // set up next null terminated sequence
         {
             // Try to write the terminating null
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-            n = mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
-#else
-            n = __mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
-#endif
+            n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
             if (n != 0)  // on error
                 return error;
             ++to_nxt;
@@ -1596,11 +1646,7 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
 {
     to_nxt = to;
     extern_type tmp[MB_LEN_MAX];
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    size_t n = wcrtomb_l(tmp, intern_type(), &st, __l);
-#else
-    size_t n = __wcrtomb_l(tmp, intern_type(), &st, __l);
-#endif
+    size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
     if (n == size_t(-1) || n == 0)  // on error
         return error;
     --n;
@@ -1614,22 +1660,15 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
 int
 codecvt<wchar_t, char, mbstate_t>::do_encoding() const  _NOEXCEPT
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0)
-#else
-    if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0)
-#endif
-    {
-        // stateless encoding
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        if (__l == 0 || MB_CUR_MAX_L(__l) == 1)  // there are no known constant length encodings
-#else
-        if (__l == 0 || __mb_cur_max_l(__l) == 1)  // there are no known constant length encodings
+#ifndef __CloudABI__
+    if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
+        return -1;
 #endif
-            return 1;                // which take more than 1 char to form a wchar_t
-         return 0;
-    }
-    return -1;
+
+    // stateless encoding
+    if (__l == 0 || __libcpp_mb_cur_max_l(__l) == 1)  // there are no known constant length encodings
+        return 1;                // which take more than 1 char to form a wchar_t
+    return 0;
 }
 
 bool
@@ -1645,11 +1684,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
     int nbytes = 0;
     for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
     {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        size_t n = mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l);
-#else
-        size_t n = __mbrlen_l(frm, frm_end-frm, &st, __l);
-#endif
+        size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l);
         switch (n)
         {
         case 0:
@@ -1671,11 +1706,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
 int
 codecvt<wchar_t, char, mbstate_t>::do_max_length() const  _NOEXCEPT
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    return __l == 0 ? 1 : static_cast<int>(  MB_CUR_MAX_L(__l));
-#else
-    return __l == 0 ? 1 : static_cast<int>(__mb_cur_max_l(__l));
-#endif
+    return __l == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l));
 }
 
 //                                     Valid UTF ranges
@@ -2794,10 +2825,10 @@ ucs4_to_utf16le(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& f
     to_nxt = to;
     if (mode & generate_header)
     {
-        if (to_end-to_nxt < 2)
+        if (to_end - to_nxt < 2)
             return codecvt_base::partial;
-            *to_nxt++ = static_cast<uint8_t>(0xFF);
-            *to_nxt++ = static_cast<uint8_t>(0xFE);
+        *to_nxt++ = static_cast<uint8_t>(0xFF);
+        *to_nxt++ = static_cast<uint8_t>(0xFE);
     }
     for (; frm_nxt < frm_end; ++frm_nxt)
     {
@@ -4233,11 +4264,7 @@ numpunct_byname<char>::__init(const char* nm)
             throw runtime_error("numpunct_byname<char>::numpunct_byname"
                                 " failed to construct for " + string(nm));
 #endif  // _LIBCPP_NO_EXCEPTIONS
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        lconv* lc = localeconv_l(loc.get());
-#else
-        lconv* lc = __localeconv_l(loc.get());
-#endif
+        lconv* lc = __libcpp_localeconv_l(loc.get());
         if (*lc->decimal_point)
             __decimal_point_ = *lc->decimal_point;
         if (*lc->thousands_sep)
@@ -4276,11 +4303,7 @@ numpunct_byname<wchar_t>::__init(const char* nm)
             throw runtime_error("numpunct_byname<char>::numpunct_byname"
                                 " failed to construct for " + string(nm));
 #endif  // _LIBCPP_NO_EXCEPTIONS
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        lconv* lc = localeconv_l(loc.get());
-#else
-        lconv* lc = __localeconv_l(loc.get());
-#endif
+        lconv* lc = __libcpp_localeconv_l(loc.get());
         if (*lc->decimal_point)
             __decimal_point_ = *lc->decimal_point;
         if (*lc->thousands_sep)
@@ -4881,11 +4904,7 @@ __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
     wchar_t* wbb = wbuf;
     mbstate_t mb = {0};
     const char* bb = buf;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    size_t j = mbsrtowcs_l( wbb, &bb, countof(wbuf), &mb, __loc_);
-#else
-    size_t j = __mbsrtowcs_l( wbb, &bb, countof(wbuf), &mb, __loc_);
-#endif
+    size_t j = __libcpp_mbsrtowcs_l( wbb, &bb, countof(wbuf), &mb, __loc_);
     if (j == size_t(-1))
         __throw_runtime_error("locale not supported");
     wchar_t* wbe = wbb + j;
@@ -5065,11 +5084,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
         strftime_l(buf, countof(buf), "%A", &t, __loc_);
         mb = mbstate_t();
         const char* bb = buf;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#else
-        size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#endif
+        size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
         if (j == size_t(-1))
             __throw_runtime_error("locale not supported");
         wbe = wbuf + j;
@@ -5077,11 +5092,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
         strftime_l(buf, countof(buf), "%a", &t, __loc_);
         mb = mbstate_t();
         bb = buf;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#else
-        j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#endif
+        j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
         if (j == size_t(-1))
             __throw_runtime_error("locale not supported");
         wbe = wbuf + j;
@@ -5094,11 +5105,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
         strftime_l(buf, countof(buf), "%B", &t, __loc_);
         mb = mbstate_t();
         const char* bb = buf;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#else
-        size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#endif
+        size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
         if (j == size_t(-1))
             __throw_runtime_error("locale not supported");
         wbe = wbuf + j;
@@ -5106,11 +5113,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
         strftime_l(buf, countof(buf), "%b", &t, __loc_);
         mb = mbstate_t();
         bb = buf;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#else
-        j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#endif
+        j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
         if (j == size_t(-1))
             __throw_runtime_error("locale not supported");
         wbe = wbuf + j;
@@ -5121,11 +5124,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
     strftime_l(buf, countof(buf), "%p", &t, __loc_);
     mb = mbstate_t();
     const char* bb = buf;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#else
-    size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#endif
+    size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
     if (j == size_t(-1))
         __throw_runtime_error("locale not supported");
     wbe = wbuf + j;
@@ -5134,11 +5133,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
     strftime_l(buf, countof(buf), "%p", &t, __loc_);
     mb = mbstate_t();
     bb = buf;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#else
-    j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
-#endif
+    j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
     if (j == size_t(-1))
         __throw_runtime_error("locale not supported");
     wbe = wbuf + j;
@@ -5413,11 +5408,7 @@ __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
     __do_put(__nar, __ne, __tm, __fmt, __mod);
     mbstate_t mb = {0};
     const char* __nb = __nar;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    size_t j = mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
-#else
-    size_t j = __mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
-#endif
+    size_t j = __libcpp_mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
     if (j == size_t(-1))
         __throw_runtime_error("locale not supported");
     __we = __wb + j;
@@ -5808,11 +5799,7 @@ moneypunct_byname<char, false>::init(const char* nm)
         throw runtime_error("moneypunct_byname"
                             " failed to construct for " + string(nm));
 #endif  // _LIBCPP_NO_EXCEPTIONS
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    lconv* lc = localeconv_l(loc.get());
-#else
-    lconv* lc = __localeconv_l(loc.get());
-#endif
+    lconv* lc = __libcpp_localeconv_l(loc.get());
     if (*lc->mon_decimal_point)
         __decimal_point_ = *lc->mon_decimal_point;
     else
@@ -5856,11 +5843,7 @@ moneypunct_byname<char, true>::init(const char* nm)
         throw runtime_error("moneypunct_byname"
                             " failed to construct for " + string(nm));
 #endif  // _LIBCPP_NO_EXCEPTIONS
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    lconv* lc = localeconv_l(loc.get());
-#else
-    lconv* lc = __localeconv_l(loc.get());
-#endif
+    lconv* lc = __libcpp_localeconv_l(loc.get());
     if (*lc->mon_decimal_point)
         __decimal_point_ = *lc->mon_decimal_point;
     else
@@ -5921,11 +5904,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
         throw runtime_error("moneypunct_byname"
                             " failed to construct for " + string(nm));
 #endif  // _LIBCPP_NO_EXCEPTIONS
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    lconv* lc = localeconv_l(loc.get());
-#else
-    lconv* lc = __localeconv_l(loc.get());
-#endif
+    lconv* lc = __libcpp_localeconv_l(loc.get());
     if (*lc->mon_decimal_point)
         __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
     else
@@ -5938,11 +5917,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
     wchar_t wbuf[100];
     mbstate_t mb = {0};
     const char* bb = lc->currency_symbol;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#else
-    size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#endif
+    size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
     if (j == size_t(-1))
         __throw_runtime_error("locale not supported");
     wchar_t* wbe = wbuf + j;
@@ -5957,11 +5932,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
     {
         mb = mbstate_t();
         bb = lc->positive_sign;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#else
-        j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#endif
+        j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
         if (j == size_t(-1))
             __throw_runtime_error("locale not supported");
         wbe = wbuf + j;
@@ -5973,11 +5944,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
     {
         mb = mbstate_t();
         bb = lc->negative_sign;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#else
-        j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#endif
+        j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
         if (j == size_t(-1))
             __throw_runtime_error("locale not supported");
         wbe = wbuf + j;
@@ -6004,11 +5971,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
         throw runtime_error("moneypunct_byname"
                             " failed to construct for " + string(nm));
 #endif  // _LIBCPP_NO_EXCEPTIONS
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    lconv* lc = localeconv_l(loc.get());
-#else
-    lconv* lc = __localeconv_l(loc.get());
-#endif
+    lconv* lc = __libcpp_localeconv_l(loc.get());
     if (*lc->mon_decimal_point)
         __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
     else
@@ -6021,11 +5984,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
     wchar_t wbuf[100];
     mbstate_t mb = {0};
     const char* bb = lc->int_curr_symbol;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#else
-    size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#endif
+    size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
     if (j == size_t(-1))
         __throw_runtime_error("locale not supported");
     wchar_t* wbe = wbuf + j;
@@ -6044,11 +6003,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
     {
         mb = mbstate_t();
         bb = lc->positive_sign;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#else
-        j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#endif
+        j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
         if (j == size_t(-1))
             __throw_runtime_error("locale not supported");
         wbe = wbuf + j;
@@ -6064,11 +6019,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
     {
         mb = mbstate_t();
         bb = lc->negative_sign;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-        j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#else
-        j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
-#endif
+        j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
         if (j == size_t(-1))
             __throw_runtime_error("locale not supported");
         wbe = wbuf + j;
diff --git a/system/lib/libcxx/memory.cpp b/system/lib/libcxx/memory.cpp
index c56d031adfbf3..5b81f26e3dc00 100644
--- a/system/lib/libcxx/memory.cpp
+++ b/system/lib/libcxx/memory.cpp
@@ -13,24 +13,28 @@
 #include "mutex"
 #include "thread"
 #endif
+#include "include/atomic_support.h"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 namespace
 {
 
+// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
+// should be sufficient for thread safety.
+// See https://llvm.org/bugs/show_bug.cgi?id=22803
 template <class T>
 inline T
 increment(T& t) _NOEXCEPT
 {
-    return __sync_add_and_fetch(&t, 1);
+    return __libcpp_atomic_add(&t, 1, _AO_Relaxed);
 }
 
 template <class T>
 inline T
 decrement(T& t) _NOEXCEPT
 {
-    return __sync_add_and_fetch(&t, -1);
+    return __libcpp_atomic_add(&t, -1, _AO_Acq_Rel);
 }
 
 }  // namespace
@@ -99,19 +103,18 @@ __shared_weak_count::__release_weak() _NOEXCEPT
 __shared_weak_count*
 __shared_weak_count::lock() _NOEXCEPT
 {
-    long object_owners = __shared_owners_;
+    long object_owners = __libcpp_atomic_load(&__shared_owners_);
     while (object_owners != -1)
     {
-        if (__sync_bool_compare_and_swap(&__shared_owners_,
-                                         object_owners,
-                                         object_owners+1))
+        if (__libcpp_atomic_compare_exchange(&__shared_owners_,
+                                             &object_owners,
+                                             object_owners+1))
             return this;
-        object_owners = __shared_owners_;
     }
     return 0;
 }
 
-#ifndef _LIBCPP_NO_RTTI
+#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
 
 const void*
 __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
@@ -121,7 +124,7 @@ __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
 
 #endif  // _LIBCPP_NO_RTTI
 
-#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
+#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
 
 static const std::size_t __sp_mut_count = 16;
 static pthread_mutex_t mut_back_imp[__sp_mut_count] =
@@ -174,7 +177,7 @@ __get_sp_mut(const void* p)
     return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
 }
 
-#endif // __has_feature(cxx_atomic) && !_LIBCPP_HAS_NO_THREADS
+#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
 
 void
 declare_reachable(void*)
diff --git a/system/lib/libcxx/mutex.cpp b/system/lib/libcxx/mutex.cpp
index e56271d308e6f..127e67a2627e6 100644
--- a/system/lib/libcxx/mutex.cpp
+++ b/system/lib/libcxx/mutex.cpp
@@ -12,6 +12,7 @@
 #include "limits"
 #include "system_error"
 #include "cassert"
+#include "include/atomic_support.h"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 #ifndef _LIBCPP_HAS_NO_THREADS
@@ -220,6 +221,9 @@ static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
 #endif
 
+/// NOTE: Changes to flag are done via relaxed atomic stores
+///       even though the accesses are protected by a mutex because threads
+///       just entering 'call_once` concurrently read from flag.
 void
 __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
 {
@@ -252,11 +256,11 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
         try
         {
 #endif  // _LIBCPP_NO_EXCEPTIONS
-            flag = 1;
+            __libcpp_relaxed_store(&flag, 1ul);
             pthread_mutex_unlock(&mut);
             func(arg);
             pthread_mutex_lock(&mut);
-            flag = ~0ul;
+            __libcpp_relaxed_store(&flag, ~0ul);
             pthread_mutex_unlock(&mut);
             pthread_cond_broadcast(&cv);
 #ifndef _LIBCPP_NO_EXCEPTIONS
@@ -264,7 +268,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
         catch (...)
         {
             pthread_mutex_lock(&mut);
-            flag = 0ul;
+            __libcpp_relaxed_store(&flag, 0ul);
             pthread_mutex_unlock(&mut);
             pthread_cond_broadcast(&cv);
             throw;
diff --git a/system/lib/libcxx/new.cpp b/system/lib/libcxx/new.cpp
index 3b7c34138df97..f4f73d86803d3 100644
--- a/system/lib/libcxx/new.cpp
+++ b/system/lib/libcxx/new.cpp
@@ -13,11 +13,7 @@
 
 #include "new"
 
-#ifndef __has_include
-#define __has_include(inc) 0
-#endif
-
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(LIBCXXRT)
     #include <cxxabi.h>
 
     #ifndef _LIBCPPABI_VERSION
@@ -27,9 +23,9 @@
         #define __new_handler __cxxabiapple::__cxa_new_handler
     #endif
 #else  // __APPLE__
-    #if defined(LIBCXXRT) || __has_include(<cxxabi.h>)
+    #if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
         #include <cxxabi.h>
-    #endif  // __has_include(<cxxabi.h>)
+    #endif  // defined(LIBCXX_BUILDING_LIBCXXABI)
     #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)
         static std::new_handler __new_handler;
     #endif  // _LIBCPPABI_VERSION
@@ -38,7 +34,7 @@
 #ifndef __GLIBCXX__
 
 // Implement all new and delete operators as weak definitions
-// in this shared library, so that they can be overriden by programs
+// in this shared library, so that they can be overridden by programs
 // that define non-weak copies of the functions.
 
 _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
@@ -131,11 +127,18 @@ operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT
     ::operator delete(ptr);
 }
 
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void
+operator delete(void* ptr, size_t) _NOEXCEPT
+{
+    ::operator delete(ptr);
+}
+
 _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
 void
 operator delete[] (void* ptr) _NOEXCEPT
 {
-    ::operator delete (ptr);
+    ::operator delete(ptr);
 }
 
 _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
@@ -145,6 +148,13 @@ operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT
     ::operator delete[](ptr);
 }
 
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void
+operator delete[] (void* ptr, size_t) _NOEXCEPT
+{
+    ::operator delete[](ptr);
+}
+
 #endif // !__GLIBCXX__
 
 namespace std
@@ -192,8 +202,6 @@ bad_alloc::what() const _NOEXCEPT
 
 #endif // !__GLIBCXX__
 
-#endif //LIBCXXRT
-
 bad_array_new_length::bad_array_new_length() _NOEXCEPT
 {
 }
@@ -202,6 +210,14 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT
 {
 }
 
+const char*
+bad_array_new_length::what() const _NOEXCEPT
+{
+    return "bad_array_new_length";
+}
+
+#endif //LIBCXXRT
+
 const char*
 bad_array_length::what() const _NOEXCEPT
 {
@@ -216,12 +232,6 @@ bad_array_length::~bad_array_length() _NOEXCEPT
 {
 }
 
-const char*
-bad_array_new_length::what() const _NOEXCEPT
-{
-    return "bad_array_new_length";
-}
-
 #endif // _LIBCPPABI_VERSION
 
 #ifndef LIBSTDCXX
diff --git a/system/lib/libcxx/optional.cpp b/system/lib/libcxx/optional.cpp
index b614d811612fa..8c5dd76d86d6b 100644
--- a/system/lib/libcxx/optional.cpp
+++ b/system/lib/libcxx/optional.cpp
@@ -9,8 +9,7 @@
 
 #include "experimental/optional"
 
-namespace std  // purposefully not using versioning namespace
-{ namespace experimental {
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
 
 #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
@@ -22,4 +21,4 @@ bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
 
 #endif
 
-}}  // std::experimental
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL
diff --git a/system/lib/libcxx/random.cpp b/system/lib/libcxx/random.cpp
index 86017ef0d46ba..4ab424eaa6e58 100644
--- a/system/lib/libcxx/random.cpp
+++ b/system/lib/libcxx/random.cpp
@@ -7,29 +7,38 @@
 //
 //===----------------------------------------------------------------------===//
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_USING_WIN32_RANDOM)
 // Must be defined before including stdlib.h to enable rand_s().
 #define _CRT_RAND_S
-#include <stdio.h>
-#endif
+#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
 
 #include "random"
 #include "system_error"
 
-#ifdef __sun__
+#if defined(__sun__)
 #define rename solaris_headers_are_broken
-#endif
-#if !defined(_WIN32)
+#endif // defined(__sun__)
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#if defined(_LIBCPP_USING_DEV_RANDOM)
 #include <fcntl.h>
 #include <unistd.h>
-#endif // defined(_WIN32)
-#include <errno.h>
+#elif defined(_LIBCPP_USING_NACL_RANDOM)
+#include <nacl/nacl_random.h>
+#endif
+
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_WIN32)
-random_device::random_device(const string&)
+#if defined(_LIBCPP_USING_ARC4_RANDOM)
+
+random_device::random_device(const string& __token)
 {
+    if (__token != "/dev/urandom")
+        __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
 }
 
 random_device::~random_device()
@@ -39,13 +48,11 @@ random_device::~random_device()
 unsigned
 random_device::operator()()
 {
-    unsigned r;
-    errno_t err = rand_s(&r);
-    if (err)
-        __throw_system_error(err, "random_device rand_s failed.");
-    return r;
+    return arc4random();
 }
-#else
+
+#elif defined(_LIBCPP_USING_DEV_RANDOM)
+
 random_device::random_device(const string& __token)
     : __f_(open(__token.c_str(), O_RDONLY))
 {
@@ -80,7 +87,61 @@ random_device::operator()()
     }
     return r;
 }
-#endif // defined(_WIN32)
+
+#elif defined(_LIBCPP_USING_NACL_RANDOM)
+
+random_device::random_device(const string& __token)
+{
+    if (__token != "/dev/urandom")
+        __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+    int error = nacl_secure_random_init();
+    if (error)
+        __throw_system_error(error, ("random device failed to open " + __token).c_str());
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+    unsigned r;
+    size_t n = sizeof(r);
+    size_t bytes_written;
+    int error = nacl_secure_random(&r, n, &bytes_written);
+    if (error != 0)
+        __throw_system_error(error, "random_device failed getting bytes");
+    else if (bytes_written != n)
+        __throw_runtime_error("random_device failed to obtain enough bytes");
+    return r;
+}
+
+#elif defined(_LIBCPP_USING_WIN32_RANDOM)
+
+random_device::random_device(const string& __token)
+{
+    if (__token != "/dev/urandom")
+        __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+    unsigned r;
+    errno_t err = rand_s(&r);
+    if (err)
+        __throw_system_error(err, "random_device rand_s failed.");
+    return r;
+}
+
+#else
+#error "Random device not implemented for this architecture"
+#endif
 
 double
 random_device::entropy() const _NOEXCEPT
diff --git a/system/lib/libcxx/readme.txt b/system/lib/libcxx/readme.txt
index 7487d2914bb80..811cf9aec605a 100644
--- a/system/lib/libcxx/readme.txt
+++ b/system/lib/libcxx/readme.txt
@@ -1 +1 @@
-These files are from libc++, svn revision 218372, 2014-09-24. See http://libcxx.llvm.org
+These files are from libc++, svn revision 268153, 2016-04-29.
diff --git a/system/lib/libcxx/regex.cpp b/system/lib/libcxx/regex.cpp
index 17dd6eaa60a7e..a7363599d5a5c 100644
--- a/system/lib/libcxx/regex.cpp
+++ b/system/lib/libcxx/regex.cpp
@@ -69,21 +69,12 @@ regex_error::~regex_error() throw() {}
 
 namespace {
 
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
 struct collationnames
 {
     const char* elem_;
     char char_;
 };
 
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
 const collationnames collatenames[] =
 {
     {"A", 0x41},
@@ -199,21 +190,12 @@ const collationnames collatenames[] =
     {"zero", 0x30}
 };
 
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
 struct classnames
 {
     const char* elem_;
     regex_traits<char>::char_class_type mask_;
 };
 
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
 const classnames ClassNames[] =
 {
     {"alnum",  ctype_base::alnum},
diff --git a/system/lib/libcxx/shared_mutex.cpp b/system/lib/libcxx/shared_mutex.cpp
index 2b78c1feb9f53..874aceb1b03a9 100644
--- a/system/lib/libcxx/shared_mutex.cpp
+++ b/system/lib/libcxx/shared_mutex.cpp
@@ -15,7 +15,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-shared_timed_mutex::shared_timed_mutex()
+// Shared Mutex Base
+__shared_mutex_base::__shared_mutex_base()
     : __state_(0)
 {
 }
@@ -23,7 +24,7 @@ shared_timed_mutex::shared_timed_mutex()
 // Exclusive ownership
 
 void
-shared_timed_mutex::lock()
+__shared_mutex_base::lock()
 {
     unique_lock<mutex> lk(__mut_);
     while (__state_ & __write_entered_)
@@ -34,7 +35,7 @@ shared_timed_mutex::lock()
 }
 
 bool
-shared_timed_mutex::try_lock()
+__shared_mutex_base::try_lock()
 {
     unique_lock<mutex> lk(__mut_);
     if (__state_ == 0)
@@ -46,7 +47,7 @@ shared_timed_mutex::try_lock()
 }
 
 void
-shared_timed_mutex::unlock()
+__shared_mutex_base::unlock()
 {
     lock_guard<mutex> _(__mut_);
     __state_ = 0;
@@ -56,7 +57,7 @@ shared_timed_mutex::unlock()
 // Shared ownership
 
 void
-shared_timed_mutex::lock_shared()
+__shared_mutex_base::lock_shared()
 {
     unique_lock<mutex> lk(__mut_);
     while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
@@ -67,7 +68,7 @@ shared_timed_mutex::lock_shared()
 }
 
 bool
-shared_timed_mutex::try_lock_shared()
+__shared_mutex_base::try_lock_shared()
 {
     unique_lock<mutex> lk(__mut_);
     unsigned num_readers = __state_ & __n_readers_;
@@ -82,7 +83,7 @@ shared_timed_mutex::try_lock_shared()
 }
 
 void
-shared_timed_mutex::unlock_shared()
+__shared_mutex_base::unlock_shared()
 {
     lock_guard<mutex> _(__mut_);
     unsigned num_readers = (__state_ & __n_readers_) - 1;
@@ -101,6 +102,16 @@ shared_timed_mutex::unlock_shared()
 }
 
 
+// Shared Timed Mutex
+// These routines are here for ABI stability
+shared_timed_mutex::shared_timed_mutex() : __base() {}
+void shared_timed_mutex::lock()     { return __base.lock(); }
+bool shared_timed_mutex::try_lock() { return __base.try_lock(); }
+void shared_timed_mutex::unlock()   { return __base.unlock(); }
+void shared_timed_mutex::lock_shared() { return __base.lock_shared(); }
+bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); }
+void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); }
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // !_LIBCPP_HAS_NO_THREADS
diff --git a/system/lib/libcxx/stdexcept.cpp b/system/lib/libcxx/stdexcept.cpp
index aff4b1850d36b..0a08bfec27ec9 100644
--- a/system/lib/libcxx/stdexcept.cpp
+++ b/system/lib/libcxx/stdexcept.cpp
@@ -13,12 +13,8 @@
 #include "string"
 #include "system_error"
 
-#ifndef __has_include
-#define __has_include(inc) 0
-#endif
-
 /* For _LIBCPPABI_VERSION */
-#if __has_include(<cxxabi.h>) || defined(__APPLE_) || defined(LIBCXXRT)
+#if defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)
 #include <cxxabi.h>
 #endif
 
diff --git a/system/lib/libcxx/string.cpp b/system/lib/libcxx/string.cpp
index fdaad2927340b..d3f29df639f48 100644
--- a/system/lib/libcxx/string.cpp
+++ b/system/lib/libcxx/string.cpp
@@ -39,7 +39,7 @@ void throw_helper( const string& msg )
 #ifndef _LIBCPP_NO_EXCEPTIONS
     throw T( msg );
 #else
-    printf("%s\n", msg.c_str());
+    fprintf(stderr, "%s\n", msg.c_str());
     abort();
 #endif
 }
@@ -63,7 +63,7 @@ inline
 V
 as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)
 {
-    typename S::value_type* ptr;
+    typename S::value_type* ptr = nullptr;
     const typename S::value_type* const p = str.c_str();
     typename remove_reference<decltype(errno)>::type errno_save = errno;
     errno = 0;
@@ -180,7 +180,7 @@ inline
 V
 as_float_helper(const string& func, const S& str, size_t* idx, F f )
 {
-    typename S::value_type* ptr;
+    typename S::value_type* ptr = nullptr;
     const typename S::value_type* const p = str.c_str();
     typename remove_reference<decltype(errno)>::type errno_save = errno;
     errno = 0;
diff --git a/system/lib/libcxx/support/solaris/xlocale.c b/system/lib/libcxx/support/solaris/xlocale.c
index 39dd8e36835e0..9125eea73777f 100644
--- a/system/lib/libcxx/support/solaris/xlocale.c
+++ b/system/lib/libcxx/support/solaris/xlocale.c
@@ -8,167 +8,25 @@
 //===----------------------------------------------------------------------===//
 
 #ifdef __sun__
-      
+
+#include "support/solaris/xlocale.h"
+#include <stdarg.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h> 
-#include <dlfcn.h>
-#include <locale.h>
-#include <limits.h>
-#include <assert.h>
 #include <sys/localedef.h>
-#include "xlocale.h"
-
-static _LC_locale_t *__C_locale;
-
-#define FIX_LOCALE(l) l = (l == 0) ? __C_locale : l
-
-#include "mbsnrtowcs.inc"
-#include "wcsnrtombs.inc"
-      
-size_t __mb_cur_max(locale_t __l) {
-  FIX_LOCALE(__l);
-  return (__l->lc_ctype->cmapp->cm_mb_cur_max);
-}
-
-wint_t btowc_l(int __c, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->cmapp->core.user_api->btowc(__l->lc_ctype->cmapp, __c);
-}
-
-int wctob_l(wint_t __c, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->cmapp->core.user_api->wctob(__l->lc_ctype->cmapp, __c);
-}
-
-size_t wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->cmapp->core.user_api->wcrtomb(__l->lc_ctype->cmapp,
-      __s, __wc, __ps);
-}
-
-size_t mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
-                 mbstate_t *__ps, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->cmapp->core.user_api->mbrtowc(__l->lc_ctype->cmapp,
-      __pwc, __s, __n, __ps);
-}
-
-int mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->cmapp->core.user_api->mbtowc(__l->lc_ctype->cmapp,
-      __pwc, __pmb, __max);
-} 
-  
-size_t mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->cmapp->core.user_api->mbrlen(__l->lc_ctype->cmapp, __s,
-    __n, __ps);
-}
-
-struct lconv *localeconv_l(locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->core.user_api->localeconv(__l);
-} 
-  
-size_t mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
-                   mbstate_t *__ps, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->cmapp->core.user_api->mbsrtowcs(__l->lc_ctype->cmapp,
-      __dest, __src, __len, __ps);
-}
-
-int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_collate->core.user_api->wcscoll(__l->lc_collate,
-      __s1, __s2);
-}
-
-int strcoll_l(const char *__s1, const char *__s2, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_collate->core.user_api->strcoll(__l->lc_collate,
-      __s1, __s2);
-}
 
-size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_collate->core.user_api->strxfrm(__l->lc_collate,
-      __s1, __s2, __n);
-}
-size_t strftime_l(char *__s, size_t __size, const char *__fmt, const struct tm
-    *__tm, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_time->core.user_api->strftime(__l->lc_time,
-      __s, __size, __fmt, __tm);
-}
 
-size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n,
-    locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_collate->core.user_api->wcsxfrm(__l->lc_collate,
-      __ws1, __ws2, __n);
+int isxdigit_l(int __c, locale_t __l) {
+    return isxdigit(__c);
 }
 
-#define LOCALE_ISCTYPE(ctype, m) \
-  int is##ctype##_l(int __c, locale_t __l) { \
-    if ((__c < 0) || (__c > 255)) return 0;\
-    FIX_LOCALE(__l);\
-    return __l->lc_ctype->mask[__c] & m;\
-  }\
-  int isw##ctype##_l(wchar_t __c, locale_t __l) { \
-    FIX_LOCALE(__l);\
-    return __l->lc_ctype->core.user_api->iswctype(__l->lc_ctype, __c, m);\
-  }
-
-LOCALE_ISCTYPE(alnum, _ISALNUM)
-LOCALE_ISCTYPE(alpha, _ISALPHA)
-LOCALE_ISCTYPE(blank, _ISALPHA)
-LOCALE_ISCTYPE(cntrl, _ISCNTRL)
-LOCALE_ISCTYPE(digit, _ISDIGIT)
-LOCALE_ISCTYPE(graph, _ISGRAPH)
-LOCALE_ISCTYPE(lower, _ISLOWER)
-LOCALE_ISCTYPE(print, _ISPRINT)
-LOCALE_ISCTYPE(punct, _ISPUNCT)
-LOCALE_ISCTYPE(space, _ISSPACE)
-LOCALE_ISCTYPE(upper, _ISUPPER)
-LOCALE_ISCTYPE(xdigit, _ISXDIGIT)
-
-int iswctype_l(wint_t __c, wctype_t __m, locale_t __l) {
-    FIX_LOCALE(__l);\
-    return __l->lc_ctype->core.user_api->iswctype(__l->lc_ctype, __c, __m);\
-}
-
-int toupper_l(int __c, locale_t __l) {
-  FIX_LOCALE(__l);
-    if ((__c < 0) || (__c > __l->lc_ctype->max_upper)) return __c;
-  return __l->lc_ctype->upper[__c];
-}
-int tolower_l(int __c, locale_t __l) {
-  FIX_LOCALE(__l);
-  if ((__c < 0) || (__c > __l->lc_ctype->max_lower)) return __c;
-  return __l->lc_ctype->lower[__c];
-}
-wint_t towupper_l(wint_t __c, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->core.user_api->towupper(__l->lc_ctype, __c);
-}
-wint_t towlower_l(wint_t __c, locale_t __l) {
-  FIX_LOCALE(__l);
-  return __l->lc_ctype->core.user_api->towlower(__l->lc_ctype, __c);
+int iswxdigit_l(wchar_t __c, locale_t __l) {
+    return isxdigit(__c);
 }
 
 // FIXME: This disregards the locale, which is Very Wrong
 #define vsnprintf_l(__s, __n, __l, __format, __va)  \
     vsnprintf(__s, __n, __format, __va) 
 
-int sprintf_l(char *__s, locale_t __l, const char *__format, ...) {
-  va_list __va;
-  va_start(__va, __format);
-  int __res = vsnprintf_l(__s, SIZE_MAX, __l, __format, __va);
-  va_end(__va);
-  return __res;
-}
-
 int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...)
 {
   va_list __va;
@@ -196,58 +54,13 @@ int sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
   return __res;
 }
 
-locale_t newlocale(int mask, const char *locale, locale_t base) {
-
-  if ((locale == NULL) || (locale[0] == '\0') ||
-      ((locale[0] == 'C') && (locale[1] == '\0')))
-  {
-    return __C_locale;
-  }
-
-  // Solaris locales are shared libraries that contain 
-  char *path;
-#ifdef __LP64
-  asprintf(&path, "/usr/lib/locale/%1$s/amd64/%1$s.so.3", locale);
-#else
-  asprintf(&path, "/usr/lib/locale/%1$s/%1$s.so.3", locale);
-#endif
-  void *handle = dlopen(path, RTLD_LOCAL | RTLD_NOW);
-  free(path);
-  if (!handle) 
-    return 0;
-  _LC_locale_t *(*init)() = dlsym(handle, "instantiate");
-  if (!init)
-    return 0;
-  _LC_locale_t  *p = init();
-  if (!p)
-    return 0;
-
-  if (!base)
-    base = __C_locale;
-
-  locale_t ret = calloc(1, sizeof(struct _LC_locale_t));
-  memcpy(ret, p, sizeof (_LC_locale_t));
-  ret->lc_collate = (mask & LC_COLLATE_MASK) ? p->lc_collate : base->lc_collate;
-  ret->lc_ctype = (mask & LC_CTYPE_MASK) ? p->lc_ctype : base->lc_ctype;
-  ret->lc_messages = (mask & LC_MESSAGES_MASK) ? p->lc_messages : base->lc_messages;
-  ret->lc_monetary = (mask & LC_MONETARY_MASK) ? p->lc_monetary : base->lc_monetary;
-  ret->lc_time = (mask & LC_TIME_MASK) ? p->lc_time : base->lc_time;
-  return ret;
+size_t mbrtowc_l(wchar_t *__pwc, const char *__pmb,
+                 size_t __max, mbstate_t *__ps, locale_t __loc) {
+  return mbrtowc(__pwc, __pmb, __max, __ps);
 }
 
-void freelocale(locale_t loc)
-{
-  if (loc != __C_locale)
-    free(loc);
+struct lconv *localeconv_l(locale_t __l) {
+  return localeconv();
 }
 
-__attribute__((constructor))
-static void setupCLocale(void) {
-  // The default initial locale is the C locale.  This is a statically
-  // allocated locale inside libc.  At program start, __lc_locale will point to
-  // this.  We need to grab a copy because it's not a public symbol.  If we had
-  // access to the source code for libc, then we'd just use it directly...
-  assert('C' == setlocale(LC_ALL, 0)[0]);
-  __C_locale = __lc_locale;
-}
-#endif
+#endif // __sun__
diff --git a/system/lib/libcxx/symbols b/system/lib/libcxx/symbols
index 9384940b2bb14..9db0523d4ca5a 100644
--- a/system/lib/libcxx/symbols
+++ b/system/lib/libcxx/symbols
@@ -1,79 +1,164 @@
-         T _ZNKSt16nested_exception14rethrow_nestedEv
-         T _ZNKSt3__110__time_put8__do_putEPcRS1_PK2tmcc
-         T _ZNKSt3__110__time_put8__do_putEPwRS1_PK2tmcc
-         T _ZNKSt3__110error_code7messageEv
-         W _ZNKSt3__110moneypunctIcLb0EE10neg_formatEv
-         W _ZNKSt3__110moneypunctIcLb0EE10pos_formatEv
-         W _ZNKSt3__110moneypunctIcLb0EE11curr_symbolEv
-         W _ZNKSt3__110moneypunctIcLb0EE11do_groupingEv
-         W _ZNKSt3__110moneypunctIcLb0EE11frac_digitsEv
-         W _ZNKSt3__110moneypunctIcLb0EE13decimal_pointEv
-         W _ZNKSt3__110moneypunctIcLb0EE13do_neg_formatEv
-         W _ZNKSt3__110moneypunctIcLb0EE13do_pos_formatEv
-         W _ZNKSt3__110moneypunctIcLb0EE13negative_signEv
-         W _ZNKSt3__110moneypunctIcLb0EE13positive_signEv
-         W _ZNKSt3__110moneypunctIcLb0EE13thousands_sepEv
-         W _ZNKSt3__110moneypunctIcLb0EE14do_curr_symbolEv
-         W _ZNKSt3__110moneypunctIcLb0EE14do_frac_digitsEv
-         W _ZNKSt3__110moneypunctIcLb0EE16do_decimal_pointEv
-         W _ZNKSt3__110moneypunctIcLb0EE16do_negative_signEv
-         W _ZNKSt3__110moneypunctIcLb0EE16do_positive_signEv
-         W _ZNKSt3__110moneypunctIcLb0EE16do_thousands_sepEv
-         W _ZNKSt3__110moneypunctIcLb0EE8groupingEv
-         W _ZNKSt3__110moneypunctIcLb1EE10neg_formatEv
-         W _ZNKSt3__110moneypunctIcLb1EE10pos_formatEv
-         W _ZNKSt3__110moneypunctIcLb1EE11curr_symbolEv
-         W _ZNKSt3__110moneypunctIcLb1EE11do_groupingEv
-         W _ZNKSt3__110moneypunctIcLb1EE11frac_digitsEv
-         W _ZNKSt3__110moneypunctIcLb1EE13decimal_pointEv
-         W _ZNKSt3__110moneypunctIcLb1EE13do_neg_formatEv
-         W _ZNKSt3__110moneypunctIcLb1EE13do_pos_formatEv
-         W _ZNKSt3__110moneypunctIcLb1EE13negative_signEv
-         W _ZNKSt3__110moneypunctIcLb1EE13positive_signEv
-         W _ZNKSt3__110moneypunctIcLb1EE13thousands_sepEv
-         W _ZNKSt3__110moneypunctIcLb1EE14do_curr_symbolEv
-         W _ZNKSt3__110moneypunctIcLb1EE14do_frac_digitsEv
-         W _ZNKSt3__110moneypunctIcLb1EE16do_decimal_pointEv
-         W _ZNKSt3__110moneypunctIcLb1EE16do_negative_signEv
-         W _ZNKSt3__110moneypunctIcLb1EE16do_positive_signEv
-         W _ZNKSt3__110moneypunctIcLb1EE16do_thousands_sepEv
-         W _ZNKSt3__110moneypunctIcLb1EE8groupingEv
-         W _ZNKSt3__110moneypunctIwLb0EE10neg_formatEv
-         W _ZNKSt3__110moneypunctIwLb0EE10pos_formatEv
-         W _ZNKSt3__110moneypunctIwLb0EE11curr_symbolEv
-         W _ZNKSt3__110moneypunctIwLb0EE11do_groupingEv
-         W _ZNKSt3__110moneypunctIwLb0EE11frac_digitsEv
-         W _ZNKSt3__110moneypunctIwLb0EE13decimal_pointEv
-         W _ZNKSt3__110moneypunctIwLb0EE13do_neg_formatEv
-         W _ZNKSt3__110moneypunctIwLb0EE13do_pos_formatEv
-         W _ZNKSt3__110moneypunctIwLb0EE13negative_signEv
-         W _ZNKSt3__110moneypunctIwLb0EE13positive_signEv
-         W _ZNKSt3__110moneypunctIwLb0EE13thousands_sepEv
-         W _ZNKSt3__110moneypunctIwLb0EE14do_curr_symbolEv
-         W _ZNKSt3__110moneypunctIwLb0EE14do_frac_digitsEv
-         W _ZNKSt3__110moneypunctIwLb0EE16do_decimal_pointEv
-         W _ZNKSt3__110moneypunctIwLb0EE16do_negative_signEv
-         W _ZNKSt3__110moneypunctIwLb0EE16do_positive_signEv
-         W _ZNKSt3__110moneypunctIwLb0EE16do_thousands_sepEv
-         W _ZNKSt3__110moneypunctIwLb0EE8groupingEv
-         W _ZNKSt3__110moneypunctIwLb1EE10neg_formatEv
-         W _ZNKSt3__110moneypunctIwLb1EE10pos_formatEv
-         W _ZNKSt3__110moneypunctIwLb1EE11curr_symbolEv
-         W _ZNKSt3__110moneypunctIwLb1EE11do_groupingEv
-         W _ZNKSt3__110moneypunctIwLb1EE11frac_digitsEv
-         W _ZNKSt3__110moneypunctIwLb1EE13decimal_pointEv
-         W _ZNKSt3__110moneypunctIwLb1EE13do_neg_formatEv
-         W _ZNKSt3__110moneypunctIwLb1EE13do_pos_formatEv
-         W _ZNKSt3__110moneypunctIwLb1EE13negative_signEv
-         W _ZNKSt3__110moneypunctIwLb1EE13positive_signEv
-         W _ZNKSt3__110moneypunctIwLb1EE13thousands_sepEv
-         W _ZNKSt3__110moneypunctIwLb1EE14do_curr_symbolEv
-         W _ZNKSt3__110moneypunctIwLb1EE14do_frac_digitsEv
-         W _ZNKSt3__110moneypunctIwLb1EE16do_decimal_pointEv
-         W _ZNKSt3__110moneypunctIwLb1EE16do_negative_signEv
-         W _ZNKSt3__110moneypunctIwLb1EE16do_positive_signEv
-         W _ZNKSt3__110moneypunctIwLb1EE16do_thousands_sepEv
-         W _ZNKSt3__110moneypunctIwLb1EE8groupingEv
+         D _ZNSt3__112__rs_default4__c_E
+         T _ZNSt3__112__rs_defaultC1ERKS0_
+         T _ZNSt3__112__rs_defaultC1Ev
+         T _ZNSt3__112__rs_defaultC2ERKS0_
+         T _ZNSt3__112__rs_defaultC2Ev
+         T _ZNSt3__112__rs_defaultD1Ev
+         T _ZNSt3__112__rs_defaultD2Ev
+         T _ZNSt3__112__rs_defaultclEv
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIaaEEPaEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIccEEPcEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIddEEPdEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIeeEEPeEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIffEEPfEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIhhEEPhEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIiiEEPiEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIjjEEPjEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIllEEPlEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessImmEEPmEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIssEEPsEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIttEEPtEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIwwEEPwEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIxxEEPxEEvT0_S5_T_
+         W _ZNSt3__118__insertion_sort_3IRNS_6__lessIyyEEPyEEvT0_S5_T_
+         W _ZNSt3__123mersenne_twister_engineIjLj32ELj624ELj397ELj31ELj2567483615ELj11ELj4294967295ELj7ELj2636928640ELj15ELj4022730752ELj18ELj1812433253EE4seedEj
+         W _ZNSt3__123mersenne_twister_engineIjLj32ELj624ELj397ELj31ELj2567483615ELj11ELj4294967295ELj7ELj2636928640ELj15ELj4022730752ELj18ELj1812433253EEclEv
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIaaEEPaEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIccEEPcEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIddEEPdEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIeeEEPeEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIffEEPfEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIhhEEPhEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIiiEEPiEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIjjEEPjEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIllEEPlEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessImmEEPmEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIssEEPsEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIttEEPtEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIwwEEPwEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIxxEEPxEEbT0_S5_T_
+         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIyyEEPyEEbT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIeeEEPeEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIffEEPfEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIhhEEPhEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIiiEEPiEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIjjEEPjEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIllEEPlEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessImmEEPmEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIssEEPsEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIttEEPtEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIwwEEPwEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIxxEEPxEEvT0_S5_T_
+         W _ZNSt3__16__sortIRNS_6__lessIyyEEPyEEvT0_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIaaEEPaEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIccEEPcEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIddEEPdEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIeeEEPeEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIffEEPfEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIhhEEPhEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIiiEEPiEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIjjEEPjEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIllEEPlEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessImmEEPmEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIssEEPsEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIttEEPtEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIwwEEPwEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIxxEEPxEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort3IRNS_6__lessIyyEEPyEEjT0_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIaaEEPaEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIccEEPcEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIddEEPdEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIeeEEPeEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIffEEPfEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIhhEEPhEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIiiEEPiEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIjjEEPjEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIllEEPlEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessImmEEPmEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIssEEPsEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIttEEPtEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIwwEEPwEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIxxEEPxEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort4IRNS_6__lessIyyEEPyEEjT0_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIaaEEPaEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIccEEPcEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIddEEPdEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIeeEEPeEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIffEEPfEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIhhEEPhEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIiiEEPiEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIjjEEPjEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIllEEPlEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessImmEEPmEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIssEEPsEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIttEEPtEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIwwEEPwEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIxxEEPxEEjT0_S5_S5_S5_S5_T_
+         W _ZNSt3__17__sort5IRNS_6__lessIyyEEPyEEjT0_S5_S5_S5_S5_T_
+         T _ZNSt3__18__rs_getEv
+         U _ZSt9terminatev
+         W __clang_call_terminate
+         U __cxa_begin_catch
+         U __cxa_guard_acquire
+         U __cxa_guard_release
+         U __gxx_personality_v0
+         U pthread_mutex_lock
+         U pthread_mutex_unlock
+         T _ZNKSt12experimental15fundamentals_v112bad_any_cast4whatEv
+         W _ZNSt12experimental15fundamentals_v112bad_any_castD0Ev
+         U _ZNSt8bad_castD2Ev
+         D _ZTINSt12experimental15fundamentals_v112bad_any_castE
+         U _ZTISt8bad_cast
+         D _ZTSNSt12experimental15fundamentals_v112bad_any_castE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         D _ZTVNSt12experimental15fundamentals_v112bad_any_castE
+         U _ZdlPv
+         D _ZNSt3__112placeholders2_1E
+         D _ZNSt3__112placeholders2_2E
+         D _ZNSt3__112placeholders2_3E
+         D _ZNSt3__112placeholders2_4E
+         D _ZNSt3__112placeholders2_5E
+         D _ZNSt3__112placeholders2_6E
+         D _ZNSt3__112placeholders2_7E
+         D _ZNSt3__112placeholders2_8E
+         D _ZNSt3__112placeholders2_9E
+         D _ZNSt3__112placeholders3_10E
+         U _ZNSt3__120__throw_system_errorEiPKc
+         T _ZNSt3__16chrono12steady_clock3nowEv
+         D _ZNSt3__16chrono12steady_clock9is_steadyE
+         T _ZNSt3__16chrono12system_clock11from_time_tEl
+         T _ZNSt3__16chrono12system_clock3nowEv
+         D _ZNSt3__16chrono12system_clock9is_steadyE
+         T _ZNSt3__16chrono12system_clock9to_time_tERKNS0_10time_pointIS1_NS0_8durationIxNS_5ratioILx1ELx1000000EEEEEEE
+         U _ZSt9terminatev
+         W __clang_call_terminate
+         U __cxa_begin_catch
+         U __errno_location
+         U __gxx_personality_v0
+         U clock_gettime
+         U _ZNSt3__115__thread_struct25notify_all_at_thread_exitEPNS_18condition_variableEPNS_5mutexE
+         T _ZNSt3__118condition_variable10notify_allEv
+         T _ZNSt3__118condition_variable10notify_oneEv
+         T _ZNSt3__118condition_variable15__do_timed_waitERNS_11unique_lockINS_5mutexEEENS_6chrono10time_pointINS5_12system_clockENS5_8durationIxNS_5ratioILx1ELx1000000000EEEEEEE
+         T _ZNSt3__118condition_variable4waitERNS_11unique_lockINS_5mutexEEE
+         T _ZNSt3__118condition_variableD1Ev
+         T _ZNSt3__118condition_variableD2Ev
+         U _ZNSt3__119__thread_local_dataEv
+         U _ZNSt3__120__throw_system_errorEiPKc
+         T _ZNSt3__125notify_all_at_thread_exitERNS_18condition_variableENS_11unique_lockINS_5mutexEEE
+         U _ZSt9terminatev
+         W __clang_call_terminate
+         U __cxa_begin_catch
+         U __gxx_personality_v0
+         U pthread_cond_broadcast
+         U pthread_cond_destroy
+         U pthread_cond_signal
+         U pthread_cond_timedwait
+         U pthread_cond_wait
+         U pthread_getspecific
          T _ZNKSt3__111__libcpp_db15__decrementableEPKv
          T _ZNKSt3__111__libcpp_db15__find_c_from_iEPv
          T _ZNKSt3__111__libcpp_db15__find_iteratorEPKv
@@ -84,224 +169,196 @@
          T _ZNKSt3__111__libcpp_db6unlockEv
          T _ZNKSt3__111__libcpp_db8__find_cEPv
          T _ZNKSt3__111__libcpp_db9__addableEPKvi
-         T _ZNKSt3__112__do_message7messageEi
-         T _ZNKSt3__112bad_weak_ptr4whatEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12__invariantsEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofEPKcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofEPKcjj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofERKS5_j
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofEcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__get_pointerEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13find_first_ofEPKcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13find_first_ofEPKcjj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13find_first_ofERKS5_j
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13find_first_ofEcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13get_allocatorEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE14__get_long_capEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE15__get_long_sizeEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__get_short_sizeEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofEPKcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofEPKcjj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofERKS5_j
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofEcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofEPKcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofEPKcjj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofERKS5_j
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofEcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE18__get_long_pointerEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__get_short_pointerEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE2atEj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE3endEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4backEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4cendEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcjj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findEPKcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findEPKcjj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findERKS5_j
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findEcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4rendEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4sizeEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5beginEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5c_strEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5crendEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5emptyEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5frontEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5rfindEPKcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5rfindEPKcjj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5rfindERKS5_j
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5rfindEcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6cbeginEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6lengthEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6rbeginEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6substrEjj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7__allocEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEPKc
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareERKS5_
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjPKc
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjPKcj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjRKS5_
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjRKS5_jj
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7crbeginEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE8capacityEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE8max_sizeEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__is_longEv
-         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEixEj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12__invariantsEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12find_last_ofEPKwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12find_last_ofEPKwjj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12find_last_ofERKS5_j
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12find_last_ofEwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13__get_pointerEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13find_first_ofEPKwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13find_first_ofEPKwjj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13find_first_ofERKS5_j
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13find_first_ofEwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13get_allocatorEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE14__get_long_capEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE15__get_long_sizeEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16__get_short_sizeEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16find_last_not_ofEPKwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16find_last_not_ofEPKwjj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16find_last_not_ofERKS5_j
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16find_last_not_ofEwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE17find_first_not_ofEPKwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE17find_first_not_ofEPKwjj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE17find_first_not_ofERKS5_j
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE17find_first_not_ofEwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE18__get_long_pointerEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__get_short_pointerEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE2atEj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE3endEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4backEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4cendEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4copyEPwjj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4dataEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4findEPKwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4findEPKwjj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4findERKS5_j
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4findEwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4rendEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4sizeEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5beginEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5c_strEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5crendEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5emptyEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5frontEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5rfindEPKwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5rfindEPKwjj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5rfindERKS5_j
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5rfindEwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6cbeginEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6lengthEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6rbeginEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6substrEjj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7__allocEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEPKw
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareERKS5_
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEjjPKw
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEjjPKwj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEjjRKS5_
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEjjRKS5_jj
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7crbeginEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE8capacityEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE8max_sizeEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9__is_longEv
-         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEixEj
-         T _ZNKSt3__112ctype_bynameIcE10do_tolowerEPcPKc
-         T _ZNKSt3__112ctype_bynameIcE10do_tolowerEc
-         T _ZNKSt3__112ctype_bynameIcE10do_toupperEPcPKc
-         T _ZNKSt3__112ctype_bynameIcE10do_toupperEc
-         T _ZNKSt3__112ctype_bynameIwE10do_scan_isEtPKwS3_
-         T _ZNKSt3__112ctype_bynameIwE10do_tolowerEPwPKw
-         T _ZNKSt3__112ctype_bynameIwE10do_tolowerEw
-         T _ZNKSt3__112ctype_bynameIwE10do_toupperEPwPKw
-         T _ZNKSt3__112ctype_bynameIwE10do_toupperEw
-         T _ZNKSt3__112ctype_bynameIwE11do_scan_notEtPKwS3_
-         T _ZNKSt3__112ctype_bynameIwE5do_isEPKwS3_Pt
-         T _ZNKSt3__112ctype_bynameIwE5do_isEtw
-         T _ZNKSt3__112ctype_bynameIwE8do_widenEPKcS3_Pw
-         T _ZNKSt3__112ctype_bynameIwE8do_widenEc
-         T _ZNKSt3__112ctype_bynameIwE9do_narrowEPKwS3_cPc
-         T _ZNKSt3__112ctype_bynameIwE9do_narrowEwc
-         T _ZNKSt3__112strstreambuf6pcountEv
+         T _ZNSt3__111__libcpp_db10__insert_cEPv
+         T _ZNSt3__111__libcpp_db10__insert_iEPv
+         T _ZNSt3__111__libcpp_db11__insert_icEPvPKv
+         T _ZNSt3__111__libcpp_db15__iterator_copyEPvPKv
+         T _ZNSt3__111__libcpp_db16__invalidate_allEPv
+         T _ZNSt3__111__libcpp_db17__insert_iteratorEPv
+         T _ZNSt3__111__libcpp_db4swapEPvS1_
+         T _ZNSt3__111__libcpp_db9__erase_cEPv
+         T _ZNSt3__111__libcpp_db9__erase_iEPv
+         T _ZNSt3__111__libcpp_dbC1Ev
+         T _ZNSt3__111__libcpp_dbC2Ev
+         T _ZNSt3__111__libcpp_dbD1Ev
+         T _ZNSt3__111__libcpp_dbD2Ev
+         U _ZNSt3__112__next_primeEj
+         T _ZNSt3__114__get_const_dbEv
+         W _ZNSt3__121__murmur2_or_cityhashIjLj32EEclEPKvj
+         U _ZNSt3__15mutex4lockEv
+         U _ZNSt3__15mutex6unlockEv
+         U _ZNSt3__15mutexD1Ev
+         T _ZNSt3__18__c_node5__addEPNS_8__i_nodeE
+         T _ZNSt3__18__c_node8__removeEPNS_8__i_nodeE
+         T _ZNSt3__18__c_nodeD0Ev
+         T _ZNSt3__18__c_nodeD1Ev
+         T _ZNSt3__18__c_nodeD2Ev
+         T _ZNSt3__18__get_dbEv
+         T _ZNSt3__18__i_nodeD1Ev
+         T _ZNSt3__18__i_nodeD2Ev
+         U _ZNSt9bad_allocC1Ev
+         U _ZNSt9bad_allocD1Ev
+         D _ZTINSt3__18__c_nodeE
+         U _ZTISt9bad_alloc
+         D _ZTSNSt3__18__c_nodeE
+         U _ZTVN10__cxxabiv117__class_type_infoE
+         D _ZTVNSt3__18__c_nodeE
+         U _ZdlPv
+         U __cxa_allocate_exception
+         U __cxa_atexit
+         U __cxa_guard_acquire
+         U __cxa_guard_release
+         U __cxa_pure_virtual
+         U __cxa_throw
+         U __dso_handle
+         U __gxx_personality_v0
+         U abort
+         U calloc
+         U fprintf
+         U free
+         U malloc
+         U stderr
+         T _ZNKSt16nested_exception14rethrow_nestedEv
+         T _ZNSt13exception_ptrC1ERKS_
+         T _ZNSt13exception_ptrC2ERKS_
+         T _ZNSt13exception_ptrD1Ev
+         T _ZNSt13exception_ptrD2Ev
+         T _ZNSt13exception_ptraSERKS_
+         T _ZNSt16nested_exceptionC1Ev
+         T _ZNSt16nested_exceptionC2Ev
+         T _ZNSt16nested_exceptionD0Ev
+         T _ZNSt16nested_exceptionD1Ev
+         T _ZNSt16nested_exceptionD2Ev
+         T _ZSt17current_exceptionv
+         T _ZSt17rethrow_exceptionSt13exception_ptr
+         U _ZSt9terminatev
+         D _ZTISt16nested_exception
+         D _ZTSSt16nested_exception
+         U _ZTVN10__cxxabiv117__class_type_infoE
+         D _ZTVSt16nested_exception
+         U _ZdlPv
+         U __cxa_current_primary_exception
+         U __cxa_decrement_exception_refcount
+         U __cxa_increment_exception_refcount
+         U __cxa_rethrow_primary_exception
+         U __gxx_personality_v0
+         U _ZNKSt11logic_error4whatEv
+         U _ZNKSt3__110error_code7messageEv
+         U _ZNKSt3__114error_category10equivalentERKNS_10error_codeEi
+         U _ZNKSt3__114error_category10equivalentEiRKNS_15error_conditionE
+         U _ZNKSt3__114error_category23default_error_conditionEi
+         T _ZNKSt3__123__future_error_category4nameEv
+         T _ZNKSt3__123__future_error_category7messageEi
+         U _ZNSt11logic_errorC2ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
+         U _ZNSt11logic_errorC2ERKS_
+         U _ZNSt11logic_errorD2Ev
+         U _ZNSt13exception_ptrC1ERKS_
+         U _ZNSt13exception_ptrD1Ev
+         U _ZNSt13exception_ptraSERKS_
+         W _ZNSt3__111unique_lockINS_5mutexEE6unlockEv
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
+         T _ZNSt3__112future_errorC1ENS_10error_codeE
+         T _ZNSt3__112future_errorC2ENS_10error_codeE
+         W _ZNSt3__112future_errorC2ERKS0_
+         T _ZNSt3__112future_errorD0Ev
+         T _ZNSt3__112future_errorD1Ev
+         T _ZNSt3__112future_errorD2Ev
+         T _ZNSt3__113shared_futureIvED1Ev
+         T _ZNSt3__113shared_futureIvED2Ev
+         T _ZNSt3__113shared_futureIvEaSERKS1_
+         U _ZNSt3__114__shared_count12__add_sharedEv
+         U _ZNSt3__114__shared_count16__release_sharedEv
+         U _ZNSt3__114__shared_countD2Ev
+         U _ZNSt3__114error_categoryD2Ev
+         U _ZNSt3__115__thread_struct27__make_ready_at_thread_exitEPNS_17__assoc_sub_stateE
+         T _ZNSt3__115future_categoryEv
+         T _ZNSt3__117__assoc_sub_state10__sub_waitERNS_11unique_lockINS_5mutexEEE
+         T _ZNSt3__117__assoc_sub_state12__make_readyEv
+         T _ZNSt3__117__assoc_sub_state13set_exceptionESt13exception_ptr
+         T _ZNSt3__117__assoc_sub_state16__on_zero_sharedEv
+         T _ZNSt3__117__assoc_sub_state24set_value_at_thread_exitEv
+         T _ZNSt3__117__assoc_sub_state28set_exception_at_thread_exitESt13exception_ptr
+         T _ZNSt3__117__assoc_sub_state4copyEv
+         T _ZNSt3__117__assoc_sub_state4waitEv
+         T _ZNSt3__117__assoc_sub_state9__executeEv
+         T _ZNSt3__117__assoc_sub_state9set_valueEv
+         W _ZNSt3__117__assoc_sub_stateD0Ev
+         W _ZNSt3__117__assoc_sub_stateD2Ev
+         U _ZNSt3__118condition_variable10notify_allEv
+         U _ZNSt3__118condition_variable4waitERNS_11unique_lockINS_5mutexEEE
+         U _ZNSt3__118condition_variableD1Ev
+         U _ZNSt3__119__thread_local_dataEv
+         U _ZNSt3__120__throw_system_errorEiPKc
+         W _ZNSt3__123__future_error_categoryD0Ev
+         U _ZNSt3__15mutex4lockEv
+         U _ZNSt3__15mutex6unlockEv
+         U _ZNSt3__15mutexD1Ev
+         T _ZNSt3__16futureIvE3getEv
+         T _ZNSt3__16futureIvEC1EPNS_17__assoc_sub_stateE
+         T _ZNSt3__16futureIvEC2EPNS_17__assoc_sub_stateE
+         T _ZNSt3__16futureIvED1Ev
+         T _ZNSt3__16futureIvED2Ev
+         T _ZNSt3__17promiseIvE10get_futureEv
+         T _ZNSt3__17promiseIvE13set_exceptionESt13exception_ptr
+         T _ZNSt3__17promiseIvE24set_value_at_thread_exitEv
+         T _ZNSt3__17promiseIvE28set_exception_at_thread_exitESt13exception_ptr
+         T _ZNSt3__17promiseIvE9set_valueEv
+         T _ZNSt3__17promiseIvEC1Ev
+         T _ZNSt3__17promiseIvEC2Ev
+         T _ZNSt3__17promiseIvED1Ev
+         T _ZNSt3__17promiseIvED2Ev
+         U _ZSt17current_exceptionv
+         U _ZSt17rethrow_exceptionSt13exception_ptr
+         W _ZSt18make_exception_ptrINSt3__112future_errorEESt13exception_ptrT_
+         U _ZSt9terminatev
+         U _ZTINSt3__112__do_messageE
+         D _ZTINSt3__112future_errorE
+         U _ZTINSt3__114__shared_countE
+         D _ZTINSt3__117__assoc_sub_stateE
+         D _ZTINSt3__123__future_error_categoryE
+         U _ZTISt11logic_error
+         D _ZTSNSt3__112future_errorE
+         D _ZTSNSt3__117__assoc_sub_stateE
+         D _ZTSNSt3__123__future_error_categoryE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         D _ZTVNSt3__112future_errorE
+         D _ZTVNSt3__117__assoc_sub_stateE
+         D _ZTVNSt3__123__future_error_categoryE
+         U _ZdlPv
+         U _Znwj
+         W __clang_call_terminate
+         U __cxa_allocate_exception
+         U __cxa_atexit
+         U __cxa_begin_catch
+         U __cxa_end_catch
+         U __cxa_free_exception
+         U __cxa_guard_acquire
+         U __cxa_guard_release
+         U __cxa_throw
+         U __dso_handle
+         U __gxx_personality_v0
+         U pthread_getspecific
+         U _ZNSt13runtime_errorC2EPKc
+         U _ZNSt14overflow_errorD1Ev
+         T _ZNSt3__112__next_primeEj
+         U _ZTISt14overflow_error
+         U _ZTVSt14overflow_error
+         U __cxa_allocate_exception
+         U __cxa_free_exception
+         U __cxa_throw
+         U __gxx_personality_v0
+         U _ZNKSt13runtime_error4whatEv
+         U _ZNKSt3__112__do_message7messageEi
          W _ZNKSt3__113basic_istreamIcNS_11char_traitsIcEEE6gcountEv
          W _ZNKSt3__113basic_istreamIcNS_11char_traitsIcEEE6sentrycvbEv
          W _ZNKSt3__113basic_istreamIwNS_11char_traitsIwEEE6gcountEv
          W _ZNKSt3__113basic_istreamIwNS_11char_traitsIwEEE6sentrycvbEv
          W _ZNKSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentrycvbEv
          W _ZNKSt3__113basic_ostreamIwNS_11char_traitsIwEEE6sentrycvbEv
-         T _ZNKSt3__113random_device7entropyEv
-         T _ZNKSt3__114__codecvt_utf8IDiE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__114__codecvt_utf8IDiE11do_encodingEv
-         T _ZNKSt3__114__codecvt_utf8IDiE13do_max_lengthEv
-         T _ZNKSt3__114__codecvt_utf8IDiE16do_always_noconvEv
-         T _ZNKSt3__114__codecvt_utf8IDiE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_
-         T _ZNKSt3__114__codecvt_utf8IDiE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_
-         T _ZNKSt3__114__codecvt_utf8IDiE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__114__codecvt_utf8IDsE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__114__codecvt_utf8IDsE11do_encodingEv
-         T _ZNKSt3__114__codecvt_utf8IDsE13do_max_lengthEv
-         T _ZNKSt3__114__codecvt_utf8IDsE16do_always_noconvEv
-         T _ZNKSt3__114__codecvt_utf8IDsE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_
-         T _ZNKSt3__114__codecvt_utf8IDsE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_
-         T _ZNKSt3__114__codecvt_utf8IDsE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__114__codecvt_utf8IwE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__114__codecvt_utf8IwE11do_encodingEv
-         T _ZNKSt3__114__codecvt_utf8IwE13do_max_lengthEv
-         T _ZNKSt3__114__codecvt_utf8IwE16do_always_noconvEv
-         T _ZNKSt3__114__codecvt_utf8IwE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_
-         T _ZNKSt3__114__codecvt_utf8IwE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_
-         T _ZNKSt3__114__codecvt_utf8IwE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__114collate_bynameIcE10do_compareEPKcS3_S3_S3_
-         T _ZNKSt3__114collate_bynameIcE12do_transformEPKcS3_
-         T _ZNKSt3__114collate_bynameIwE10do_compareEPKwS3_S3_S3_
-         T _ZNKSt3__114collate_bynameIwE12do_transformEPKwS3_
-         T _ZNKSt3__114error_category10equivalentERKNS_10error_codeEi
-         T _ZNKSt3__114error_category10equivalentEiRKNS_15error_conditionE
-         T _ZNKSt3__114error_category23default_error_conditionEi
-         T _ZNKSt3__115__codecvt_utf16IDiLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__115__codecvt_utf16IDiLb0EE11do_encodingEv
-         T _ZNKSt3__115__codecvt_utf16IDiLb0EE13do_max_lengthEv
-         T _ZNKSt3__115__codecvt_utf16IDiLb0EE16do_always_noconvEv
-         T _ZNKSt3__115__codecvt_utf16IDiLb0EE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IDiLb0EE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IDiLb0EE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__115__codecvt_utf16IDiLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__115__codecvt_utf16IDiLb1EE11do_encodingEv
-         T _ZNKSt3__115__codecvt_utf16IDiLb1EE13do_max_lengthEv
-         T _ZNKSt3__115__codecvt_utf16IDiLb1EE16do_always_noconvEv
-         T _ZNKSt3__115__codecvt_utf16IDiLb1EE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IDiLb1EE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IDiLb1EE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__115__codecvt_utf16IDsLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__115__codecvt_utf16IDsLb0EE11do_encodingEv
-         T _ZNKSt3__115__codecvt_utf16IDsLb0EE13do_max_lengthEv
-         T _ZNKSt3__115__codecvt_utf16IDsLb0EE16do_always_noconvEv
-         T _ZNKSt3__115__codecvt_utf16IDsLb0EE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IDsLb0EE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IDsLb0EE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__115__codecvt_utf16IDsLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__115__codecvt_utf16IDsLb1EE11do_encodingEv
-         T _ZNKSt3__115__codecvt_utf16IDsLb1EE13do_max_lengthEv
-         T _ZNKSt3__115__codecvt_utf16IDsLb1EE16do_always_noconvEv
-         T _ZNKSt3__115__codecvt_utf16IDsLb1EE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IDsLb1EE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IDsLb1EE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__115__codecvt_utf16IwLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__115__codecvt_utf16IwLb0EE11do_encodingEv
-         T _ZNKSt3__115__codecvt_utf16IwLb0EE13do_max_lengthEv
-         T _ZNKSt3__115__codecvt_utf16IwLb0EE16do_always_noconvEv
-         T _ZNKSt3__115__codecvt_utf16IwLb0EE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IwLb0EE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IwLb0EE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__115__codecvt_utf16IwLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__115__codecvt_utf16IwLb1EE11do_encodingEv
-         T _ZNKSt3__115__codecvt_utf16IwLb1EE13do_max_lengthEv
-         T _ZNKSt3__115__codecvt_utf16IwLb1EE16do_always_noconvEv
-         T _ZNKSt3__115__codecvt_utf16IwLb1EE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IwLb1EE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_
-         T _ZNKSt3__115__codecvt_utf16IwLb1EE9do_lengthER11__mbstate_tPKcS5_j
+         U _ZNKSt3__114error_category10equivalentERKNS_10error_codeEi
+         U _ZNKSt3__114error_category10equivalentEiRKNS_15error_conditionE
+         U _ZNKSt3__114error_category23default_error_conditionEi
          W _ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE4gptrEv
          W _ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE4pptrEv
          W _ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE5ebackEv
@@ -316,361 +373,10 @@
          W _ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE5epptrEv
          W _ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbaseEv
          W _ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv
-         T _ZNKSt3__115error_condition7messageEv
-         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13do_date_orderEv
-         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__XEv
-         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__cEv
-         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__rEv
-         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__xEv
-         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE7__am_pmEv
-         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE7__weeksEv
-         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8__monthsEv
-         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13do_date_orderEv
-         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__XEv
-         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__cEv
-         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__rEv
-         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__xEv
-         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE7__am_pmEv
-         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE7__weeksEv
-         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8__monthsEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE11do_groupingEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE13do_neg_formatEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE13do_pos_formatEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE14do_curr_symbolEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE14do_frac_digitsEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE16do_decimal_pointEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE16do_negative_signEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE16do_positive_signEv
-         W _ZNKSt3__117moneypunct_bynameIcLb0EE16do_thousands_sepEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE11do_groupingEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE13do_neg_formatEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE13do_pos_formatEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE14do_curr_symbolEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE14do_frac_digitsEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE16do_decimal_pointEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE16do_negative_signEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE16do_positive_signEv
-         W _ZNKSt3__117moneypunct_bynameIcLb1EE16do_thousands_sepEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE11do_groupingEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE13do_neg_formatEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE13do_pos_formatEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE14do_curr_symbolEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE14do_frac_digitsEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE16do_decimal_pointEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE16do_negative_signEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE16do_positive_signEv
-         W _ZNKSt3__117moneypunct_bynameIwLb0EE16do_thousands_sepEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE11do_groupingEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE13do_neg_formatEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE13do_pos_formatEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE14do_curr_symbolEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE14do_frac_digitsEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE16do_decimal_pointEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE16do_negative_signEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE16do_positive_signEv
-         W _ZNKSt3__117moneypunct_bynameIwLb1EE16do_thousands_sepEv
-         T _ZNKSt3__118__time_get_storageIcE15__do_date_orderEv
-         T _ZNKSt3__118__time_get_storageIwE15__do_date_orderEv
          T _ZNKSt3__119__iostream_category4nameEv
          T _ZNKSt3__119__iostream_category7messageEi
-         T _ZNKSt3__119__shared_weak_count13__get_deleterERKSt9type_info
-         T _ZNKSt3__120__codecvt_utf8_utf16IDiE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__120__codecvt_utf8_utf16IDiE11do_encodingEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IDiE13do_max_lengthEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IDiE16do_always_noconvEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IDiE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_
-         T _ZNKSt3__120__codecvt_utf8_utf16IDiE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_
-         T _ZNKSt3__120__codecvt_utf8_utf16IDiE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__120__codecvt_utf8_utf16IDsE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__120__codecvt_utf8_utf16IDsE11do_encodingEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IDsE13do_max_lengthEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IDsE16do_always_noconvEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IDsE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_
-         T _ZNKSt3__120__codecvt_utf8_utf16IDsE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_
-         T _ZNKSt3__120__codecvt_utf8_utf16IDsE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__120__codecvt_utf8_utf16IwE10do_unshiftER11__mbstate_tPcS4_RS4_
-         T _ZNKSt3__120__codecvt_utf8_utf16IwE11do_encodingEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IwE13do_max_lengthEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IwE16do_always_noconvEv
-         T _ZNKSt3__120__codecvt_utf8_utf16IwE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_
-         T _ZNKSt3__120__codecvt_utf8_utf16IwE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_
-         T _ZNKSt3__120__codecvt_utf8_utf16IwE9do_lengthER11__mbstate_tPKcS5_j
-         T _ZNKSt3__120__time_get_c_storageIcE3__XEv
-         T _ZNKSt3__120__time_get_c_storageIcE3__cEv
-         T _ZNKSt3__120__time_get_c_storageIcE3__rEv
-         T _ZNKSt3__120__time_get_c_storageIcE3__xEv
-         T _ZNKSt3__120__time_get_c_storageIcE7__am_pmEv
-         T _ZNKSt3__120__time_get_c_storageIcE7__weeksEv
-         T _ZNKSt3__120__time_get_c_storageIcE8__monthsEv
-         T _ZNKSt3__120__time_get_c_storageIwE3__XEv
-         T _ZNKSt3__120__time_get_c_storageIwE3__cEv
-         T _ZNKSt3__120__time_get_c_storageIwE3__rEv
-         T _ZNKSt3__120__time_get_c_storageIwE3__xEv
-         T _ZNKSt3__120__time_get_c_storageIwE7__am_pmEv
-         T _ZNKSt3__120__time_get_c_storageIwE7__weeksEv
-         T _ZNKSt3__120__time_get_c_storageIwE8__monthsEv
-         W _ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv
-         W _ZNKSt3__120__vector_base_commonILb1EE20__throw_out_of_rangeEv
-         W _ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv
-         W _ZNKSt3__121__basic_string_commonILb1EE20__throw_out_of_rangeEv
-         T _ZNKSt3__123__future_error_category4nameEv
-         T _ZNKSt3__123__future_error_category7messageEi
-         T _ZNKSt3__123__match_any_but_newlineIcE6__execERNS_7__stateIcEE
-         T _ZNKSt3__123__match_any_but_newlineIwE6__execERNS_7__stateIwEE
-         T _ZNKSt3__123__system_error_category23default_error_conditionEi
-         T _ZNKSt3__123__system_error_category4nameEv
-         T _ZNKSt3__123__system_error_category7messageEi
-         T _ZNKSt3__124__generic_error_category4nameEv
-         T _ZNKSt3__124__generic_error_category7messageEi
-         T _ZNKSt3__15ctypeIcE10do_tolowerEPcPKc
-         T _ZNKSt3__15ctypeIcE10do_tolowerEc
-         T _ZNKSt3__15ctypeIcE10do_toupperEPcPKc
-         T _ZNKSt3__15ctypeIcE10do_toupperEc
-         T _ZNKSt3__15ctypeIcE8do_widenEPKcS3_Pc
-         T _ZNKSt3__15ctypeIcE8do_widenEc
-         T _ZNKSt3__15ctypeIcE9do_narrowEPKcS3_cPc
-         T _ZNKSt3__15ctypeIcE9do_narrowEcc
-         T _ZNKSt3__15ctypeIwE10do_scan_isEtPKwS3_
-         T _ZNKSt3__15ctypeIwE10do_tolowerEPwPKw
-         T _ZNKSt3__15ctypeIwE10do_tolowerEw
-         T _ZNKSt3__15ctypeIwE10do_toupperEPwPKw
-         T _ZNKSt3__15ctypeIwE10do_toupperEw
-         T _ZNKSt3__15ctypeIwE11do_scan_notEtPKwS3_
-         T _ZNKSt3__15ctypeIwE5do_isEPKwS3_Pt
-         T _ZNKSt3__15ctypeIwE5do_isEtw
-         T _ZNKSt3__15ctypeIwE8do_widenEPKcS3_Pw
-         T _ZNKSt3__15ctypeIwE8do_widenEc
-         T _ZNKSt3__15ctypeIwE9do_narrowEPKwS3_cPc
-         T _ZNKSt3__15ctypeIwE9do_narrowEwc
-         T _ZNKSt3__16locale4nameEv
-         C _ZNKSt3__16locale5__imp9has_facetEl
-         T _ZNKSt3__16locale5__imp9use_facetEl
-         T _ZNKSt3__16locale9has_facetERNS0_2idE
-         T _ZNKSt3__16locale9use_facetERNS0_2idE
-         T _ZNKSt3__16localeeqERKS0_
-         T _ZNKSt3__17codecvtIDic11__mbstate_tE10do_unshiftERS1_PcS4_RS4_
-         T _ZNKSt3__17codecvtIDic11__mbstate_tE11do_encodingEv
-         T _ZNKSt3__17codecvtIDic11__mbstate_tE13do_max_lengthEv
-         T _ZNKSt3__17codecvtIDic11__mbstate_tE16do_always_noconvEv
-         T _ZNKSt3__17codecvtIDic11__mbstate_tE5do_inERS1_PKcS5_RS5_PDiS7_RS7_
-         T _ZNKSt3__17codecvtIDic11__mbstate_tE6do_outERS1_PKDiS5_RS5_PcS7_RS7_
-         T _ZNKSt3__17codecvtIDic11__mbstate_tE9do_lengthERS1_PKcS5_j
-         T _ZNKSt3__17codecvtIDsc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_
-         T _ZNKSt3__17codecvtIDsc11__mbstate_tE11do_encodingEv
-         T _ZNKSt3__17codecvtIDsc11__mbstate_tE13do_max_lengthEv
-         T _ZNKSt3__17codecvtIDsc11__mbstate_tE16do_always_noconvEv
-         T _ZNKSt3__17codecvtIDsc11__mbstate_tE5do_inERS1_PKcS5_RS5_PDsS7_RS7_
-         T _ZNKSt3__17codecvtIDsc11__mbstate_tE6do_outERS1_PKDsS5_RS5_PcS7_RS7_
-         T _ZNKSt3__17codecvtIDsc11__mbstate_tE9do_lengthERS1_PKcS5_j
-         T _ZNKSt3__17codecvtIcc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_
-         T _ZNKSt3__17codecvtIcc11__mbstate_tE11do_encodingEv
-         T _ZNKSt3__17codecvtIcc11__mbstate_tE13do_max_lengthEv
-         T _ZNKSt3__17codecvtIcc11__mbstate_tE16do_always_noconvEv
-         T _ZNKSt3__17codecvtIcc11__mbstate_tE5do_inERS1_PKcS5_RS5_PcS7_RS7_
-         T _ZNKSt3__17codecvtIcc11__mbstate_tE6do_outERS1_PKcS5_RS5_PcS7_RS7_
-         T _ZNKSt3__17codecvtIcc11__mbstate_tE9do_lengthERS1_PKcS5_j
-         T _ZNKSt3__17codecvtIwc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_
-         T _ZNKSt3__17codecvtIwc11__mbstate_tE11do_encodingEv
-         T _ZNKSt3__17codecvtIwc11__mbstate_tE13do_max_lengthEv
-         T _ZNKSt3__17codecvtIwc11__mbstate_tE16do_always_noconvEv
-         T _ZNKSt3__17codecvtIwc11__mbstate_tE5do_inERS1_PKcS5_RS5_PwS7_RS7_
-         T _ZNKSt3__17codecvtIwc11__mbstate_tE6do_outERS1_PKwS5_RS5_PcS7_RS7_
-         T _ZNKSt3__17codecvtIwc11__mbstate_tE9do_lengthERS1_PKcS5_j
-         W _ZNKSt3__17collateIcE10do_compareEPKcS3_S3_S3_
-         W _ZNKSt3__17collateIcE12do_transformEPKcS3_
-         W _ZNKSt3__17collateIcE4hashEPKcS3_
-         W _ZNKSt3__17collateIcE7compareEPKcS3_S3_S3_
-         W _ZNKSt3__17collateIcE7do_hashEPKcS3_
-         W _ZNKSt3__17collateIcE9transformEPKcS3_
-         W _ZNKSt3__17collateIwE10do_compareEPKwS3_S3_S3_
-         W _ZNKSt3__17collateIwE12do_transformEPKwS3_
-         W _ZNKSt3__17collateIwE4hashEPKwS3_
-         W _ZNKSt3__17collateIwE7compareEPKwS3_S3_S3_
-         W _ZNKSt3__17collateIwE7do_hashEPKwS3_
-         W _ZNKSt3__17collateIwE9transformEPKwS3_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE15__do_get_signedIlEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE15__do_get_signedIxEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedIjEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedImEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedItEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedIyEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIdEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIeEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIfEES4_S4_S4_RNS_8ios_baseERjRT_
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRPv
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRb
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRd
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRe
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRf
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRl
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRm
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRt
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRx
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRy
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjS8_
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRPv
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRb
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRd
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRe
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRf
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRl
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRm
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRt
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRx
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRy
-         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjS8_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE15__do_get_signedIlEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE15__do_get_signedIxEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedIjEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedImEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedItEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedIyEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIdEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIeEES4_S4_S4_RNS_8ios_baseERjRT_
-         C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIfEES4_S4_S4_RNS_8ios_baseERjRT_
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRPv
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRb
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRd
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRe
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRf
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRl
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRm
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRt
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRx
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRy
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjS8_
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRPv
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRb
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRd
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRe
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRf
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRl
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRm
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRt
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRx
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRy
-         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjS8_
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcPKv
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcb
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcd
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEce
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcl
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcm
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcx
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcy
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcPKv
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcb
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcd
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEce
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcl
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcm
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcx
-         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcy
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwPKv
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwb
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwd
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwe
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwl
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwm
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwx
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwy
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwPKv
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwb
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwd
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwe
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwl
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwm
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwx
-         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwy
+         U _ZNKSt3__16locale9use_facetERNS0_2idE
          T _ZNKSt3__18ios_base6getlocEv
-         W _ZNKSt3__18messagesIcE3getEiiiRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         W _ZNKSt3__18messagesIcE4openERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_6localeE
-         W _ZNKSt3__18messagesIcE5closeEi
-         W _ZNKSt3__18messagesIcE6do_getEiiiRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         W _ZNKSt3__18messagesIcE7do_openERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_6localeE
-         W _ZNKSt3__18messagesIcE8do_closeEi
-         W _ZNKSt3__18messagesIwE3getEiiiRKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEE
-         W _ZNKSt3__18messagesIwE4openERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_6localeE
-         W _ZNKSt3__18messagesIwE5closeEi
-         W _ZNKSt3__18messagesIwE6do_getEiiiRKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEE
-         W _ZNKSt3__18messagesIwE7do_openERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_6localeE
-         W _ZNKSt3__18messagesIwE8do_closeEi
-         T _ZNKSt3__18numpunctIcE11do_groupingEv
-         T _ZNKSt3__18numpunctIcE11do_truenameEv
-         T _ZNKSt3__18numpunctIcE12do_falsenameEv
-         T _ZNKSt3__18numpunctIcE16do_decimal_pointEv
-         T _ZNKSt3__18numpunctIcE16do_thousands_sepEv
-         T _ZNKSt3__18numpunctIwE11do_groupingEv
-         T _ZNKSt3__18numpunctIwE11do_truenameEv
-         T _ZNKSt3__18numpunctIwE12do_falsenameEv
-         T _ZNKSt3__18numpunctIwE16do_decimal_pointEv
-         T _ZNKSt3__18numpunctIwE16do_thousands_sepEv
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE10__get_hourERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE10__get_yearERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE10date_orderEv
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11__get_am_pmERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11__get_monthERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11__get_year4ERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11do_get_dateES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11do_get_timeES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11do_get_yearES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11get_weekdayES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE12__get_minuteERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE12__get_secondERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13__get_12_hourERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13__get_percentERS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13__get_weekdayERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13do_date_orderEv
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13get_monthnameES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE14do_get_weekdayES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE15__get_monthnameERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE16do_get_monthnameES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__get_weekdaynameERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__get_white_spaceERS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE18__get_day_year_numERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjP2tmPKcSC_
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjP2tmcc
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjP2tmcc
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8get_dateES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8get_timeES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8get_yearES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE9__get_dayERiRS4_S4_RjRKNS_5ctypeIcEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE10__get_hourERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE10__get_yearERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE10date_orderEv
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11__get_am_pmERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11__get_monthERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11__get_year4ERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11do_get_dateES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11do_get_timeES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11do_get_yearES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11get_weekdayES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE12__get_minuteERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE12__get_secondERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13__get_12_hourERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13__get_percentERS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13__get_weekdayERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13do_date_orderEv
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13get_monthnameES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE14do_get_weekdayES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE15__get_monthnameERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE16do_get_monthnameES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__get_weekdaynameERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__get_white_spaceERS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE18__get_day_year_numERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjP2tmPKwSC_
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjP2tmcc
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjP2tmcc
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8get_dateES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8get_timeES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8get_yearES4_S4_RNS_8ios_baseERjP2tm
-         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE9__get_dayERiRS4_S4_RjRKNS_5ctypeIwEE
-         W _ZNKSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcPK2tmPKcSC_
-         W _ZNKSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcPK2tmcc
-         W _ZNKSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcPK2tmcc
-         W _ZNKSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwPK2tmPKwSC_
-         W _ZNKSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwPK2tmcc
-         W _ZNKSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwPK2tmcc
          W _ZNKSt3__19basic_iosIcNS_11char_traitsIcEEE10exceptionsEv
          W _ZNKSt3__19basic_iosIcNS_11char_traitsIcEEE3badEv
          W _ZNKSt3__19basic_iosIcNS_11char_traitsIcEEE3eofEv
@@ -697,544 +403,11 @@
          W _ZNKSt3__19basic_iosIwNS_11char_traitsIwEEE7rdstateEv
          W _ZNKSt3__19basic_iosIwNS_11char_traitsIwEEEcvbEv
          W _ZNKSt3__19basic_iosIwNS_11char_traitsIwEEEntEv
-         W _ZNKSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_bRNS_8ios_baseERjRNS_12basic_stringIcS3_NS_9allocatorIcEEEE
-         W _ZNKSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_bRNS_8ios_baseERjRe
-         W _ZNKSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_bRNS_8ios_baseERjRNS_12basic_stringIcS3_NS_9allocatorIcEEEE
-         W _ZNKSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_bRNS_8ios_baseERjRe
-         W _ZNKSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_bRNS_8ios_baseERjRNS_12basic_stringIwS3_NS_9allocatorIwEEEE
-         W _ZNKSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_bRNS_8ios_baseERjRe
-         W _ZNKSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_bRNS_8ios_baseERjRNS_12basic_stringIwS3_NS_9allocatorIwEEEE
-         W _ZNKSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_bRNS_8ios_baseERjRe
-         W _ZNKSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_bRNS_8ios_baseEcRKNS_12basic_stringIcS3_NS_9allocatorIcEEEE
-         W _ZNKSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_bRNS_8ios_baseEce
-         W _ZNKSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_bRNS_8ios_baseEcRKNS_12basic_stringIcS3_NS_9allocatorIcEEEE
-         W _ZNKSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_bRNS_8ios_baseEce
-         W _ZNKSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_bRNS_8ios_baseEwRKNS_12basic_stringIwS3_NS_9allocatorIwEEEE
-         W _ZNKSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_bRNS_8ios_baseEwe
-         W _ZNKSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_bRNS_8ios_baseEwRKNS_12basic_stringIwS3_NS_9allocatorIwEEEE
-         W _ZNKSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_bRNS_8ios_baseEwe
-         T _ZNSt11logic_errorC1EPKc
-         T _ZNSt11logic_errorC1ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
-         T _ZNSt11logic_errorC1ERKS_
-         T _ZNSt11logic_errorC2EPKc
-         T _ZNSt11logic_errorC2ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
-         T _ZNSt11logic_errorC2ERKS_
-         T _ZNSt11logic_erroraSERKS_
-         T _ZNSt13exception_ptrC1ERKS_
-         T _ZNSt13exception_ptrC2ERKS_
-         T _ZNSt13exception_ptrD1Ev
-         T _ZNSt13exception_ptrD2Ev
-         T _ZNSt13exception_ptraSERKS_
-         T _ZNSt13runtime_errorC1EPKc
-         T _ZNSt13runtime_errorC1ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
-         T _ZNSt13runtime_errorC1ERKS_
-         T _ZNSt13runtime_errorC2EPKc
-         T _ZNSt13runtime_errorC2ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
-         T _ZNSt13runtime_errorC2ERKS_
-         T _ZNSt13runtime_erroraSERKS_
-         T _ZNSt16nested_exceptionC1Ev
-         T _ZNSt16nested_exceptionC2Ev
-         T _ZNSt16nested_exceptionD0Ev
-         T _ZNSt16nested_exceptionD1Ev
-         T _ZNSt16nested_exceptionD2Ev
-         C _ZNSt3__110__find_endIPFbwwEPKwS4_EET0_S5_S5_T1_S6_T_NS_26random_access_iterator_tagES8_
-         C _ZNSt3__110__sscanf_lEPKcP15__locale_structS1_z
-         C _ZNSt3__110__stdinbufIcE5imbueERKNS_6localeE
-         C _ZNSt3__110__stdinbufIcE5uflowEv
-         C _ZNSt3__110__stdinbufIcE9__getcharEb
-         C _ZNSt3__110__stdinbufIcE9pbackfailEi
-         C _ZNSt3__110__stdinbufIcE9underflowEv
-         C _ZNSt3__110__stdinbufIcEC2EP8_IO_FILEP11__mbstate_t
-         C _ZNSt3__110__stdinbufIcED0Ev
-         C _ZNSt3__110__stdinbufIcED1Ev
-         C _ZNSt3__110__stdinbufIwE5imbueERKNS_6localeE
-         C _ZNSt3__110__stdinbufIwE5uflowEv
-         C _ZNSt3__110__stdinbufIwE9__getcharEb
-         C _ZNSt3__110__stdinbufIwE9pbackfailEj
-         C _ZNSt3__110__stdinbufIwE9underflowEv
-         C _ZNSt3__110__stdinbufIwEC2EP8_IO_FILEP11__mbstate_t
-         C _ZNSt3__110__stdinbufIwED0Ev
-         C _ZNSt3__110__stdinbufIwED1Ev
-         T _ZNSt3__110__time_getC1EPKc
-         T _ZNSt3__110__time_getC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__110__time_getC2EPKc
-         T _ZNSt3__110__time_getC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__110__time_getD1Ev
-         T _ZNSt3__110__time_getD2Ev
-         T _ZNSt3__110__time_putC1EPKc
-         T _ZNSt3__110__time_putC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__110__time_putC2EPKc
-         T _ZNSt3__110__time_putC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__110__time_putD1Ev
-         T _ZNSt3__110__time_putD2Ev
-         D _ZNSt3__110adopt_lockE
-         D _ZNSt3__110ctype_base5alnumE
-         D _ZNSt3__110ctype_base5alphaE
-         D _ZNSt3__110ctype_base5blankE
-         D _ZNSt3__110ctype_base5cntrlE
-         D _ZNSt3__110ctype_base5digitE
-         D _ZNSt3__110ctype_base5graphE
-         D _ZNSt3__110ctype_base5lowerE
-         D _ZNSt3__110ctype_base5printE
-         D _ZNSt3__110ctype_base5punctE
-         D _ZNSt3__110ctype_base5spaceE
-         D _ZNSt3__110ctype_base5upperE
-         D _ZNSt3__110ctype_base6xdigitE
-         D _ZNSt3__110defer_lockE
-         T _ZNSt3__110istrstreamD0Ev
-         T _ZNSt3__110istrstreamD1Ev
-         T _ZNSt3__110istrstreamD2Ev
-         W _ZNSt3__110moneypunctIcLb0EE2idE
-         W _ZNSt3__110moneypunctIcLb0EE4intlE
-         W _ZNSt3__110moneypunctIcLb0EEC1Ej
-         W _ZNSt3__110moneypunctIcLb0EEC2Ej
-         W _ZNSt3__110moneypunctIcLb0EED0Ev
-         W _ZNSt3__110moneypunctIcLb0EED1Ev
-         W _ZNSt3__110moneypunctIcLb0EED2Ev
-         W _ZNSt3__110moneypunctIcLb1EE2idE
-         W _ZNSt3__110moneypunctIcLb1EE4intlE
-         W _ZNSt3__110moneypunctIcLb1EEC1Ej
-         W _ZNSt3__110moneypunctIcLb1EEC2Ej
-         W _ZNSt3__110moneypunctIcLb1EED0Ev
-         W _ZNSt3__110moneypunctIcLb1EED1Ev
-         W _ZNSt3__110moneypunctIcLb1EED2Ev
-         W _ZNSt3__110moneypunctIwLb0EE2idE
-         W _ZNSt3__110moneypunctIwLb0EE4intlE
-         W _ZNSt3__110moneypunctIwLb0EEC1Ej
-         W _ZNSt3__110moneypunctIwLb0EEC2Ej
-         W _ZNSt3__110moneypunctIwLb0EED0Ev
-         W _ZNSt3__110moneypunctIwLb0EED1Ev
-         W _ZNSt3__110moneypunctIwLb0EED2Ev
-         W _ZNSt3__110moneypunctIwLb1EE2idE
-         W _ZNSt3__110moneypunctIwLb1EE4intlE
-         W _ZNSt3__110moneypunctIwLb1EEC1Ej
-         W _ZNSt3__110moneypunctIwLb1EEC2Ej
-         W _ZNSt3__110moneypunctIwLb1EED0Ev
-         W _ZNSt3__110moneypunctIwLb1EED1Ev
-         W _ZNSt3__110moneypunctIwLb1EED2Ev
-         T _ZNSt3__110ostrstreamD0Ev
-         T _ZNSt3__110ostrstreamD1Ev
-         T _ZNSt3__110ostrstreamD2Ev
-         T _ZNSt3__110to_wstringEd
-         T _ZNSt3__110to_wstringEe
-         T _ZNSt3__110to_wstringEf
-         T _ZNSt3__110to_wstringEi
-         T _ZNSt3__110to_wstringEj
-         T _ZNSt3__110to_wstringEl
-         T _ZNSt3__110to_wstringEm
-         T _ZNSt3__110to_wstringEx
-         T _ZNSt3__110to_wstringEy
-         T _ZNSt3__111__call_onceERVmPvPFvS2_E
-         T _ZNSt3__111__libcpp_db10__insert_cEPv
-         T _ZNSt3__111__libcpp_db10__insert_iEPv
-         T _ZNSt3__111__libcpp_db11__insert_icEPvPKv
-         T _ZNSt3__111__libcpp_db15__iterator_copyEPvPKv
-         T _ZNSt3__111__libcpp_db16__invalidate_allEPv
-         T _ZNSt3__111__libcpp_db17__insert_iteratorEPv
-         T _ZNSt3__111__libcpp_db4swapEPvS1_
-         T _ZNSt3__111__libcpp_db9__erase_cEPv
-         T _ZNSt3__111__libcpp_db9__erase_iEPv
-         T _ZNSt3__111__libcpp_dbC1Ev
-         T _ZNSt3__111__libcpp_dbC2Ev
-         T _ZNSt3__111__libcpp_dbD1Ev
-         T _ZNSt3__111__libcpp_dbD2Ev
-         W _ZNSt3__111__money_getIcE13__gather_infoEbRKNS_6localeERNS_10money_base7patternERcS8_RNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESF_SF_SF_Ri
-         W _ZNSt3__111__money_getIcEC1Ev
-         W _ZNSt3__111__money_getIcEC2Ev
-         W _ZNSt3__111__money_getIwE13__gather_infoEbRKNS_6localeERNS_10money_base7patternERwS8_RNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERNS9_IwNSA_IwEENSC_IwEEEESJ_SJ_Ri
-         W _ZNSt3__111__money_getIwEC1Ev
-         W _ZNSt3__111__money_getIwEC2Ev
-         W _ZNSt3__111__money_putIcE13__gather_infoEbbRKNS_6localeERNS_10money_base7patternERcS8_RNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESF_SF_Ri
-         W _ZNSt3__111__money_putIcE8__formatEPcRS2_S3_jPKcS5_RKNS_5ctypeIcEEbRKNS_10money_base7patternEccRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESL_SL_i
-         W _ZNSt3__111__money_putIcEC1Ev
-         W _ZNSt3__111__money_putIcEC2Ev
-         W _ZNSt3__111__money_putIwE13__gather_infoEbbRKNS_6localeERNS_10money_base7patternERwS8_RNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERNS9_IwNSA_IwEENSC_IwEEEESJ_Ri
-         W _ZNSt3__111__money_putIwE8__formatEPwRS2_S3_jPKwS5_RKNS_5ctypeIwEEbRKNS_10money_base7patternEwwRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNSE_IwNSF_IwEENSH_IwEEEESQ_i
-         W _ZNSt3__111__money_putIwEC1Ev
-         W _ZNSt3__111__money_putIwEC2Ev
-         C _ZNSt3__111__stdoutbufIcE4syncEv
-         C _ZNSt3__111__stdoutbufIcE5imbueERKNS_6localeE
-         C _ZNSt3__111__stdoutbufIcE6xsputnEPKci
-         C _ZNSt3__111__stdoutbufIcE8overflowEi
-         C _ZNSt3__111__stdoutbufIcEC2EP8_IO_FILEP11__mbstate_t
-         C _ZNSt3__111__stdoutbufIcED0Ev
-         C _ZNSt3__111__stdoutbufIcED1Ev
-         C _ZNSt3__111__stdoutbufIwE4syncEv
-         C _ZNSt3__111__stdoutbufIwE5imbueERKNS_6localeE
-         C _ZNSt3__111__stdoutbufIwE6xsputnEPKwi
-         C _ZNSt3__111__stdoutbufIwE8overflowEj
-         C _ZNSt3__111__stdoutbufIwEC2EP8_IO_FILEP11__mbstate_t
-         C _ZNSt3__111__stdoutbufIwED0Ev
-         C _ZNSt3__111__stdoutbufIwED1Ev
-         C _ZNSt3__111char_traitsIcE4findEPKcjRS2_
-         C _ZNSt3__111char_traitsIwE2eqEww
-         T _ZNSt3__111regex_errorC1ENS_15regex_constants10error_typeE
-         T _ZNSt3__111regex_errorC2ENS_15regex_constants10error_typeE
-         T _ZNSt3__111regex_errorD0Ev
-         T _ZNSt3__111regex_errorD1Ev
-         T _ZNSt3__111regex_errorD2Ev
-         T _ZNSt3__111this_thread9sleep_forERKNS_6chrono8durationIxNS_5ratioILx1ELx1000000000EEEEE
-         T _ZNSt3__111timed_mutex4lockEv
-         T _ZNSt3__111timed_mutex6unlockEv
-         T _ZNSt3__111timed_mutex8try_lockEv
-         T _ZNSt3__111timed_mutexC1Ev
-         T _ZNSt3__111timed_mutexC2Ev
-         T _ZNSt3__111timed_mutexD1Ev
-         T _ZNSt3__111timed_mutexD2Ev
-         D _ZNSt3__111try_to_lockE
-         C _ZNSt3__111unique_lockINS_5mutexEE6unlockEv
-         C _ZNSt3__112__asprintf_lEPPcP15__locale_structPKcz
-         C _ZNSt3__112__do_messageD0Ev
-         C _ZNSt3__112__do_messageD1Ev
-         T _ZNSt3__112__do_nothingEPv
-         T _ZNSt3__112__get_sp_mutEPKv
-         T _ZNSt3__112__next_primeEj
-         C _ZNSt3__112__rotate_gcdINS_11__wrap_iterIPcEEEET_S4_S4_S4_
-         C _ZNSt3__112__rotate_gcdINS_11__wrap_iterIPwEEEET_S4_S4_S4_
-         D _ZNSt3__112__rs_default4__c_E
-         T _ZNSt3__112__rs_defaultC1ERKS0_
-         T _ZNSt3__112__rs_defaultC1Ev
-         T _ZNSt3__112__rs_defaultC2ERKS0_
-         T _ZNSt3__112__rs_defaultC2Ev
-         T _ZNSt3__112__rs_defaultD1Ev
-         T _ZNSt3__112__rs_defaultD2Ev
-         T _ZNSt3__112__rs_defaultclEv
-         C _ZNSt3__112__snprintf_lEPcjP15__locale_structPKcz
-         T _ZNSt3__112bad_weak_ptrD0Ev
-         T _ZNSt3__112bad_weak_ptrD1Ev
-         T _ZNSt3__112bad_weak_ptrD2Ev
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE10__set_sizeEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE11__recommendEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12__swap_allocERS4_S6_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12__swap_allocERS4_S6_NS_17integral_constantIbLb0EEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12__swap_allocERS4_S6_NS_17integral_constantIbLb1EEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__get_pointerEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__move_assignERS5_NS_17integral_constantIbLb0EEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__move_assignERS5_NS_17integral_constantIbLb1EEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13shrink_to_fitEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE14__erase_to_endEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE14__set_long_capEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE15__set_long_sizeEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__set_short_sizeEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE18__get_long_pointerEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE18__set_long_pointerEPc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__copy_assign_allocERKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__copy_assign_allocERKS5_NS_17integral_constantIbLb0EEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__copy_assign_allocERKS5_NS_17integral_constantIbLb1EEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__get_short_pointerEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__move_assign_allocERS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__move_assign_allocERS5_NS_17integral_constantIbLb0EEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__move_assign_allocERS5_NS_17integral_constantIbLb1EEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE21__grow_by_and_replaceEjjjjjjPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE26__invalidate_all_iteratorsEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE27__invalidate_iterators_pastEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE2atEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE3endEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4backEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4nposE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4rendEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4swapERS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5beginEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5clearEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5eraseENS_11__wrap_iterIPKcEE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5eraseENS_11__wrap_iterIPKcEES9_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5eraseEjj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5frontEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcjj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEjc
-         C _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__zeroEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendERKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendERKS5_jj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendESt16initializer_listIcE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEjc
-         C _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendIPcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeES9_S9_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEOS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKcj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignERKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignERKS5_jj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignESt16initializer_listIcE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEjc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertENS_11__wrap_iterIPKcEESt16initializer_listIcE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertENS_11__wrap_iterIPKcEEc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertENS_11__wrap_iterIPKcEEjc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjPKcj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjRKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjRKS5_jj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjjc
-         C _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueENS_11__wrap_iterIPcEEE4typeENSB_IS8_EESA_SA_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6rbeginEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6resizeEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6resizeEjc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7__allocEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_RKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_S8_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_S8_j
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_St16initializer_listIcE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_jc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjPKcj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjRKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjRKS5_jj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjjc
-         C _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceIPKcEENS_9enable_ifIXsr19__is_input_iteratorIT_EE5valueERS5_E4typeENS_11__wrap_iterIS8_EESF_SA_SA_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE8pop_backEv
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEjjjjjj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EOS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EOS5_RKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EPKcRKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EPKcj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EPKcjRKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_RKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_jjRKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ESt16initializer_listIcE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ESt16initializer_listIcERKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1Ejc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EjcRKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1Ev
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EOS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EOS5_RKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EPKcRKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EPKcj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EPKcjRKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_RKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_jjRKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ESt16initializer_listIcE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ESt16initializer_listIcERKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2Ejc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EjcRKS4_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2Ev
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSEOS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSEPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSERKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSESt16initializer_listIcE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSEc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEixEj
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLEPKc
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLERKS5_
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLESt16initializer_listIcE
-         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLEc
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE10__set_sizeEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE11__recommendEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12__swap_allocERS4_S6_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12__swap_allocERS4_S6_NS_17integral_constantIbLb0EEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12__swap_allocERS4_S6_NS_17integral_constantIbLb1EEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13__get_pointerEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13__move_assignERS5_NS_17integral_constantIbLb0EEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13__move_assignERS5_NS_17integral_constantIbLb1EEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13shrink_to_fitEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE14__erase_to_endEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE14__set_long_capEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE15__set_long_sizeEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16__set_short_sizeEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE18__get_long_pointerEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE18__set_long_pointerEPw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__copy_assign_allocERKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__copy_assign_allocERKS5_NS_17integral_constantIbLb0EEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__copy_assign_allocERKS5_NS_17integral_constantIbLb1EEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__get_short_pointerEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__move_assign_allocERS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__move_assign_allocERS5_NS_17integral_constantIbLb0EEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__move_assign_allocERS5_NS_17integral_constantIbLb1EEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE21__grow_by_and_replaceEjjjjjjPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE26__invalidate_all_iteratorsEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE27__invalidate_iterators_pastEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE2atEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE3endEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4backEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4nposE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4rendEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4swapERS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5beginEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5clearEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5eraseENS_11__wrap_iterIPKwEE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5eraseENS_11__wrap_iterIPKwEES9_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5eraseEjj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5frontEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwjj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEjw
-         C _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initIPKwEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__zeroEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendEPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendEPKwj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendERKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendERKS5_jj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendESt16initializer_listIwE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendEjw
-         C _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendIPwEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeES9_S9_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEOS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEPKwj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignERKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignERKS5_jj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignESt16initializer_listIwE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEjw
-         C _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignIPwEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeES9_S9_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertENS_11__wrap_iterIPKwEESt16initializer_listIwE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertENS_11__wrap_iterIPKwEEjw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertENS_11__wrap_iterIPKwEEw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjPKwj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjRKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjRKS5_jj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjjw
-         C _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertIPKwEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueENS_11__wrap_iterIPwEEE4typeENSB_IS8_EESA_SA_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6rbeginEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEjw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7__allocEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_RKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_S8_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_S8_j
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_St16initializer_listIwE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_jw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjPKwj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjRKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjRKS5_jj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjjw
-         C _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceIPKwEENS_9enable_ifIXsr19__is_input_iteratorIT_EE5valueERS5_E4typeENS_11__wrap_iterIS8_EESF_SA_SA_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7reserveEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE8pop_backEv
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9__grow_byEjjjjjj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EOS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EOS5_RKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EPKwRKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EPKwj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EPKwjRKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS5_RKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS5_jjRKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ESt16initializer_listIwE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ESt16initializer_listIwERKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1Ejw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EjwRKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1Ev
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EOS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EOS5_RKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EPKwRKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EPKwj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EPKwjRKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS5_RKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS5_jjRKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ESt16initializer_listIwE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ESt16initializer_listIwERKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2Ejw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EjwRKS4_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2Ev
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED1Ev
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSEOS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSEPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSERKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSESt16initializer_listIwE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSEw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEixEj
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEpLEPKw
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEpLERKS5_
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEpLESt16initializer_listIwE
-         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEpLEw
-         T _ZNSt3__112ctype_bynameIcEC1EPKcj
-         T _ZNSt3__112ctype_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__112ctype_bynameIcEC2EPKcj
-         T _ZNSt3__112ctype_bynameIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__112ctype_bynameIcED0Ev
-         T _ZNSt3__112ctype_bynameIcED1Ev
-         T _ZNSt3__112ctype_bynameIcED2Ev
-         T _ZNSt3__112ctype_bynameIwEC1EPKcj
-         T _ZNSt3__112ctype_bynameIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__112ctype_bynameIwEC2EPKcj
-         T _ZNSt3__112ctype_bynameIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__112ctype_bynameIwED0Ev
-         T _ZNSt3__112ctype_bynameIwED1Ev
-         T _ZNSt3__112ctype_bynameIwED2Ev
-         T _ZNSt3__112future_errorC1ENS_10error_codeE
-         T _ZNSt3__112future_errorC2ENS_10error_codeE
-         C _ZNSt3__112future_errorC2ERKS0_
-         T _ZNSt3__112future_errorD0Ev
-         T _ZNSt3__112future_errorD1Ev
-         T _ZNSt3__112future_errorD2Ev
-         D _ZNSt3__112placeholders2_1E
-         D _ZNSt3__112placeholders2_2E
-         D _ZNSt3__112placeholders2_3E
-         D _ZNSt3__112placeholders2_4E
-         D _ZNSt3__112placeholders2_5E
-         D _ZNSt3__112placeholders2_6E
-         D _ZNSt3__112placeholders2_7E
-         D _ZNSt3__112placeholders2_8E
-         D _ZNSt3__112placeholders2_9E
-         D _ZNSt3__112placeholders3_10E
-         T _ZNSt3__112strstreambuf3strEv
-         T _ZNSt3__112strstreambuf4swapERS0_
-         T _ZNSt3__112strstreambuf6__initEPciS1_
-         T _ZNSt3__112strstreambuf6freezeEb
-         T _ZNSt3__112strstreambuf7seekoffExNS_8ios_base7seekdirEj
-         T _ZNSt3__112strstreambuf7seekposENS_4fposI11__mbstate_tEEj
-         T _ZNSt3__112strstreambuf8overflowEi
-         T _ZNSt3__112strstreambuf9pbackfailEi
-         T _ZNSt3__112strstreambuf9underflowEv
-         T _ZNSt3__112strstreambufC1EPFPvjEPFvS1_E
-         T _ZNSt3__112strstreambufC1EPKai
-         T _ZNSt3__112strstreambufC1EPKci
-         T _ZNSt3__112strstreambufC1EPKhi
-         T _ZNSt3__112strstreambufC1EPaiS1_
-         T _ZNSt3__112strstreambufC1EPciS1_
-         T _ZNSt3__112strstreambufC1EPhiS1_
-         T _ZNSt3__112strstreambufC1Ei
-         T _ZNSt3__112strstreambufC2EPFPvjEPFvS1_E
-         T _ZNSt3__112strstreambufC2EPKai
-         T _ZNSt3__112strstreambufC2EPKci
-         T _ZNSt3__112strstreambufC2EPKhi
-         T _ZNSt3__112strstreambufC2EPaiS1_
-         T _ZNSt3__112strstreambufC2EPciS1_
-         T _ZNSt3__112strstreambufC2EPhiS1_
-         T _ZNSt3__112strstreambufC2Ei
-         T _ZNSt3__112strstreambufD0Ev
-         T _ZNSt3__112strstreambufD1Ev
-         T _ZNSt3__112strstreambufD2Ev
-         T _ZNSt3__112system_error6__initERKNS_10error_codeENS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__112system_errorC1ENS_10error_codeE
-         T _ZNSt3__112system_errorC1ENS_10error_codeEPKc
-         T _ZNSt3__112system_errorC1ENS_10error_codeERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__112system_errorC1EiRKNS_14error_categoryE
-         T _ZNSt3__112system_errorC1EiRKNS_14error_categoryEPKc
-         T _ZNSt3__112system_errorC1EiRKNS_14error_categoryERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__112system_errorC2ENS_10error_codeE
-         T _ZNSt3__112system_errorC2ENS_10error_codeEPKc
-         T _ZNSt3__112system_errorC2ENS_10error_codeERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__112system_errorC2EiRKNS_14error_categoryE
-         T _ZNSt3__112system_errorC2EiRKNS_14error_categoryEPKc
-         T _ZNSt3__112system_errorC2EiRKNS_14error_categoryERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__112system_errorD0Ev
-         T _ZNSt3__112system_errorD1Ev
-         T _ZNSt3__112system_errorD2Ev
-         C _ZNSt3__113__lower_boundIRNS_6__lessIjjEEPKjjEET0_S6_S6_RKT1_T_
-         C _ZNSt3__113__vector_baseINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEED2Ev
-         C _ZNSt3__113__vector_baseIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEED2Ev
-         C _ZNSt3__113__vector_baseIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEED2Ev
-         D _ZNSt3__113allocator_argE
+         W _ZNSt3__111char_traitsIwE4copyEPwPKwj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj
+         U _ZNSt3__112system_errorC2ENS_10error_codeEPKc
+         U _ZNSt3__112system_errorC2ENS_10error_codeERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         U _ZNSt3__112system_errorD2Ev
          W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPci
          W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcic
          W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE
@@ -1403,42 +576,6 @@
          W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEt
          W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEx
          W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEy
-         T _ZNSt3__113random_deviceC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__113random_deviceC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__113random_deviceD1Ev
-         T _ZNSt3__113random_deviceD2Ev
-         T _ZNSt3__113random_deviceclEv
-         T _ZNSt3__113shared_futureIvED1Ev
-         T _ZNSt3__113shared_futureIvED2Ev
-         T _ZNSt3__113shared_futureIvEaSERKS1_
-         C _ZNSt3__114__codecvt_utf8IDiED0Ev
-         C _ZNSt3__114__codecvt_utf8IDiED1Ev
-         C _ZNSt3__114__codecvt_utf8IDsED0Ev
-         C _ZNSt3__114__codecvt_utf8IDsED1Ev
-         C _ZNSt3__114__codecvt_utf8IwED0Ev
-         C _ZNSt3__114__codecvt_utf8IwED1Ev
-         T _ZNSt3__114__get_const_dbEv
-         T _ZNSt3__114__num_get_base10__get_baseERNS_8ios_baseE
-         D _ZNSt3__114__num_get_base5__srcE
-         T _ZNSt3__114__num_put_base12__format_intEPcPKcbj
-         T _ZNSt3__114__num_put_base14__format_floatEPcPKcj
-         T _ZNSt3__114__num_put_base18__identify_paddingEPcS1_RKNS_8ios_baseE
-         C _ZNSt3__114__scan_keywordINS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEPKNS_12basic_stringIcS3_NS_9allocatorIcEEEENS_5ctypeIcEEEET0_RT_SE_SD_SD_RKT1_Rjb
-         C _ZNSt3__114__scan_keywordINS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEPKNS_12basic_stringIwS3_NS_9allocatorIwEEEENS_5ctypeIwEEEET0_RT_SE_SD_SD_RKT1_Rjb
-         C _ZNSt3__114__scan_keywordIPcPNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_5ctypeIcEEEET0_RT_SC_SB_SB_RKT1_Rjb
-         C _ZNSt3__114__scan_keywordIPwPNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEENS_5ctypeIwEEEET0_RT_SC_SB_SB_RKT1_Rjb
-         T _ZNSt3__114__shared_count12__add_sharedEv
-         T _ZNSt3__114__shared_count16__release_sharedEv
-         T _ZNSt3__114__shared_countD0Ev
-         T _ZNSt3__114__shared_countD1Ev
-         T _ZNSt3__114__shared_countD2Ev
-         C _ZNSt3__114__split_bufferINS_4pairIPNS_18condition_variableEPNS_5mutexEEERNS_18__hidden_allocatorIS6_EEEC2EjjS9_
-         C _ZNSt3__114__split_bufferINS_4pairIPNS_18condition_variableEPNS_5mutexEEERNS_18__hidden_allocatorIS6_EEED2Ev
-         C _ZNSt3__114__split_bufferIPNS_17__assoc_sub_stateERNS_18__hidden_allocatorIS2_EEEC2EjjS5_
-         C _ZNSt3__114__split_bufferIPNS_17__assoc_sub_stateERNS_18__hidden_allocatorIS2_EEED2Ev
-         C _ZNSt3__114__split_bufferIPNS_6locale5facetERNS_15__sso_allocatorIS3_Lj28EEEE18__construct_at_endEj
-         C _ZNSt3__114__split_bufferIPNS_6locale5facetERNS_15__sso_allocatorIS3_Lj28EEEEC2EjjS6_
-         C _ZNSt3__114__split_bufferIPNS_6locale5facetERNS_15__sso_allocatorIS3_Lj28EEEED2Ev
          W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_
          W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EOS3_
          W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE
@@ -1448,82 +585,7 @@
          W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev
          W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEED2Ev
          W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEaSEOS3_
-         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC1EPKcj
-         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC2EPKcj
-         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED0Ev
-         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED1Ev
-         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED2Ev
-         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC1EPKcj
-         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC2EPKcj
-         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED0Ev
-         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED1Ev
-         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED2Ev
-         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC1EPKcj
-         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC2EPKcj
-         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED0Ev
-         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED1Ev
-         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED2Ev
-         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC1EPKcj
-         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC2EPKcj
-         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED0Ev
-         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED1Ev
-         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED2Ev
-         T _ZNSt3__114collate_bynameIcEC1EPKcj
-         T _ZNSt3__114collate_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__114collate_bynameIcEC2EPKcj
-         T _ZNSt3__114collate_bynameIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__114collate_bynameIcED0Ev
-         T _ZNSt3__114collate_bynameIcED1Ev
-         T _ZNSt3__114collate_bynameIcED2Ev
-         T _ZNSt3__114collate_bynameIwEC1EPKcj
-         T _ZNSt3__114collate_bynameIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__114collate_bynameIwEC2EPKcj
-         T _ZNSt3__114collate_bynameIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__114collate_bynameIwED0Ev
-         T _ZNSt3__114collate_bynameIwED1Ev
-         T _ZNSt3__114collate_bynameIwED2Ev
-         T _ZNSt3__114error_categoryC2Ev
-         T _ZNSt3__114error_categoryD0Ev
-         T _ZNSt3__114error_categoryD1Ev
-         T _ZNSt3__114error_categoryD2Ev
-         C _ZNSt3__115__codecvt_utf16IDiLb0EED0Ev
-         C _ZNSt3__115__codecvt_utf16IDiLb0EED1Ev
-         C _ZNSt3__115__codecvt_utf16IDiLb1EED0Ev
-         C _ZNSt3__115__codecvt_utf16IDiLb1EED1Ev
-         C _ZNSt3__115__codecvt_utf16IDsLb0EED0Ev
-         C _ZNSt3__115__codecvt_utf16IDsLb0EED1Ev
-         C _ZNSt3__115__codecvt_utf16IDsLb1EED0Ev
-         C _ZNSt3__115__codecvt_utf16IDsLb1EED1Ev
-         C _ZNSt3__115__codecvt_utf16IwLb0EED0Ev
-         C _ZNSt3__115__codecvt_utf16IwLb0EED1Ev
-         C _ZNSt3__115__codecvt_utf16IwLb1EED0Ev
-         C _ZNSt3__115__codecvt_utf16IwLb1EED1Ev
-         T _ZNSt3__115__get_classnameEPKcb
-         C _ZNSt3__115__num_get_floatIdEET_PKcS3_Rj
-         C _ZNSt3__115__num_get_floatIeEET_PKcS3_Rj
-         C _ZNSt3__115__num_get_floatIfEET_PKcS3_Rj
-         T _ZNSt3__115__thread_struct25notify_all_at_thread_exitEPNS_18condition_variableEPNS_5mutexE
-         T _ZNSt3__115__thread_struct27__make_ready_at_thread_exitEPNS_17__assoc_sub_stateE
-         T _ZNSt3__115__thread_structC1Ev
-         T _ZNSt3__115__thread_structC2Ev
-         T _ZNSt3__115__thread_structD1Ev
-         T _ZNSt3__115__thread_structD2Ev
-         C _ZNSt3__115__time_get_tempIcEC2EPKc
-         C _ZNSt3__115__time_get_tempIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         C _ZNSt3__115__time_get_tempIcED0Ev
-         C _ZNSt3__115__time_get_tempIcED1Ev
-         C _ZNSt3__115__time_get_tempIwEC2EPKc
-         C _ZNSt3__115__time_get_tempIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         C _ZNSt3__115__time_get_tempIwED0Ev
-         C _ZNSt3__115__time_get_tempIwED1Ev
+         U _ZNSt3__114error_categoryD2Ev
          W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj
          W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj
          W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_
@@ -1602,593 +664,18 @@
          W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEED1Ev
          W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEED2Ev
          W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEEaSERKS3_
-         T _ZNSt3__115future_categoryEv
-         W _ZNSt3__115messages_bynameIcEC1EPKcj
-         W _ZNSt3__115messages_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__115messages_bynameIcEC2EPKcj
-         W _ZNSt3__115messages_bynameIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__115messages_bynameIcED0Ev
-         W _ZNSt3__115messages_bynameIcED1Ev
-         W _ZNSt3__115messages_bynameIcED2Ev
-         W _ZNSt3__115messages_bynameIwEC1EPKcj
-         W _ZNSt3__115messages_bynameIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__115messages_bynameIwEC2EPKcj
-         W _ZNSt3__115messages_bynameIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__115messages_bynameIwED0Ev
-         W _ZNSt3__115messages_bynameIwED1Ev
-         W _ZNSt3__115messages_bynameIwED2Ev
-         T _ZNSt3__115numpunct_bynameIcE6__initEPKc
-         T _ZNSt3__115numpunct_bynameIcEC1EPKcj
-         T _ZNSt3__115numpunct_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__115numpunct_bynameIcEC2EPKcj
-         T _ZNSt3__115numpunct_bynameIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__115numpunct_bynameIcED0Ev
-         T _ZNSt3__115numpunct_bynameIcED1Ev
-         T _ZNSt3__115numpunct_bynameIcED2Ev
-         T _ZNSt3__115numpunct_bynameIwE6__initEPKc
-         T _ZNSt3__115numpunct_bynameIwEC1EPKcj
-         T _ZNSt3__115numpunct_bynameIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__115numpunct_bynameIwEC2EPKcj
-         T _ZNSt3__115numpunct_bynameIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__115numpunct_bynameIwED0Ev
-         T _ZNSt3__115numpunct_bynameIwED1Ev
-         T _ZNSt3__115numpunct_bynameIwED2Ev
-         T _ZNSt3__115recursive_mutex4lockEv
-         T _ZNSt3__115recursive_mutex6unlockEv
-         T _ZNSt3__115recursive_mutex8try_lockEv
-         T _ZNSt3__115recursive_mutexC1Ev
-         T _ZNSt3__115recursive_mutexC2Ev
-         T _ZNSt3__115recursive_mutexD1Ev
-         T _ZNSt3__115recursive_mutexD2Ev
-         T _ZNSt3__115system_categoryEv
-         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1EPKcj
-         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
-         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC2EPKcj
-         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC2ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
-         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
-         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
-         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
-         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC1EPKcj
-         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC1ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
-         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC2EPKcj
-         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC2ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
-         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
-         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
-         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
-         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1EPKcj
-         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
-         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2EPKcj
-         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
-         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
-         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
-         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
-         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1EPKcj
-         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
-         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2EPKcj
-         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
-         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
-         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
-         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
-         T _ZNSt3__116__check_groupingERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjS8_Rj
-         T _ZNSt3__116__narrow_to_utf8ILj16EED0Ev
-         T _ZNSt3__116__narrow_to_utf8ILj16EED1Ev
-         T _ZNSt3__116__narrow_to_utf8ILj16EED2Ev
-         T _ZNSt3__116__narrow_to_utf8ILj32EED0Ev
-         T _ZNSt3__116__narrow_to_utf8ILj32EED1Ev
-         T _ZNSt3__116__narrow_to_utf8ILj32EED2Ev
-         C _ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
-         C _ZNSt3__116__pad_and_outputIwNS_11char_traitsIwEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
-         T _ZNSt3__116generic_categoryEv
-         T _ZNSt3__117__assoc_sub_state10__sub_waitERNS_11unique_lockINS_5mutexEEE
-         T _ZNSt3__117__assoc_sub_state12__make_readyEv
-         T _ZNSt3__117__assoc_sub_state13set_exceptionESt13exception_ptr
-         T _ZNSt3__117__assoc_sub_state16__on_zero_sharedEv
-         T _ZNSt3__117__assoc_sub_state24set_value_at_thread_exitEv
-         T _ZNSt3__117__assoc_sub_state28set_exception_at_thread_exitESt13exception_ptr
-         T _ZNSt3__117__assoc_sub_state4copyEv
-         T _ZNSt3__117__assoc_sub_state4waitEv
-         T _ZNSt3__117__assoc_sub_state9__executeEv
-         T _ZNSt3__117__assoc_sub_state9set_valueEv
-         C _ZNSt3__117__assoc_sub_stateD0Ev
-         C _ZNSt3__117__assoc_sub_stateD1Ev
-         C _ZNSt3__117__assoc_sub_stateD2Ev
-         T _ZNSt3__117__widen_from_utf8ILj16EED0Ev
-         T _ZNSt3__117__widen_from_utf8ILj16EED1Ev
-         T _ZNSt3__117__widen_from_utf8ILj16EED2Ev
-         T _ZNSt3__117__widen_from_utf8ILj32EED0Ev
-         T _ZNSt3__117__widen_from_utf8ILj32EED1Ev
-         T _ZNSt3__117__widen_from_utf8ILj32EED2Ev
-         T _ZNSt3__117declare_reachableEPv
          T _ZNSt3__117iostream_categoryEv
-         T _ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc
-         W _ZNSt3__117moneypunct_bynameIcLb0EEC1EPKcj
-         W _ZNSt3__117moneypunct_bynameIcLb0EEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__117moneypunct_bynameIcLb0EEC2EPKcj
-         W _ZNSt3__117moneypunct_bynameIcLb0EEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__117moneypunct_bynameIcLb0EED0Ev
-         W _ZNSt3__117moneypunct_bynameIcLb0EED1Ev
-         W _ZNSt3__117moneypunct_bynameIcLb0EED2Ev
-         T _ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc
-         W _ZNSt3__117moneypunct_bynameIcLb1EEC1EPKcj
-         W _ZNSt3__117moneypunct_bynameIcLb1EEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__117moneypunct_bynameIcLb1EEC2EPKcj
-         W _ZNSt3__117moneypunct_bynameIcLb1EEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__117moneypunct_bynameIcLb1EED0Ev
-         W _ZNSt3__117moneypunct_bynameIcLb1EED1Ev
-         W _ZNSt3__117moneypunct_bynameIcLb1EED2Ev
-         T _ZNSt3__117moneypunct_bynameIwLb0EE4initEPKc
-         W _ZNSt3__117moneypunct_bynameIwLb0EEC1EPKcj
-         W _ZNSt3__117moneypunct_bynameIwLb0EEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__117moneypunct_bynameIwLb0EEC2EPKcj
-         W _ZNSt3__117moneypunct_bynameIwLb0EEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__117moneypunct_bynameIwLb0EED0Ev
-         W _ZNSt3__117moneypunct_bynameIwLb0EED1Ev
-         W _ZNSt3__117moneypunct_bynameIwLb0EED2Ev
-         T _ZNSt3__117moneypunct_bynameIwLb1EE4initEPKc
-         W _ZNSt3__117moneypunct_bynameIwLb1EEC1EPKcj
-         W _ZNSt3__117moneypunct_bynameIwLb1EEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__117moneypunct_bynameIwLb1EEC2EPKcj
-         W _ZNSt3__117moneypunct_bynameIwLb1EEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         W _ZNSt3__117moneypunct_bynameIwLb1EED0Ev
-         W _ZNSt3__117moneypunct_bynameIwLb1EED1Ev
-         W _ZNSt3__117moneypunct_bynameIwLb1EED2Ev
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIaaEEPaEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIccEEPcEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIddEEPdEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIeeEEPeEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIffEEPfEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIhhEEPhEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIiiEEPiEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIjjEEPjEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIllEEPlEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessImmEEPmEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIssEEPsEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIttEEPtEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIwwEEPwEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIxxEEPxEEvT0_S5_T_
-         C _ZNSt3__118__insertion_sort_3IRNS_6__lessIyyEEPyEEvT0_S5_T_
-         C _ZNSt3__118__libcpp_refstringC2EPKc
-         C _ZNSt3__118__libcpp_refstringaSERKS0_
-         T _ZNSt3__118__time_get_storageIcE4initERKNS_5ctypeIcEE
-         T _ZNSt3__118__time_get_storageIcE9__analyzeEcRKNS_5ctypeIcEE
-         T _ZNSt3__118__time_get_storageIcEC1EPKc
-         T _ZNSt3__118__time_get_storageIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__118__time_get_storageIcEC2EPKc
-         T _ZNSt3__118__time_get_storageIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__118__time_get_storageIwE4initERKNS_5ctypeIwEE
-         T _ZNSt3__118__time_get_storageIwE9__analyzeEcRKNS_5ctypeIwEE
-         T _ZNSt3__118__time_get_storageIwEC1EPKc
-         T _ZNSt3__118__time_get_storageIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__118__time_get_storageIwEC2EPKc
-         T _ZNSt3__118__time_get_storageIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__118condition_variable10notify_allEv
-         T _ZNSt3__118condition_variable10notify_oneEv
-         T _ZNSt3__118condition_variable15__do_timed_waitERNS_11unique_lockINS_5mutexEEENS_6chrono10time_pointINS5_12system_clockENS5_8durationIxNS_5ratioILx1ELx1000000000EEEEEEE
-         T _ZNSt3__118condition_variable4waitERNS_11unique_lockINS_5mutexEEE
-         T _ZNSt3__118condition_variableD1Ev
-         T _ZNSt3__118condition_variableD2Ev
-         T _ZNSt3__118get_pointer_safetyEv
-         C _ZNSt3__119__double_or_nothingIcEEvRNS_10unique_ptrIT_PFvPvEEERPS2_S9_
-         C _ZNSt3__119__double_or_nothingIjEEvRNS_10unique_ptrIT_PFvPvEEERPS2_S9_
-         C _ZNSt3__119__double_or_nothingIwEEvRNS_10unique_ptrIT_PFvPvEEERPS2_S9_
-         C _ZNSt3__119__iostream_categoryD0Ev
-         C _ZNSt3__119__iostream_categoryD1Ev
-         T _ZNSt3__119__shared_weak_count10__add_weakEv
-         T _ZNSt3__119__shared_weak_count12__add_sharedEv
-         T _ZNSt3__119__shared_weak_count14__release_weakEv
-         T _ZNSt3__119__shared_weak_count16__release_sharedEv
-         T _ZNSt3__119__shared_weak_count4lockEv
-         T _ZNSt3__119__shared_weak_countD0Ev
-         T _ZNSt3__119__shared_weak_countD1Ev
-         T _ZNSt3__119__shared_weak_countD2Ev
-         D _ZNSt3__119__start_std_streamsE
-         T _ZNSt3__119__thread_local_dataEv
-         T _ZNSt3__119__thread_struct_imp25notify_all_at_thread_exitEPNS_18condition_variableEPNS_5mutexE
-         T _ZNSt3__119__thread_struct_imp27__make_ready_at_thread_exitEPNS_17__assoc_sub_stateE
-         T _ZNSt3__119__thread_struct_impD1Ev
-         T _ZNSt3__119__thread_struct_impD2Ev
-         T _ZNSt3__119declare_no_pointersEPcj
-         D _ZNSt3__119piecewise_constructE
-         C _ZNSt3__120__codecvt_utf8_utf16IDiED0Ev
-         C _ZNSt3__120__codecvt_utf8_utf16IDiED1Ev
-         C _ZNSt3__120__codecvt_utf8_utf16IDsED0Ev
-         C _ZNSt3__120__codecvt_utf8_utf16IDsED1Ev
-         C _ZNSt3__120__codecvt_utf8_utf16IwED0Ev
-         C _ZNSt3__120__codecvt_utf8_utf16IwED1Ev
-         T _ZNSt3__120__get_collation_nameEPKc
-         C _ZNSt3__120__get_up_to_n_digitsIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEiRT0_S5_RjRKNS_5ctypeIT_EEi
-         C _ZNSt3__120__get_up_to_n_digitsIcPcEEiRT0_S2_RjRKNS_5ctypeIT_EEi
-         C _ZNSt3__120__get_up_to_n_digitsIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEiRT0_S5_RjRKNS_5ctypeIT_EEi
-         C _ZNSt3__120__get_up_to_n_digitsIwPwEEiRT0_S2_RjRKNS_5ctypeIT_EEi
-         T _ZNSt3__120__throw_system_errorEiPKc
-         W _ZNSt3__120__vector_base_commonILb1EEC1Ev
-         W _ZNSt3__120__vector_base_commonILb1EEC2Ev
-         C _ZNSt3__121__murmur2_or_cityhashIjLj32EEclEPKvj
-         C _ZNSt3__121__thread_specific_ptrINS_15__thread_structEE16__at_thread_exitEPv
-         C _ZNSt3__121__thread_specific_ptrINS_15__thread_structEEC2Ev
-         C _ZNSt3__121__thread_specific_ptrINS_15__thread_structEED1Ev
-         C _ZNSt3__121__thread_specific_ptrINS_15__thread_structEED2Ev
-         T _ZNSt3__121__throw_runtime_errorEPKc
-         T _ZNSt3__121__undeclare_reachableEPv
-         T _ZNSt3__121recursive_timed_mutex4lockEv
-         T _ZNSt3__121recursive_timed_mutex6unlockEv
-         T _ZNSt3__121recursive_timed_mutex8try_lockEv
-         T _ZNSt3__121recursive_timed_mutexC1Ev
-         T _ZNSt3__121recursive_timed_mutexC2Ev
-         T _ZNSt3__121recursive_timed_mutexD1Ev
-         T _ZNSt3__121recursive_timed_mutexD2Ev
-         T _ZNSt3__121undeclare_no_pointersEPcj
-         C _ZNSt3__123__future_error_categoryD0Ev
-         C _ZNSt3__123__future_error_categoryD1Ev
-         C _ZNSt3__123__system_error_categoryD0Ev
-         C _ZNSt3__123__system_error_categoryD1Ev
-         C _ZNSt3__123mersenne_twister_engineIjLj32ELj624ELj397ELj31ELj2567483615ELj11ELj4294967295ELj7ELj2636928640ELj15ELj4022730752ELj18ELj1812433253EE4seedEj
-         C _ZNSt3__123mersenne_twister_engineIjLj32ELj624ELj397ELj31ELj2567483615ELj11ELj4294967295ELj7ELj2636928640ELj15ELj4022730752ELj18ELj1812433253EEclEv
-         C _ZNSt3__124__generic_error_categoryD0Ev
-         C _ZNSt3__124__generic_error_categoryD1Ev
-         C _ZNSt3__125__num_get_signed_integralIlEET_PKcS3_Rji
-         C _ZNSt3__125__num_get_signed_integralIxEET_PKcS3_Rji
-         T _ZNSt3__125notify_all_at_thread_exitERNS_18condition_variableENS_11unique_lockINS_5mutexEEE
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIaaEEPaEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIccEEPcEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIddEEPdEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIeeEEPeEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIffEEPfEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIhhEEPhEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIiiEEPiEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIjjEEPjEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIllEEPlEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessImmEEPmEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIssEEPsEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIttEEPtEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIwwEEPwEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIxxEEPxEEbT0_S5_T_
-         W _ZNSt3__127__insertion_sort_incompleteIRNS_6__lessIyyEEPyEEbT0_S5_T_
-         C _ZNSt3__127__num_get_unsigned_integralIjEET_PKcS3_Rji
-         C _ZNSt3__127__num_get_unsigned_integralImEET_PKcS3_Rji
-         C _ZNSt3__127__num_get_unsigned_integralItEET_PKcS3_Rji
-         C _ZNSt3__127__num_get_unsigned_integralIyEET_PKcS3_Rji
-         D _ZNSt3__13cinE
-         D _ZNSt3__14cerrE
-         D _ZNSt3__14clogE
-         D _ZNSt3__14coutE
-         T _ZNSt3__14stodERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPj
-         T _ZNSt3__14stodERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPj
-         T _ZNSt3__14stofERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPj
-         T _ZNSt3__14stofERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPj
-         T _ZNSt3__14stoiERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
-         T _ZNSt3__14stoiERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
-         T _ZNSt3__14stolERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
-         T _ZNSt3__14stolERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
-         D _ZNSt3__14wcinE
-         T _ZNSt3__15alignEjjRPvRj
-         T _ZNSt3__15ctypeIcE13classic_tableEv
-         T _ZNSt3__15ctypeIcE21__classic_lower_tableEv
-         T _ZNSt3__15ctypeIcE21__classic_upper_tableEv
-         D _ZNSt3__15ctypeIcE2idE
-         T _ZNSt3__15ctypeIcEC1EPKtbj
-         T _ZNSt3__15ctypeIcEC2EPKtbj
-         T _ZNSt3__15ctypeIcED0Ev
-         T _ZNSt3__15ctypeIcED1Ev
-         T _ZNSt3__15ctypeIcED2Ev
-         D _ZNSt3__15ctypeIwE2idE
-         T _ZNSt3__15ctypeIwED0Ev
-         T _ZNSt3__15ctypeIwED1Ev
-         T _ZNSt3__15ctypeIwED2Ev
-         T _ZNSt3__15mutex4lockEv
-         T _ZNSt3__15mutex6unlockEv
-         T _ZNSt3__15mutex8try_lockEv
-         T _ZNSt3__15mutexD1Ev
-         T _ZNSt3__15mutexD2Ev
-         T _ZNSt3__15stoldERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPj
-         T _ZNSt3__15stoldERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPj
-         T _ZNSt3__15stollERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
-         T _ZNSt3__15stollERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
-         T _ZNSt3__15stoulERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
-         T _ZNSt3__15stoulERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
-         D _ZNSt3__15wcerrE
-         D _ZNSt3__15wclogE
-         D _ZNSt3__15wcoutE
-         T _ZNSt3__16__clocEv
-         W _ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIeeEEPeEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIffEEPfEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIhhEEPhEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIiiEEPiEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIjjEEPjEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIllEEPlEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessImmEEPmEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIssEEPsEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIttEEPtEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIwwEEPwEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIxxEEPxEEvT0_S5_T_
-         W _ZNSt3__16__sortIRNS_6__lessIyyEEPyEEvT0_S5_T_
-         T _ZNSt3__16chrono12steady_clock3nowEv
-         D _ZNSt3__16chrono12steady_clock9is_steadyE
-         T _ZNSt3__16chrono12system_clock11from_time_tEl
-         T _ZNSt3__16chrono12system_clock3nowEv
-         D _ZNSt3__16chrono12system_clock9is_steadyE
-         T _ZNSt3__16chrono12system_clock9to_time_tERKNS0_10time_pointIS1_NS0_8durationIxNS_5ratioILx1ELx1000000EEEEEEE
-         T _ZNSt3__16futureIvE3getEv
-         T _ZNSt3__16futureIvEC1EPNS_17__assoc_sub_stateE
-         T _ZNSt3__16futureIvEC2EPNS_17__assoc_sub_stateE
-         T _ZNSt3__16futureIvED1Ev
-         T _ZNSt3__16futureIvED2Ev
-         T _ZNSt3__16gslice6__initEj
-         T _ZNSt3__16locale14__install_ctorERKS0_PNS0_5facetEl
-         T _ZNSt3__16locale2id5__getEv
-         T _ZNSt3__16locale2id6__initEv
-         D _ZNSt3__16locale2id9__next_idE
-         D _ZNSt3__16locale3allE
-         D _ZNSt3__16locale4noneE
-         D _ZNSt3__16locale4timeE
-         T _ZNSt3__16locale5__imp11make_globalEv
-         C _ZNSt3__16locale5__imp12install_fromINS_10moneypunctIcLb0EEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_10moneypunctIcLb1EEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_10moneypunctIwLb0EEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_10moneypunctIwLb1EEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_5ctypeIcEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_5ctypeIwEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7codecvtIDic11__mbstate_tEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7codecvtIDsc11__mbstate_tEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7codecvtIcc11__mbstate_tEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7codecvtIwc11__mbstate_tEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7collateIcEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7collateIwEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_7num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_8messagesIcEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_8messagesIwEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_8numpunctIcEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_8numpunctIwEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_8time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_8time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_8time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_8time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_9money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_9money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_9money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
-         C _ZNSt3__16locale5__imp12install_fromINS_9money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
-         T _ZNSt3__16locale5__imp12make_classicEv
-         T _ZNSt3__16locale5__imp7installEPNS0_5facetEl
-         C _ZNSt3__16locale5__imp7installINS_10moneypunctIcLb0EEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_10moneypunctIcLb1EEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_10moneypunctIwLb0EEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_10moneypunctIwLb1EEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_12ctype_bynameIcEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_12ctype_bynameIwEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_14codecvt_bynameIDic11__mbstate_tEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_14codecvt_bynameIDsc11__mbstate_tEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_14codecvt_bynameIcc11__mbstate_tEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_14codecvt_bynameIwc11__mbstate_tEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_14collate_bynameIcEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_14collate_bynameIwEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_15messages_bynameIcEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_15messages_bynameIwEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_15numpunct_bynameIcEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_15numpunct_bynameIwEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_15time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_15time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_15time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_15time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_17moneypunct_bynameIcLb0EEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_17moneypunct_bynameIcLb1EEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_17moneypunct_bynameIwLb0EEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_17moneypunct_bynameIwLb1EEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_5ctypeIcEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_5ctypeIwEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7codecvtIDic11__mbstate_tEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7codecvtIDsc11__mbstate_tEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7codecvtIcc11__mbstate_tEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7codecvtIwc11__mbstate_tEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7collateIcEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7collateIwEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_7num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_8messagesIcEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_8messagesIwEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_8numpunctIcEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_8numpunctIwEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_8time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_8time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_8time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_8time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_9money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_9money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_9money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
-         C _ZNSt3__16locale5__imp7installINS_9money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
-         T _ZNSt3__16locale5__impC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__16locale5__impC1ERKS1_
-         T _ZNSt3__16locale5__impC1ERKS1_PNS0_5facetEl
-         T _ZNSt3__16locale5__impC1ERKS1_RKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEi
-         T _ZNSt3__16locale5__impC1ERKS1_S3_i
-         T _ZNSt3__16locale5__impC1Ej
-         T _ZNSt3__16locale5__impC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
-         T _ZNSt3__16locale5__impC2ERKS1_
-         T _ZNSt3__16locale5__impC2ERKS1_PNS0_5facetEl
-         T _ZNSt3__16locale5__impC2ERKS1_RKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEi
-         T _ZNSt3__16locale5__impC2ERKS1_S3_i
-         T _ZNSt3__16locale5__impC2Ej
-         T _ZNSt3__16locale5__impD0Ev
-         T _ZNSt3__16locale5__impD1Ev
-         T _ZNSt3__16locale5__impD2Ev
-         D _ZNSt3__16locale5ctypeE
-         T _ZNSt3__16locale5facet16__on_zero_sharedEv
-         T _ZNSt3__16locale5facetD0Ev
-         T _ZNSt3__16locale5facetD1Ev
-         T _ZNSt3__16locale5facetD2Ev
-         T _ZNSt3__16locale6globalERKS0_
-         T _ZNSt3__16locale7classicEv
-         D _ZNSt3__16locale7collateE
-         D _ZNSt3__16locale7numericE
-         T _ZNSt3__16locale8__globalEv
-         D _ZNSt3__16locale8messagesE
-         D _ZNSt3__16locale8monetaryE
-         T _ZNSt3__16localeC1EPKc
-         T _ZNSt3__16localeC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__16localeC1ERKS0_
-         T _ZNSt3__16localeC1ERKS0_PKci
-         T _ZNSt3__16localeC1ERKS0_RKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEi
-         T _ZNSt3__16localeC1ERKS0_S2_i
-         T _ZNSt3__16localeC1Ev
-         T _ZNSt3__16localeC2EPKc
-         T _ZNSt3__16localeC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
-         T _ZNSt3__16localeC2ERKS0_
-         T _ZNSt3__16localeC2ERKS0_PKci
-         T _ZNSt3__16localeC2ERKS0_RKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEi
-         T _ZNSt3__16localeC2ERKS0_S2_i
-         T _ZNSt3__16localeC2Ev
-         T _ZNSt3__16localeD1Ev
-         T _ZNSt3__16localeD2Ev
-         T _ZNSt3__16localeaSERKS0_
-         T _ZNSt3__16stoullERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
-         T _ZNSt3__16stoullERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
-         T _ZNSt3__16thread20hardware_concurrencyEv
-         T _ZNSt3__16thread4joinEv
-         T _ZNSt3__16thread6detachEv
-         T _ZNSt3__16threadD1Ev
-         T _ZNSt3__16threadD2Ev
-         C _ZNSt3__16vectorINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEE21__push_back_slow_pathIS6_EEvOT_
-         C _ZNSt3__16vectorINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS6_RS8_EE
-         C _ZNSt3__16vectorIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEE21__push_back_slow_pathIRKS2_EEvOT_
-         C _ZNSt3__16vectorIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS2_RS4_EE
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE10deallocateEv
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE18__construct_at_endEj
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE18__construct_at_endIPS3_EENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE26__swap_out_circular_bufferERNS_14__split_bufferIS3_RS5_EE
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE6assignIPS3_EENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr16is_constructibleIS3_NS_15iterator_traitsISA_E9referenceEEE5valueEvE4typeESA_SA_
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE6resizeEj
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE8__appendEj
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE8allocateEj
-         C _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEEC2Ej
-         C _ZNSt3__17__sort3IRNS_6__lessIaaEEPaEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIccEEPcEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIddEEPdEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIeeEEPeEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIffEEPfEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIhhEEPhEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIiiEEPiEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIjjEEPjEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIllEEPlEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessImmEEPmEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIssEEPsEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIttEEPtEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIwwEEPwEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIxxEEPxEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort3IRNS_6__lessIyyEEPyEEjT0_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIaaEEPaEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIccEEPcEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIddEEPdEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIeeEEPeEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIffEEPfEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIhhEEPhEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIiiEEPiEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIjjEEPjEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIllEEPlEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessImmEEPmEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIssEEPsEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIttEEPtEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIwwEEPwEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIxxEEPxEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort4IRNS_6__lessIyyEEPyEEjT0_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIaaEEPaEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIccEEPcEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIddEEPdEEjT0_S5_S5_S5_S5_T_
-         W _ZNSt3__17__sort5IRNS_6__lessIeeEEPeEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIffEEPfEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIhhEEPhEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIiiEEPiEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIjjEEPjEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIllEEPlEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessImmEEPmEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIssEEPsEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIttEEPtEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIwwEEPwEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIxxEEPxEEjT0_S5_S5_S5_S5_T_
-         C _ZNSt3__17__sort5IRNS_6__lessIyyEEPyEEjT0_S5_S5_S5_S5_T_
-         D _ZNSt3__17codecvtIDic11__mbstate_tE2idE
-         T _ZNSt3__17codecvtIDic11__mbstate_tED0Ev
-         T _ZNSt3__17codecvtIDic11__mbstate_tED1Ev
-         T _ZNSt3__17codecvtIDic11__mbstate_tED2Ev
-         D _ZNSt3__17codecvtIDsc11__mbstate_tE2idE
-         T _ZNSt3__17codecvtIDsc11__mbstate_tED0Ev
-         T _ZNSt3__17codecvtIDsc11__mbstate_tED1Ev
-         T _ZNSt3__17codecvtIDsc11__mbstate_tED2Ev
-         D _ZNSt3__17codecvtIcc11__mbstate_tE2idE
-         T _ZNSt3__17codecvtIcc11__mbstate_tED0Ev
-         T _ZNSt3__17codecvtIcc11__mbstate_tED1Ev
-         T _ZNSt3__17codecvtIcc11__mbstate_tED2Ev
-         D _ZNSt3__17codecvtIwc11__mbstate_tE2idE
-         T _ZNSt3__17codecvtIwc11__mbstate_tEC1EPKcj
-         T _ZNSt3__17codecvtIwc11__mbstate_tEC1Ej
-         T _ZNSt3__17codecvtIwc11__mbstate_tEC2EPKcj
-         T _ZNSt3__17codecvtIwc11__mbstate_tEC2Ej
-         T _ZNSt3__17codecvtIwc11__mbstate_tED0Ev
-         T _ZNSt3__17codecvtIwc11__mbstate_tED1Ev
-         T _ZNSt3__17codecvtIwc11__mbstate_tED2Ev
-         W _ZNSt3__17collateIcE2idE
-         W _ZNSt3__17collateIcEC1Ej
-         W _ZNSt3__17collateIcEC2Ej
-         W _ZNSt3__17collateIcED0Ev
-         W _ZNSt3__17collateIcED1Ev
-         W _ZNSt3__17collateIcED2Ev
-         W _ZNSt3__17collateIwE2idE
-         W _ZNSt3__17collateIwEC1Ej
-         W _ZNSt3__17collateIwEC2Ej
-         W _ZNSt3__17collateIwED0Ev
-         W _ZNSt3__17collateIwED1Ev
-         W _ZNSt3__17collateIwED2Ev
-         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
-         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
-         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC2Ej
-         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
-         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
-         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
-         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
-         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC1Ej
-         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC2Ej
-         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
-         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
-         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
-         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
-         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
-         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2Ej
-         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
-         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
-         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
-         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
-         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1Ej
-         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2Ej
-         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
-         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
-         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
-         T _ZNSt3__17promiseIvE10get_futureEv
-         T _ZNSt3__17promiseIvE13set_exceptionESt13exception_ptr
-         T _ZNSt3__17promiseIvE24set_value_at_thread_exitEv
-         T _ZNSt3__17promiseIvE28set_exception_at_thread_exitESt13exception_ptr
-         T _ZNSt3__17promiseIvE9set_valueEv
-         T _ZNSt3__17promiseIvEC1Ev
-         T _ZNSt3__17promiseIvEC2Ev
-         T _ZNSt3__17promiseIvED1Ev
-         T _ZNSt3__17promiseIvED2Ev
-         T _ZNSt3__18__c_node5__addEPNS_8__i_nodeE
-         T _ZNSt3__18__c_node8__removeEPNS_8__i_nodeE
-         T _ZNSt3__18__c_nodeD0Ev
-         T _ZNSt3__18__c_nodeD1Ev
-         T _ZNSt3__18__c_nodeD2Ev
-         T _ZNSt3__18__get_dbEv
-         T _ZNSt3__18__i_nodeD1Ev
-         T _ZNSt3__18__i_nodeD2Ev
-         T _ZNSt3__18__rs_getEv
-         C _ZNSt3__18__searchIPFbwwEPKwS4_EET0_S5_S5_T1_S6_T_NS_26random_access_iterator_tagES8_
-         T _ZNSt3__18__sp_mut4lockEv
-         T _ZNSt3__18__sp_mut6unlockEv
+         W _ZNSt3__119__iostream_categoryD0Ev
+         U _ZNSt3__15ctypeIcE2idE
+         U _ZNSt3__15ctypeIwE2idE
+         U _ZNSt3__16localeC1ERKS0_
+         U _ZNSt3__16localeC1Ev
+         U _ZNSt3__16localeD1Ev
+         U _ZNSt3__16localeaSERKS0_
+         U _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
+         U _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
+         U _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
+         U _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
          D _ZNSt3__18ios_base10floatfieldE
          D _ZNSt3__18ios_base10scientificE
          D _ZNSt3__18ios_base11adjustfieldE
@@ -2204,10 +691,6 @@
          D _ZNSt3__18ios_base3hexE
          D _ZNSt3__18ios_base3octE
          D _ZNSt3__18ios_base3outE
-         T _ZNSt3__18ios_base4InitC1Ev
-         T _ZNSt3__18ios_base4InitC2Ev
-         T _ZNSt3__18ios_base4InitD1Ev
-         T _ZNSt3__18ios_base4InitD2Ev
          T _ZNSt3__18ios_base4initEPv
          D _ZNSt3__18ios_base4leftE
          T _ZNSt3__18ios_base4moveERS0_
@@ -2246,79 +729,6 @@
          T _ZNSt3__18ios_baseD0Ev
          T _ZNSt3__18ios_baseD1Ev
          T _ZNSt3__18ios_baseD2Ev
-         W _ZNSt3__18messagesIcE2idE
-         W _ZNSt3__18messagesIcEC1Ej
-         W _ZNSt3__18messagesIcEC2Ej
-         W _ZNSt3__18messagesIcED0Ev
-         W _ZNSt3__18messagesIcED1Ev
-         W _ZNSt3__18messagesIcED2Ev
-         W _ZNSt3__18messagesIwE2idE
-         W _ZNSt3__18messagesIwEC1Ej
-         W _ZNSt3__18messagesIwEC2Ej
-         W _ZNSt3__18messagesIwED0Ev
-         W _ZNSt3__18messagesIwED1Ev
-         W _ZNSt3__18messagesIwED2Ev
-         D _ZNSt3__18numpunctIcE2idE
-         T _ZNSt3__18numpunctIcEC1Ej
-         T _ZNSt3__18numpunctIcEC2Ej
-         T _ZNSt3__18numpunctIcED0Ev
-         T _ZNSt3__18numpunctIcED1Ev
-         T _ZNSt3__18numpunctIcED2Ev
-         D _ZNSt3__18numpunctIwE2idE
-         T _ZNSt3__18numpunctIwEC1Ej
-         T _ZNSt3__18numpunctIwEC2Ej
-         T _ZNSt3__18numpunctIwED0Ev
-         T _ZNSt3__18numpunctIwED1Ev
-         T _ZNSt3__18numpunctIwED2Ev
-         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
-         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
-         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC2Ej
-         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
-         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
-         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
-         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
-         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC1Ej
-         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC2Ej
-         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
-         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
-         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1EPKcj
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2EPKcj
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2Ej
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
-         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1EPKcj
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1Ej
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2EPKcj
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2Ej
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
-         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
-         W _ZNSt3__18valarrayIjE6resizeEjj
-         W _ZNSt3__18valarrayIjEC1Ej
-         W _ZNSt3__18valarrayIjEC2Ej
-         W _ZNSt3__18valarrayIjED1Ev
-         W _ZNSt3__18valarrayIjED2Ev
-         W _ZNSt3__19__num_getIcE17__stage2_int_loopEciPcRS2_RjcRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjRSD_S2_
-         W _ZNSt3__19__num_getIcE17__stage2_int_prepERNS_8ios_baseEPcRc
-         W _ZNSt3__19__num_getIcE19__stage2_float_loopEcRbRcPcRS4_ccRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjRSE_RjS4_
-         W _ZNSt3__19__num_getIcE19__stage2_float_prepERNS_8ios_baseEPcRcS5_
-         W _ZNSt3__19__num_getIwE17__stage2_int_loopEwiPcRS2_RjwRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjRSD_Pw
-         W _ZNSt3__19__num_getIwE17__stage2_int_prepERNS_8ios_baseEPwRw
-         W _ZNSt3__19__num_getIwE19__stage2_float_loopEwRbRcPcRS4_wwRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjRSE_RjPw
-         W _ZNSt3__19__num_getIwE19__stage2_float_prepERNS_8ios_baseEPwRwS5_
-         W _ZNSt3__19__num_putIcE21__widen_and_group_intEPcS2_S2_S2_RS2_S3_RKNS_6localeE
-         W _ZNSt3__19__num_putIcE23__widen_and_group_floatEPcS2_S2_S2_RS2_S3_RKNS_6localeE
-         W _ZNSt3__19__num_putIwE21__widen_and_group_intEPcS2_S2_PwRS3_S4_RKNS_6localeE
-         W _ZNSt3__19__num_putIwE23__widen_and_group_floatEPcS2_S2_PwRS3_S4_RKNS_6localeE
          W _ZNSt3__19basic_iosIcNS_11char_traitsIcEEE10exceptionsEj
          W _ZNSt3__19basic_iosIcNS_11char_traitsIcEEE3tieEPNS_13basic_ostreamIcS2_EE
          W _ZNSt3__19basic_iosIcNS_11char_traitsIcEEE4fillEc
@@ -2359,6 +769,1321 @@
          W _ZNSt3__19basic_iosIwNS_11char_traitsIwEEED0Ev
          W _ZNSt3__19basic_iosIwNS_11char_traitsIwEEED1Ev
          W _ZNSt3__19basic_iosIwNS_11char_traitsIwEEED2Ev
+         U _ZNSt9bad_allocC1Ev
+         U _ZNSt9bad_allocD1Ev
+         U _ZSt18uncaught_exceptionv
+         U _ZSt9terminatev
+         W _ZTCNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE0_NS_13basic_istreamIcS2_EE
+         W _ZTCNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE8_NS_13basic_ostreamIcS2_EE
+         U _ZTINSt3__112__do_messageE
+         U _ZTINSt3__112system_errorE
+         W _ZTINSt3__113basic_istreamIcNS_11char_traitsIcEEEE
+         W _ZTINSt3__113basic_istreamIwNS_11char_traitsIwEEEE
+         W _ZTINSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
+         W _ZTINSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
+         W _ZTINSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
+         W _ZTINSt3__115basic_streambufIcNS_11char_traitsIcEEEE
+         W _ZTINSt3__115basic_streambufIwNS_11char_traitsIwEEEE
+         D _ZTINSt3__119__iostream_categoryE
+         D _ZTINSt3__18ios_base7failureE
+         D _ZTINSt3__18ios_baseE
+         W _ZTINSt3__19basic_iosIcNS_11char_traitsIcEEEE
+         W _ZTINSt3__19basic_iosIwNS_11char_traitsIwEEEE
+         U _ZTISt9bad_alloc
+         W _ZTSNSt3__113basic_istreamIcNS_11char_traitsIcEEEE
+         W _ZTSNSt3__113basic_istreamIwNS_11char_traitsIwEEEE
+         W _ZTSNSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
+         W _ZTSNSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
+         W _ZTSNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
+         W _ZTSNSt3__115basic_streambufIcNS_11char_traitsIcEEEE
+         W _ZTSNSt3__115basic_streambufIwNS_11char_traitsIwEEEE
+         D _ZTSNSt3__119__iostream_categoryE
+         D _ZTSNSt3__18ios_base7failureE
+         D _ZTSNSt3__18ios_baseE
+         W _ZTSNSt3__19basic_iosIcNS_11char_traitsIcEEEE
+         W _ZTSNSt3__19basic_iosIwNS_11char_traitsIwEEEE
+         W _ZTTNSt3__113basic_istreamIcNS_11char_traitsIcEEEE
+         W _ZTTNSt3__113basic_istreamIwNS_11char_traitsIwEEEE
+         W _ZTTNSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
+         W _ZTTNSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
+         W _ZTTNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
+         U _ZTVN10__cxxabiv117__class_type_infoE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         U _ZTVN10__cxxabiv121__vmi_class_type_infoE
+         W _ZTVNSt3__113basic_istreamIcNS_11char_traitsIcEEEE
+         W _ZTVNSt3__113basic_istreamIwNS_11char_traitsIwEEEE
+         W _ZTVNSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
+         W _ZTVNSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
+         W _ZTVNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
+         W _ZTVNSt3__115basic_streambufIcNS_11char_traitsIcEEEE
+         W _ZTVNSt3__115basic_streambufIwNS_11char_traitsIwEEEE
+         D _ZTVNSt3__119__iostream_categoryE
+         D _ZTVNSt3__18ios_base7failureE
+         D _ZTVNSt3__18ios_baseE
+         W _ZTVNSt3__19basic_iosIcNS_11char_traitsIcEEEE
+         W _ZTVNSt3__19basic_iosIwNS_11char_traitsIwEEEE
+         W _ZThn8_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev
+         W _ZThn8_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev
+         W _ZTv0_n12_NSt3__113basic_istreamIcNS_11char_traitsIcEEED0Ev
+         W _ZTv0_n12_NSt3__113basic_istreamIcNS_11char_traitsIcEEED1Ev
+         W _ZTv0_n12_NSt3__113basic_istreamIwNS_11char_traitsIwEEED0Ev
+         W _ZTv0_n12_NSt3__113basic_istreamIwNS_11char_traitsIwEEED1Ev
+         W _ZTv0_n12_NSt3__113basic_ostreamIcNS_11char_traitsIcEEED0Ev
+         W _ZTv0_n12_NSt3__113basic_ostreamIcNS_11char_traitsIcEEED1Ev
+         W _ZTv0_n12_NSt3__113basic_ostreamIwNS_11char_traitsIwEEED0Ev
+         W _ZTv0_n12_NSt3__113basic_ostreamIwNS_11char_traitsIwEEED1Ev
+         W _ZTv0_n12_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev
+         W _ZTv0_n12_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev
+         U _ZdlPv
+         W __clang_call_terminate
+         U __cxa_allocate_exception
+         U __cxa_atexit
+         U __cxa_begin_catch
+         U __cxa_end_catch
+         U __cxa_free_exception
+         U __cxa_guard_acquire
+         U __cxa_guard_release
+         U __cxa_rethrow
+         U __cxa_throw
+         U __dso_handle
+         U __gxx_personality_v0
+         U free
+         U malloc
+         U realloc
+         U wmemcpy
+         U _ZNKSt3__16locale9use_facetERNS0_2idE
+         W _ZNSt3__110__stdinbufIcE5imbueERKNS_6localeE
+         W _ZNSt3__110__stdinbufIcE5uflowEv
+         W _ZNSt3__110__stdinbufIcE9__getcharEb
+         W _ZNSt3__110__stdinbufIcE9pbackfailEi
+         W _ZNSt3__110__stdinbufIcE9underflowEv
+         W _ZNSt3__110__stdinbufIcEC2EP8_IO_FILEP11__mbstate_t
+         W _ZNSt3__110__stdinbufIcED0Ev
+         W _ZNSt3__110__stdinbufIwE5imbueERKNS_6localeE
+         W _ZNSt3__110__stdinbufIwE5uflowEv
+         W _ZNSt3__110__stdinbufIwE9__getcharEb
+         W _ZNSt3__110__stdinbufIwE9pbackfailEj
+         W _ZNSt3__110__stdinbufIwE9underflowEv
+         W _ZNSt3__110__stdinbufIwEC2EP8_IO_FILEP11__mbstate_t
+         W _ZNSt3__110__stdinbufIwED0Ev
+         W _ZNSt3__111__stdoutbufIcE4syncEv
+         W _ZNSt3__111__stdoutbufIcE5imbueERKNS_6localeE
+         W _ZNSt3__111__stdoutbufIcE6xsputnEPKci
+         W _ZNSt3__111__stdoutbufIcE8overflowEi
+         W _ZNSt3__111__stdoutbufIcEC2EP8_IO_FILEP11__mbstate_t
+         W _ZNSt3__111__stdoutbufIcED0Ev
+         W _ZNSt3__111__stdoutbufIwE4syncEv
+         W _ZNSt3__111__stdoutbufIwE5imbueERKNS_6localeE
+         W _ZNSt3__111__stdoutbufIwE6xsputnEPKwi
+         W _ZNSt3__111__stdoutbufIwE8overflowEj
+         W _ZNSt3__111__stdoutbufIwEC2EP8_IO_FILEP11__mbstate_t
+         W _ZNSt3__111__stdoutbufIwED0Ev
+         U _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv
+         U _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5flushEv
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4syncEv
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5uflowEv
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6setbufEPci
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6xsgetnEPci
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6xsputnEPKci
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7seekoffExNS_8ios_base7seekdirEj
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7seekposENS_4fposI11__mbstate_tEEj
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8overflowEi
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pbackfailEi
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9showmanycEv
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9underflowEv
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEEC2Ev
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEED2Ev
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4syncEv
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5uflowEv
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6setbufEPwi
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6xsgetnEPwi
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6xsputnEPKwi
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7seekoffExNS_8ios_base7seekdirEj
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7seekposENS_4fposI11__mbstate_tEEj
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8overflowEj
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pbackfailEj
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9showmanycEv
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9underflowEv
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEEC2Ev
+         U _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEED2Ev
+         D _ZNSt3__119__start_std_streamsE
+         U _ZNSt3__121__throw_runtime_errorEPKc
+         D _ZNSt3__13cinE
+         D _ZNSt3__14cerrE
+         D _ZNSt3__14clogE
+         D _ZNSt3__14coutE
+         D _ZNSt3__14wcinE
+         D _ZNSt3__15wcerrE
+         D _ZNSt3__15wclogE
+         D _ZNSt3__15wcoutE
+         U _ZNSt3__16localeC1ERKS0_
+         U _ZNSt3__16localeD1Ev
+         U _ZNSt3__17codecvtIcc11__mbstate_tE2idE
+         U _ZNSt3__17codecvtIwc11__mbstate_tE2idE
+         T _ZNSt3__18ios_base4InitC1Ev
+         T _ZNSt3__18ios_base4InitC2Ev
+         T _ZNSt3__18ios_base4InitD1Ev
+         T _ZNSt3__18ios_base4InitD2Ev
+         U _ZNSt3__18ios_base4initEPv
+         U _ZNSt3__19basic_iosIcNS_11char_traitsIcEEED2Ev
+         U _ZNSt3__19basic_iosIwNS_11char_traitsIwEEED2Ev
+         U _ZSt9terminatev
+         W _ZTINSt3__110__stdinbufIcEE
+         W _ZTINSt3__110__stdinbufIwEE
+         W _ZTINSt3__111__stdoutbufIcEE
+         W _ZTINSt3__111__stdoutbufIwEE
+         U _ZTINSt3__115basic_streambufIcNS_11char_traitsIcEEEE
+         U _ZTINSt3__115basic_streambufIwNS_11char_traitsIwEEEE
+         W _ZTSNSt3__110__stdinbufIcEE
+         W _ZTSNSt3__110__stdinbufIwEE
+         W _ZTSNSt3__111__stdoutbufIcEE
+         W _ZTSNSt3__111__stdoutbufIwEE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         W _ZTVNSt3__110__stdinbufIcEE
+         W _ZTVNSt3__110__stdinbufIwEE
+         W _ZTVNSt3__111__stdoutbufIcEE
+         W _ZTVNSt3__111__stdoutbufIwEE
+         U _ZTVNSt3__113basic_istreamIcNS_11char_traitsIcEEEE
+         U _ZTVNSt3__113basic_istreamIwNS_11char_traitsIwEEEE
+         U _ZTVNSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
+         U _ZTVNSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
+         U _ZdlPv
+         W __clang_call_terminate
+         U __cxa_atexit
+         U __cxa_begin_catch
+         U __dso_handle
+         U __gxx_personality_v0
+         U fflush
+         U fwrite
+         U getc
+         U stderr
+         U stdin
+         U stdout
+         U ungetc
+         T _ZNKSt3__110__time_put8__do_putEPcRS1_PK2tmcc
+         T _ZNKSt3__110__time_put8__do_putEPwRS1_PK2tmcc
+         W _ZNKSt3__110moneypunctIcLb0EE10neg_formatEv
+         W _ZNKSt3__110moneypunctIcLb0EE10pos_formatEv
+         W _ZNKSt3__110moneypunctIcLb0EE11curr_symbolEv
+         W _ZNKSt3__110moneypunctIcLb0EE11do_groupingEv
+         W _ZNKSt3__110moneypunctIcLb0EE11frac_digitsEv
+         W _ZNKSt3__110moneypunctIcLb0EE13decimal_pointEv
+         W _ZNKSt3__110moneypunctIcLb0EE13do_neg_formatEv
+         W _ZNKSt3__110moneypunctIcLb0EE13do_pos_formatEv
+         W _ZNKSt3__110moneypunctIcLb0EE13negative_signEv
+         W _ZNKSt3__110moneypunctIcLb0EE13positive_signEv
+         W _ZNKSt3__110moneypunctIcLb0EE13thousands_sepEv
+         W _ZNKSt3__110moneypunctIcLb0EE14do_curr_symbolEv
+         W _ZNKSt3__110moneypunctIcLb0EE14do_frac_digitsEv
+         W _ZNKSt3__110moneypunctIcLb0EE16do_decimal_pointEv
+         W _ZNKSt3__110moneypunctIcLb0EE16do_negative_signEv
+         W _ZNKSt3__110moneypunctIcLb0EE16do_positive_signEv
+         W _ZNKSt3__110moneypunctIcLb0EE16do_thousands_sepEv
+         W _ZNKSt3__110moneypunctIcLb0EE8groupingEv
+         W _ZNKSt3__110moneypunctIcLb1EE10neg_formatEv
+         W _ZNKSt3__110moneypunctIcLb1EE10pos_formatEv
+         W _ZNKSt3__110moneypunctIcLb1EE11curr_symbolEv
+         W _ZNKSt3__110moneypunctIcLb1EE11do_groupingEv
+         W _ZNKSt3__110moneypunctIcLb1EE11frac_digitsEv
+         W _ZNKSt3__110moneypunctIcLb1EE13decimal_pointEv
+         W _ZNKSt3__110moneypunctIcLb1EE13do_neg_formatEv
+         W _ZNKSt3__110moneypunctIcLb1EE13do_pos_formatEv
+         W _ZNKSt3__110moneypunctIcLb1EE13negative_signEv
+         W _ZNKSt3__110moneypunctIcLb1EE13positive_signEv
+         W _ZNKSt3__110moneypunctIcLb1EE13thousands_sepEv
+         W _ZNKSt3__110moneypunctIcLb1EE14do_curr_symbolEv
+         W _ZNKSt3__110moneypunctIcLb1EE14do_frac_digitsEv
+         W _ZNKSt3__110moneypunctIcLb1EE16do_decimal_pointEv
+         W _ZNKSt3__110moneypunctIcLb1EE16do_negative_signEv
+         W _ZNKSt3__110moneypunctIcLb1EE16do_positive_signEv
+         W _ZNKSt3__110moneypunctIcLb1EE16do_thousands_sepEv
+         W _ZNKSt3__110moneypunctIcLb1EE8groupingEv
+         W _ZNKSt3__110moneypunctIwLb0EE10neg_formatEv
+         W _ZNKSt3__110moneypunctIwLb0EE10pos_formatEv
+         W _ZNKSt3__110moneypunctIwLb0EE11curr_symbolEv
+         W _ZNKSt3__110moneypunctIwLb0EE11do_groupingEv
+         W _ZNKSt3__110moneypunctIwLb0EE11frac_digitsEv
+         W _ZNKSt3__110moneypunctIwLb0EE13decimal_pointEv
+         W _ZNKSt3__110moneypunctIwLb0EE13do_neg_formatEv
+         W _ZNKSt3__110moneypunctIwLb0EE13do_pos_formatEv
+         W _ZNKSt3__110moneypunctIwLb0EE13negative_signEv
+         W _ZNKSt3__110moneypunctIwLb0EE13positive_signEv
+         W _ZNKSt3__110moneypunctIwLb0EE13thousands_sepEv
+         W _ZNKSt3__110moneypunctIwLb0EE14do_curr_symbolEv
+         W _ZNKSt3__110moneypunctIwLb0EE14do_frac_digitsEv
+         W _ZNKSt3__110moneypunctIwLb0EE16do_decimal_pointEv
+         W _ZNKSt3__110moneypunctIwLb0EE16do_negative_signEv
+         W _ZNKSt3__110moneypunctIwLb0EE16do_positive_signEv
+         W _ZNKSt3__110moneypunctIwLb0EE16do_thousands_sepEv
+         W _ZNKSt3__110moneypunctIwLb0EE8groupingEv
+         W _ZNKSt3__110moneypunctIwLb1EE10neg_formatEv
+         W _ZNKSt3__110moneypunctIwLb1EE10pos_formatEv
+         W _ZNKSt3__110moneypunctIwLb1EE11curr_symbolEv
+         W _ZNKSt3__110moneypunctIwLb1EE11do_groupingEv
+         W _ZNKSt3__110moneypunctIwLb1EE11frac_digitsEv
+         W _ZNKSt3__110moneypunctIwLb1EE13decimal_pointEv
+         W _ZNKSt3__110moneypunctIwLb1EE13do_neg_formatEv
+         W _ZNKSt3__110moneypunctIwLb1EE13do_pos_formatEv
+         W _ZNKSt3__110moneypunctIwLb1EE13negative_signEv
+         W _ZNKSt3__110moneypunctIwLb1EE13positive_signEv
+         W _ZNKSt3__110moneypunctIwLb1EE13thousands_sepEv
+         W _ZNKSt3__110moneypunctIwLb1EE14do_curr_symbolEv
+         W _ZNKSt3__110moneypunctIwLb1EE14do_frac_digitsEv
+         W _ZNKSt3__110moneypunctIwLb1EE16do_decimal_pointEv
+         W _ZNKSt3__110moneypunctIwLb1EE16do_negative_signEv
+         W _ZNKSt3__110moneypunctIwLb1EE16do_positive_signEv
+         W _ZNKSt3__110moneypunctIwLb1EE16do_thousands_sepEv
+         W _ZNKSt3__110moneypunctIwLb1EE8groupingEv
+         U _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjPKcj
+         T _ZNKSt3__112ctype_bynameIcE10do_tolowerEPcPKc
+         T _ZNKSt3__112ctype_bynameIcE10do_tolowerEc
+         T _ZNKSt3__112ctype_bynameIcE10do_toupperEPcPKc
+         T _ZNKSt3__112ctype_bynameIcE10do_toupperEc
+         T _ZNKSt3__112ctype_bynameIwE10do_scan_isEtPKwS3_
+         T _ZNKSt3__112ctype_bynameIwE10do_tolowerEPwPKw
+         T _ZNKSt3__112ctype_bynameIwE10do_tolowerEw
+         T _ZNKSt3__112ctype_bynameIwE10do_toupperEPwPKw
+         T _ZNKSt3__112ctype_bynameIwE10do_toupperEw
+         T _ZNKSt3__112ctype_bynameIwE11do_scan_notEtPKwS3_
+         T _ZNKSt3__112ctype_bynameIwE5do_isEPKwS3_Pt
+         T _ZNKSt3__112ctype_bynameIwE5do_isEtw
+         T _ZNKSt3__112ctype_bynameIwE8do_widenEPKcS3_Pw
+         T _ZNKSt3__112ctype_bynameIwE8do_widenEc
+         T _ZNKSt3__112ctype_bynameIwE9do_narrowEPKwS3_cPc
+         T _ZNKSt3__112ctype_bynameIwE9do_narrowEwc
+         T _ZNKSt3__114__codecvt_utf8IDiE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__114__codecvt_utf8IDiE11do_encodingEv
+         T _ZNKSt3__114__codecvt_utf8IDiE13do_max_lengthEv
+         T _ZNKSt3__114__codecvt_utf8IDiE16do_always_noconvEv
+         T _ZNKSt3__114__codecvt_utf8IDiE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_
+         T _ZNKSt3__114__codecvt_utf8IDiE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_
+         T _ZNKSt3__114__codecvt_utf8IDiE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__114__codecvt_utf8IDsE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__114__codecvt_utf8IDsE11do_encodingEv
+         T _ZNKSt3__114__codecvt_utf8IDsE13do_max_lengthEv
+         T _ZNKSt3__114__codecvt_utf8IDsE16do_always_noconvEv
+         T _ZNKSt3__114__codecvt_utf8IDsE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_
+         T _ZNKSt3__114__codecvt_utf8IDsE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_
+         T _ZNKSt3__114__codecvt_utf8IDsE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__114__codecvt_utf8IwE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__114__codecvt_utf8IwE11do_encodingEv
+         T _ZNKSt3__114__codecvt_utf8IwE13do_max_lengthEv
+         T _ZNKSt3__114__codecvt_utf8IwE16do_always_noconvEv
+         T _ZNKSt3__114__codecvt_utf8IwE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_
+         T _ZNKSt3__114__codecvt_utf8IwE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_
+         T _ZNKSt3__114__codecvt_utf8IwE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__114collate_bynameIcE10do_compareEPKcS3_S3_S3_
+         T _ZNKSt3__114collate_bynameIcE12do_transformEPKcS3_
+         T _ZNKSt3__114collate_bynameIwE10do_compareEPKwS3_S3_S3_
+         T _ZNKSt3__114collate_bynameIwE12do_transformEPKwS3_
+         T _ZNKSt3__115__codecvt_utf16IDiLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__115__codecvt_utf16IDiLb0EE11do_encodingEv
+         T _ZNKSt3__115__codecvt_utf16IDiLb0EE13do_max_lengthEv
+         T _ZNKSt3__115__codecvt_utf16IDiLb0EE16do_always_noconvEv
+         T _ZNKSt3__115__codecvt_utf16IDiLb0EE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IDiLb0EE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IDiLb0EE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__115__codecvt_utf16IDiLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__115__codecvt_utf16IDiLb1EE11do_encodingEv
+         T _ZNKSt3__115__codecvt_utf16IDiLb1EE13do_max_lengthEv
+         T _ZNKSt3__115__codecvt_utf16IDiLb1EE16do_always_noconvEv
+         T _ZNKSt3__115__codecvt_utf16IDiLb1EE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IDiLb1EE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IDiLb1EE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__115__codecvt_utf16IDsLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__115__codecvt_utf16IDsLb0EE11do_encodingEv
+         T _ZNKSt3__115__codecvt_utf16IDsLb0EE13do_max_lengthEv
+         T _ZNKSt3__115__codecvt_utf16IDsLb0EE16do_always_noconvEv
+         T _ZNKSt3__115__codecvt_utf16IDsLb0EE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IDsLb0EE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IDsLb0EE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__115__codecvt_utf16IDsLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__115__codecvt_utf16IDsLb1EE11do_encodingEv
+         T _ZNKSt3__115__codecvt_utf16IDsLb1EE13do_max_lengthEv
+         T _ZNKSt3__115__codecvt_utf16IDsLb1EE16do_always_noconvEv
+         T _ZNKSt3__115__codecvt_utf16IDsLb1EE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IDsLb1EE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IDsLb1EE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__115__codecvt_utf16IwLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__115__codecvt_utf16IwLb0EE11do_encodingEv
+         T _ZNKSt3__115__codecvt_utf16IwLb0EE13do_max_lengthEv
+         T _ZNKSt3__115__codecvt_utf16IwLb0EE16do_always_noconvEv
+         T _ZNKSt3__115__codecvt_utf16IwLb0EE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IwLb0EE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IwLb0EE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__115__codecvt_utf16IwLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__115__codecvt_utf16IwLb1EE11do_encodingEv
+         T _ZNKSt3__115__codecvt_utf16IwLb1EE13do_max_lengthEv
+         T _ZNKSt3__115__codecvt_utf16IwLb1EE16do_always_noconvEv
+         T _ZNKSt3__115__codecvt_utf16IwLb1EE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IwLb1EE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_
+         T _ZNKSt3__115__codecvt_utf16IwLb1EE9do_lengthER11__mbstate_tPKcS5_j
+         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13do_date_orderEv
+         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__XEv
+         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__cEv
+         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__rEv
+         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__xEv
+         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE7__am_pmEv
+         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE7__weeksEv
+         W _ZNKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8__monthsEv
+         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13do_date_orderEv
+         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__XEv
+         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__cEv
+         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__rEv
+         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__xEv
+         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE7__am_pmEv
+         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE7__weeksEv
+         W _ZNKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8__monthsEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE11do_groupingEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE13do_neg_formatEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE13do_pos_formatEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE14do_curr_symbolEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE14do_frac_digitsEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE16do_decimal_pointEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE16do_negative_signEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE16do_positive_signEv
+         W _ZNKSt3__117moneypunct_bynameIcLb0EE16do_thousands_sepEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE11do_groupingEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE13do_neg_formatEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE13do_pos_formatEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE14do_curr_symbolEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE14do_frac_digitsEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE16do_decimal_pointEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE16do_negative_signEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE16do_positive_signEv
+         W _ZNKSt3__117moneypunct_bynameIcLb1EE16do_thousands_sepEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE11do_groupingEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE13do_neg_formatEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE13do_pos_formatEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE14do_curr_symbolEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE14do_frac_digitsEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE16do_decimal_pointEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE16do_negative_signEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE16do_positive_signEv
+         W _ZNKSt3__117moneypunct_bynameIwLb0EE16do_thousands_sepEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE11do_groupingEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE13do_neg_formatEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE13do_pos_formatEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE14do_curr_symbolEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE14do_frac_digitsEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE16do_decimal_pointEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE16do_negative_signEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE16do_positive_signEv
+         W _ZNKSt3__117moneypunct_bynameIwLb1EE16do_thousands_sepEv
+         T _ZNKSt3__118__time_get_storageIcE15__do_date_orderEv
+         T _ZNKSt3__118__time_get_storageIwE15__do_date_orderEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IDiE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__120__codecvt_utf8_utf16IDiE11do_encodingEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IDiE13do_max_lengthEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IDiE16do_always_noconvEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IDiE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_
+         T _ZNKSt3__120__codecvt_utf8_utf16IDiE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_
+         T _ZNKSt3__120__codecvt_utf8_utf16IDiE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__120__codecvt_utf8_utf16IDsE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__120__codecvt_utf8_utf16IDsE11do_encodingEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IDsE13do_max_lengthEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IDsE16do_always_noconvEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IDsE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_
+         T _ZNKSt3__120__codecvt_utf8_utf16IDsE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_
+         T _ZNKSt3__120__codecvt_utf8_utf16IDsE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__120__codecvt_utf8_utf16IwE10do_unshiftER11__mbstate_tPcS4_RS4_
+         T _ZNKSt3__120__codecvt_utf8_utf16IwE11do_encodingEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IwE13do_max_lengthEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IwE16do_always_noconvEv
+         T _ZNKSt3__120__codecvt_utf8_utf16IwE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_
+         T _ZNKSt3__120__codecvt_utf8_utf16IwE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_
+         T _ZNKSt3__120__codecvt_utf8_utf16IwE9do_lengthER11__mbstate_tPKcS5_j
+         T _ZNKSt3__120__time_get_c_storageIcE3__XEv
+         T _ZNKSt3__120__time_get_c_storageIcE3__cEv
+         T _ZNKSt3__120__time_get_c_storageIcE3__rEv
+         T _ZNKSt3__120__time_get_c_storageIcE3__xEv
+         T _ZNKSt3__120__time_get_c_storageIcE7__am_pmEv
+         T _ZNKSt3__120__time_get_c_storageIcE7__weeksEv
+         T _ZNKSt3__120__time_get_c_storageIcE8__monthsEv
+         T _ZNKSt3__120__time_get_c_storageIwE3__XEv
+         T _ZNKSt3__120__time_get_c_storageIwE3__cEv
+         T _ZNKSt3__120__time_get_c_storageIwE3__rEv
+         T _ZNKSt3__120__time_get_c_storageIwE3__xEv
+         T _ZNKSt3__120__time_get_c_storageIwE7__am_pmEv
+         T _ZNKSt3__120__time_get_c_storageIwE7__weeksEv
+         T _ZNKSt3__120__time_get_c_storageIwE8__monthsEv
+         W _ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv
+         W _ZNKSt3__120__vector_base_commonILb1EE20__throw_out_of_rangeEv
+         U _ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv
+         T _ZNKSt3__15ctypeIcE10do_tolowerEPcPKc
+         T _ZNKSt3__15ctypeIcE10do_tolowerEc
+         T _ZNKSt3__15ctypeIcE10do_toupperEPcPKc
+         T _ZNKSt3__15ctypeIcE10do_toupperEc
+         T _ZNKSt3__15ctypeIcE8do_widenEPKcS3_Pc
+         T _ZNKSt3__15ctypeIcE8do_widenEc
+         T _ZNKSt3__15ctypeIcE9do_narrowEPKcS3_cPc
+         T _ZNKSt3__15ctypeIcE9do_narrowEcc
+         T _ZNKSt3__15ctypeIwE10do_scan_isEtPKwS3_
+         T _ZNKSt3__15ctypeIwE10do_tolowerEPwPKw
+         T _ZNKSt3__15ctypeIwE10do_tolowerEw
+         T _ZNKSt3__15ctypeIwE10do_toupperEPwPKw
+         T _ZNKSt3__15ctypeIwE10do_toupperEw
+         T _ZNKSt3__15ctypeIwE11do_scan_notEtPKwS3_
+         T _ZNKSt3__15ctypeIwE5do_isEPKwS3_Pt
+         T _ZNKSt3__15ctypeIwE5do_isEtw
+         T _ZNKSt3__15ctypeIwE8do_widenEPKcS3_Pw
+         T _ZNKSt3__15ctypeIwE8do_widenEc
+         T _ZNKSt3__15ctypeIwE9do_narrowEPKwS3_cPc
+         T _ZNKSt3__15ctypeIwE9do_narrowEwc
+         T _ZNKSt3__16locale4nameEv
+         W _ZNKSt3__16locale5__imp9has_facetEl
+         T _ZNKSt3__16locale5__imp9use_facetEl
+         T _ZNKSt3__16locale9has_facetERNS0_2idE
+         T _ZNKSt3__16locale9use_facetERNS0_2idE
+         T _ZNKSt3__16localeeqERKS0_
+         T _ZNKSt3__17codecvtIDic11__mbstate_tE10do_unshiftERS1_PcS4_RS4_
+         T _ZNKSt3__17codecvtIDic11__mbstate_tE11do_encodingEv
+         T _ZNKSt3__17codecvtIDic11__mbstate_tE13do_max_lengthEv
+         T _ZNKSt3__17codecvtIDic11__mbstate_tE16do_always_noconvEv
+         T _ZNKSt3__17codecvtIDic11__mbstate_tE5do_inERS1_PKcS5_RS5_PDiS7_RS7_
+         T _ZNKSt3__17codecvtIDic11__mbstate_tE6do_outERS1_PKDiS5_RS5_PcS7_RS7_
+         T _ZNKSt3__17codecvtIDic11__mbstate_tE9do_lengthERS1_PKcS5_j
+         T _ZNKSt3__17codecvtIDsc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_
+         T _ZNKSt3__17codecvtIDsc11__mbstate_tE11do_encodingEv
+         T _ZNKSt3__17codecvtIDsc11__mbstate_tE13do_max_lengthEv
+         T _ZNKSt3__17codecvtIDsc11__mbstate_tE16do_always_noconvEv
+         T _ZNKSt3__17codecvtIDsc11__mbstate_tE5do_inERS1_PKcS5_RS5_PDsS7_RS7_
+         T _ZNKSt3__17codecvtIDsc11__mbstate_tE6do_outERS1_PKDsS5_RS5_PcS7_RS7_
+         T _ZNKSt3__17codecvtIDsc11__mbstate_tE9do_lengthERS1_PKcS5_j
+         T _ZNKSt3__17codecvtIcc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_
+         T _ZNKSt3__17codecvtIcc11__mbstate_tE11do_encodingEv
+         T _ZNKSt3__17codecvtIcc11__mbstate_tE13do_max_lengthEv
+         T _ZNKSt3__17codecvtIcc11__mbstate_tE16do_always_noconvEv
+         T _ZNKSt3__17codecvtIcc11__mbstate_tE5do_inERS1_PKcS5_RS5_PcS7_RS7_
+         T _ZNKSt3__17codecvtIcc11__mbstate_tE6do_outERS1_PKcS5_RS5_PcS7_RS7_
+         T _ZNKSt3__17codecvtIcc11__mbstate_tE9do_lengthERS1_PKcS5_j
+         T _ZNKSt3__17codecvtIwc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_
+         T _ZNKSt3__17codecvtIwc11__mbstate_tE11do_encodingEv
+         T _ZNKSt3__17codecvtIwc11__mbstate_tE13do_max_lengthEv
+         T _ZNKSt3__17codecvtIwc11__mbstate_tE16do_always_noconvEv
+         T _ZNKSt3__17codecvtIwc11__mbstate_tE5do_inERS1_PKcS5_RS5_PwS7_RS7_
+         T _ZNKSt3__17codecvtIwc11__mbstate_tE6do_outERS1_PKwS5_RS5_PcS7_RS7_
+         T _ZNKSt3__17codecvtIwc11__mbstate_tE9do_lengthERS1_PKcS5_j
+         W _ZNKSt3__17collateIcE10do_compareEPKcS3_S3_S3_
+         W _ZNKSt3__17collateIcE12do_transformEPKcS3_
+         W _ZNKSt3__17collateIcE4hashEPKcS3_
+         W _ZNKSt3__17collateIcE7compareEPKcS3_S3_S3_
+         W _ZNKSt3__17collateIcE7do_hashEPKcS3_
+         W _ZNKSt3__17collateIcE9transformEPKcS3_
+         W _ZNKSt3__17collateIwE10do_compareEPKwS3_S3_S3_
+         W _ZNKSt3__17collateIwE12do_transformEPKwS3_
+         W _ZNKSt3__17collateIwE4hashEPKwS3_
+         W _ZNKSt3__17collateIwE7compareEPKwS3_S3_S3_
+         W _ZNKSt3__17collateIwE7do_hashEPKwS3_
+         W _ZNKSt3__17collateIwE9transformEPKwS3_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE15__do_get_signedIlEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE15__do_get_signedIxEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedIjEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedImEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedItEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedIyEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIdEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIeEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIfEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRPv
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRb
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRd
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRe
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRf
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRl
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRm
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRt
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRx
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRy
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjS8_
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRPv
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRb
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRd
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRe
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRf
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRl
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRm
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRt
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRx
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRy
+         W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjS8_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE15__do_get_signedIlEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE15__do_get_signedIxEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedIjEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedImEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedItEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedIyEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIdEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIeEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIfEES4_S4_S4_RNS_8ios_baseERjRT_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRPv
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRb
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRd
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRe
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRf
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRl
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRm
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRt
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRx
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRy
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjS8_
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRPv
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRb
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRd
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRe
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRf
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRl
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRm
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRt
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRx
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjRy
+         W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjS8_
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcPKv
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcb
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcd
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEce
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcl
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcm
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcx
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcy
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcPKv
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcb
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcd
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEce
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcl
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcm
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcx
+         W _ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcy
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwPKv
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwb
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwd
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwe
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwl
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwm
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwx
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwy
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwPKv
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwb
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwd
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwe
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwl
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwm
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwx
+         W _ZNKSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwy
+         U _ZNKSt3__18ios_base6getlocEv
+         W _ZNKSt3__18messagesIcE3getEiiiRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         W _ZNKSt3__18messagesIcE4openERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_6localeE
+         W _ZNKSt3__18messagesIcE5closeEi
+         W _ZNKSt3__18messagesIcE6do_getEiiiRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         W _ZNKSt3__18messagesIcE7do_openERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_6localeE
+         W _ZNKSt3__18messagesIcE8do_closeEi
+         W _ZNKSt3__18messagesIwE3getEiiiRKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEE
+         W _ZNKSt3__18messagesIwE4openERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_6localeE
+         W _ZNKSt3__18messagesIwE5closeEi
+         W _ZNKSt3__18messagesIwE6do_getEiiiRKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEE
+         W _ZNKSt3__18messagesIwE7do_openERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_6localeE
+         W _ZNKSt3__18messagesIwE8do_closeEi
+         T _ZNKSt3__18numpunctIcE11do_groupingEv
+         T _ZNKSt3__18numpunctIcE11do_truenameEv
+         T _ZNKSt3__18numpunctIcE12do_falsenameEv
+         T _ZNKSt3__18numpunctIcE16do_decimal_pointEv
+         T _ZNKSt3__18numpunctIcE16do_thousands_sepEv
+         T _ZNKSt3__18numpunctIwE11do_groupingEv
+         T _ZNKSt3__18numpunctIwE11do_truenameEv
+         T _ZNKSt3__18numpunctIwE12do_falsenameEv
+         T _ZNKSt3__18numpunctIwE16do_decimal_pointEv
+         T _ZNKSt3__18numpunctIwE16do_thousands_sepEv
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE10__get_hourERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE10__get_yearERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE10date_orderEv
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11__get_am_pmERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11__get_monthERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11__get_year4ERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11do_get_dateES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11do_get_timeES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11do_get_yearES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE11get_weekdayES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE12__get_minuteERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE12__get_secondERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13__get_12_hourERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13__get_percentERS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13__get_weekdayERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13do_date_orderEv
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE13get_monthnameES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE14do_get_weekdayES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE15__get_monthnameERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE16do_get_monthnameES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__get_weekdaynameERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__get_white_spaceERS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE18__get_day_year_numERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjP2tmPKcSC_
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjP2tmcc
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjP2tmcc
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8get_dateES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8get_timeES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8get_yearES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE9__get_dayERiRS4_S4_RjRKNS_5ctypeIcEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE10__get_hourERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE10__get_yearERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE10date_orderEv
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11__get_am_pmERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11__get_monthERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11__get_year4ERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11do_get_dateES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11do_get_timeES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11do_get_yearES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE11get_weekdayES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE12__get_minuteERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE12__get_secondERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13__get_12_hourERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13__get_percentERS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13__get_weekdayERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13do_date_orderEv
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE13get_monthnameES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE14do_get_weekdayES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE15__get_monthnameERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE16do_get_monthnameES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__get_weekdaynameERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__get_white_spaceERS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE18__get_day_year_numERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjP2tmPKwSC_
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjP2tmcc
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_RNS_8ios_baseERjP2tmcc
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8get_dateES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8get_timeES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8get_yearES4_S4_RNS_8ios_baseERjP2tm
+         W _ZNKSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE9__get_dayERiRS4_S4_RjRKNS_5ctypeIwEE
+         W _ZNKSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcPK2tmPKcSC_
+         W _ZNKSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcPK2tmcc
+         W _ZNKSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcPK2tmcc
+         W _ZNKSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwPK2tmPKwSC_
+         W _ZNKSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_RNS_8ios_baseEwPK2tmcc
+         W _ZNKSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_RNS_8ios_baseEwPK2tmcc
+         W _ZNKSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_bRNS_8ios_baseERjRNS_12basic_stringIcS3_NS_9allocatorIcEEEE
+         W _ZNKSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_bRNS_8ios_baseERjRe
+         W _ZNKSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_bRNS_8ios_baseERjRNS_12basic_stringIcS3_NS_9allocatorIcEEEE
+         W _ZNKSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_bRNS_8ios_baseERjRe
+         W _ZNKSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_bRNS_8ios_baseERjRNS_12basic_stringIwS3_NS_9allocatorIwEEEE
+         W _ZNKSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_bRNS_8ios_baseERjRe
+         W _ZNKSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_bRNS_8ios_baseERjRNS_12basic_stringIwS3_NS_9allocatorIwEEEE
+         W _ZNKSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_getES4_S4_bRNS_8ios_baseERjRe
+         W _ZNKSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_bRNS_8ios_baseEcRKNS_12basic_stringIcS3_NS_9allocatorIcEEEE
+         W _ZNKSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_bRNS_8ios_baseEce
+         W _ZNKSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_bRNS_8ios_baseEcRKNS_12basic_stringIcS3_NS_9allocatorIcEEEE
+         W _ZNKSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_bRNS_8ios_baseEce
+         W _ZNKSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_bRNS_8ios_baseEwRKNS_12basic_stringIwS3_NS_9allocatorIwEEEE
+         W _ZNKSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE3putES4_bRNS_8ios_baseEwe
+         W _ZNKSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_bRNS_8ios_baseEwRKNS_12basic_stringIwS3_NS_9allocatorIwEEEE
+         W _ZNKSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE6do_putES4_bRNS_8ios_baseEwe
+         U _ZNSt11logic_errorC2EPKc
+         U _ZNSt12length_errorD1Ev
+         U _ZNSt12out_of_rangeD1Ev
+         U _ZNSt13runtime_errorC1EPKc
+         U _ZNSt13runtime_errorC1ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
+         U _ZNSt13runtime_errorD1Ev
+         T _ZNSt3__110__time_getC1EPKc
+         T _ZNSt3__110__time_getC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__110__time_getC2EPKc
+         T _ZNSt3__110__time_getC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__110__time_getD1Ev
+         T _ZNSt3__110__time_getD2Ev
+         T _ZNSt3__110__time_putC1EPKc
+         T _ZNSt3__110__time_putC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__110__time_putC2EPKc
+         T _ZNSt3__110__time_putC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__110__time_putD1Ev
+         T _ZNSt3__110__time_putD2Ev
+         D _ZNSt3__110ctype_base5alnumE
+         D _ZNSt3__110ctype_base5alphaE
+         D _ZNSt3__110ctype_base5blankE
+         D _ZNSt3__110ctype_base5cntrlE
+         D _ZNSt3__110ctype_base5digitE
+         D _ZNSt3__110ctype_base5graphE
+         D _ZNSt3__110ctype_base5lowerE
+         D _ZNSt3__110ctype_base5printE
+         D _ZNSt3__110ctype_base5punctE
+         D _ZNSt3__110ctype_base5spaceE
+         D _ZNSt3__110ctype_base5upperE
+         D _ZNSt3__110ctype_base6xdigitE
+         W _ZNSt3__110moneypunctIcLb0EE2idE
+         W _ZNSt3__110moneypunctIcLb0EE4intlE
+         W _ZNSt3__110moneypunctIcLb0EEC1Ej
+         W _ZNSt3__110moneypunctIcLb0EEC2Ej
+         W _ZNSt3__110moneypunctIcLb0EED0Ev
+         W _ZNSt3__110moneypunctIcLb0EED1Ev
+         W _ZNSt3__110moneypunctIcLb0EED2Ev
+         W _ZNSt3__110moneypunctIcLb1EE2idE
+         W _ZNSt3__110moneypunctIcLb1EE4intlE
+         W _ZNSt3__110moneypunctIcLb1EEC1Ej
+         W _ZNSt3__110moneypunctIcLb1EEC2Ej
+         W _ZNSt3__110moneypunctIcLb1EED0Ev
+         W _ZNSt3__110moneypunctIcLb1EED1Ev
+         W _ZNSt3__110moneypunctIcLb1EED2Ev
+         W _ZNSt3__110moneypunctIwLb0EE2idE
+         W _ZNSt3__110moneypunctIwLb0EE4intlE
+         W _ZNSt3__110moneypunctIwLb0EEC1Ej
+         W _ZNSt3__110moneypunctIwLb0EEC2Ej
+         W _ZNSt3__110moneypunctIwLb0EED0Ev
+         W _ZNSt3__110moneypunctIwLb0EED1Ev
+         W _ZNSt3__110moneypunctIwLb0EED2Ev
+         W _ZNSt3__110moneypunctIwLb1EE2idE
+         W _ZNSt3__110moneypunctIwLb1EE4intlE
+         W _ZNSt3__110moneypunctIwLb1EEC1Ej
+         W _ZNSt3__110moneypunctIwLb1EEC2Ej
+         W _ZNSt3__110moneypunctIwLb1EED0Ev
+         W _ZNSt3__110moneypunctIwLb1EED1Ev
+         W _ZNSt3__110moneypunctIwLb1EED2Ev
+         U _ZNSt3__111__call_onceERVmPvPFvS2_E
+         W _ZNSt3__111__money_getIcE13__gather_infoEbRKNS_6localeERNS_10money_base7patternERcS8_RNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESF_SF_SF_Ri
+         W _ZNSt3__111__money_getIcEC1Ev
+         W _ZNSt3__111__money_getIcEC2Ev
+         W _ZNSt3__111__money_getIwE13__gather_infoEbRKNS_6localeERNS_10money_base7patternERwS8_RNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERNS9_IwNSA_IwEENSC_IwEEEESJ_SJ_Ri
+         W _ZNSt3__111__money_getIwEC1Ev
+         W _ZNSt3__111__money_getIwEC2Ev
+         W _ZNSt3__111__money_putIcE13__gather_infoEbbRKNS_6localeERNS_10money_base7patternERcS8_RNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESF_SF_Ri
+         W _ZNSt3__111__money_putIcE8__formatEPcRS2_S3_jPKcS5_RKNS_5ctypeIcEEbRKNS_10money_base7patternEccRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESL_SL_i
+         W _ZNSt3__111__money_putIcEC1Ev
+         W _ZNSt3__111__money_putIcEC2Ev
+         W _ZNSt3__111__money_putIwE13__gather_infoEbbRKNS_6localeERNS_10money_base7patternERwS8_RNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERNS9_IwNSA_IwEENSC_IwEEEESJ_Ri
+         W _ZNSt3__111__money_putIwE8__formatEPwRS2_S3_jPKwS5_RKNS_5ctypeIwEEbRKNS_10money_base7patternEwwRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNSE_IwNSF_IwEENSH_IwEEEESQ_i
+         W _ZNSt3__111__money_putIwEC1Ev
+         W _ZNSt3__111__money_putIwEC2Ev
+         W _ZNSt3__111char_traitsIcE7compareEPKcS3_j
+         T _ZNSt3__112__do_nothingEPv
+         W _ZNSt3__112__rotate_gcdINS_11__wrap_iterIPcEEEET_S4_S4_S4_
+         W _ZNSt3__112__rotate_gcdINS_11__wrap_iterIPwEEEET_S4_S4_S4_
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5eraseEjj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcjj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEjc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendIPcEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorIS9_EE5valueERS5_E4typeES9_S9_
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjPKc
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjjc
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6resizeEjc
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEjjjjjj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5eraseEjj
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwj
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEjw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initIPKwEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendIPwEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorIS9_EE5valueERS5_E4typeES9_S9_
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignIPwEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorIS9_EE5valueERS5_E4typeES9_S9_
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjjw
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7reserveEj
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9__grow_byEjjjjjj
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS5_
+         U _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED1Ev
+         T _ZNSt3__112ctype_bynameIcEC1EPKcj
+         T _ZNSt3__112ctype_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__112ctype_bynameIcEC2EPKcj
+         T _ZNSt3__112ctype_bynameIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__112ctype_bynameIcED0Ev
+         T _ZNSt3__112ctype_bynameIcED1Ev
+         T _ZNSt3__112ctype_bynameIcED2Ev
+         T _ZNSt3__112ctype_bynameIwEC1EPKcj
+         T _ZNSt3__112ctype_bynameIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__112ctype_bynameIwEC2EPKcj
+         T _ZNSt3__112ctype_bynameIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__112ctype_bynameIwED0Ev
+         T _ZNSt3__112ctype_bynameIwED1Ev
+         T _ZNSt3__112ctype_bynameIwED2Ev
+         W _ZNSt3__113__vector_baseIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEED2Ev
+         W _ZNSt3__114__codecvt_utf8IDiED0Ev
+         W _ZNSt3__114__codecvt_utf8IDsED0Ev
+         W _ZNSt3__114__codecvt_utf8IwED0Ev
+         T _ZNSt3__114__num_get_base10__get_baseERNS_8ios_baseE
+         D _ZNSt3__114__num_get_base5__srcE
+         T _ZNSt3__114__num_put_base12__format_intEPcPKcbj
+         T _ZNSt3__114__num_put_base14__format_floatEPcPKcj
+         T _ZNSt3__114__num_put_base18__identify_paddingEPcS1_RKNS_8ios_baseE
+         W _ZNSt3__114__scan_keywordINS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEPKNS_12basic_stringIcS3_NS_9allocatorIcEEEENS_5ctypeIcEEEET0_RT_SE_SD_SD_RKT1_Rjb
+         W _ZNSt3__114__scan_keywordINS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEPKNS_12basic_stringIwS3_NS_9allocatorIwEEEENS_5ctypeIwEEEET0_RT_SE_SD_SD_RKT1_Rjb
+         W _ZNSt3__114__scan_keywordIPcPNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_5ctypeIcEEEET0_RT_SC_SB_SB_RKT1_Rjb
+         W _ZNSt3__114__scan_keywordIPwPNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEENS_5ctypeIwEEEET0_RT_SC_SB_SB_RKT1_Rjb
+         U _ZNSt3__114__shared_count12__add_sharedEv
+         U _ZNSt3__114__shared_count16__release_sharedEv
+         U _ZNSt3__114__shared_countD2Ev
+         W _ZNSt3__114__split_bufferIPNS_6locale5facetERNS_15__sso_allocatorIS3_Lj28EEEEC2EjjS6_
+         W _ZNSt3__114__split_bufferIPNS_6locale5facetERNS_15__sso_allocatorIS3_Lj28EEEED2Ev
+         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC1EPKcj
+         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC2EPKcj
+         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED0Ev
+         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED1Ev
+         W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED2Ev
+         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC1EPKcj
+         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC2EPKcj
+         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED0Ev
+         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED1Ev
+         W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED2Ev
+         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC1EPKcj
+         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC2EPKcj
+         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED0Ev
+         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED1Ev
+         W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED2Ev
+         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC1EPKcj
+         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC2EPKcj
+         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED0Ev
+         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED1Ev
+         W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED2Ev
+         T _ZNSt3__114collate_bynameIcEC1EPKcj
+         T _ZNSt3__114collate_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__114collate_bynameIcEC2EPKcj
+         T _ZNSt3__114collate_bynameIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__114collate_bynameIcED0Ev
+         T _ZNSt3__114collate_bynameIcED1Ev
+         T _ZNSt3__114collate_bynameIcED2Ev
+         T _ZNSt3__114collate_bynameIwEC1EPKcj
+         T _ZNSt3__114collate_bynameIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__114collate_bynameIwEC2EPKcj
+         T _ZNSt3__114collate_bynameIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__114collate_bynameIwED0Ev
+         T _ZNSt3__114collate_bynameIwED1Ev
+         T _ZNSt3__114collate_bynameIwED2Ev
+         W _ZNSt3__115__codecvt_utf16IDiLb0EED0Ev
+         W _ZNSt3__115__codecvt_utf16IDiLb1EED0Ev
+         W _ZNSt3__115__codecvt_utf16IDsLb0EED0Ev
+         W _ZNSt3__115__codecvt_utf16IDsLb1EED0Ev
+         W _ZNSt3__115__codecvt_utf16IwLb0EED0Ev
+         W _ZNSt3__115__codecvt_utf16IwLb1EED0Ev
+         W _ZNSt3__115__num_get_floatIdEET_PKcS3_Rj
+         W _ZNSt3__115__num_get_floatIeEET_PKcS3_Rj
+         W _ZNSt3__115__num_get_floatIfEET_PKcS3_Rj
+         W _ZNSt3__115__time_get_tempIcEC2EPKc
+         W _ZNSt3__115__time_get_tempIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         W _ZNSt3__115__time_get_tempIcED0Ev
+         W _ZNSt3__115__time_get_tempIwEC2EPKc
+         W _ZNSt3__115__time_get_tempIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         W _ZNSt3__115__time_get_tempIwED0Ev
+         W _ZNSt3__115messages_bynameIcEC1EPKcj
+         W _ZNSt3__115messages_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__115messages_bynameIcEC2EPKcj
+         W _ZNSt3__115messages_bynameIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__115messages_bynameIcED0Ev
+         W _ZNSt3__115messages_bynameIcED1Ev
+         W _ZNSt3__115messages_bynameIcED2Ev
+         W _ZNSt3__115messages_bynameIwEC1EPKcj
+         W _ZNSt3__115messages_bynameIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__115messages_bynameIwEC2EPKcj
+         W _ZNSt3__115messages_bynameIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__115messages_bynameIwED0Ev
+         W _ZNSt3__115messages_bynameIwED1Ev
+         W _ZNSt3__115messages_bynameIwED2Ev
+         T _ZNSt3__115numpunct_bynameIcE6__initEPKc
+         T _ZNSt3__115numpunct_bynameIcEC1EPKcj
+         T _ZNSt3__115numpunct_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__115numpunct_bynameIcEC2EPKcj
+         T _ZNSt3__115numpunct_bynameIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__115numpunct_bynameIcED0Ev
+         T _ZNSt3__115numpunct_bynameIcED1Ev
+         T _ZNSt3__115numpunct_bynameIcED2Ev
+         T _ZNSt3__115numpunct_bynameIwE6__initEPKc
+         T _ZNSt3__115numpunct_bynameIwEC1EPKcj
+         T _ZNSt3__115numpunct_bynameIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__115numpunct_bynameIwEC2EPKcj
+         T _ZNSt3__115numpunct_bynameIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__115numpunct_bynameIwED0Ev
+         T _ZNSt3__115numpunct_bynameIwED1Ev
+         T _ZNSt3__115numpunct_bynameIwED2Ev
+         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1EPKcj
+         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
+         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC2EPKcj
+         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC2ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
+         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
+         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
+         W _ZNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
+         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC1EPKcj
+         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC1ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
+         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC2EPKcj
+         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC2ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
+         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
+         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
+         W _ZNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
+         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1EPKcj
+         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
+         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2EPKcj
+         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
+         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
+         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
+         W _ZNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
+         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1EPKcj
+         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
+         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2EPKcj
+         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
+         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
+         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
+         W _ZNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
+         T _ZNSt3__116__check_groupingERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjS8_Rj
+         T _ZNSt3__116__narrow_to_utf8ILj16EED0Ev
+         T _ZNSt3__116__narrow_to_utf8ILj16EED1Ev
+         T _ZNSt3__116__narrow_to_utf8ILj16EED2Ev
+         T _ZNSt3__116__narrow_to_utf8ILj32EED0Ev
+         T _ZNSt3__116__narrow_to_utf8ILj32EED1Ev
+         T _ZNSt3__116__narrow_to_utf8ILj32EED2Ev
+         W _ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
+         W _ZNSt3__116__pad_and_outputIwNS_11char_traitsIwEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
+         W _ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z
+         T _ZNSt3__117__widen_from_utf8ILj16EED0Ev
+         T _ZNSt3__117__widen_from_utf8ILj16EED1Ev
+         T _ZNSt3__117__widen_from_utf8ILj16EED2Ev
+         T _ZNSt3__117__widen_from_utf8ILj32EED0Ev
+         T _ZNSt3__117__widen_from_utf8ILj32EED1Ev
+         T _ZNSt3__117__widen_from_utf8ILj32EED2Ev
+         T _ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc
+         W _ZNSt3__117moneypunct_bynameIcLb0EEC1EPKcj
+         W _ZNSt3__117moneypunct_bynameIcLb0EEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__117moneypunct_bynameIcLb0EEC2EPKcj
+         W _ZNSt3__117moneypunct_bynameIcLb0EEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__117moneypunct_bynameIcLb0EED0Ev
+         W _ZNSt3__117moneypunct_bynameIcLb0EED1Ev
+         W _ZNSt3__117moneypunct_bynameIcLb0EED2Ev
+         T _ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc
+         W _ZNSt3__117moneypunct_bynameIcLb1EEC1EPKcj
+         W _ZNSt3__117moneypunct_bynameIcLb1EEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__117moneypunct_bynameIcLb1EEC2EPKcj
+         W _ZNSt3__117moneypunct_bynameIcLb1EEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__117moneypunct_bynameIcLb1EED0Ev
+         W _ZNSt3__117moneypunct_bynameIcLb1EED1Ev
+         W _ZNSt3__117moneypunct_bynameIcLb1EED2Ev
+         T _ZNSt3__117moneypunct_bynameIwLb0EE4initEPKc
+         W _ZNSt3__117moneypunct_bynameIwLb0EEC1EPKcj
+         W _ZNSt3__117moneypunct_bynameIwLb0EEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__117moneypunct_bynameIwLb0EEC2EPKcj
+         W _ZNSt3__117moneypunct_bynameIwLb0EEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__117moneypunct_bynameIwLb0EED0Ev
+         W _ZNSt3__117moneypunct_bynameIwLb0EED1Ev
+         W _ZNSt3__117moneypunct_bynameIwLb0EED2Ev
+         T _ZNSt3__117moneypunct_bynameIwLb1EE4initEPKc
+         W _ZNSt3__117moneypunct_bynameIwLb1EEC1EPKcj
+         W _ZNSt3__117moneypunct_bynameIwLb1EEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__117moneypunct_bynameIwLb1EEC2EPKcj
+         W _ZNSt3__117moneypunct_bynameIwLb1EEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         W _ZNSt3__117moneypunct_bynameIwLb1EED0Ev
+         W _ZNSt3__117moneypunct_bynameIwLb1EED1Ev
+         W _ZNSt3__117moneypunct_bynameIwLb1EED2Ev
+         T _ZNSt3__118__time_get_storageIcE4initERKNS_5ctypeIcEE
+         T _ZNSt3__118__time_get_storageIcE9__analyzeEcRKNS_5ctypeIcEE
+         T _ZNSt3__118__time_get_storageIcEC1EPKc
+         T _ZNSt3__118__time_get_storageIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__118__time_get_storageIcEC2EPKc
+         T _ZNSt3__118__time_get_storageIcEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__118__time_get_storageIwE4initERKNS_5ctypeIwEE
+         T _ZNSt3__118__time_get_storageIwE9__analyzeEcRKNS_5ctypeIwEE
+         T _ZNSt3__118__time_get_storageIwEC1EPKc
+         T _ZNSt3__118__time_get_storageIwEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__118__time_get_storageIwEC2EPKc
+         T _ZNSt3__118__time_get_storageIwEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         W _ZNSt3__119__double_or_nothingIcEEvRNS_10unique_ptrIT_PFvPvEEERPS2_S9_
+         W _ZNSt3__119__double_or_nothingIjEEvRNS_10unique_ptrIT_PFvPvEEERPS2_S9_
+         W _ZNSt3__119__double_or_nothingIwEEvRNS_10unique_ptrIT_PFvPvEEERPS2_S9_
+         W _ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz
+         W _ZNSt3__119__libcpp_snprintf_lEPcjP15__locale_structPKcz
+         W _ZNSt3__120__codecvt_utf8_utf16IDiED0Ev
+         W _ZNSt3__120__codecvt_utf8_utf16IDsED0Ev
+         W _ZNSt3__120__codecvt_utf8_utf16IwED0Ev
+         W _ZNSt3__120__get_up_to_n_digitsIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEiRT0_S5_RjRKNS_5ctypeIT_EEi
+         W _ZNSt3__120__get_up_to_n_digitsIcPcEEiRT0_S2_RjRKNS_5ctypeIT_EEi
+         W _ZNSt3__120__get_up_to_n_digitsIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEiRT0_S5_RjRKNS_5ctypeIT_EEi
+         W _ZNSt3__120__get_up_to_n_digitsIwPwEEiRT0_S2_RjRKNS_5ctypeIT_EEi
+         W _ZNSt3__120__vector_base_commonILb1EEC1Ev
+         W _ZNSt3__120__vector_base_commonILb1EEC2Ev
+         T _ZNSt3__121__throw_runtime_errorEPKc
+         W _ZNSt3__125__num_get_signed_integralIlEET_PKcS3_Rji
+         W _ZNSt3__125__num_get_signed_integralIxEET_PKcS3_Rji
+         W _ZNSt3__127__num_get_unsigned_integralIjEET_PKcS3_Rji
+         W _ZNSt3__127__num_get_unsigned_integralImEET_PKcS3_Rji
+         W _ZNSt3__127__num_get_unsigned_integralItEET_PKcS3_Rji
+         W _ZNSt3__127__num_get_unsigned_integralIyEET_PKcS3_Rji
+         T _ZNSt3__15ctypeIcE13classic_tableEv
+         T _ZNSt3__15ctypeIcE21__classic_lower_tableEv
+         T _ZNSt3__15ctypeIcE21__classic_upper_tableEv
+         D _ZNSt3__15ctypeIcE2idE
+         T _ZNSt3__15ctypeIcEC1EPKtbj
+         T _ZNSt3__15ctypeIcEC2EPKtbj
+         T _ZNSt3__15ctypeIcED0Ev
+         T _ZNSt3__15ctypeIcED1Ev
+         T _ZNSt3__15ctypeIcED2Ev
+         D _ZNSt3__15ctypeIwE2idE
+         T _ZNSt3__15ctypeIwED0Ev
+         T _ZNSt3__15ctypeIwED1Ev
+         T _ZNSt3__15ctypeIwED2Ev
+         T _ZNSt3__16__clocEv
+         T _ZNSt3__16locale14__install_ctorERKS0_PNS0_5facetEl
+         T _ZNSt3__16locale2id5__getEv
+         T _ZNSt3__16locale2id6__initEv
+         D _ZNSt3__16locale2id9__next_idE
+         D _ZNSt3__16locale3allE
+         D _ZNSt3__16locale4noneE
+         D _ZNSt3__16locale4timeE
+         T _ZNSt3__16locale5__imp11make_globalEv
+         W _ZNSt3__16locale5__imp12install_fromINS_10moneypunctIcLb0EEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_10moneypunctIcLb1EEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_10moneypunctIwLb0EEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_10moneypunctIwLb1EEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_5ctypeIcEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_5ctypeIwEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7codecvtIDic11__mbstate_tEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7codecvtIDsc11__mbstate_tEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7codecvtIcc11__mbstate_tEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7codecvtIwc11__mbstate_tEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7collateIcEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7collateIwEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_7num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_8messagesIcEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_8messagesIwEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_8numpunctIcEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_8numpunctIwEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_8time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_8time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_8time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_8time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_9money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_9money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_9money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvRKS1_
+         W _ZNSt3__16locale5__imp12install_fromINS_9money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvRKS1_
+         T _ZNSt3__16locale5__imp12make_classicEv
+         T _ZNSt3__16locale5__imp7installEPNS0_5facetEl
+         W _ZNSt3__16locale5__imp7installINS_10moneypunctIcLb0EEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_10moneypunctIcLb1EEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_10moneypunctIwLb0EEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_10moneypunctIwLb1EEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_12ctype_bynameIcEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_12ctype_bynameIwEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_14codecvt_bynameIDic11__mbstate_tEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_14codecvt_bynameIDsc11__mbstate_tEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_14codecvt_bynameIcc11__mbstate_tEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_14codecvt_bynameIwc11__mbstate_tEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_14collate_bynameIcEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_14collate_bynameIwEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_15messages_bynameIcEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_15messages_bynameIwEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_15numpunct_bynameIcEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_15numpunct_bynameIwEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_15time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_15time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_15time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_15time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_17moneypunct_bynameIcLb0EEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_17moneypunct_bynameIcLb1EEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_17moneypunct_bynameIwLb0EEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_17moneypunct_bynameIwLb1EEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_5ctypeIcEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_5ctypeIwEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7codecvtIDic11__mbstate_tEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7codecvtIDsc11__mbstate_tEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7codecvtIcc11__mbstate_tEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7codecvtIwc11__mbstate_tEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7collateIcEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7collateIwEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_7num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_8messagesIcEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_8messagesIwEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_8numpunctIcEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_8numpunctIwEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_8time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_8time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_8time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_8time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_9money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_9money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_9money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEEEEvPT_
+         W _ZNSt3__16locale5__imp7installINS_9money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEEEEvPT_
+         T _ZNSt3__16locale5__impC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__16locale5__impC1ERKS1_
+         T _ZNSt3__16locale5__impC1ERKS1_PNS0_5facetEl
+         T _ZNSt3__16locale5__impC1ERKS1_RKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEi
+         T _ZNSt3__16locale5__impC1ERKS1_S3_i
+         T _ZNSt3__16locale5__impC1Ej
+         T _ZNSt3__16locale5__impC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj
+         T _ZNSt3__16locale5__impC2ERKS1_
+         T _ZNSt3__16locale5__impC2ERKS1_PNS0_5facetEl
+         T _ZNSt3__16locale5__impC2ERKS1_RKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEi
+         T _ZNSt3__16locale5__impC2ERKS1_S3_i
+         T _ZNSt3__16locale5__impC2Ej
+         T _ZNSt3__16locale5__impD0Ev
+         T _ZNSt3__16locale5__impD1Ev
+         T _ZNSt3__16locale5__impD2Ev
+         D _ZNSt3__16locale5ctypeE
+         T _ZNSt3__16locale5facet16__on_zero_sharedEv
+         T _ZNSt3__16locale5facetD0Ev
+         T _ZNSt3__16locale5facetD1Ev
+         T _ZNSt3__16locale5facetD2Ev
+         T _ZNSt3__16locale6globalERKS0_
+         T _ZNSt3__16locale7classicEv
+         D _ZNSt3__16locale7collateE
+         D _ZNSt3__16locale7numericE
+         T _ZNSt3__16locale8__globalEv
+         D _ZNSt3__16locale8messagesE
+         D _ZNSt3__16locale8monetaryE
+         T _ZNSt3__16localeC1EPKc
+         T _ZNSt3__16localeC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__16localeC1ERKS0_
+         T _ZNSt3__16localeC1ERKS0_PKci
+         T _ZNSt3__16localeC1ERKS0_RKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEi
+         T _ZNSt3__16localeC1ERKS0_S2_i
+         T _ZNSt3__16localeC1Ev
+         T _ZNSt3__16localeC2EPKc
+         T _ZNSt3__16localeC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__16localeC2ERKS0_
+         T _ZNSt3__16localeC2ERKS0_PKci
+         T _ZNSt3__16localeC2ERKS0_RKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEi
+         T _ZNSt3__16localeC2ERKS0_S2_i
+         T _ZNSt3__16localeC2Ev
+         T _ZNSt3__16localeD1Ev
+         T _ZNSt3__16localeD2Ev
+         T _ZNSt3__16localeaSERKS0_
+         W _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE10deallocateEv
+         W _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE26__swap_out_circular_bufferERNS_14__split_bufferIS3_RS5_EE
+         W _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE6assignIPS3_EENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr16is_constructibleIS3_NS_15iterator_traitsISA_E9referenceEEE5valueEvE4typeESA_SA_
+         W _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE6resizeEj
+         W _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE8__appendEj
+         W _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEE8allocateEj
+         W _ZNSt3__16vectorIPNS_6locale5facetENS_15__sso_allocatorIS3_Lj28EEEEC2Ej
+         D _ZNSt3__17codecvtIDic11__mbstate_tE2idE
+         T _ZNSt3__17codecvtIDic11__mbstate_tED0Ev
+         T _ZNSt3__17codecvtIDic11__mbstate_tED1Ev
+         T _ZNSt3__17codecvtIDic11__mbstate_tED2Ev
+         D _ZNSt3__17codecvtIDsc11__mbstate_tE2idE
+         T _ZNSt3__17codecvtIDsc11__mbstate_tED0Ev
+         T _ZNSt3__17codecvtIDsc11__mbstate_tED1Ev
+         T _ZNSt3__17codecvtIDsc11__mbstate_tED2Ev
+         D _ZNSt3__17codecvtIcc11__mbstate_tE2idE
+         T _ZNSt3__17codecvtIcc11__mbstate_tED0Ev
+         T _ZNSt3__17codecvtIcc11__mbstate_tED1Ev
+         T _ZNSt3__17codecvtIcc11__mbstate_tED2Ev
+         D _ZNSt3__17codecvtIwc11__mbstate_tE2idE
+         T _ZNSt3__17codecvtIwc11__mbstate_tEC1EPKcj
+         T _ZNSt3__17codecvtIwc11__mbstate_tEC1Ej
+         T _ZNSt3__17codecvtIwc11__mbstate_tEC2EPKcj
+         T _ZNSt3__17codecvtIwc11__mbstate_tEC2Ej
+         T _ZNSt3__17codecvtIwc11__mbstate_tED0Ev
+         T _ZNSt3__17codecvtIwc11__mbstate_tED1Ev
+         T _ZNSt3__17codecvtIwc11__mbstate_tED2Ev
+         W _ZNSt3__17collateIcE2idE
+         W _ZNSt3__17collateIcEC1Ej
+         W _ZNSt3__17collateIcEC2Ej
+         W _ZNSt3__17collateIcED0Ev
+         W _ZNSt3__17collateIcED1Ev
+         W _ZNSt3__17collateIcED2Ev
+         W _ZNSt3__17collateIwE2idE
+         W _ZNSt3__17collateIwEC1Ej
+         W _ZNSt3__17collateIwEC2Ej
+         W _ZNSt3__17collateIwED0Ev
+         W _ZNSt3__17collateIwED1Ev
+         W _ZNSt3__17collateIwED2Ev
+         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
+         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
+         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC2Ej
+         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
+         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
+         W _ZNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
+         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
+         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC1Ej
+         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC2Ej
+         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
+         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
+         W _ZNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
+         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
+         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
+         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2Ej
+         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
+         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
+         W _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
+         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
+         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1Ej
+         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2Ej
+         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
+         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
+         W _ZNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
+         W _ZNSt3__18messagesIcE2idE
+         W _ZNSt3__18messagesIcEC1Ej
+         W _ZNSt3__18messagesIcEC2Ej
+         W _ZNSt3__18messagesIcED0Ev
+         W _ZNSt3__18messagesIcED1Ev
+         W _ZNSt3__18messagesIcED2Ev
+         W _ZNSt3__18messagesIwE2idE
+         W _ZNSt3__18messagesIwEC1Ej
+         W _ZNSt3__18messagesIwEC2Ej
+         W _ZNSt3__18messagesIwED0Ev
+         W _ZNSt3__18messagesIwED1Ev
+         W _ZNSt3__18messagesIwED2Ev
+         D _ZNSt3__18numpunctIcE2idE
+         T _ZNSt3__18numpunctIcEC1Ej
+         T _ZNSt3__18numpunctIcEC2Ej
+         T _ZNSt3__18numpunctIcED0Ev
+         T _ZNSt3__18numpunctIcED1Ev
+         T _ZNSt3__18numpunctIcED2Ev
+         D _ZNSt3__18numpunctIwE2idE
+         T _ZNSt3__18numpunctIwEC1Ej
+         T _ZNSt3__18numpunctIwEC2Ej
+         T _ZNSt3__18numpunctIwED0Ev
+         T _ZNSt3__18numpunctIwED1Ev
+         T _ZNSt3__18numpunctIwED2Ev
+         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
+         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
+         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC2Ej
+         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
+         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
+         W _ZNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
+         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
+         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC1Ej
+         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEC2Ej
+         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
+         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
+         W _ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1EPKcj
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2EPKcj
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2ERKNS_12basic_stringIcS3_NS_9allocatorIcEEEEj
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEC2Ej
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED0Ev
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED1Ev
+         W _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEED2Ev
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1EPKcj
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC1Ej
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2EPKcj
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2ERKNS_12basic_stringIcNS2_IcEENS_9allocatorIcEEEEj
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEC2Ej
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
+         W _ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
+         W _ZNSt3__19__num_getIcE17__stage2_int_loopEciPcRS2_RjcRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjRSD_S2_
+         W _ZNSt3__19__num_getIcE17__stage2_int_prepERNS_8ios_baseEPcRc
+         W _ZNSt3__19__num_getIcE19__stage2_float_loopEcRbRcPcRS4_ccRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjRSE_RjS4_
+         W _ZNSt3__19__num_getIcE19__stage2_float_prepERNS_8ios_baseEPcRcS5_
+         W _ZNSt3__19__num_getIwE17__stage2_int_loopEwiPcRS2_RjwRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjRSD_Pw
+         W _ZNSt3__19__num_getIwE17__stage2_int_prepERNS_8ios_baseEPwRw
+         W _ZNSt3__19__num_getIwE19__stage2_float_loopEwRbRcPcRS4_wwRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPjRSE_RjPw
+         W _ZNSt3__19__num_getIwE19__stage2_float_prepERNS_8ios_baseEPwRwS5_
+         W _ZNSt3__19__num_putIcE21__widen_and_group_intEPcS2_S2_S2_RS2_S3_RKNS_6localeE
+         W _ZNSt3__19__num_putIcE23__widen_and_group_floatEPcS2_S2_S2_RS2_S3_RKNS_6localeE
+         W _ZNSt3__19__num_putIwE21__widen_and_group_intEPcS2_S2_PwRS3_S4_RKNS_6localeE
+         W _ZNSt3__19__num_putIwE23__widen_and_group_floatEPcS2_S2_PwRS3_S4_RKNS_6localeE
          W _ZNSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE
          W _ZNSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8__do_getERS4_S4_bRKNS_6localeEjRjRbRKNS_5ctypeIcEERNS_10unique_ptrIcPFvPvEEERPcSM_
          W _ZNSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEC1Ej
@@ -2385,418 +2110,1300 @@
          W _ZNSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED0Ev
          W _ZNSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED1Ev
          W _ZNSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEED2Ev
-         T _ZNSt3__19strstreamD0Ev
-         T _ZNSt3__19strstreamD1Ev
-         T _ZNSt3__19strstreamD2Ev
+         W _ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EEPKS6_RKS9_
+         U _ZNSt8bad_castC1Ev
+         U _ZNSt8bad_castD1Ev
+         U _ZNSt9bad_allocC1Ev
+         U _ZNSt9bad_allocD1Ev
+         U _ZSt17__throw_bad_allocv
+         U _ZSt9terminatev
+         W _ZTINSt3__110__time_getE
+         W _ZTINSt3__110__time_putE
+         W _ZTINSt3__110ctype_baseE
+         W _ZTINSt3__110money_baseE
+         W _ZTINSt3__110moneypunctIcLb0EEE
+         W _ZTINSt3__110moneypunctIcLb1EEE
+         W _ZTINSt3__110moneypunctIwLb0EEE
+         W _ZTINSt3__110moneypunctIwLb1EEE
+         W _ZTINSt3__111__money_getIcEE
+         W _ZTINSt3__111__money_getIwEE
+         W _ZTINSt3__111__money_putIcEE
+         W _ZTINSt3__111__money_putIwEE
+         W _ZTINSt3__112codecvt_baseE
+         D _ZTINSt3__112ctype_bynameIcEE
+         D _ZTINSt3__112ctype_bynameIwEE
+         W _ZTINSt3__113messages_baseE
+         D _ZTINSt3__114__codecvt_utf8IDiEE
+         D _ZTINSt3__114__codecvt_utf8IDsEE
+         D _ZTINSt3__114__codecvt_utf8IwEE
+         W _ZTINSt3__114__num_get_baseE
+         W _ZTINSt3__114__num_put_baseE
+         U _ZTINSt3__114__shared_countE
+         W _ZTINSt3__114codecvt_bynameIDic11__mbstate_tEE
+         W _ZTINSt3__114codecvt_bynameIDsc11__mbstate_tEE
+         W _ZTINSt3__114codecvt_bynameIcc11__mbstate_tEE
+         W _ZTINSt3__114codecvt_bynameIwc11__mbstate_tEE
+         D _ZTINSt3__114collate_bynameIcEE
+         D _ZTINSt3__114collate_bynameIwEE
+         D _ZTINSt3__115__codecvt_utf16IDiLb0EEE
+         D _ZTINSt3__115__codecvt_utf16IDiLb1EEE
+         D _ZTINSt3__115__codecvt_utf16IDsLb0EEE
+         D _ZTINSt3__115__codecvt_utf16IDsLb1EEE
+         D _ZTINSt3__115__codecvt_utf16IwLb0EEE
+         D _ZTINSt3__115__codecvt_utf16IwLb1EEE
+         W _ZTINSt3__115__time_get_tempIcEE
+         W _ZTINSt3__115__time_get_tempIwEE
+         W _ZTINSt3__115messages_bynameIcEE
+         W _ZTINSt3__115messages_bynameIwEE
+         D _ZTINSt3__115numpunct_bynameIcEE
+         D _ZTINSt3__115numpunct_bynameIwEE
+         W _ZTINSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTINSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTINSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTINSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         D _ZTINSt3__116__narrow_to_utf8ILj16EEE
+         D _ZTINSt3__116__narrow_to_utf8ILj32EEE
+         D _ZTINSt3__117__widen_from_utf8ILj16EEE
+         D _ZTINSt3__117__widen_from_utf8ILj32EEE
+         W _ZTINSt3__117moneypunct_bynameIcLb0EEE
+         W _ZTINSt3__117moneypunct_bynameIcLb1EEE
+         W _ZTINSt3__117moneypunct_bynameIwLb0EEE
+         W _ZTINSt3__117moneypunct_bynameIwLb1EEE
+         W _ZTINSt3__118__time_get_storageIcEE
+         W _ZTINSt3__118__time_get_storageIwEE
+         D _ZTINSt3__120__codecvt_utf8_utf16IDiEE
+         D _ZTINSt3__120__codecvt_utf8_utf16IDsEE
+         D _ZTINSt3__120__codecvt_utf8_utf16IwEE
+         W _ZTINSt3__120__time_get_c_storageIcEE
+         W _ZTINSt3__120__time_get_c_storageIwEE
+         D _ZTINSt3__15ctypeIcEE
+         D _ZTINSt3__15ctypeIwEE
+         D _ZTINSt3__16locale5__impE
+         D _ZTINSt3__16locale5facetE
+         D _ZTINSt3__17codecvtIDic11__mbstate_tEE
+         D _ZTINSt3__17codecvtIDsc11__mbstate_tEE
+         D _ZTINSt3__17codecvtIcc11__mbstate_tEE
+         D _ZTINSt3__17codecvtIwc11__mbstate_tEE
+         W _ZTINSt3__17collateIcEE
+         W _ZTINSt3__17collateIwEE
+         W _ZTINSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTINSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTINSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTINSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTINSt3__18messagesIcEE
+         W _ZTINSt3__18messagesIwEE
+         D _ZTINSt3__18numpunctIcEE
+         D _ZTINSt3__18numpunctIwEE
+         W _ZTINSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTINSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTINSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTINSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTINSt3__19__num_getIcEE
+         W _ZTINSt3__19__num_getIwEE
+         W _ZTINSt3__19__num_putIcEE
+         W _ZTINSt3__19__num_putIwEE
+         W _ZTINSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTINSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTINSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTINSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTINSt3__19time_baseE
+         U _ZTISt12length_error
+         U _ZTISt12out_of_range
+         U _ZTISt13runtime_error
+         U _ZTISt8bad_cast
+         U _ZTISt9bad_alloc
+         W _ZTSNSt3__110__time_getE
+         W _ZTSNSt3__110__time_putE
+         W _ZTSNSt3__110ctype_baseE
+         W _ZTSNSt3__110money_baseE
+         W _ZTSNSt3__110moneypunctIcLb0EEE
+         W _ZTSNSt3__110moneypunctIcLb1EEE
+         W _ZTSNSt3__110moneypunctIwLb0EEE
+         W _ZTSNSt3__110moneypunctIwLb1EEE
+         W _ZTSNSt3__111__money_getIcEE
+         W _ZTSNSt3__111__money_getIwEE
+         W _ZTSNSt3__111__money_putIcEE
+         W _ZTSNSt3__111__money_putIwEE
+         W _ZTSNSt3__112codecvt_baseE
+         D _ZTSNSt3__112ctype_bynameIcEE
+         D _ZTSNSt3__112ctype_bynameIwEE
+         W _ZTSNSt3__113messages_baseE
+         D _ZTSNSt3__114__codecvt_utf8IDiEE
+         D _ZTSNSt3__114__codecvt_utf8IDsEE
+         D _ZTSNSt3__114__codecvt_utf8IwEE
+         W _ZTSNSt3__114__num_get_baseE
+         W _ZTSNSt3__114__num_put_baseE
+         W _ZTSNSt3__114codecvt_bynameIDic11__mbstate_tEE
+         W _ZTSNSt3__114codecvt_bynameIDsc11__mbstate_tEE
+         W _ZTSNSt3__114codecvt_bynameIcc11__mbstate_tEE
+         W _ZTSNSt3__114codecvt_bynameIwc11__mbstate_tEE
+         D _ZTSNSt3__114collate_bynameIcEE
+         D _ZTSNSt3__114collate_bynameIwEE
+         D _ZTSNSt3__115__codecvt_utf16IDiLb0EEE
+         D _ZTSNSt3__115__codecvt_utf16IDiLb1EEE
+         D _ZTSNSt3__115__codecvt_utf16IDsLb0EEE
+         D _ZTSNSt3__115__codecvt_utf16IDsLb1EEE
+         D _ZTSNSt3__115__codecvt_utf16IwLb0EEE
+         D _ZTSNSt3__115__codecvt_utf16IwLb1EEE
+         W _ZTSNSt3__115__time_get_tempIcEE
+         W _ZTSNSt3__115__time_get_tempIwEE
+         W _ZTSNSt3__115messages_bynameIcEE
+         W _ZTSNSt3__115messages_bynameIwEE
+         D _ZTSNSt3__115numpunct_bynameIcEE
+         D _ZTSNSt3__115numpunct_bynameIwEE
+         W _ZTSNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTSNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTSNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTSNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         D _ZTSNSt3__116__narrow_to_utf8ILj16EEE
+         D _ZTSNSt3__116__narrow_to_utf8ILj32EEE
+         D _ZTSNSt3__117__widen_from_utf8ILj16EEE
+         D _ZTSNSt3__117__widen_from_utf8ILj32EEE
+         W _ZTSNSt3__117moneypunct_bynameIcLb0EEE
+         W _ZTSNSt3__117moneypunct_bynameIcLb1EEE
+         W _ZTSNSt3__117moneypunct_bynameIwLb0EEE
+         W _ZTSNSt3__117moneypunct_bynameIwLb1EEE
+         W _ZTSNSt3__118__time_get_storageIcEE
+         W _ZTSNSt3__118__time_get_storageIwEE
+         D _ZTSNSt3__120__codecvt_utf8_utf16IDiEE
+         D _ZTSNSt3__120__codecvt_utf8_utf16IDsEE
+         D _ZTSNSt3__120__codecvt_utf8_utf16IwEE
+         W _ZTSNSt3__120__time_get_c_storageIcEE
+         W _ZTSNSt3__120__time_get_c_storageIwEE
+         D _ZTSNSt3__15ctypeIcEE
+         D _ZTSNSt3__15ctypeIwEE
+         D _ZTSNSt3__16locale5__impE
+         D _ZTSNSt3__16locale5facetE
+         D _ZTSNSt3__17codecvtIDic11__mbstate_tEE
+         D _ZTSNSt3__17codecvtIDsc11__mbstate_tEE
+         D _ZTSNSt3__17codecvtIcc11__mbstate_tEE
+         D _ZTSNSt3__17codecvtIwc11__mbstate_tEE
+         W _ZTSNSt3__17collateIcEE
+         W _ZTSNSt3__17collateIwEE
+         W _ZTSNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTSNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTSNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTSNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTSNSt3__18messagesIcEE
+         W _ZTSNSt3__18messagesIwEE
+         D _ZTSNSt3__18numpunctIcEE
+         D _ZTSNSt3__18numpunctIwEE
+         W _ZTSNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTSNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTSNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTSNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTSNSt3__19__num_getIcEE
+         W _ZTSNSt3__19__num_getIwEE
+         W _ZTSNSt3__19__num_putIcEE
+         W _ZTSNSt3__19__num_putIwEE
+         W _ZTSNSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTSNSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTSNSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTSNSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTSNSt3__19time_baseE
+         U _ZTVN10__cxxabiv117__class_type_infoE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         U _ZTVN10__cxxabiv121__vmi_class_type_infoE
+         W _ZTVNSt3__110moneypunctIcLb0EEE
+         W _ZTVNSt3__110moneypunctIcLb1EEE
+         W _ZTVNSt3__110moneypunctIwLb0EEE
+         W _ZTVNSt3__110moneypunctIwLb1EEE
+         D _ZTVNSt3__112ctype_bynameIcEE
+         D _ZTVNSt3__112ctype_bynameIwEE
+         D _ZTVNSt3__114__codecvt_utf8IDiEE
+         D _ZTVNSt3__114__codecvt_utf8IDsEE
+         D _ZTVNSt3__114__codecvt_utf8IwEE
+         W _ZTVNSt3__114codecvt_bynameIDic11__mbstate_tEE
+         W _ZTVNSt3__114codecvt_bynameIDsc11__mbstate_tEE
+         W _ZTVNSt3__114codecvt_bynameIcc11__mbstate_tEE
+         W _ZTVNSt3__114codecvt_bynameIwc11__mbstate_tEE
+         D _ZTVNSt3__114collate_bynameIcEE
+         D _ZTVNSt3__114collate_bynameIwEE
+         D _ZTVNSt3__115__codecvt_utf16IDiLb0EEE
+         D _ZTVNSt3__115__codecvt_utf16IDiLb1EEE
+         D _ZTVNSt3__115__codecvt_utf16IDsLb0EEE
+         D _ZTVNSt3__115__codecvt_utf16IDsLb1EEE
+         D _ZTVNSt3__115__codecvt_utf16IwLb0EEE
+         D _ZTVNSt3__115__codecvt_utf16IwLb1EEE
+         W _ZTVNSt3__115__time_get_tempIcEE
+         W _ZTVNSt3__115__time_get_tempIwEE
+         W _ZTVNSt3__115messages_bynameIcEE
+         W _ZTVNSt3__115messages_bynameIwEE
+         D _ZTVNSt3__115numpunct_bynameIcEE
+         D _ZTVNSt3__115numpunct_bynameIwEE
+         W _ZTVNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTVNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTVNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTVNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         D _ZTVNSt3__116__narrow_to_utf8ILj16EEE
+         D _ZTVNSt3__116__narrow_to_utf8ILj32EEE
+         D _ZTVNSt3__117__widen_from_utf8ILj16EEE
+         D _ZTVNSt3__117__widen_from_utf8ILj32EEE
+         W _ZTVNSt3__117moneypunct_bynameIcLb0EEE
+         W _ZTVNSt3__117moneypunct_bynameIcLb1EEE
+         W _ZTVNSt3__117moneypunct_bynameIwLb0EEE
+         W _ZTVNSt3__117moneypunct_bynameIwLb1EEE
+         D _ZTVNSt3__120__codecvt_utf8_utf16IDiEE
+         D _ZTVNSt3__120__codecvt_utf8_utf16IDsEE
+         D _ZTVNSt3__120__codecvt_utf8_utf16IwEE
+         D _ZTVNSt3__15ctypeIcEE
+         D _ZTVNSt3__15ctypeIwEE
+         D _ZTVNSt3__16locale5__impE
+         D _ZTVNSt3__16locale5facetE
+         D _ZTVNSt3__17codecvtIDic11__mbstate_tEE
+         D _ZTVNSt3__17codecvtIDsc11__mbstate_tEE
+         D _ZTVNSt3__17codecvtIcc11__mbstate_tEE
+         D _ZTVNSt3__17codecvtIwc11__mbstate_tEE
+         W _ZTVNSt3__17collateIcEE
+         W _ZTVNSt3__17collateIwEE
+         W _ZTVNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTVNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTVNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTVNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTVNSt3__18messagesIcEE
+         W _ZTVNSt3__18messagesIwEE
+         D _ZTVNSt3__18numpunctIcEE
+         D _ZTVNSt3__18numpunctIwEE
+         W _ZTVNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTVNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTVNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTVNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTVNSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTVNSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         W _ZTVNSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
+         W _ZTVNSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         U _ZTVSt12length_error
+         U _ZTVSt12out_of_range
+         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__XEv
+         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__cEv
+         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__rEv
+         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__xEv
+         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE7__am_pmEv
+         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE7__weeksEv
+         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8__monthsEv
+         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__XEv
+         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__cEv
+         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__rEv
+         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__xEv
+         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE7__am_pmEv
+         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE7__weeksEv
+         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8__monthsEv
+         U _ZdaPv
+         U _ZdlPv
+         U _Znwj
+         W __clang_call_terminate
+         U __ctype_b_loc
+         U __ctype_tolower_loc
+         U __ctype_toupper_loc
+         U __cxa_allocate_exception
+         U __cxa_atexit
+         U __cxa_begin_catch
+         U __cxa_end_catch
+         U __cxa_free_exception
+         U __cxa_guard_abort
+         U __cxa_guard_acquire
+         U __cxa_guard_release
+         U __cxa_rethrow
+         U __cxa_throw
+         U __dso_handle
+         U __errno_location
+         U __gxx_personality_v0
+         U btowc
+         U catclose
+         U catgets
+         U catopen
+         U free
+         U freelocale
+         U isdigit_l
+         U iswalpha_l
+         U iswblank_l
+         U iswcntrl_l
+         U iswdigit_l
+         U iswlower_l
+         U iswprint_l
+         U iswpunct_l
+         U iswspace_l
+         U iswupper_l
+         U iswxdigit_l
+         U isxdigit_l
+         U localeconv
+         U malloc
+         U mbrlen
+         U mbrtowc
+         U mbsnrtowcs
+         U mbsrtowcs
+         U mbtowc
+         U memcmp
+         U newlocale
+         U realloc
+         U setlocale
+         U snprintf
+         U sscanf
+         U strcmp
+         U strcoll_l
+         U strftime_l
+         U strlen
+         U strtold_l
+         U strtoll_l
+         U strtoull_l
+         U strxfrm_l
+         U tolower_l
+         U toupper_l
+         U towlower_l
+         U towupper_l
+         U uselocale
+         U vasprintf
+         U vsnprintf
+         U vsscanf
+         U wcrtomb
+         U wcscoll_l
+         U wcslen
+         U wcsnrtombs
+         U wcsxfrm_l
+         U wctob
+         T _ZNKSt3__112bad_weak_ptr4whatEv
+         T _ZNKSt3__119__shared_weak_count13__get_deleterERKSt9type_info
+         T _ZNSt3__112__get_sp_mutEPKv
+         T _ZNSt3__112bad_weak_ptrD0Ev
+         T _ZNSt3__112bad_weak_ptrD1Ev
+         T _ZNSt3__112bad_weak_ptrD2Ev
+         D _ZNSt3__113allocator_argE
+         T _ZNSt3__114__shared_count12__add_sharedEv
+         T _ZNSt3__114__shared_count16__release_sharedEv
+         T _ZNSt3__114__shared_countD0Ev
+         T _ZNSt3__114__shared_countD1Ev
+         T _ZNSt3__114__shared_countD2Ev
+         T _ZNSt3__117declare_reachableEPv
+         T _ZNSt3__118get_pointer_safetyEv
+         T _ZNSt3__119__shared_weak_count10__add_weakEv
+         T _ZNSt3__119__shared_weak_count12__add_sharedEv
+         T _ZNSt3__119__shared_weak_count14__release_weakEv
+         T _ZNSt3__119__shared_weak_count16__release_sharedEv
+         T _ZNSt3__119__shared_weak_count4lockEv
+         T _ZNSt3__119__shared_weak_countD0Ev
+         T _ZNSt3__119__shared_weak_countD1Ev
+         T _ZNSt3__119__shared_weak_countD2Ev
+         T _ZNSt3__119declare_no_pointersEPcj
+         W _ZNSt3__121__murmur2_or_cityhashIjLj32EEclEPKvj
+         T _ZNSt3__121__undeclare_reachableEPv
+         T _ZNSt3__121undeclare_no_pointersEPcj
+         T _ZNSt3__15alignEjjRPvRj
+         U _ZNSt3__15mutex4lockEv
+         U _ZNSt3__15mutex6unlockEv
+         U _ZNSt3__15mutex8try_lockEv
+         T _ZNSt3__18__sp_mut4lockEv
+         T _ZNSt3__18__sp_mut6unlockEv
+         U _ZNSt9exceptionD2Ev
+         U _ZSt9terminatev
+         D _ZTINSt3__112bad_weak_ptrE
+         D _ZTINSt3__114__shared_countE
+         D _ZTINSt3__119__shared_weak_countE
+         U _ZTISt9exception
+         D _ZTSNSt3__112bad_weak_ptrE
+         D _ZTSNSt3__114__shared_countE
+         D _ZTSNSt3__119__shared_weak_countE
+         U _ZTVN10__cxxabiv117__class_type_infoE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         U _ZTVN10__cxxabiv121__vmi_class_type_infoE
+         D _ZTVNSt3__112bad_weak_ptrE
+         D _ZTVNSt3__114__shared_countE
+         D _ZTVNSt3__119__shared_weak_countE
+         U _ZdlPv
+         W __clang_call_terminate
+         U __cxa_begin_catch
+         U __cxa_guard_acquire
+         U __cxa_guard_release
+         U __cxa_pure_virtual
+         U __gxx_personality_v0
+         U sched_yield
+         D _ZNSt3__110adopt_lockE
+         D _ZNSt3__110defer_lockE
+         T _ZNSt3__111__call_onceERVmPvPFvS2_E
+         T _ZNSt3__111timed_mutex4lockEv
+         T _ZNSt3__111timed_mutex6unlockEv
+         T _ZNSt3__111timed_mutex8try_lockEv
+         T _ZNSt3__111timed_mutexC1Ev
+         T _ZNSt3__111timed_mutexC2Ev
+         T _ZNSt3__111timed_mutexD1Ev
+         T _ZNSt3__111timed_mutexD2Ev
+         D _ZNSt3__111try_to_lockE
+         W _ZNSt3__111unique_lockINS_5mutexEE6unlockEv
+         T _ZNSt3__115recursive_mutex4lockEv
+         T _ZNSt3__115recursive_mutex6unlockEv
+         T _ZNSt3__115recursive_mutex8try_lockEv
+         T _ZNSt3__115recursive_mutexC1Ev
+         T _ZNSt3__115recursive_mutexC2Ev
+         T _ZNSt3__115recursive_mutexD1Ev
+         T _ZNSt3__115recursive_mutexD2Ev
+         U _ZNSt3__118condition_variable10notify_oneEv
+         U _ZNSt3__118condition_variable4waitERNS_11unique_lockINS_5mutexEEE
+         U _ZNSt3__118condition_variableD1Ev
+         U _ZNSt3__120__throw_system_errorEiPKc
+         T _ZNSt3__121recursive_timed_mutex4lockEv
+         T _ZNSt3__121recursive_timed_mutex6unlockEv
+         T _ZNSt3__121recursive_timed_mutex8try_lockEv
+         T _ZNSt3__121recursive_timed_mutexC1Ev
+         T _ZNSt3__121recursive_timed_mutexC2Ev
+         T _ZNSt3__121recursive_timed_mutexD1Ev
+         T _ZNSt3__121recursive_timed_mutexD2Ev
+         T _ZNSt3__15mutex4lockEv
+         T _ZNSt3__15mutex6unlockEv
+         T _ZNSt3__15mutex8try_lockEv
+         T _ZNSt3__15mutexD1Ev
+         T _ZNSt3__15mutexD2Ev
+         U _ZSt9terminatev
+         U __assert_fail
+         W __clang_call_terminate
+         U __cxa_begin_catch
+         U __cxa_end_catch
+         U __cxa_rethrow
+         U __gxx_personality_v0
+         U pthread_cond_broadcast
+         U pthread_cond_wait
+         U pthread_mutex_destroy
+         U pthread_mutex_init
+         U pthread_mutex_lock
+         U pthread_mutex_trylock
+         U pthread_mutex_unlock
+         U pthread_mutexattr_destroy
+         U pthread_mutexattr_init
+         U pthread_mutexattr_settype
+         U pthread_self
+         U _ZNSt9bad_allocC1Ev
+         U _ZNSt9bad_allocD1Ev
+         U _ZSt15get_new_handlerv
+         T _ZSt17__throw_bad_allocv
+         D _ZSt7nothrow
+         U _ZSt9terminatev
+         U _ZTISt9bad_alloc
+         W _ZdaPv
+         W _ZdaPvRKSt9nothrow_t
+         W _ZdaPvj
+         W _ZdlPv
+         W _ZdlPvRKSt9nothrow_t
+         W _ZdlPvj
+         W _Znaj
+         W _ZnajRKSt9nothrow_t
+         W _Znwj
+         W _ZnwjRKSt9nothrow_t
+         W __clang_call_terminate
+         U __cxa_allocate_exception
+         U __cxa_begin_catch
+         U __cxa_end_catch
+         U __cxa_throw
+         U __gxx_personality_v0
+         U free
+         U malloc
+         U _ZNKSt11logic_error4whatEv
+         U _ZNSt11logic_errorD2Ev
+         T _ZNSt12experimental19bad_optional_accessD0Ev
+         T _ZNSt12experimental19bad_optional_accessD1Ev
+         T _ZNSt12experimental19bad_optional_accessD2Ev
+         D _ZTINSt12experimental19bad_optional_accessE
+         U _ZTISt11logic_error
+         D _ZTSNSt12experimental19bad_optional_accessE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         D _ZTVNSt12experimental19bad_optional_accessE
+         U _ZdlPv
+         T _ZNKSt3__113random_device7entropyEv
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcjj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
+         T _ZNSt3__113random_deviceC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__113random_deviceC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__113random_deviceD1Ev
+         T _ZNSt3__113random_deviceD2Ev
+         T _ZNSt3__113random_deviceclEv
+         U _ZNSt3__120__throw_system_errorEiPKc
+         W _ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EEPKS6_RKS9_
+         U _ZSt9terminatev
+         W __clang_call_terminate
+         U __cxa_begin_catch
+         U __errno_location
+         U __gxx_personality_v0
+         U close
+         U open
+         U read
+         U strlen
+         U _ZNKSt13runtime_error4whatEv
+         T _ZNKSt3__123__match_any_but_newlineIcE6__execERNS_7__stateIcEE
+         T _ZNKSt3__123__match_any_but_newlineIwE6__execERNS_7__stateIwEE
+         U _ZNSt13runtime_errorC2EPKc
+         U _ZNSt13runtime_errorD2Ev
+         T _ZNSt3__111regex_errorC1ENS_15regex_constants10error_typeE
+         T _ZNSt3__111regex_errorC2ENS_15regex_constants10error_typeE
+         T _ZNSt3__111regex_errorD0Ev
+         T _ZNSt3__111regex_errorD1Ev
+         T _ZNSt3__111regex_errorD2Ev
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSEc
+         T _ZNSt3__115__get_classnameEPKcb
+         T _ZNSt3__120__get_collation_nameEPKc
+         D _ZTINSt3__111regex_errorE
+         U _ZTISt13runtime_error
+         D _ZTSNSt3__111regex_errorE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         D _ZTVNSt3__111regex_errorE
+         U _ZdlPv
+         U __gxx_personality_v0
+         U strcmp
+         U _ZNSt3__118condition_variable10notify_allEv
+         U _ZNSt3__118condition_variable10notify_oneEv
+         U _ZNSt3__118condition_variable4waitERNS_11unique_lockINS_5mutexEEE
+         T _ZNSt3__118shared_timed_mutex11lock_sharedEv
+         T _ZNSt3__118shared_timed_mutex13unlock_sharedEv
+         T _ZNSt3__118shared_timed_mutex15try_lock_sharedEv
+         T _ZNSt3__118shared_timed_mutex4lockEv
+         T _ZNSt3__118shared_timed_mutex6unlockEv
+         T _ZNSt3__118shared_timed_mutex8try_lockEv
+         T _ZNSt3__118shared_timed_mutexC1Ev
+         T _ZNSt3__118shared_timed_mutexC2Ev
+         T _ZNSt3__119__shared_mutex_base11lock_sharedEv
+         T _ZNSt3__119__shared_mutex_base13unlock_sharedEv
+         T _ZNSt3__119__shared_mutex_base15try_lock_sharedEv
+         T _ZNSt3__119__shared_mutex_base4lockEv
+         T _ZNSt3__119__shared_mutex_base6unlockEv
+         T _ZNSt3__119__shared_mutex_base8try_lockEv
+         T _ZNSt3__119__shared_mutex_baseC1Ev
+         T _ZNSt3__119__shared_mutex_baseC2Ev
+         U _ZNSt3__15mutex4lockEv
+         U _ZNSt3__15mutex6unlockEv
+         U __gxx_personality_v0
+         T _ZNSt11logic_errorC1EPKc
+         T _ZNSt11logic_errorC1ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
+         T _ZNSt11logic_errorC1ERKS_
+         T _ZNSt11logic_errorC2EPKc
+         T _ZNSt11logic_errorC2ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
+         T _ZNSt11logic_errorC2ERKS_
+         T _ZNSt11logic_erroraSERKS_
+         T _ZNSt13runtime_errorC1EPKc
+         T _ZNSt13runtime_errorC1ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
+         T _ZNSt13runtime_errorC1ERKS_
+         T _ZNSt13runtime_errorC2EPKc
+         T _ZNSt13runtime_errorC2ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
+         T _ZNSt13runtime_errorC2ERKS_
+         T _ZNSt13runtime_erroraSERKS_
+         W _ZNSt3__118__libcpp_refstringC2EPKc
+         W _ZNSt3__118__libcpp_refstringaSERKS0_
+         U _ZNSt9exceptionD2Ev
+         U _ZTVSt11logic_error
+         U _ZTVSt13runtime_error
+         U _ZdlPv
+         U _Znwj
+         U __gxx_personality_v0
+         U strlen
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12__invariantsEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofEPKcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofEPKcjj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofERKS5_j
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofEcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__get_pointerEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13find_first_ofEPKcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13find_first_ofEPKcjj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13find_first_ofERKS5_j
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13find_first_ofEcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13get_allocatorEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE14__get_long_capEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE15__get_long_sizeEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__get_short_sizeEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofEPKcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofEPKcjj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofERKS5_j
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofEcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofEPKcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofEPKcjj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofERKS5_j
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofEcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE18__get_long_pointerEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__get_short_pointerEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE2atEj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE3endEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4backEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4cendEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcjj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findEPKcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findEPKcjj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findERKS5_j
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findEcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4rendEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4sizeEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5beginEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5c_strEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5crendEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5emptyEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5frontEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5rfindEPKcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5rfindEPKcjj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5rfindERKS5_j
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5rfindEcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6cbeginEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6lengthEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6rbeginEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6substrEjj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7__allocEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEPKc
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareERKS5_
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjPKc
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjPKcj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjRKS5_
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEjjRKS5_jj
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7crbeginEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE8capacityEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE8max_sizeEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__is_longEv
+         W _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEixEj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12__invariantsEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12find_last_ofEPKwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12find_last_ofEPKwjj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12find_last_ofERKS5_j
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE12find_last_ofEwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13__get_pointerEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13find_first_ofEPKwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13find_first_ofEPKwjj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13find_first_ofERKS5_j
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13find_first_ofEwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13get_allocatorEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE14__get_long_capEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE15__get_long_sizeEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16__get_short_sizeEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16find_last_not_ofEPKwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16find_last_not_ofEPKwjj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16find_last_not_ofERKS5_j
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16find_last_not_ofEwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE17find_first_not_ofEPKwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE17find_first_not_ofEPKwjj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE17find_first_not_ofERKS5_j
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE17find_first_not_ofEwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE18__get_long_pointerEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__get_short_pointerEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE2atEj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE3endEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4backEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4cendEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4copyEPwjj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4dataEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4findEPKwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4findEPKwjj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4findERKS5_j
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4findEwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4rendEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4sizeEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5beginEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5c_strEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5crendEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5emptyEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5frontEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5rfindEPKwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5rfindEPKwjj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5rfindERKS5_j
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5rfindEwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6cbeginEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6lengthEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6rbeginEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6substrEjj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7__allocEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEPKw
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareERKS5_
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEjjPKw
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEjjPKwj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEjjRKS5_
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEjjRKS5_jj
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7crbeginEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE8capacityEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE8max_sizeEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9__is_longEv
+         W _ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEixEj
+         W _ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv
+         W _ZNKSt3__121__basic_string_commonILb1EE20__throw_out_of_rangeEv
+         U _ZNSt11logic_errorC2EPKc
+         U _ZNSt11logic_errorC2ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
+         U _ZNSt12length_errorD1Ev
+         U _ZNSt12out_of_rangeD1Ev
+         U _ZNSt16invalid_argumentD1Ev
+         T _ZNSt3__110to_wstringEd
+         T _ZNSt3__110to_wstringEe
+         T _ZNSt3__110to_wstringEf
+         T _ZNSt3__110to_wstringEi
+         T _ZNSt3__110to_wstringEj
+         T _ZNSt3__110to_wstringEl
+         T _ZNSt3__110to_wstringEm
+         T _ZNSt3__110to_wstringEx
+         T _ZNSt3__110to_wstringEy
+         W _ZNSt3__111char_traitsIcE4findEPKcjRS2_
+         W _ZNSt3__111char_traitsIcE7compareEPKcS3_j
+         W _ZNSt3__111char_traitsIwE4copyEPwPKwj
+         W _ZNSt3__111char_traitsIwE4findEPKwjRS2_
+         W _ZNSt3__111char_traitsIwE4moveEPwPKwj
+         W _ZNSt3__111char_traitsIwE6assignEPwjw
+         W _ZNSt3__111char_traitsIwE7compareEPKwS3_j
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE10__set_sizeEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE11__recommendEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__get_pointerEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__move_assignERS5_NS_17integral_constantIbLb0EEE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__move_assignERS5_NS_17integral_constantIbLb1EEE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13shrink_to_fitEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE14__erase_to_endEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE14__set_long_capEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE15__set_long_sizeEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__set_short_sizeEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE18__get_long_pointerEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE18__set_long_pointerEPc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__copy_assign_allocERKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__copy_assign_allocERKS5_NS_17integral_constantIbLb0EEE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__copy_assign_allocERKS5_NS_17integral_constantIbLb1EEE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__get_short_pointerEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__move_assign_allocERS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__move_assign_allocERS5_NS_17integral_constantIbLb0EEE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__move_assign_allocERS5_NS_17integral_constantIbLb1EEE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE21__grow_by_and_replaceEjjjjjjPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE26__invalidate_all_iteratorsEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE27__invalidate_iterators_pastEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE2atEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE3endEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4backEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4nposE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4rendEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4swapERS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5beginEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5clearEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5eraseENS_11__wrap_iterIPKcEE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5eraseENS_11__wrap_iterIPKcEES9_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5eraseEjj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5frontEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcjj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEjc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__zeroEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendERKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendERKS5_jj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendESt16initializer_listIcE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEjc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEOS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKcj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignERKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignERKS5_jj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignESt16initializer_listIcE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEjc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertENS_11__wrap_iterIPKcEESt16initializer_listIcE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertENS_11__wrap_iterIPKcEEc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertENS_11__wrap_iterIPKcEEjc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjPKcj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjRKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjRKS5_jj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEjjc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertIPKcEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorISA_EE5valueENS_11__wrap_iterIPcEEE4typeENSB_IS8_EESA_SA_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6rbeginEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6resizeEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6resizeEjc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7__allocEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_RKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_S8_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_S8_j
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_St16initializer_listIcE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceENS_11__wrap_iterIPKcEES9_jc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjPKcj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjRKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjRKS5_jj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEjjjc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceIPKcEENS_9enable_ifIXsr19__is_input_iteratorIT_EE5valueERS5_E4typeENS_11__wrap_iterIS8_EESF_SA_SA_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE8pop_backEv
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEjjjjjj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EOS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EOS5_RKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EPKcRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EPKcj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EPKcjRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_RKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_jRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_jjRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ESt16initializer_listIcE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ESt16initializer_listIcERKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1Ejc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1EjcRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1Ev
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EOS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EOS5_RKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EPKcRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EPKcj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EPKcjRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_RKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_jRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_jjRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ESt16initializer_listIcE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ESt16initializer_listIcERKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2Ejc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2EjcRKS4_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2Ev
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSEOS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSEPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSERKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSESt16initializer_listIcE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSEc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEixEj
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLEPKc
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLERKS5_
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLESt16initializer_listIcE
+         W _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLEc
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE10__set_sizeEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE11__recommendEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13__get_pointerEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13__move_assignERS5_NS_17integral_constantIbLb0EEE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13__move_assignERS5_NS_17integral_constantIbLb1EEE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE13shrink_to_fitEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE14__erase_to_endEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE14__set_long_capEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE15__set_long_sizeEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE16__set_short_sizeEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE18__get_long_pointerEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE18__set_long_pointerEPw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__copy_assign_allocERKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__copy_assign_allocERKS5_NS_17integral_constantIbLb0EEE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__copy_assign_allocERKS5_NS_17integral_constantIbLb1EEE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__get_short_pointerEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__move_assign_allocERS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__move_assign_allocERS5_NS_17integral_constantIbLb0EEE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE19__move_assign_allocERS5_NS_17integral_constantIbLb1EEE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE21__grow_by_and_replaceEjjjjjjPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE26__invalidate_all_iteratorsEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE27__invalidate_iterators_pastEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE2atEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE3endEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4backEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4nposE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4rendEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE4swapERS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5beginEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5clearEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5eraseENS_11__wrap_iterIPKwEE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5eraseENS_11__wrap_iterIPKwEES9_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5eraseEjj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE5frontEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwjj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEjw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initIPKwEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeESA_SA_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__zeroEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendEPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendEPKwj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendERKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendERKS5_jj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendESt16initializer_listIwE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendEjw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEOS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEPKwj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignERKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignERKS5_jj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignESt16initializer_listIwE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEjw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertENS_11__wrap_iterIPKwEESt16initializer_listIwE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertENS_11__wrap_iterIPKwEEjw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertENS_11__wrap_iterIPKwEEw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjPKwj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjRKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjRKS5_jj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEjjw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertIPKwEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorISA_EE5valueENS_11__wrap_iterIPwEEE4typeENSB_IS8_EESA_SA_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6rbeginEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEjw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7__allocEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_RKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_S8_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_S8_j
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_St16initializer_listIwE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceENS_11__wrap_iterIPKwEES9_jw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjPKwj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjRKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjRKS5_jj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEjjjw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceIPKwEENS_9enable_ifIXsr19__is_input_iteratorIT_EE5valueERS5_E4typeENS_11__wrap_iterIS8_EESF_SA_SA_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7reserveEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE8pop_backEv
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9__grow_byEjjjjjj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EOS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EOS5_RKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EPKwRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EPKwj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EPKwjRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS5_RKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS5_jRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ERKS5_jjRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ESt16initializer_listIwE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1ESt16initializer_listIwERKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1Ejw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1EjwRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC1Ev
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EOS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EOS5_RKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EPKwRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EPKwj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EPKwjRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS5_RKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS5_jRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ERKS5_jjRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ESt16initializer_listIwE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2ESt16initializer_listIwERKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2Ejw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2EjwRKS4_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2Ev
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED1Ev
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSEOS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSEPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSERKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSESt16initializer_listIwE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEaSEw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEixEj
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEpLEPKw
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEpLERKS5_
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEpLESt16initializer_listIwE
+         W _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEpLEw
+         T _ZNSt3__14stodERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPj
+         T _ZNSt3__14stodERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPj
+         T _ZNSt3__14stofERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPj
+         T _ZNSt3__14stofERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPj
+         T _ZNSt3__14stoiERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
+         T _ZNSt3__14stoiERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
+         T _ZNSt3__14stolERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
+         T _ZNSt3__14stolERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
+         T _ZNSt3__15stoldERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPj
+         T _ZNSt3__15stoldERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPj
+         T _ZNSt3__15stollERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
+         T _ZNSt3__15stollERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
+         T _ZNSt3__15stoulERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
+         T _ZNSt3__15stoulERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
+         T _ZNSt3__16stoullERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPji
+         T _ZNSt3__16stoullERKNS_12basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEEPji
          T _ZNSt3__19to_stringEd
-         T _ZNSt3__19to_stringEe
-         T _ZNSt3__19to_stringEf
-         T _ZNSt3__19to_stringEi
-         T _ZNSt3__19to_stringEj
-         T _ZNSt3__19to_stringEl
-         T _ZNSt3__19to_stringEm
-         T _ZNSt3__19to_stringEx
-         T _ZNSt3__19to_stringEy
-         W _ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EEPKS6_RKS9_
-         C _ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EERKS9_PKS6_
-         T _ZSt17current_exceptionv
-         T _ZSt17rethrow_exceptionSt13exception_ptr
-         C _ZSt18make_exception_ptrINSt3__112future_errorEESt13exception_ptrT_
-         D _ZTCNSt3__110istrstreamE0_NS_13basic_istreamIcNS_11char_traitsIcEEEE
-         D _ZTCNSt3__110ostrstreamE0_NS_13basic_ostreamIcNS_11char_traitsIcEEEE
-         W _ZTCNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE0_NS_13basic_istreamIcS2_EE
-         W _ZTCNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE8_NS_13basic_ostreamIcS2_EE
-         D _ZTCNSt3__19strstreamE0_NS_13basic_istreamIcNS_11char_traitsIcEEEE
-         D _ZTCNSt3__19strstreamE0_NS_14basic_iostreamIcNS_11char_traitsIcEEEE
-         D _ZTCNSt3__19strstreamE8_NS_13basic_ostreamIcNS_11char_traitsIcEEEE
-         C _ZTINSt3__110__stdinbufIcEE
-         C _ZTINSt3__110__stdinbufIwEE
-         C _ZTINSt3__110__time_getE
-         C _ZTINSt3__110__time_putE
-         C _ZTINSt3__110ctype_baseE
-         D _ZTINSt3__110istrstreamE
-         C _ZTINSt3__110money_baseE
-         W _ZTINSt3__110moneypunctIcLb0EEE
-         W _ZTINSt3__110moneypunctIcLb1EEE
-         W _ZTINSt3__110moneypunctIwLb0EEE
-         W _ZTINSt3__110moneypunctIwLb1EEE
-         D _ZTINSt3__110ostrstreamE
-         C _ZTINSt3__111__money_getIcEE
-         C _ZTINSt3__111__money_getIwEE
-         C _ZTINSt3__111__money_putIcEE
-         C _ZTINSt3__111__money_putIwEE
-         C _ZTINSt3__111__stdoutbufIcEE
-         C _ZTINSt3__111__stdoutbufIwEE
-         D _ZTINSt3__111regex_errorE
-         D _ZTINSt3__112__do_messageE
-         D _ZTINSt3__112bad_weak_ptrE
-         C _ZTINSt3__112codecvt_baseE
-         D _ZTINSt3__112ctype_bynameIcEE
-         D _ZTINSt3__112ctype_bynameIwEE
-         D _ZTINSt3__112future_errorE
-         D _ZTINSt3__112strstreambufE
-         D _ZTINSt3__112system_errorE
-         W _ZTINSt3__113basic_istreamIcNS_11char_traitsIcEEEE
-         W _ZTINSt3__113basic_istreamIwNS_11char_traitsIwEEEE
-         W _ZTINSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
-         W _ZTINSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
-         C _ZTINSt3__113messages_baseE
-         D _ZTINSt3__114__codecvt_utf8IDiEE
-         D _ZTINSt3__114__codecvt_utf8IDsEE
-         D _ZTINSt3__114__codecvt_utf8IwEE
-         C _ZTINSt3__114__num_get_baseE
-         C _ZTINSt3__114__num_put_baseE
-         D _ZTINSt3__114__shared_countE
-         W _ZTINSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
-         W _ZTINSt3__114codecvt_bynameIDic11__mbstate_tEE
-         W _ZTINSt3__114codecvt_bynameIDsc11__mbstate_tEE
-         W _ZTINSt3__114codecvt_bynameIcc11__mbstate_tEE
-         W _ZTINSt3__114codecvt_bynameIwc11__mbstate_tEE
-         D _ZTINSt3__114collate_bynameIcEE
-         D _ZTINSt3__114collate_bynameIwEE
-         D _ZTINSt3__114error_categoryE
-         D _ZTINSt3__115__codecvt_utf16IDiLb0EEE
-         D _ZTINSt3__115__codecvt_utf16IDiLb1EEE
-         D _ZTINSt3__115__codecvt_utf16IDsLb0EEE
-         D _ZTINSt3__115__codecvt_utf16IDsLb1EEE
-         D _ZTINSt3__115__codecvt_utf16IwLb0EEE
-         D _ZTINSt3__115__codecvt_utf16IwLb1EEE
-         C _ZTINSt3__115__time_get_tempIcEE
-         C _ZTINSt3__115__time_get_tempIwEE
-         W _ZTINSt3__115basic_streambufIcNS_11char_traitsIcEEEE
-         W _ZTINSt3__115basic_streambufIwNS_11char_traitsIwEEEE
-         W _ZTINSt3__115messages_bynameIcEE
-         W _ZTINSt3__115messages_bynameIwEE
-         D _ZTINSt3__115numpunct_bynameIcEE
-         D _ZTINSt3__115numpunct_bynameIwEE
-         W _ZTINSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTINSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTINSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTINSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         D _ZTINSt3__116__narrow_to_utf8ILj16EEE
-         D _ZTINSt3__116__narrow_to_utf8ILj32EEE
-         D _ZTINSt3__117__assoc_sub_stateE
-         D _ZTINSt3__117__widen_from_utf8ILj16EEE
-         D _ZTINSt3__117__widen_from_utf8ILj32EEE
-         W _ZTINSt3__117moneypunct_bynameIcLb0EEE
-         W _ZTINSt3__117moneypunct_bynameIcLb1EEE
-         W _ZTINSt3__117moneypunct_bynameIwLb0EEE
-         W _ZTINSt3__117moneypunct_bynameIwLb1EEE
-         C _ZTINSt3__118__time_get_storageIcEE
-         C _ZTINSt3__118__time_get_storageIwEE
-         D _ZTINSt3__119__iostream_categoryE
-         D _ZTINSt3__119__shared_weak_countE
-         D _ZTINSt3__120__codecvt_utf8_utf16IDiEE
-         D _ZTINSt3__120__codecvt_utf8_utf16IDsEE
-         D _ZTINSt3__120__codecvt_utf8_utf16IwEE
-         C _ZTINSt3__120__time_get_c_storageIcEE
-         C _ZTINSt3__120__time_get_c_storageIwEE
-         D _ZTINSt3__123__future_error_categoryE
-         D _ZTINSt3__123__system_error_categoryE
-         D _ZTINSt3__124__generic_error_categoryE
-         D _ZTINSt3__15ctypeIcEE
-         D _ZTINSt3__15ctypeIwEE
-         D _ZTINSt3__16locale5__impE
-         D _ZTINSt3__16locale5facetE
-         D _ZTINSt3__17codecvtIDic11__mbstate_tEE
-         D _ZTINSt3__17codecvtIDsc11__mbstate_tEE
-         D _ZTINSt3__17codecvtIcc11__mbstate_tEE
-         D _ZTINSt3__17codecvtIwc11__mbstate_tEE
-         W _ZTINSt3__17collateIcEE
-         W _ZTINSt3__17collateIwEE
-         W _ZTINSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTINSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTINSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTINSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         D _ZTINSt3__18__c_nodeE
-         D _ZTINSt3__18ios_base7failureE
-         D _ZTINSt3__18ios_baseE
-         W _ZTINSt3__18messagesIcEE
-         W _ZTINSt3__18messagesIwEE
-         D _ZTINSt3__18numpunctIcEE
-         D _ZTINSt3__18numpunctIwEE
-         W _ZTINSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTINSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTINSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTINSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         C _ZTINSt3__19__num_getIcEE
-         C _ZTINSt3__19__num_getIwEE
-         C _ZTINSt3__19__num_putIcEE
-         C _ZTINSt3__19__num_putIwEE
-         W _ZTINSt3__19basic_iosIcNS_11char_traitsIcEEEE
-         W _ZTINSt3__19basic_iosIwNS_11char_traitsIwEEEE
-         W _ZTINSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTINSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTINSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTINSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         D _ZTINSt3__19strstreamE
-         C _ZTINSt3__19time_baseE
-         D _ZTISt16nested_exception
-         C _ZTSNSt3__110__stdinbufIcEE
-         C _ZTSNSt3__110__stdinbufIwEE
-         C _ZTSNSt3__110__time_getE
-         C _ZTSNSt3__110__time_putE
-         C _ZTSNSt3__110ctype_baseE
-         D _ZTSNSt3__110istrstreamE
-         C _ZTSNSt3__110money_baseE
-         W _ZTSNSt3__110moneypunctIcLb0EEE
-         W _ZTSNSt3__110moneypunctIcLb1EEE
-         W _ZTSNSt3__110moneypunctIwLb0EEE
-         W _ZTSNSt3__110moneypunctIwLb1EEE
-         D _ZTSNSt3__110ostrstreamE
-         C _ZTSNSt3__111__money_getIcEE
-         C _ZTSNSt3__111__money_getIwEE
-         C _ZTSNSt3__111__money_putIcEE
-         C _ZTSNSt3__111__money_putIwEE
-         C _ZTSNSt3__111__stdoutbufIcEE
-         C _ZTSNSt3__111__stdoutbufIwEE
-         D _ZTSNSt3__111regex_errorE
-         D _ZTSNSt3__112__do_messageE
-         D _ZTSNSt3__112bad_weak_ptrE
-         C _ZTSNSt3__112codecvt_baseE
-         D _ZTSNSt3__112ctype_bynameIcEE
-         D _ZTSNSt3__112ctype_bynameIwEE
-         D _ZTSNSt3__112future_errorE
-         D _ZTSNSt3__112strstreambufE
-         D _ZTSNSt3__112system_errorE
-         W _ZTSNSt3__113basic_istreamIcNS_11char_traitsIcEEEE
-         W _ZTSNSt3__113basic_istreamIwNS_11char_traitsIwEEEE
-         W _ZTSNSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
-         W _ZTSNSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
-         C _ZTSNSt3__113messages_baseE
-         D _ZTSNSt3__114__codecvt_utf8IDiEE
-         D _ZTSNSt3__114__codecvt_utf8IDsEE
-         D _ZTSNSt3__114__codecvt_utf8IwEE
-         C _ZTSNSt3__114__num_get_baseE
-         C _ZTSNSt3__114__num_put_baseE
-         D _ZTSNSt3__114__shared_countE
-         W _ZTSNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
-         W _ZTSNSt3__114codecvt_bynameIDic11__mbstate_tEE
-         W _ZTSNSt3__114codecvt_bynameIDsc11__mbstate_tEE
-         W _ZTSNSt3__114codecvt_bynameIcc11__mbstate_tEE
-         W _ZTSNSt3__114codecvt_bynameIwc11__mbstate_tEE
-         D _ZTSNSt3__114collate_bynameIcEE
-         D _ZTSNSt3__114collate_bynameIwEE
-         D _ZTSNSt3__114error_categoryE
-         D _ZTSNSt3__115__codecvt_utf16IDiLb0EEE
-         D _ZTSNSt3__115__codecvt_utf16IDiLb1EEE
-         D _ZTSNSt3__115__codecvt_utf16IDsLb0EEE
-         D _ZTSNSt3__115__codecvt_utf16IDsLb1EEE
-         D _ZTSNSt3__115__codecvt_utf16IwLb0EEE
-         D _ZTSNSt3__115__codecvt_utf16IwLb1EEE
-         C _ZTSNSt3__115__time_get_tempIcEE
-         C _ZTSNSt3__115__time_get_tempIwEE
-         W _ZTSNSt3__115basic_streambufIcNS_11char_traitsIcEEEE
-         W _ZTSNSt3__115basic_streambufIwNS_11char_traitsIwEEEE
-         W _ZTSNSt3__115messages_bynameIcEE
-         W _ZTSNSt3__115messages_bynameIwEE
-         D _ZTSNSt3__115numpunct_bynameIcEE
-         D _ZTSNSt3__115numpunct_bynameIwEE
-         W _ZTSNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTSNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTSNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTSNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         D _ZTSNSt3__116__narrow_to_utf8ILj16EEE
-         D _ZTSNSt3__116__narrow_to_utf8ILj32EEE
-         D _ZTSNSt3__117__assoc_sub_stateE
-         D _ZTSNSt3__117__widen_from_utf8ILj16EEE
-         D _ZTSNSt3__117__widen_from_utf8ILj32EEE
-         W _ZTSNSt3__117moneypunct_bynameIcLb0EEE
-         W _ZTSNSt3__117moneypunct_bynameIcLb1EEE
-         W _ZTSNSt3__117moneypunct_bynameIwLb0EEE
-         W _ZTSNSt3__117moneypunct_bynameIwLb1EEE
-         C _ZTSNSt3__118__time_get_storageIcEE
-         C _ZTSNSt3__118__time_get_storageIwEE
-         D _ZTSNSt3__119__iostream_categoryE
-         D _ZTSNSt3__119__shared_weak_countE
-         D _ZTSNSt3__120__codecvt_utf8_utf16IDiEE
-         D _ZTSNSt3__120__codecvt_utf8_utf16IDsEE
-         D _ZTSNSt3__120__codecvt_utf8_utf16IwEE
-         C _ZTSNSt3__120__time_get_c_storageIcEE
-         C _ZTSNSt3__120__time_get_c_storageIwEE
-         D _ZTSNSt3__123__future_error_categoryE
-         D _ZTSNSt3__123__system_error_categoryE
-         D _ZTSNSt3__124__generic_error_categoryE
-         D _ZTSNSt3__15ctypeIcEE
-         D _ZTSNSt3__15ctypeIwEE
-         D _ZTSNSt3__16locale5__impE
-         D _ZTSNSt3__16locale5facetE
-         D _ZTSNSt3__17codecvtIDic11__mbstate_tEE
-         D _ZTSNSt3__17codecvtIDsc11__mbstate_tEE
-         D _ZTSNSt3__17codecvtIcc11__mbstate_tEE
-         D _ZTSNSt3__17codecvtIwc11__mbstate_tEE
-         W _ZTSNSt3__17collateIcEE
-         W _ZTSNSt3__17collateIwEE
-         W _ZTSNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTSNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTSNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTSNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         D _ZTSNSt3__18__c_nodeE
-         D _ZTSNSt3__18ios_base7failureE
-         D _ZTSNSt3__18ios_baseE
-         W _ZTSNSt3__18messagesIcEE
-         W _ZTSNSt3__18messagesIwEE
-         D _ZTSNSt3__18numpunctIcEE
-         D _ZTSNSt3__18numpunctIwEE
-         W _ZTSNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTSNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTSNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTSNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         C _ZTSNSt3__19__num_getIcEE
-         C _ZTSNSt3__19__num_getIwEE
-         C _ZTSNSt3__19__num_putIcEE
-         C _ZTSNSt3__19__num_putIwEE
-         W _ZTSNSt3__19basic_iosIcNS_11char_traitsIcEEEE
-         W _ZTSNSt3__19basic_iosIwNS_11char_traitsIwEEEE
-         W _ZTSNSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTSNSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTSNSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTSNSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
+         T _ZNSt3__19to_stringEe
+         T _ZNSt3__19to_stringEf
+         T _ZNSt3__19to_stringEi
+         T _ZNSt3__19to_stringEj
+         T _ZNSt3__19to_stringEl
+         T _ZNSt3__19to_stringEm
+         T _ZNSt3__19to_stringEx
+         T _ZNSt3__19to_stringEy
+         W _ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EEPKS6_RKS9_
+         W _ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EERKS9_PKS6_
+         U _ZNSt9bad_allocC1Ev
+         U _ZNSt9bad_allocD1Ev
+         U _ZSt9terminatev
+         U _ZTISt12length_error
+         U _ZTISt12out_of_range
+         U _ZTISt16invalid_argument
+         U _ZTISt9bad_alloc
+         U _ZTVSt12length_error
+         U _ZTVSt12out_of_range
+         U _ZTVSt16invalid_argument
+         U _ZdlPv
+         U _Znwj
+         W __clang_call_terminate
+         U __cxa_allocate_exception
+         U __cxa_begin_catch
+         U __cxa_end_catch
+         U __cxa_free_exception
+         U __cxa_throw
+         U __errno_location
+         U __gxx_personality_v0
+         U memchr
+         U memcmp
+         U snprintf
+         U strlen
+         U strtod
+         U strtof
+         U strtol
+         U strtold
+         U strtoll
+         U strtoul
+         U strtoull
+         U swprintf
+         U wcslen
+         U wcstod
+         U wcstof
+         U wcstol
+         U wcstold
+         U wcstoll
+         U wcstoul
+         U wcstoull
+         U wmemchr
+         U wmemcmp
+         U wmemcpy
+         U wmemmove
+         U wmemset
+         T _ZNKSt3__112strstreambuf6pcountEv
+         T _ZNSt3__110istrstreamD0Ev
+         T _ZNSt3__110istrstreamD1Ev
+         T _ZNSt3__110istrstreamD2Ev
+         T _ZNSt3__110ostrstreamD0Ev
+         T _ZNSt3__110ostrstreamD1Ev
+         T _ZNSt3__110ostrstreamD2Ev
+         T _ZNSt3__112strstreambuf3strEv
+         T _ZNSt3__112strstreambuf4swapERS0_
+         T _ZNSt3__112strstreambuf6__initEPciS1_
+         T _ZNSt3__112strstreambuf6freezeEb
+         T _ZNSt3__112strstreambuf7seekoffExNS_8ios_base7seekdirEj
+         T _ZNSt3__112strstreambuf7seekposENS_4fposI11__mbstate_tEEj
+         T _ZNSt3__112strstreambuf8overflowEi
+         T _ZNSt3__112strstreambuf9pbackfailEi
+         T _ZNSt3__112strstreambuf9underflowEv
+         T _ZNSt3__112strstreambufC1EPFPvjEPFvS1_E
+         T _ZNSt3__112strstreambufC1EPKai
+         T _ZNSt3__112strstreambufC1EPKci
+         T _ZNSt3__112strstreambufC1EPKhi
+         T _ZNSt3__112strstreambufC1EPaiS1_
+         T _ZNSt3__112strstreambufC1EPciS1_
+         T _ZNSt3__112strstreambufC1EPhiS1_
+         T _ZNSt3__112strstreambufC1Ei
+         T _ZNSt3__112strstreambufC2EPFPvjEPFvS1_E
+         T _ZNSt3__112strstreambufC2EPKai
+         T _ZNSt3__112strstreambufC2EPKci
+         T _ZNSt3__112strstreambufC2EPKhi
+         T _ZNSt3__112strstreambufC2EPaiS1_
+         T _ZNSt3__112strstreambufC2EPciS1_
+         T _ZNSt3__112strstreambufC2EPhiS1_
+         T _ZNSt3__112strstreambufC2Ei
+         T _ZNSt3__112strstreambufD0Ev
+         T _ZNSt3__112strstreambufD1Ev
+         T _ZNSt3__112strstreambufD2Ev
+         U _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEED0Ev
+         U _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEED1Ev
+         U _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEED2Ev
+         U _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEED0Ev
+         U _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEED1Ev
+         U _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEED2Ev
+         U _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev
+         U _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev
+         U _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEED2Ev
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4swapERS3_
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4syncEv
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5imbueERKNS_6localeE
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5uflowEv
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6setbufEPci
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6xsgetnEPci
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6xsputnEPKci
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9showmanycEv
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEEC2Ev
+         U _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEED2Ev
+         U _ZNSt3__19basic_iosIcNS_11char_traitsIcEEED2Ev
+         T _ZNSt3__19strstreamD0Ev
+         T _ZNSt3__19strstreamD1Ev
+         T _ZNSt3__19strstreamD2Ev
+         U _ZSt9terminatev
+         D _ZTCNSt3__110istrstreamE0_NS_13basic_istreamIcNS_11char_traitsIcEEEE
+         D _ZTCNSt3__110ostrstreamE0_NS_13basic_ostreamIcNS_11char_traitsIcEEEE
+         D _ZTCNSt3__19strstreamE0_NS_13basic_istreamIcNS_11char_traitsIcEEEE
+         D _ZTCNSt3__19strstreamE0_NS_14basic_iostreamIcNS_11char_traitsIcEEEE
+         D _ZTCNSt3__19strstreamE8_NS_13basic_ostreamIcNS_11char_traitsIcEEEE
+         D _ZTINSt3__110istrstreamE
+         D _ZTINSt3__110ostrstreamE
+         D _ZTINSt3__112strstreambufE
+         U _ZTINSt3__113basic_istreamIcNS_11char_traitsIcEEEE
+         U _ZTINSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
+         U _ZTINSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
+         U _ZTINSt3__115basic_streambufIcNS_11char_traitsIcEEEE
+         D _ZTINSt3__19strstreamE
+         D _ZTSNSt3__110istrstreamE
+         D _ZTSNSt3__110ostrstreamE
+         D _ZTSNSt3__112strstreambufE
          D _ZTSNSt3__19strstreamE
-         C _ZTSNSt3__19time_baseE
-         D _ZTSSt16nested_exception
          D _ZTTNSt3__110istrstreamE
          D _ZTTNSt3__110ostrstreamE
-         W _ZTTNSt3__113basic_istreamIcNS_11char_traitsIcEEEE
-         W _ZTTNSt3__113basic_istreamIwNS_11char_traitsIwEEEE
-         W _ZTTNSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
-         W _ZTTNSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
-         W _ZTTNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
          D _ZTTNSt3__19strstreamE
-         C _ZTVNSt3__110__stdinbufIcEE
-         C _ZTVNSt3__110__stdinbufIwEE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
          D _ZTVNSt3__110istrstreamE
-         W _ZTVNSt3__110moneypunctIcLb0EEE
-         W _ZTVNSt3__110moneypunctIcLb1EEE
-         W _ZTVNSt3__110moneypunctIwLb0EEE
-         W _ZTVNSt3__110moneypunctIwLb1EEE
          D _ZTVNSt3__110ostrstreamE
-         C _ZTVNSt3__111__stdoutbufIcEE
-         C _ZTVNSt3__111__stdoutbufIwEE
-         D _ZTVNSt3__111regex_errorE
-         D _ZTVNSt3__112__do_messageE
-         D _ZTVNSt3__112bad_weak_ptrE
-         D _ZTVNSt3__112ctype_bynameIcEE
-         D _ZTVNSt3__112ctype_bynameIwEE
-         D _ZTVNSt3__112future_errorE
          D _ZTVNSt3__112strstreambufE
-         D _ZTVNSt3__112system_errorE
-         W _ZTVNSt3__113basic_istreamIcNS_11char_traitsIcEEEE
-         W _ZTVNSt3__113basic_istreamIwNS_11char_traitsIwEEEE
-         W _ZTVNSt3__113basic_ostreamIcNS_11char_traitsIcEEEE
-         W _ZTVNSt3__113basic_ostreamIwNS_11char_traitsIwEEEE
-         D _ZTVNSt3__114__codecvt_utf8IDiEE
-         D _ZTVNSt3__114__codecvt_utf8IDsEE
-         D _ZTVNSt3__114__codecvt_utf8IwEE
-         D _ZTVNSt3__114__shared_countE
-         W _ZTVNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE
-         W _ZTVNSt3__114codecvt_bynameIDic11__mbstate_tEE
-         W _ZTVNSt3__114codecvt_bynameIDsc11__mbstate_tEE
-         W _ZTVNSt3__114codecvt_bynameIcc11__mbstate_tEE
-         W _ZTVNSt3__114codecvt_bynameIwc11__mbstate_tEE
-         D _ZTVNSt3__114collate_bynameIcEE
-         D _ZTVNSt3__114collate_bynameIwEE
-         D _ZTVNSt3__114error_categoryE
-         D _ZTVNSt3__115__codecvt_utf16IDiLb0EEE
-         D _ZTVNSt3__115__codecvt_utf16IDiLb1EEE
-         D _ZTVNSt3__115__codecvt_utf16IDsLb0EEE
-         D _ZTVNSt3__115__codecvt_utf16IDsLb1EEE
-         D _ZTVNSt3__115__codecvt_utf16IwLb0EEE
-         D _ZTVNSt3__115__codecvt_utf16IwLb1EEE
-         C _ZTVNSt3__115__time_get_tempIcEE
-         C _ZTVNSt3__115__time_get_tempIwEE
-         W _ZTVNSt3__115basic_streambufIcNS_11char_traitsIcEEEE
-         W _ZTVNSt3__115basic_streambufIwNS_11char_traitsIwEEEE
-         W _ZTVNSt3__115messages_bynameIcEE
-         W _ZTVNSt3__115messages_bynameIwEE
-         D _ZTVNSt3__115numpunct_bynameIcEE
-         D _ZTVNSt3__115numpunct_bynameIwEE
-         W _ZTVNSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTVNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTVNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTVNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         D _ZTVNSt3__116__narrow_to_utf8ILj16EEE
-         D _ZTVNSt3__116__narrow_to_utf8ILj32EEE
-         D _ZTVNSt3__117__assoc_sub_stateE
-         D _ZTVNSt3__117__widen_from_utf8ILj16EEE
-         D _ZTVNSt3__117__widen_from_utf8ILj32EEE
-         W _ZTVNSt3__117moneypunct_bynameIcLb0EEE
-         W _ZTVNSt3__117moneypunct_bynameIcLb1EEE
-         W _ZTVNSt3__117moneypunct_bynameIwLb0EEE
-         W _ZTVNSt3__117moneypunct_bynameIwLb1EEE
-         D _ZTVNSt3__119__iostream_categoryE
-         D _ZTVNSt3__119__shared_weak_countE
-         D _ZTVNSt3__120__codecvt_utf8_utf16IDiEE
-         D _ZTVNSt3__120__codecvt_utf8_utf16IDsEE
-         D _ZTVNSt3__120__codecvt_utf8_utf16IwEE
-         D _ZTVNSt3__123__future_error_categoryE
-         D _ZTVNSt3__123__system_error_categoryE
-         D _ZTVNSt3__124__generic_error_categoryE
-         D _ZTVNSt3__15ctypeIcEE
-         D _ZTVNSt3__15ctypeIwEE
-         D _ZTVNSt3__16locale5__impE
-         D _ZTVNSt3__16locale5facetE
-         D _ZTVNSt3__17codecvtIDic11__mbstate_tEE
-         D _ZTVNSt3__17codecvtIDsc11__mbstate_tEE
-         D _ZTVNSt3__17codecvtIcc11__mbstate_tEE
-         D _ZTVNSt3__17codecvtIwc11__mbstate_tEE
-         W _ZTVNSt3__17collateIcEE
-         W _ZTVNSt3__17collateIwEE
-         W _ZTVNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTVNSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTVNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTVNSt3__17num_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         D _ZTVNSt3__18__c_nodeE
-         D _ZTVNSt3__18ios_base7failureE
-         D _ZTVNSt3__18ios_baseE
-         W _ZTVNSt3__18messagesIcEE
-         W _ZTVNSt3__18messagesIwEE
-         D _ZTVNSt3__18numpunctIcEE
-         D _ZTVNSt3__18numpunctIwEE
-         W _ZTVNSt3__18time_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTVNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTVNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTVNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTVNSt3__19basic_iosIcNS_11char_traitsIcEEEE
-         W _ZTVNSt3__19basic_iosIwNS_11char_traitsIwEEEE
-         W _ZTVNSt3__19money_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTVNSt3__19money_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE
-         W _ZTVNSt3__19money_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE
-         W _ZTVNSt3__19money_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE
          D _ZTVNSt3__19strstreamE
-         D _ZTVSt16nested_exception
-         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__XEv
-         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__cEv
-         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__rEv
-         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3__xEv
-         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE7__am_pmEv
-         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE7__weeksEv
-         W _ZThn8_NKSt3__115time_get_bynameIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE8__monthsEv
-         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__XEv
-         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__cEv
-         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__rEv
-         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3__xEv
-         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE7__am_pmEv
-         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE7__weeksEv
-         W _ZThn8_NKSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE8__monthsEv
-         W _ZThn8_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev
-         W _ZThn8_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev
+         U _ZThn8_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev
+         U _ZThn8_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev
          T _ZThn8_NSt3__19strstreamD0Ev
          T _ZThn8_NSt3__19strstreamD1Ev
          T _ZTv0_n12_NSt3__110istrstreamD0Ev
          T _ZTv0_n12_NSt3__110istrstreamD1Ev
          T _ZTv0_n12_NSt3__110ostrstreamD0Ev
          T _ZTv0_n12_NSt3__110ostrstreamD1Ev
-         W _ZTv0_n12_NSt3__113basic_istreamIcNS_11char_traitsIcEEED0Ev
-         W _ZTv0_n12_NSt3__113basic_istreamIcNS_11char_traitsIcEEED1Ev
-         W _ZTv0_n12_NSt3__113basic_istreamIwNS_11char_traitsIwEEED0Ev
-         W _ZTv0_n12_NSt3__113basic_istreamIwNS_11char_traitsIwEEED1Ev
-         W _ZTv0_n12_NSt3__113basic_ostreamIcNS_11char_traitsIcEEED0Ev
-         W _ZTv0_n12_NSt3__113basic_ostreamIcNS_11char_traitsIcEEED1Ev
-         W _ZTv0_n12_NSt3__113basic_ostreamIwNS_11char_traitsIwEEED0Ev
-         W _ZTv0_n12_NSt3__113basic_ostreamIwNS_11char_traitsIwEEED1Ev
-         W _ZTv0_n12_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev
-         W _ZTv0_n12_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev
+         U _ZTv0_n12_NSt3__113basic_istreamIcNS_11char_traitsIcEEED0Ev
+         U _ZTv0_n12_NSt3__113basic_istreamIcNS_11char_traitsIcEEED1Ev
+         U _ZTv0_n12_NSt3__113basic_ostreamIcNS_11char_traitsIcEEED0Ev
+         U _ZTv0_n12_NSt3__113basic_ostreamIcNS_11char_traitsIcEEED1Ev
+         U _ZTv0_n12_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev
+         U _ZTv0_n12_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev
          T _ZTv0_n12_NSt3__19strstreamD0Ev
          T _ZTv0_n12_NSt3__19strstreamD1Ev
-         C __clang_call_terminate
+         U _ZdaPv
+         U _ZdlPv
+         U _Znaj
+         W __clang_call_terminate
+         U __cxa_begin_catch
+         U __gxx_personality_v0
+         U strlen
+         U _ZNKSt13runtime_error4whatEv
+         T _ZNKSt3__110error_code7messageEv
+         T _ZNKSt3__112__do_message7messageEi
+         T _ZNKSt3__114error_category10equivalentERKNS_10error_codeEi
+         T _ZNKSt3__114error_category10equivalentEiRKNS_15error_conditionE
+         T _ZNKSt3__114error_category23default_error_conditionEi
+         T _ZNKSt3__115error_condition7messageEv
+         T _ZNKSt3__123__system_error_category23default_error_conditionEi
+         T _ZNKSt3__123__system_error_category4nameEv
+         T _ZNKSt3__123__system_error_category7messageEi
+         T _ZNKSt3__124__generic_error_category4nameEv
+         T _ZNKSt3__124__generic_error_category7messageEi
+         U _ZNSt13runtime_errorC2ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
+         U _ZNSt13runtime_errorD2Ev
+         W _ZNSt3__112__do_messageD0Ev
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKc
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcj
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_
+         U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
+         T _ZNSt3__112system_error6__initERKNS_10error_codeENS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__112system_errorC1ENS_10error_codeE
+         T _ZNSt3__112system_errorC1ENS_10error_codeEPKc
+         T _ZNSt3__112system_errorC1ENS_10error_codeERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__112system_errorC1EiRKNS_14error_categoryE
+         T _ZNSt3__112system_errorC1EiRKNS_14error_categoryEPKc
+         T _ZNSt3__112system_errorC1EiRKNS_14error_categoryERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__112system_errorC2ENS_10error_codeE
+         T _ZNSt3__112system_errorC2ENS_10error_codeEPKc
+         T _ZNSt3__112system_errorC2ENS_10error_codeERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__112system_errorC2EiRKNS_14error_categoryE
+         T _ZNSt3__112system_errorC2EiRKNS_14error_categoryEPKc
+         T _ZNSt3__112system_errorC2EiRKNS_14error_categoryERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
+         T _ZNSt3__112system_errorD0Ev
+         T _ZNSt3__112system_errorD1Ev
+         T _ZNSt3__112system_errorD2Ev
+         T _ZNSt3__114error_categoryC2Ev
+         T _ZNSt3__114error_categoryD0Ev
+         T _ZNSt3__114error_categoryD1Ev
+         T _ZNSt3__114error_categoryD2Ev
+         T _ZNSt3__115system_categoryEv
+         T _ZNSt3__116generic_categoryEv
+         T _ZNSt3__120__throw_system_errorEiPKc
+         W _ZNSt3__123__system_error_categoryD0Ev
+         W _ZNSt3__124__generic_error_categoryD0Ev
+         D _ZTINSt3__112__do_messageE
+         D _ZTINSt3__112system_errorE
+         D _ZTINSt3__114error_categoryE
+         D _ZTINSt3__123__system_error_categoryE
+         D _ZTINSt3__124__generic_error_categoryE
+         U _ZTISt13runtime_error
+         D _ZTSNSt3__112__do_messageE
+         D _ZTSNSt3__112system_errorE
+         D _ZTSNSt3__114error_categoryE
+         D _ZTSNSt3__123__system_error_categoryE
+         D _ZTSNSt3__124__generic_error_categoryE
+         U _ZTVN10__cxxabiv117__class_type_infoE
+         U _ZTVN10__cxxabiv120__si_class_type_infoE
+         D _ZTVNSt3__112__do_messageE
+         D _ZTVNSt3__112system_errorE
+         D _ZTVNSt3__114error_categoryE
+         D _ZTVNSt3__123__system_error_categoryE
+         D _ZTVNSt3__124__generic_error_categoryE
+         U _ZdlPv
+         U __cxa_allocate_exception
+         U __cxa_free_exception
+         U __cxa_guard_acquire
+         U __cxa_guard_release
+         U __cxa_pure_virtual
+         U __cxa_throw
+         U __gxx_personality_v0
+         U strerror
+         U strlen
+         U _ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv
+         T _ZNSt3__111this_thread9sleep_forERKNS_6chrono8durationIxNS_5ratioILx1ELx1000000000EEEEE
+         U _ZNSt3__112system_errorC1ENS_10error_codeEPKc
+         U _ZNSt3__112system_errorD1Ev
+         W _ZNSt3__113__vector_baseINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEED2Ev
+         W _ZNSt3__113__vector_baseIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEED2Ev
+         U _ZNSt3__114__shared_count12__add_sharedEv
+         U _ZNSt3__114__shared_count16__release_sharedEv
+         W _ZNSt3__114__split_bufferINS_4pairIPNS_18condition_variableEPNS_5mutexEEERNS_18__hidden_allocatorIS6_EEEC2EjjS9_
+         W _ZNSt3__114__split_bufferINS_4pairIPNS_18condition_variableEPNS_5mutexEEERNS_18__hidden_allocatorIS6_EEED2Ev
+         W _ZNSt3__114__split_bufferIPNS_17__assoc_sub_stateERNS_18__hidden_allocatorIS2_EEEC2EjjS5_
+         W _ZNSt3__114__split_bufferIPNS_17__assoc_sub_stateERNS_18__hidden_allocatorIS2_EEED2Ev
+         T _ZNSt3__115__thread_struct25notify_all_at_thread_exitEPNS_18condition_variableEPNS_5mutexE
+         T _ZNSt3__115__thread_struct27__make_ready_at_thread_exitEPNS_17__assoc_sub_stateE
+         T _ZNSt3__115__thread_structC1Ev
+         T _ZNSt3__115__thread_structC2Ev
+         T _ZNSt3__115__thread_structD1Ev
+         T _ZNSt3__115__thread_structD2Ev
+         U _ZNSt3__115system_categoryEv
+         U _ZNSt3__117__assoc_sub_state12__make_readyEv
+         U _ZNSt3__118condition_variable10notify_allEv
+         T _ZNSt3__119__thread_local_dataEv
+         T _ZNSt3__119__thread_struct_imp25notify_all_at_thread_exitEPNS_18condition_variableEPNS_5mutexE
+         T _ZNSt3__119__thread_struct_imp27__make_ready_at_thread_exitEPNS_17__assoc_sub_stateE
+         T _ZNSt3__119__thread_struct_impD1Ev
+         T _ZNSt3__119__thread_struct_impD2Ev
+         W _ZNSt3__121__thread_specific_ptrINS_15__thread_structEE16__at_thread_exitEPv
+         W _ZNSt3__121__thread_specific_ptrINS_15__thread_structEEC2Ev
+         U _ZNSt3__15mutex6unlockEv
+         T _ZNSt3__16thread20hardware_concurrencyEv
+         T _ZNSt3__16thread4joinEv
+         T _ZNSt3__16thread6detachEv
+         T _ZNSt3__16threadD1Ev
+         T _ZNSt3__16threadD2Ev
+         W _ZNSt3__16vectorINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEE21__push_back_slow_pathIS6_EEvOT_
+         W _ZNSt3__16vectorINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS6_RS8_EE
+         W _ZNSt3__16vectorIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEE21__push_back_slow_pathIRKS2_EEvOT_
+         W _ZNSt3__16vectorIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS2_RS4_EE
+         U _ZSt9terminatev
+         U _ZTINSt3__112system_errorE
+         U _ZdlPv
+         U _Znwj
+         W __clang_call_terminate
+         U __cxa_allocate_exception
+         U __cxa_begin_catch
+         U __cxa_free_exception
+         U __cxa_guard_abort
+         U __cxa_guard_acquire
+         U __cxa_guard_release
+         U __cxa_throw
+         U __errno_location
+         U __gxx_personality_v0
+         U nanosleep
+         U pthread_detach
+         U pthread_join
+         U pthread_key_create
+         U sysconf
+         D _ZNSt3__119piecewise_constructE
+         T _ZNSt3__16gslice6__initEj
+         W _ZNSt3__18valarrayIjE6resizeEjj
+         W _ZNSt3__18valarrayIjEC1Ej
+         W _ZNSt3__18valarrayIjEC2Ej
+         W _ZNSt3__18valarrayIjED1Ev
+         W _ZNSt3__18valarrayIjED2Ev
+         U _ZSt9terminatev
+         U _ZdlPv
+         U _Znwj
+         W __clang_call_terminate
+         U __cxa_begin_catch
+         U __gxx_personality_v0
diff --git a/system/lib/libcxx/system_error.cpp b/system/lib/libcxx/system_error.cpp
index 9c8adc4f323e4..3023e200aa34d 100644
--- a/system/lib/libcxx/system_error.cpp
+++ b/system/lib/libcxx/system_error.cpp
@@ -7,11 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#define _LIBCPP_BUILDING_SYSTEM_ERROR
 #include "__config"
+
+#define _LIBCPP_BUILDING_SYSTEM_ERROR
 #include "system_error"
-#include "string"
+
+#include "include/config_elast.h"
 #include "cstring"
+#include "string"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -149,7 +152,7 @@ system_error::__init(const error_code& ec, string what_arg)
             what_arg += ": ";
         what_arg += ec.message();
     }
-    return _VSTD::move(what_arg);
+    return what_arg;
 }
 
 system_error::system_error(error_code ec, const string& what_arg)
diff --git a/system/lib/libcxx/thread.cpp b/system/lib/libcxx/thread.cpp
index 0ced1e3bba1e4..2243a34eb33a4 100644
--- a/system/lib/libcxx/thread.cpp
+++ b/system/lib/libcxx/thread.cpp
@@ -16,11 +16,16 @@
 #include "future"
 #include "limits"
 #include <sys/types.h>
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+# include <sys/param.h>
+# if defined(BSD)
+#   include <sys/sysctl.h>
+# endif // defined(BSD)
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+
 #if !defined(_WIN32)
-#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX)
-#include <sys/sysctl.h>
-#endif // !__sun__ && !__linux__ && !_AIX
-#include <unistd.h>
+# include <unistd.h>
 #endif // !_WIN32
 
 #if defined(__NetBSD__)
diff --git a/system/lib/libcxx/typeinfo.cpp b/system/lib/libcxx/typeinfo.cpp
index b4281209170cd..5c0a609b5e5ca 100644
--- a/system/lib/libcxx/typeinfo.cpp
+++ b/system/lib/libcxx/typeinfo.cpp
@@ -8,13 +8,8 @@
 //===----------------------------------------------------------------------===//
 #include <stdlib.h>
 
-#ifndef __has_include
-#define __has_include(inc) 0
-#endif
-
-#ifdef __APPLE__
-#include <cxxabi.h>
-#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
+#if defined(__APPLE__) || defined(LIBCXXRT) ||                                 \
+    defined(LIBCXX_BUILDING_LIBCXXABI)
 #include <cxxabi.h>
 #endif
 
diff --git a/tests/browser_test_hello_world.c b/tests/browser_test_hello_world.c
index 92d69295b1bba..9220583639e6e 100644
--- a/tests/browser_test_hello_world.c
+++ b/tests/browser_test_hello_world.c
@@ -1,7 +1,23 @@
 #include<stdio.h>
 
+#include<emscripten.h>
+
 int main() {
+  EM_ASM({
+    Module.prints = [];
+
+    var real = Module['print'];
+
+    Module['print'] = function(x) {
+      real(x);
+      Module.prints.push(x);
+    }
+  });
   printf("hello, world!\n");
+  EM_ASM({
+    assert(Module.prints.length === 1, 'bad length');
+    assert(Module.prints[0] == 'hello, world!', 'bad contents: ' + Module.prints[0]);
+  });
   int result = 0;
   REPORT_RESULT();
   return 0;
diff --git a/tests/test_browser.py b/tests/test_browser.py
index f256c4416de4a..6c94ba77902ca 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -3136,4 +3136,5 @@ def test_split_memory_large_file(self):
 
   def test_binaryen(self):
     self.btest('browser_test_hello_world.c', expected='0', args=['-s', 'BINARYEN=1', '-s', 'BINARYEN_METHOD="interpret-binary"'])
+    self.btest('browser_test_hello_world.c', expected='0', args=['-s', 'BINARYEN=1', '-s', 'BINARYEN_METHOD="interpret-binary"', '-O2'])
 
diff --git a/tests/test_core.py b/tests/test_core.py
index b6c82ae35b9aa..de0b89bdc7431 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -6929,13 +6929,20 @@ def test_emulate_function_pointer_casts(self):
     src = r'''
     #include <stdio.h>
     #include <math.h>
+    
+    // We have to use a proxy function 'acos_test' here because the updated libc++ library provides a set of overloads to acos,
+    // this has the result that we can't take the function pointer to acos anymore due to failed overload resolution.
+    // This proxy function has no overloads so it's allowed to take the function pointer directly.
+    double acos_test(double x) {
+      return acos(x);
+    }
 
     typedef double (*ddd)(double x, double unused);
     typedef int    (*iii)(int x,    int unused);
 
     int main() {
-      volatile ddd d = (ddd)acos;
-      volatile iii i = (iii)acos;
+      volatile ddd d = (ddd)acos_test;
+      volatile iii i = (iii)acos_test;
       printf("|%.3f,%d|\n", d(0.3, 0.6), i(0, 0));
       return 0;
     }
@@ -8065,4 +8072,3 @@ def setUp(self):
 asm2nn = make_run("asm2nn", compiler=CLANG, emcc_args=["-O2"], env={"EMCC_NATIVE_OPTIMIZER": "0"})
 
 del T # T is just a shape for the specific subclasses, we don't test it itself
-
diff --git a/tests/test_html5.c b/tests/test_html5.c
index ece7dd8f09ecc..ad8fba431b410 100644
--- a/tests/test_html5.c
+++ b/tests/test_html5.c
@@ -264,8 +264,8 @@ void mainloop()
   for(int i = 0; i < numGamepads && i < 32; ++i)
   {
     EmscriptenGamepadEvent ge;
-    int failed = emscripten_get_gamepad_status(i, &ge);
-    if (!failed)
+    int ret = emscripten_get_gamepad_status(i, &ge);
+    if (ret == EMSCRIPTEN_RESULT_SUCCESS)
     {
       int g = ge.index;
       for(int j = 0; j < ge.numAxes; ++j)
diff --git a/tests/test_other.py b/tests/test_other.py
index 7e9797b93ae56..0ed461cf52a9b 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -2217,7 +2217,8 @@ def test_crunch(self):
     # run again, should not recrunch!
     time.sleep(0.1)
     Popen([PYTHON, FILE_PACKAGER, 'test.data', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate()
-    assert crunch_time == os.stat('ship.crn').st_mtime, 'Crunch is unchanged'
+    if 'linux' in sys.platform: # OS time reporting in other OSes (OS X) seems flaky here
+      assert crunch_time == os.stat('ship.crn').st_mtime, 'Crunch is unchanged ' + str([crunch_time, os.stat('ship.crn').st_mtime])
     # update dds, so should recrunch
     time.sleep(0.1)
     os.utime('ship.dds', None)
@@ -6365,3 +6366,21 @@ def test_cyberdwarf_union(self):
     check_execute([PYTHON, EMCC, path_from_root('tests', 'debugger', 'test_union.cpp'), '-Oz', '-s', 'CYBERDWARF=1',
     '-std=c++11', '--pre-js', path_from_root('tests', 'debugger', 'test_preamble.js'), '-o', 'test_union.js' ], stderr=PIPE)
     run_js('test_union.js', engine=NODE_JS)
+
+  def test_source_file_with_fixed_language_mode(self):
+    open('src_tmp_fixed_lang', 'w').write('''
+#include <string>
+#include <iostream>
+
+int main() {
+  std::cout << "Test_source_fixed_lang_hello" << std::endl;
+  return 0;
+}
+    ''')
+    stdout, stderr = Popen([PYTHON, EMCC, '-Wall', '-std=c++14', '-x', 'c++', 'src_tmp_fixed_lang'], stderr=PIPE).communicate()
+    self.assertNotContained("Input file has an unknown suffix, don't know what to do with it!", stderr)
+    self.assertNotContained("Unknown file suffix when compiling to LLVM bitcode", stderr)
+    self.assertContained("Test_source_fixed_lang_hello", run_js('a.out.js'))
+    
+    stdout, stderr = Popen([PYTHON, EMCC, '-Wall', '-std=c++14', 'src_tmp_fixed_lang'], stderr=PIPE).communicate()
+    self.assertContained("Input file has an unknown suffix, don't know what to do with it!", stderr)
diff --git a/third_party/wasm-polyfill/src/unpack.cpp b/third_party/wasm-polyfill/src/unpack.cpp
index bc7f4f2097b0f..b5c3c448467c8 100644
--- a/third_party/wasm-polyfill/src/unpack.cpp
+++ b/third_party/wasm-polyfill/src/unpack.cpp
@@ -10,7 +10,7 @@
 #include <cstdio>
 #include <cmath>
 
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
 # include <emscripten.h>
 #endif
 
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 96b1ba93ecbec..307969e66cb06 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -7818,6 +7818,7 @@ function JSDCE(ast) {
   }, function(node, type) {
     if (type === 'defun' || type === 'function') {
       var scope = scopes.pop();
+      var names = set();
       for (name in scope) {
         var data = scope[name];
         if (data.use && !data.def) {
@@ -7827,9 +7828,10 @@ function JSDCE(ast) {
         }
         if (data.def && !data.use && !data.param) {
           // this is eliminateable!
-          cleanUp(node[3], set(name));
+          names[name] = 0;
         }
       }
+      cleanUp(node[3], names);
     }
   });
   // toplevel
diff --git a/tools/ports/binaryen.py b/tools/ports/binaryen.py
index a171799be192b..1b0b8b901ae15 100644
--- a/tools/ports/binaryen.py
+++ b/tools/ports/binaryen.py
@@ -1,6 +1,6 @@
 import os, shutil, logging
 
-TAG = 'version_7'
+TAG = 'version_9'
 
 def needed(settings, shared, ports):
   if not settings.BINARYEN: return False
diff --git a/tools/shared.py b/tools/shared.py
index cab549c3991e2..68e1921a00e84 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -10,21 +10,21 @@
 from tempfiles import try_delete
 
 # On Windows python suffers from a particularly nasty bug if python is spawning new processes while python itself is spawned from some other non-console process.
-# Use a custom replacement for Popen on Windows to avoid the "WindowsError: [Error 6] The handle is invalid" errors when emcc is driven through cmake or mingw32-make. 
+# Use a custom replacement for Popen on Windows to avoid the "WindowsError: [Error 6] The handle is invalid" errors when emcc is driven through cmake or mingw32-make.
 # See http://bugs.python.org/issue3905
 class WindowsPopen:
-  def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, 
+  def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False,
                shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0):
     self.stdin = stdin
     self.stdout = stdout
     self.stderr = stderr
-    
+
     # (stdin, stdout, stderr) store what the caller originally wanted to be done with the streams.
     # (stdin_, stdout_, stderr_) will store the fixed set of streams that workaround the bug.
     self.stdin_ = stdin
     self.stdout_ = stdout
     self.stderr_ = stderr
-    
+
     # If the caller wants one of these PIPEd, we must PIPE them all to avoid the 'handle is invalid' bug.
     if self.stdin_ == PIPE or self.stdout_ == PIPE or self.stderr_ == PIPE:
       if self.stdin_ == None:
@@ -39,7 +39,7 @@ def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, st
     if len(args) >= 2 and args[1].endswith("emscripten.py"):
       response_filename = response_file.create_response_file(args[2:], TEMP_DIR)
       args = args[0:2] + ['@' + response_filename]
-      
+
     try:
       # Call the process with fixed streams.
       self.process = subprocess.Popen(args, bufsize, executable, self.stdin_, self.stdout_, self.stderr_, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
@@ -73,7 +73,7 @@ def poll(self):
 
   def kill(self):
     return self.process.kill()
-  
+
 __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
 def path_from_root(*pathelems):
   return os.path.join(__rootpath__, *pathelems)
@@ -266,7 +266,7 @@ def new(*args):
   logging.error('Error in evaluating %s (at %s): %s, text: %s' % (EM_CONFIG, CONFIG_FILE, str(e), config_text))
   sys.exit(1)
 
-# Returns a suggestion where current .emscripten config file might be located (if EM_CONFIG env. var is used 
+# Returns a suggestion where current .emscripten config file might be located (if EM_CONFIG env. var is used
 # without a file, this hints to "default" location at ~/.emscripten)
 def hint_config_file_location():
   if CONFIG_FILE: return CONFIG_FILE
@@ -304,7 +304,7 @@ def fix_js_engine(old, new):
 
 # Install our replacement Popen handler if we are running on Windows to avoid python spawn process function.
 # nb. This is by default disabled since it has the adverse effect of buffering up all logging messages, which makes
-# builds look unresponsive (messages are printed only after the whole build finishes). Whether this workaround is needed 
+# builds look unresponsive (messages are printed only after the whole build finishes). Whether this workaround is needed
 # seems to depend on how the host application that invokes emcc has set up its stdout and stderr.
 if EM_POPEN_WORKAROUND and os.name == 'nt':
   logging.debug('Installing Popen workaround handler to avoid bug http://bugs.python.org/issue3905')
@@ -902,28 +902,30 @@ def get_llvm_target():
 if USE_EMSDK:
   # Disable system C and C++ include directories, and add our own (using -idirafter so they are last, like system dirs, which
   # allows projects to override them)
-  C_INCLUDE_PATHS = [path_from_root('system', 'local', 'include'),
-                     path_from_root('system', 'include', 'compat'),
-                     path_from_root('system', 'include'),
-                     path_from_root('system', 'include', 'emscripten'),
-                     path_from_root('system', 'include', 'libc'),
-                     path_from_root('system', 'lib', 'libc', 'musl', 'arch', 'emscripten')
+  C_INCLUDE_PATHS = [
+    path_from_root('system', 'include', 'compat'),
+    path_from_root('system', 'include'),
+    path_from_root('system', 'include', 'emscripten'),
+    path_from_root('system', 'include', 'libc'),
+    path_from_root('system', 'lib', 'libc', 'musl', 'arch', 'emscripten'),
+    path_from_root('system', 'local', 'include')
   ]
-  
-  CXX_INCLUDE_PATHS = [path_from_root('system', 'include', 'libcxx'),
-                       path_from_root('system', 'lib', 'libcxxabi', 'include')
-  ]
-  
-  C_OPTS = ['-nostdinc', '-Xclang', '-nobuiltininc', '-Xclang', '-nostdsysteminc',
+
+  CXX_INCLUDE_PATHS = [
+    path_from_root('system', 'include', 'libcxx'),
+    path_from_root('system', 'lib', 'libcxxabi', 'include')
   ]
-  
+
+  C_OPTS = ['-nostdinc', '-Xclang', '-nobuiltininc', '-Xclang', '-nostdsysteminc']
+
   def include_directive(paths):
     result = []
     for path in paths:
       result += ['-Xclang', '-isystem' + path]
     return result
-  
-  EMSDK_OPTS = C_OPTS + include_directive(C_INCLUDE_PATHS) + include_directive(CXX_INCLUDE_PATHS)
+
+  # libcxx include paths must be defined before libc's include paths otherwise libcxx will not build
+  EMSDK_OPTS = C_OPTS + include_directive(CXX_INCLUDE_PATHS) + include_directive(C_INCLUDE_PATHS)
 
   EMSDK_CXX_OPTS = []
   COMPILER_OPTS += EMSDK_OPTS
@@ -1208,7 +1210,7 @@ def remove_sh_exe_from_path(env):
     path = filter(lambda p: not os.path.exists(os.path.join(p, 'sh.exe')), path)
     env['PATH'] = ';'.join(path)
     return env
-  
+
   @staticmethod
   def handle_CMake_toolchain(args, env):
 
@@ -1246,7 +1248,7 @@ def configure(args, stdout=None, stderr=None, env=None):
       args, env = Building.handle_CMake_toolchain(args, env)
     else:
       # When we configure via a ./configure script, don't do config-time compilation with emcc, but instead
-      # do builds natively with Clang. This is a heuristic emulation that may or may not work. 
+      # do builds natively with Clang. This is a heuristic emulation that may or may not work.
       env['EMMAKEN_JUST_CONFIGURE'] = '1'
     try:
       if EM_BUILD_VERBOSE_LEVEL >= 3: print >> sys.stderr, 'configure: ' + str(args)
@@ -1333,7 +1335,7 @@ def build_library(name, build_dir, output_dir, generated_libs, configure=['sh',
         pass # Ignore exit code != 0
     def open_make_out(i, mode='r'):
       return open(os.path.join(project_dir, 'make_' + str(i)), mode)
-    
+
     def open_make_err(i, mode='r'):
       return open(os.path.join(project_dir, 'make_err' + str(i)), mode)
 
@@ -1882,10 +1884,10 @@ def is_bitcode(filename):
   def ensure_struct_info(info_path):
     if os.path.exists(info_path): return
     Cache.ensure()
-    
+
     import gen_struct_info
     gen_struct_info.main(['-qo', info_path, path_from_root('src/struct_info.json')])
-  
+
 # compatibility with existing emcc, etc. scripts
 Cache = cache.Cache(debug=DEBUG_CACHE)
 chunkify = cache.chunkify
diff --git a/tools/system_libs.py b/tools/system_libs.py
index 069811c4b13e4..15ace0335f16f 100644
--- a/tools/system_libs.py
+++ b/tools/system_libs.py
@@ -141,29 +141,34 @@ def create_libcxx(libname):
     logging.debug('building libcxx for cache')
     libcxx_files = [
       'algorithm.cpp',
+      'any.cpp',
+      'bind.cpp',
+      'chrono.cpp',
       'condition_variable.cpp',
+      'debug.cpp',
+      'exception.cpp',
       'future.cpp',
+      'hash.cpp',
+      'ios.cpp',
       'iostream.cpp',
+      'locale.cpp',
       'memory.cpp',
+      'mutex.cpp',
+      'new.cpp',
+      'optional.cpp',
       'random.cpp',
+      'regex.cpp',
+      'shared_mutex.cpp',
       'stdexcept.cpp',
-      'system_error.cpp',
-      'utility.cpp',
-      'bind.cpp',
-      'debug.cpp',
-      'hash.cpp',
-      'mutex.cpp',
       'string.cpp',
+      'strstream.cpp',
+      'system_error.cpp',
       'thread.cpp',
-      'valarray.cpp',
-      'chrono.cpp',
-      'exception.cpp',
-      'ios.cpp',
-      'locale.cpp',
-      'regex.cpp',
-      'strstream.cpp'
+      'typeinfo.cpp',
+      'utility.cpp',
+      'valarray.cpp'
     ]
-    return build_libcxx(os.path.join('system', 'lib', 'libcxx'), libname, libcxx_files, ['-Oz', '-I' + shared.path_from_root('system', 'lib', 'libcxxabi', 'include')], has_noexcept_version=True)
+    return build_libcxx(os.path.join('system', 'lib', 'libcxx'), libname, libcxx_files, ['-DLIBCXX_BUILDING_LIBCXXABI=1', '-Oz', '-I' + shared.path_from_root('system', 'lib', 'libcxxabi', 'include')], has_noexcept_version=True)
 
   # libcxxabi - just for dynamic_cast for now
   def create_libcxxabi(libname):
@@ -180,8 +185,7 @@ def create_libcxxabi(libname):
       'exception.cpp',
       'stdexcept.cpp',
       'typeinfo.cpp',
-      'private_typeinfo.cpp',
-      os.path.join('..', '..', 'libcxx', 'new.cpp'),
+      'private_typeinfo.cpp'
     ]
     return build_libcxx(os.path.join('system', 'lib', 'libcxxabi', 'src'), libname, libcxxabi_files, ['-Oz', '-I' + shared.path_from_root('system', 'lib', 'libcxxabi', 'include')])